diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp index 831808c76..736517e46 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp @@ -3033,6 +3033,15 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList return; } + Var *curColor = (Var *)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); + + //Reflection vec + Var *ibl = (Var *)LangElement::find("ibl"); + if (!ibl) + { + ibl = new Var("ibl", "float3"); + } + Var* eyePos = (Var*)LangElement::find("eyePosWorld"); if (!eyePos) { @@ -3042,18 +3051,26 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList eyePos->uniform = true; eyePos->constSortPos = cspPass; } - - Var *curColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); - + //Reflection vec String computeForwardProbes = String(" @.rgb = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t"); computeForwardProbes += String("@,@,\r\n\t\t"); computeForwardProbes += String("@,@).rgb; \r\n"); - meta->addStatement(new GenOp(computeForwardProbes.c_str(), curColor, surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos, + meta->addStatement(new GenOp(computeForwardProbes.c_str(), new DecOp(ibl), surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos, skylightCubemapIdx, BRDFTexture, irradianceCubemapAR, specularCubemapAR)); + Var *ambient = (Var *)LangElement::find("ambient"); + if (!ambient) + { + ambient = new Var("ambient", "vec4"); + eyePos->uniform = true; + eyePos->constSortPos = cspPass; + } + meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); + meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl)); + output = meta; } diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp index 360f8f918..d2888b889 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp @@ -3149,7 +3149,15 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList meta->addStatement(new GenOp(computeForwardProbes.c_str(), new DecOp(ibl), surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos, skylightCubemapIdx, BRDFTexture, irradianceCubemapAR, specularCubemapAR)); - + + Var *ambient = (Var *)LangElement::find("ambient"); + if (!ambient) + { + ambient = new Var("ambient","float4"); + eyePos->uniform = true; + eyePos->constSortPos = cspPass; + } + meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl)); output = meta;