diff --git a/Source/Engine/Level/Actors/DirectionalLight.cpp b/Source/Engine/Level/Actors/DirectionalLight.cpp index 2059fa08e..f44375074 100644 --- a/Source/Engine/Level/Actors/DirectionalLight.cpp +++ b/Source/Engine/Level/Actors/DirectionalLight.cpp @@ -24,7 +24,7 @@ void DirectionalLight::Draw(RenderContext& renderContext) && EnumHasAnyFlags(renderContext.View.Pass, DrawPass::GBuffer) && (ViewDistance < ZeroTolerance || Float3::DistanceSquared(renderContext.View.Position, position) < ViewDistance * ViewDistance)) { - RendererDirectionalLightData data; + RenderDirectionalLightData data; data.Position = position; data.MinRoughness = MinRoughness; data.ShadowsDistance = ShadowsDistance; @@ -45,7 +45,6 @@ void DirectionalLight::Draw(RenderContext& renderContext) data.Cascade2Spacing = Cascade2Spacing; data.Cascade3Spacing = Cascade3Spacing; data.Cascade4Spacing = Cascade4Spacing; - data.PartitionMode = PartitionMode; data.ContactShadowsLength = ContactShadowsLength; data.StaticFlags = GetStaticFlags(); @@ -66,7 +65,6 @@ void DirectionalLight::Serialize(SerializeStream& stream, const void* otherObj) SERIALIZE(Cascade2Spacing); SERIALIZE(Cascade3Spacing); SERIALIZE(Cascade4Spacing); - SERIALIZE(PartitionMode); } @@ -80,7 +78,6 @@ void DirectionalLight::Deserialize(DeserializeStream& stream, ISerializeModifier DESERIALIZE(Cascade2Spacing); DESERIALIZE(Cascade3Spacing); DESERIALIZE(Cascade4Spacing); - DESERIALIZE(PartitionMode); } diff --git a/Source/Engine/Level/Actors/PointLight.cpp b/Source/Engine/Level/Actors/PointLight.cpp index ceb214922..0a4f607ae 100644 --- a/Source/Engine/Level/Actors/PointLight.cpp +++ b/Source/Engine/Level/Actors/PointLight.cpp @@ -89,7 +89,7 @@ void PointLight::Draw(RenderContext& renderContext) && radius > ZeroTolerance && (ViewDistance < ZeroTolerance || Vector3::DistanceSquared(renderContext.View.Position, position) < ViewDistance * ViewDistance)) { - RendererPointLightData data; + RenderPointLightData data; data.Position = position; data.MinRoughness = MinRoughness; data.ShadowsDistance = ShadowsDistance; diff --git a/Source/Engine/Level/Actors/SkyLight.cpp b/Source/Engine/Level/Actors/SkyLight.cpp index 3bde95f98..67116fa13 100644 --- a/Source/Engine/Level/Actors/SkyLight.cpp +++ b/Source/Engine/Level/Actors/SkyLight.cpp @@ -113,7 +113,7 @@ void SkyLight::Draw(RenderContext& renderContext) && brightness > ZeroTolerance && (ViewDistance < ZeroTolerance || Vector3::DistanceSquared(renderContext.View.Position, position) < ViewDistance * ViewDistance)) { - RendererSkyLightData data; + RenderSkyLightData data; data.Position = position; data.Color = Color.ToFloat3() * (Color.A * brightness); data.VolumetricScatteringIntensity = VolumetricScatteringIntensity; diff --git a/Source/Engine/Level/Actors/SpotLight.cpp b/Source/Engine/Level/Actors/SpotLight.cpp index d51df584b..a80c012a5 100644 --- a/Source/Engine/Level/Actors/SpotLight.cpp +++ b/Source/Engine/Level/Actors/SpotLight.cpp @@ -139,7 +139,7 @@ void SpotLight::Draw(RenderContext& renderContext) && outerConeAngle > ZeroTolerance && (ViewDistance < ZeroTolerance || Vector3::DistanceSquared(renderContext.View.Position, position) < ViewDistance * ViewDistance)) { - RendererSpotLightData data; + RenderSpotLightData data; data.Position = position; data.MinRoughness = MinRoughness; data.ShadowsDistance = ShadowsDistance; diff --git a/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.cpp b/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.cpp index d6ba5cea3..9c847fd91 100644 --- a/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.cpp +++ b/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.cpp @@ -388,7 +388,7 @@ void ParticleEmitterGraphCPUExecutor::Draw(ParticleEmitter* emitter, ParticleEff const auto module = emitter->Graph.LightModules[moduleIndex]; ASSERT(module->TypeID == 401); - RendererPointLightData lightData; + RenderPointLightData lightData; lightData.MinRoughness = 0.04f; lightData.ShadowsDistance = 2000.0f; lightData.ShadowsStrength = 1.0f; diff --git a/Source/Engine/Renderer/RenderList.cpp b/Source/Engine/Renderer/RenderList.cpp index 577d58255..32474a143 100644 --- a/Source/Engine/Renderer/RenderList.cpp +++ b/Source/Engine/Renderer/RenderList.cpp @@ -39,7 +39,7 @@ namespace CriticalSection MemPoolLocker; } -void RendererDirectionalLightData::SetupLightData(LightData* data, bool useShadow) const +void RenderDirectionalLightData::SetupLightData(LightData* data, bool useShadow) const { data->SpotAngles.X = -2.0f; data->SpotAngles.Y = 1.0f; @@ -56,7 +56,7 @@ void RendererDirectionalLightData::SetupLightData(LightData* data, bool useShado data->RadiusInv = 0; } -void RendererSpotLightData::SetupLightData(LightData* data, bool useShadow) const +void RenderSpotLightData::SetupLightData(LightData* data, bool useShadow) const { data->SpotAngles.X = CosOuterCone; data->SpotAngles.Y = InvCosConeDifference; @@ -73,7 +73,7 @@ void RendererSpotLightData::SetupLightData(LightData* data, bool useShadow) cons data->RadiusInv = 1.0f / Radius; } -void RendererPointLightData::SetupLightData(LightData* data, bool useShadow) const +void RenderPointLightData::SetupLightData(LightData* data, bool useShadow) const { data->SpotAngles.X = -2.0f; data->SpotAngles.Y = 1.0f; @@ -90,7 +90,7 @@ void RendererPointLightData::SetupLightData(LightData* data, bool useShadow) con data->RadiusInv = 1.0f / Radius; } -void RendererSkyLightData::SetupLightData(LightData* data, bool useShadow) const +void RenderSkyLightData::SetupLightData(LightData* data, bool useShadow) const { data->SpotAngles.X = AdditiveColor.X; data->SpotAngles.Y = AdditiveColor.Y; diff --git a/Source/Engine/Renderer/RenderList.h b/Source/Engine/Renderer/RenderList.h index 8d90be2e4..74b4bdf3d 100644 --- a/Source/Engine/Renderer/RenderList.h +++ b/Source/Engine/Renderer/RenderList.h @@ -22,8 +22,10 @@ class CubeTexture; struct RenderContext; struct RenderContextBatch; -struct RendererDirectionalLightData +struct RenderLightData { + Guid ID; + Float3 Position; float MinRoughness; @@ -36,49 +38,35 @@ struct RendererDirectionalLightData float ShadowsNormalOffsetScale; float ShadowsDepthBias; float ShadowsSharpness; - float VolumetricScatteringIntensity; + float ShadowsDistance; StaticFlags StaticFlags; + ShadowsCastingMode ShadowsMode; float IndirectLightingIntensity; int16 ShadowDataIndex = -1; uint8 CastVolumetricShadow : 1; uint8 RenderedVolumetricFog : 1; - float ShadowsDistance; + float VolumetricScatteringIntensity; + float ContactShadowsLength; +}; + +struct RenderDirectionalLightData : RenderLightData +{ + PartitionMode PartitionMode; int32 CascadeCount; + float Cascade1Spacing; float Cascade2Spacing; float Cascade3Spacing; float Cascade4Spacing; - PartitionMode PartitionMode; - float ContactShadowsLength; - ShadowsCastingMode ShadowsMode; - - Guid ID; - void SetupLightData(LightData* data, bool useShadow) const; }; -struct RendererSpotLightData +struct RenderSpotLightData : RenderLightData { - Float3 Position; - float MinRoughness; - - Float3 Color; - float ShadowsStrength; - - Float3 Direction; - float ShadowsFadeDistance; - - float ShadowsNormalOffsetScale; - float ShadowsDepthBias; - float ShadowsSharpness; - float VolumetricScatteringIntensity; - - float ShadowsDistance; float Radius; - float FallOffExponent; float SourceRadius; Float3 UpVector; @@ -86,77 +74,34 @@ struct RendererSpotLightData float CosOuterCone; float InvCosConeDifference; - float ContactShadowsLength; - float IndirectLightingIntensity; - ShadowsCastingMode ShadowsMode; - - StaticFlags StaticFlags; - int16 ShadowDataIndex = -1; - uint8 CastVolumetricShadow : 1; - uint8 RenderedVolumetricFog : 1; + float FallOffExponent; uint8 UseInverseSquaredFalloff : 1; GPUTexture* IESTexture; - Guid ID; void SetupLightData(LightData* data, bool useShadow) const; }; -struct RendererPointLightData +struct RenderPointLightData : RenderLightData { - Float3 Position; - float MinRoughness; - - Float3 Color; - float ShadowsStrength; - - Float3 Direction; - float ShadowsFadeDistance; - - float ShadowsNormalOffsetScale; - float ShadowsDepthBias; - float ShadowsSharpness; - float VolumetricScatteringIntensity; - - float ShadowsDistance; float Radius; - float FallOffExponent; float SourceRadius; + float FallOffExponent; float SourceLength; - float ContactShadowsLength; - float IndirectLightingIntensity; - ShadowsCastingMode ShadowsMode; - - StaticFlags StaticFlags; - int16 ShadowDataIndex = -1; - uint8 CastVolumetricShadow : 1; - uint8 RenderedVolumetricFog : 1; uint8 UseInverseSquaredFalloff : 1; GPUTexture* IESTexture; - Guid ID; void SetupLightData(LightData* data, bool useShadow) const; }; -struct RendererSkyLightData +struct RenderSkyLightData : RenderLightData { - Float3 Position; - float VolumetricScatteringIntensity; - - Float3 Color; + Float3 AdditiveColor; float Radius; - Float3 AdditiveColor; - float IndirectLightingIntensity; - - StaticFlags StaticFlags; - uint8 CastVolumetricShadow : 1; - uint8 RenderedVolumetricFog : 1; - CubeTexture* Image; - Guid ID; void SetupLightData(LightData* data, bool useShadow) const; }; @@ -318,22 +263,22 @@ public: /// /// Light pass members - directional lights /// - Array DirectionalLights; + Array DirectionalLights; /// /// Light pass members - point lights /// - Array PointLights; + Array PointLights; /// /// Light pass members - spot lights /// - Array SpotLights; + Array SpotLights; /// /// Light pass members - sky lights /// - Array SkyLights; + Array SkyLights; /// /// Environment probes to use for rendering reflections diff --git a/Source/Engine/Renderer/ShadowsPass.cpp b/Source/Engine/Renderer/ShadowsPass.cpp index ebbdfed31..99246bcce 100644 --- a/Source/Engine/Renderer/ShadowsPass.cpp +++ b/Source/Engine/Renderer/ShadowsPass.cpp @@ -219,7 +219,7 @@ void ShadowsPass::SetupRenderContext(RenderContext& renderContext, RenderContext shadowContext.Task = renderContext.Task; } -void ShadowsPass::SetupLight(RenderContext& renderContext, RenderContextBatch& renderContextBatch, RendererDirectionalLightData& light) +void ShadowsPass::SetupLight(RenderContext& renderContext, RenderContextBatch& renderContextBatch, RenderDirectionalLightData& light) { const RenderView& view = renderContext.View; auto mainCache = renderContext.List; @@ -453,7 +453,7 @@ void ShadowsPass::SetupLight(RenderContext& renderContext, RenderContextBatch& r shadowData.Constants.CascadeSplits = view.Near + Float4(cascadeSplits) * cameraRange; } -void ShadowsPass::SetupLight(RenderContext& renderContext, RenderContextBatch& renderContextBatch, RendererPointLightData& light) +void ShadowsPass::SetupLight(RenderContext& renderContext, RenderContextBatch& renderContextBatch, RenderPointLightData& light) { // Init shadow data light.ShadowDataIndex = _shadowData.Count(); @@ -493,7 +493,7 @@ void ShadowsPass::SetupLight(RenderContext& renderContext, RenderContextBatch& r shadowData.Constants.CascadeSplits = Float4::Zero; } -void ShadowsPass::SetupLight(RenderContext& renderContext, RenderContextBatch& renderContextBatch, RendererSpotLightData& light) +void ShadowsPass::SetupLight(RenderContext& renderContext, RenderContextBatch& renderContextBatch, RenderSpotLightData& light) { // Init shadow data light.ShadowDataIndex = _shadowData.Count(); @@ -585,7 +585,7 @@ void ShadowsPass::SetupShadows(RenderContext& renderContext, RenderContextBatch& } } -bool ShadowsPass::CanRenderShadow(const RenderContext& renderContext, const RendererPointLightData& light) +bool ShadowsPass::CanRenderShadow(const RenderContext& renderContext, const RenderPointLightData& light) { const Float3 lightPosition = light.Position; const float dstLightToView = Float3::Distance(lightPosition, renderContext.View.Position); @@ -597,7 +597,7 @@ bool ShadowsPass::CanRenderShadow(const RenderContext& renderContext, const Rend return fade > ZeroTolerance && _shadowMapFormat != PixelFormat::Unknown; } -bool ShadowsPass::CanRenderShadow(const RenderContext& renderContext, const RendererSpotLightData& light) +bool ShadowsPass::CanRenderShadow(const RenderContext& renderContext, const RenderSpotLightData& light) { const Float3 lightPosition = light.Position; const float dstLightToView = Float3::Distance(lightPosition, renderContext.View.Position); @@ -609,12 +609,12 @@ bool ShadowsPass::CanRenderShadow(const RenderContext& renderContext, const Rend return fade > ZeroTolerance && _shadowMapFormat != PixelFormat::Unknown; } -bool ShadowsPass::CanRenderShadow(const RenderContext& renderContext, const RendererDirectionalLightData& light) +bool ShadowsPass::CanRenderShadow(const RenderContext& renderContext, const RenderDirectionalLightData& light) { return _shadowMapFormat != PixelFormat::Unknown; } -void ShadowsPass::RenderShadow(RenderContextBatch& renderContextBatch, RendererPointLightData& light, GPUTextureView* shadowMask) +void ShadowsPass::RenderShadow(RenderContextBatch& renderContextBatch, RenderPointLightData& light, GPUTextureView* shadowMask) { if (light.ShadowDataIndex == -1) return; @@ -692,7 +692,7 @@ void ShadowsPass::RenderShadow(RenderContextBatch& renderContextBatch, RendererP VolumetricFogPass::Instance()->RenderLight(renderContext, context, light, _shadowMapCube->ViewArray(), sperLight.LightShadow); } -void ShadowsPass::RenderShadow(RenderContextBatch& renderContextBatch, RendererSpotLightData& light, GPUTextureView* shadowMask) +void ShadowsPass::RenderShadow(RenderContextBatch& renderContextBatch, RenderSpotLightData& light, GPUTextureView* shadowMask) { if (light.ShadowDataIndex == -1) return; @@ -770,7 +770,7 @@ void ShadowsPass::RenderShadow(RenderContextBatch& renderContextBatch, RendererS VolumetricFogPass::Instance()->RenderLight(renderContext, context, light, _shadowMapCube->View(faceIndex), sperLight.LightShadow); } -void ShadowsPass::RenderShadow(RenderContextBatch& renderContextBatch, RendererDirectionalLightData& light, int32 index, GPUTextureView* shadowMask) +void ShadowsPass::RenderShadow(RenderContextBatch& renderContextBatch, RenderDirectionalLightData& light, int32 index, GPUTextureView* shadowMask) { if (light.ShadowDataIndex == -1) return; diff --git a/Source/Engine/Renderer/ShadowsPass.h b/Source/Engine/Renderer/ShadowsPass.h index a811e44b1..e67abd184 100644 --- a/Source/Engine/Renderer/ShadowsPass.h +++ b/Source/Engine/Renderer/ShadowsPass.h @@ -107,7 +107,7 @@ public: /// The rendering context. /// The light. /// true if can render shadow for the specified light; otherwise, false. - bool CanRenderShadow(const RenderContext& renderContext, const RendererPointLightData& light); + bool CanRenderShadow(const RenderContext& renderContext, const RenderPointLightData& light); /// /// Determines whether can render shadow for the specified light. @@ -115,7 +115,7 @@ public: /// The rendering context. /// The light. /// true if can render shadow for the specified light; otherwise, false. - bool CanRenderShadow(const RenderContext& renderContext, const RendererSpotLightData& light); + bool CanRenderShadow(const RenderContext& renderContext, const RenderSpotLightData& light); /// /// Determines whether can render shadow for the specified light. @@ -123,7 +123,7 @@ public: /// The rendering context. /// The light. /// true if can render shadow for the specified light; otherwise, false. - bool CanRenderShadow(const RenderContext& renderContext, const RendererDirectionalLightData& light); + bool CanRenderShadow(const RenderContext& renderContext, const RenderDirectionalLightData& light); /// /// Renders the shadow mask for the given light. @@ -131,7 +131,7 @@ public: /// The rendering context batch. /// The light. /// The shadow mask (output). - void RenderShadow(RenderContextBatch& renderContextBatch, RendererPointLightData& light, GPUTextureView* shadowMask); + void RenderShadow(RenderContextBatch& renderContextBatch, RenderPointLightData& light, GPUTextureView* shadowMask); /// /// Renders the shadow mask for the given light. @@ -139,7 +139,7 @@ public: /// The rendering context batch. /// The light. /// The shadow mask (output). - void RenderShadow(RenderContextBatch& renderContextBatch, RendererSpotLightData& light, GPUTextureView* shadowMask); + void RenderShadow(RenderContextBatch& renderContextBatch, RenderSpotLightData& light, GPUTextureView* shadowMask); /// /// Renders the shadow mask for the given light. @@ -148,15 +148,15 @@ public: /// The light. /// The light index. /// The shadow mask (output). - void RenderShadow(RenderContextBatch& renderContextBatch, RendererDirectionalLightData& light, int32 index, GPUTextureView* shadowMask); + void RenderShadow(RenderContextBatch& renderContextBatch, RenderDirectionalLightData& light, int32 index, GPUTextureView* shadowMask); private: void updateShadowMapSize(); void SetupRenderContext(RenderContext& renderContext, RenderContext& shadowContext); - void SetupLight(RenderContext& renderContext, RenderContextBatch& renderContextBatch, RendererDirectionalLightData& light); - void SetupLight(RenderContext& renderContext, RenderContextBatch& renderContextBatch, RendererPointLightData& light); - void SetupLight(RenderContext& renderContext, RenderContextBatch& renderContextBatch, RendererSpotLightData& light); + void SetupLight(RenderContext& renderContext, RenderContextBatch& renderContextBatch, RenderDirectionalLightData& light); + void SetupLight(RenderContext& renderContext, RenderContextBatch& renderContextBatch, RenderPointLightData& light); + void SetupLight(RenderContext& renderContext, RenderContextBatch& renderContextBatch, RenderSpotLightData& light); #if COMPILE_WITH_DEV_ENV void OnShaderReloading(Asset* obj) diff --git a/Source/Engine/Renderer/VolumetricFogPass.cpp b/Source/Engine/Renderer/VolumetricFogPass.cpp index 130c64746..d94bd503b 100644 --- a/Source/Engine/Renderer/VolumetricFogPass.cpp +++ b/Source/Engine/Renderer/VolumetricFogPass.cpp @@ -387,7 +387,7 @@ void VolumetricFogPass::RenderRadialLight(RenderContext& renderContext, GPUConte } } -void VolumetricFogPass::RenderLight(RenderContext& renderContext, GPUContext* context, RendererPointLightData& light, GPUTextureView* shadowMap, LightShadowData& shadow) +void VolumetricFogPass::RenderLight(RenderContext& renderContext, GPUContext* context, RenderPointLightData& light, GPUTextureView* shadowMap, LightShadowData& shadow) { // Skip lights with no volumetric light influence or not casting volumetric shadow if (light.VolumetricScatteringIntensity <= ZeroTolerance || !light.CastVolumetricShadow) @@ -401,7 +401,7 @@ void VolumetricFogPass::RenderLight(RenderContext& renderContext, GPUContext* co context->UnBindSR(5); } -void VolumetricFogPass::RenderLight(RenderContext& renderContext, GPUContext* context, RendererSpotLightData& light, GPUTextureView* shadowMap, LightShadowData& shadow) +void VolumetricFogPass::RenderLight(RenderContext& renderContext, GPUContext* context, RenderSpotLightData& light, GPUTextureView* shadowMap, LightShadowData& shadow) { // Skip lights with no volumetric light influence or not casting volumetric shadow if (light.VolumetricScatteringIntensity <= ZeroTolerance || !light.CastVolumetricShadow) @@ -594,8 +594,8 @@ void VolumetricFogPass::Render(RenderContext& renderContext) GPUTextureView* localShadowedLightScattering = nullptr; { // Get lights to render - Array> pointLights; - Array> spotLights; + Array> pointLights; + Array> spotLights; for (int32 i = 0; i < renderContext.List->PointLights.Count(); i++) { const auto& light = renderContext.List->PointLights[i]; diff --git a/Source/Engine/Renderer/VolumetricFogPass.h b/Source/Engine/Renderer/VolumetricFogPass.h index 3f3384fd4..97eb89440 100644 --- a/Source/Engine/Renderer/VolumetricFogPass.h +++ b/Source/Engine/Renderer/VolumetricFogPass.h @@ -8,8 +8,8 @@ #include "GI/DynamicDiffuseGlobalIllumination.h" struct VolumetricFogOptions; -struct RendererSpotLightData; -struct RendererPointLightData; +struct RenderSpotLightData; +struct RenderPointLightData; /// /// Volumetric fog rendering service. @@ -156,7 +156,7 @@ public: /// The light. /// The shadow map. /// The light shadow data. - void RenderLight(RenderContext& renderContext, GPUContext* context, RendererPointLightData& light, GPUTextureView* shadowMap, LightShadowData& shadow); + void RenderLight(RenderContext& renderContext, GPUContext* context, RenderPointLightData& light, GPUTextureView* shadowMap, LightShadowData& shadow); /// /// Renders the light to the volumetric fog light scattering volume texture. Called by the light pass after shadow map rendering. Used by the shadows casting lights. @@ -166,7 +166,7 @@ public: /// The light. /// The shadow map. /// The light shadow data. - void RenderLight(RenderContext& renderContext, GPUContext* context, RendererSpotLightData& light, GPUTextureView* shadowMap, LightShadowData& shadow); + void RenderLight(RenderContext& renderContext, GPUContext* context, RenderSpotLightData& light, GPUTextureView* shadowMap, LightShadowData& shadow); /// /// Renders the volumetric fog (generates integrated light scattering 3D texture). Does nothing if feature is disabled or not supported.