From b92b5b34fd360b63d8c5dc5ec9f232160c0ad6d0 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 29 Mar 2025 14:43:03 -0500 Subject: [PATCH] clean up shadergen ambient handling fallback needs to a) set the same value as elswhere. b) treat uniforms the same. c) exist on both ends to ensure order of ops doesn't mangle things --- .../source/shaderGen/GLSL/shaderFeatureGLSL.cpp | 16 ++++++++++------ .../source/shaderGen/HLSL/shaderFeatureHLSL.cpp | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp index 1fd6276d3..548eb0217 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp @@ -2212,9 +2212,13 @@ void RTLightingFeatGLSL::processPix( Vector &componentList, Var *curColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); - Var *ambient = new Var( "ambient", "vec4" ); - ambient->uniform = true; - ambient->constSortPos = cspPass; + Var* ambient = (Var*)LangElement::find("ambient"); + if (!ambient) + { + ambient = new Var("ambient", "vec4"); + ambient->uniform = true; + ambient->constSortPos = cspPass; + } Var* lighting = new Var("lighting", "vec4"); meta->addStatement(new GenOp(" @ = compute4Lights( @, @, @, @,\r\n" @@ -3091,9 +3095,9 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList Var *ambient = (Var *)LangElement::find("ambient"); if (!ambient) { - ambient = new Var("ambient", "vec3"); - eyePos->uniform = true; - eyePos->constSortPos = cspPass; + ambient = new Var("ambient", "vec4"); + ambient->uniform = true; + ambient->constSortPos = cspPass; } meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl)); diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp index 8e7542052..d65cced8f 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp @@ -2284,9 +2284,13 @@ void RTLightingFeatHLSL::processPix( Vector &componentList, Var *curColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); - Var *ambient = new Var( "ambient", "float4" ); - ambient->uniform = true; - ambient->constSortPos = cspPass; + Var* ambient = (Var*)LangElement::find("ambient"); + if (!ambient) + { + ambient = new Var("ambient", "float4"); + ambient->uniform = true; + ambient->constSortPos = cspPass; + } Var* lighting = new Var("lighting", "float4"); meta->addStatement(new GenOp(" @ = compute4Lights( @, @, @, @,\r\n" @@ -3179,9 +3183,9 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList Var *ambient = (Var *)LangElement::find("ambient"); if (!ambient) { - ambient = new Var("ambient","float3"); - eyePos->uniform = true; - eyePos->constSortPos = cspPass; + ambient = new Var("ambient","float4"); + ambient->uniform = true; + ambient->constSortPos = cspPass; } meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl));