From c978ab2b843e4c35956fdfd471d2bb7d943fab5c Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 11 Feb 2026 00:25:00 +0100 Subject: [PATCH] Fix missing changes from e851efa0a84353f53ea6ef2b2f108ff0c07d0844 and ef551c36ae4c9baca91334831daceda6993077c6 on ForwardShading --- .../Features/ForwardShading.hlsl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Content/Editor/MaterialTemplates/Features/ForwardShading.hlsl b/Content/Editor/MaterialTemplates/Features/ForwardShading.hlsl index a10a573ff..29a00c9b7 100644 --- a/Content/Editor/MaterialTemplates/Features/ForwardShading.hlsl +++ b/Content/Editor/MaterialTemplates/Features/ForwardShading.hlsl @@ -30,6 +30,7 @@ TextureCube SkyLightTexture : register(t__SRV__); Buffer ShadowsBuffer : register(t__SRV__); Texture2D ShadowMap : register(t__SRV__); Texture3D VolumetricFogTexture : register(t__SRV__); +Texture2D PreIntegratedGF : register(t__SRV__); @4// Forward Shading: Utilities // Public accessors for lighting data, use them as data binding might change but those methods will remain. LightData GetDirectionalLight() { return DirectionalLight; } @@ -111,7 +112,8 @@ void PS_Forward( // Calculate reflections #if USE_REFLECTIONS - float3 reflections = SampleReflectionProbe(ViewPos, EnvProbe, EnvironmentProbe, gBuffer.WorldPos, gBuffer.Normal, gBuffer.Roughness).rgb; + float4 reflections = SampleReflectionProbe(ViewPos, EnvProbe, EnvironmentProbe, gBuffer.WorldPos, gBuffer.Normal, gBuffer.Roughness); + reflections.rgb *= reflections.a; #if MATERIAL_REFLECTIONS == MATERIAL_REFLECTIONS_SSR // Screen Space Reflections @@ -127,7 +129,7 @@ void PS_Forward( if (hit.z > 0) { float3 screenColor = sceneColorTexture.SampleLevel(SamplerPointClamp, hit.xy, 0).rgb; - reflections = lerp(reflections, screenColor, hit.z); + reflections.rgb = lerp(reflections.rgb, screenColor, hit.z); } // Fallback to software tracing if possible @@ -139,17 +141,17 @@ void PS_Forward( if (TraceSDFSoftwareReflections(gBuffer, reflectWS, surfaceAtlas)) { float3 screenColor = sceneColorTexture.SampleLevel(SamplerPointClamp, hit.xy, 0).rgb; - reflections = lerp(surfaceAtlas, float4(screenColor, 1), hit.z); + reflections.rgb = lerp(surfaceAtlas, float4(screenColor, 1), hit.z); } } #endif #endif - light.rgb += reflections * GetReflectionSpecularLighting(ViewPos, gBuffer) * light.a; + light.rgb += reflections.rgb * GetReflectionSpecularLighting(PreIntegratedGF, ViewPos, gBuffer); #endif - // Add lighting (apply ambient occlusion) - output.rgb += light.rgb * gBuffer.AO; + // Add lighting + output.rgb += light.rgb; #endif @@ -161,7 +163,8 @@ void PS_Forward( #else float fogSceneDistance = gBuffer.ViewPos.z; #endif - float4 fog = GetExponentialHeightFog(ExponentialHeightFog, materialInput.WorldPosition, ViewPos, 0, fogSceneDistance); + float fogSkipDistance = max(ExponentialHeightFog.VolumetricFogMaxDistance - 100, 0); + float4 fog = GetExponentialHeightFog(ExponentialHeightFog, materialInput.WorldPosition, ViewPos, fogSkipDistance, fogSceneDistance); if (ExponentialHeightFog.VolumetricFogMaxDistance > 0) { // Sample volumetric fog and mix it in