mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-28 02:58:35 +02:00
+ | Light array sent to gpu
This commit is contained in:
@ -139,6 +139,27 @@ void Scene::addMaterial(Material *material)
|
||||
_gpu_materials.push_back(gpu_mat);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
std::set<int> Scene::getGPULights()
|
||||
{
|
||||
return (_gpu_lights);
|
||||
}
|
||||
|
||||
const std::vector<GPUObject>& Scene::getObjectData() const
|
||||
{
|
||||
return (_gpu_objects);
|
||||
|
@ -257,12 +257,16 @@ bool SceneParser::parseLine(const std::string &line)
|
||||
if (it != object_parsers.end())
|
||||
{
|
||||
Object *obj = it->second(ss);
|
||||
(void) _scene->getMaterial(obj->getMaterialIndex()); //verify material
|
||||
|
||||
GPUMaterial mat = _scene->getMaterial(obj->getMaterialIndex()); //verify material
|
||||
|
||||
if (obj->getType() == Object::Type::PORTAL)
|
||||
_scene->addObject(static_cast<Portal *>(obj)->createSupportQuad());
|
||||
|
||||
_scene->addObject(obj);
|
||||
|
||||
if (mat.emission > 0.0)
|
||||
_scene->updateLightAndObjects(obj->getMaterialIndex());
|
||||
}
|
||||
|
||||
if (identifier == "MAT")
|
||||
|
@ -197,7 +197,11 @@ void Window::imGuiRender()
|
||||
|
||||
ImGui::Text("Material %d", i);
|
||||
has_changed |= ImGui::ColorEdit3("Color", &mat.color[0]);
|
||||
has_changed |= ImGui::SliderFloat("Emission", &mat.emission, 0.0f, 10.0f);
|
||||
if (ImGui::SliderFloat("Emission", &mat.emission, 0.0f, 10.0f))
|
||||
{
|
||||
has_changed = 1;
|
||||
_scene->updateLightAndObjects(i);
|
||||
}
|
||||
|
||||
if (mat.type == 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user