diff --git a/SDK/include/NDK/Systems/RenderSystem.hpp b/SDK/include/NDK/Systems/RenderSystem.hpp index 1ff5cedde..4ed015365 100644 --- a/SDK/include/NDK/Systems/RenderSystem.hpp +++ b/SDK/include/NDK/Systems/RenderSystem.hpp @@ -52,6 +52,7 @@ namespace Ndk void OnEntityValidation(Entity* entity, bool justAdded) override; void OnUpdate(float elapsedTime) override; + void UpdateDynamicReflections(); void UpdateDirectionalShadowMaps(const Nz::AbstractViewer& viewer); void UpdatePointSpotShadowMaps(); @@ -63,6 +64,7 @@ namespace Ndk EntityList m_lights; EntityList m_pointSpotLights; EntityList m_particleGroups; + EntityList m_realtimeReflected; GraphicsComponentCullingList m_drawableCulling; Nz::BackgroundRef m_background; Nz::DepthRenderTechnique m_shadowTechnique; diff --git a/SDK/src/NDK/Lua/LuaBinding_Graphics.cpp b/SDK/src/NDK/Lua/LuaBinding_Graphics.cpp index 4282fe26f..37d18bf5f 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Graphics.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Graphics.cpp @@ -152,6 +152,7 @@ namespace Ndk //material.BindMethod("GetPipeline", &Nz::Material::GetPipeline); //material.BindMethod("GetPipelineInfo", &Nz::Material::GetPipelineInfo); material.BindMethod("GetPointSize", &Nz::Material::GetPointSize); + material.BindMethod("GetReflectionMode", &Nz::Material::GetReflectionMode); //material.BindMethod("GetShader", &Nz::Material::GetShader); material.BindMethod("GetShininess", &Nz::Material::GetShininess); material.BindMethod("GetSpecularColor", &Nz::Material::GetSpecularColor); @@ -196,6 +197,7 @@ namespace Ndk material.BindMethod("SetFaceFilling", &Nz::Material::SetFaceFilling); material.BindMethod("SetLineWidth", &Nz::Material::SetLineWidth); material.BindMethod("SetPointSize", &Nz::Material::SetPointSize); + material.BindMethod("SetReflectionMode", &Nz::Material::SetReflectionMode); material.BindMethod("SetShininess", &Nz::Material::SetShininess); material.BindMethod("SetSpecularColor", &Nz::Material::SetSpecularColor); material.BindMethod("SetSpecularColor", &Nz::Material::SetSpecularColor); @@ -483,5 +485,15 @@ namespace Ndk model.Register(state); sprite.Register(state); spriteLibrary.Register(state); + + // Nz::ReflectionMode + static_assert(Nz::ReflectionMode_Max + 1 == 3, "Nz::ReflectionMode has been updated but change was not reflected to Lua binding"); + state.PushTable(0, 3); + { + state.PushField("Probe", Nz::ReflectionMode_Probe); + state.PushField("RealTime", Nz::ReflectionMode_RealTime); + state.PushField("Skybox", Nz::ReflectionMode_Skybox); + } + state.SetGlobal("ReflectionMode"); } } diff --git a/SDK/src/NDK/Systems/RenderSystem.cpp b/SDK/src/NDK/Systems/RenderSystem.cpp index 6b745dfc3..3dfc81724 100644 --- a/SDK/src/NDK/Systems/RenderSystem.cpp +++ b/SDK/src/NDK/Systems/RenderSystem.cpp @@ -101,15 +101,19 @@ namespace Ndk { m_drawables.Insert(entity); + GraphicsComponent& gfxComponent = entity->GetComponent(); if (justAdded) - { - GraphicsComponent& gfxComponent = entity->GetComponent(); gfxComponent.AddToCullingList(&m_drawableCulling); - } + + if (gfxComponent.DoesRequireRealTimeReflections()) + m_realtimeReflected.Insert(entity); + else + m_realtimeReflected.Remove(entity); } else { m_drawables.Remove(entity); + m_realtimeReflected.Remove(entity); if (entity->HasComponent()) { @@ -179,6 +183,7 @@ namespace Ndk m_coordinateSystemInvalidated = false; } + UpdateDynamicReflections(); UpdatePointSpotShadowMaps(); for (const Ndk::EntityHandle& camera : m_cameras) @@ -251,6 +256,19 @@ namespace Ndk * \param viewer Viewer of the scene */ + void RenderSystem::UpdateDynamicReflections() + { + Nz::SceneData dummySceneData; + dummySceneData.ambientColor = Nz::Color(0, 0, 0); + dummySceneData.background = nullptr; + dummySceneData.viewer = nullptr; //< Depth technique doesn't require any viewer + + for (const Ndk::EntityHandle& handle : m_realtimeReflected) + { + //NazaraWarning("Realtime reflected: #" + handle->ToString()); + } + } + void RenderSystem::UpdateDirectionalShadowMaps(const Nz::AbstractViewer& /*viewer*/) { if (!m_shadowRT.IsValid()) @@ -329,12 +347,12 @@ namespace Ndk { static Nz::Quaternionf rotations[6] = { - Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), Nz::Vector3f::UnitX()), // nzCubemapFace_PositiveX - Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), -Nz::Vector3f::UnitX()), // nzCubemapFace_NegativeX - Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), -Nz::Vector3f::UnitY()), // nzCubemapFace_PositiveY - Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), Nz::Vector3f::UnitY()), // nzCubemapFace_NegativeY - Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), -Nz::Vector3f::UnitZ()), // nzCubemapFace_PositiveZ - Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), Nz::Vector3f::UnitZ()) // nzCubemapFace_NegativeZ + Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), Nz::Vector3f::UnitX()), // CubemapFace_PositiveX + Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), -Nz::Vector3f::UnitX()), // CubemapFace_NegativeX + Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), -Nz::Vector3f::UnitY()), // CubemapFace_PositiveY + Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), Nz::Vector3f::UnitY()), // CubemapFace_NegativeY + Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), -Nz::Vector3f::UnitZ()), // CubemapFace_PositiveZ + Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), Nz::Vector3f::UnitZ()) // CubemapFace_NegativeZ }; for (unsigned int face = 0; face < 6; ++face)