mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 10:48:34 +02:00
+ | Fog beam laser now in objects
This commit is contained in:
@ -94,6 +94,9 @@ void Scene::addObject(Object *obj)
|
||||
gpu_obj.vertex2 = quad->getRight();
|
||||
gpu_obj.normal = quad->getNormal();
|
||||
gpu_obj.radius = quad->getSingleSided();
|
||||
|
||||
if (_gpu_materials[gpu_obj.mat_index].emission > 0.)
|
||||
this->_gpu_lights.insert(_gpu_objects.size());
|
||||
}
|
||||
else if (obj->getType() == Object::Type::CUBE)
|
||||
{
|
||||
@ -115,6 +118,16 @@ void Scene::addObject(Object *obj)
|
||||
gpu_obj.vertex2 = triangle->getVertex3();
|
||||
gpu_obj.normal = triangle->getNormal();
|
||||
}
|
||||
else if (obj->getType() == Object::Type::SPOTLIGHT)
|
||||
{
|
||||
auto spotlight = static_cast<SpotLight *>(obj);
|
||||
|
||||
gpu_obj.radius = spotlight->getRadius();
|
||||
gpu_obj.normal = spotlight->getDirection();
|
||||
gpu_obj.vertex1 = glm::vec3(spotlight->getAngle(), 0.0f, 0.0f);
|
||||
|
||||
this->_gpu_lights.insert(_gpu_objects.size());
|
||||
}
|
||||
else if (obj->getType() == Object::Type::PORTAL)
|
||||
{
|
||||
auto portal = static_cast<Portal *>(obj);
|
||||
@ -293,25 +306,9 @@ bool Scene::loadTextures()
|
||||
return (true);
|
||||
}
|
||||
|
||||
void Scene::updateLightAndObjects(int mat_id)
|
||||
{
|
||||
for (unsigned int i = 0; i < _gpu_objects.size(); i++)
|
||||
{
|
||||
if (_gpu_objects[i].mat_index == mat_id)
|
||||
_gpu_lights.insert(i);
|
||||
}
|
||||
for (auto it = _gpu_lights.begin(); it != _gpu_lights.end(); )
|
||||
{
|
||||
if (_gpu_materials[_gpu_objects[*it].mat_index].emission <= 0.0)
|
||||
it = _gpu_lights.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
bool Scene::fail(void) const
|
||||
{
|
||||
return(_fail);
|
||||
return (_fail);
|
||||
}
|
||||
|
||||
std::set<int> Scene::getGPULights()
|
||||
|
@ -21,6 +21,7 @@ SceneParser::SceneParser(Scene *scene, std::string filename) : _scene(scene), _f
|
||||
object_parsers["cu"] = [](std::stringstream &ss) -> Object * { return (new Cube(ss)); };
|
||||
object_parsers["po"] = [](std::stringstream &ss) -> Object * { return (new Portal(ss)); };
|
||||
object_parsers["cy"] = [](std::stringstream &ss) -> Object * { return (new Cylinder(ss)); };
|
||||
object_parsers["sl"] = [](std::stringstream &ss) -> Object * { return (new SpotLight(ss)); };
|
||||
}
|
||||
|
||||
void SceneParser::parseMaterial(std::stringstream &line)
|
||||
@ -170,9 +171,6 @@ bool SceneParser::parseLine(const std::string &line)
|
||||
_scene->addObject(static_cast<Portal *>(obj)->createSupportQuad());
|
||||
|
||||
_scene->addObject(obj);
|
||||
|
||||
if (mat.emission > 0.0)
|
||||
_scene->updateLightAndObjects(obj->getMaterialIndex());
|
||||
}
|
||||
|
||||
if (identifier == "MAT")
|
||||
|
@ -231,11 +231,7 @@ void Window::imGuiRender(ShaderProgram &raytracing_program)
|
||||
|
||||
ImGui::Text("Material %d", i);
|
||||
has_changed |= ImGui::ColorEdit3("Color", &mat.color[0]);
|
||||
if (ImGui::SliderFloat("Emission", &mat.emission, 0.0f, 10.0f))
|
||||
{
|
||||
has_changed = 1;
|
||||
_scene->updateLightAndObjects(i);
|
||||
}
|
||||
has_changed |= ImGui::SliderFloat("Emission", &mat.emission, 0.0f, 10.0f);
|
||||
|
||||
if (mat.type == 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user