From fad8e126677034ec84733a3cc3020fa9e6aff076 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 13 Dec 2025 20:52:36 -0600 Subject: [PATCH] take ibl amount into account for translucent opacity --- Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp | 6 +++--- Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp | 6 +++--- .../BaseGame/game/core/rendering/shaders/gl/lighting.glsl | 5 +++-- .../BaseGame/game/core/rendering/shaders/lighting.hlsl | 5 +++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp index 548eb0217..6c545b40f 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp @@ -3055,7 +3055,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList Var *ibl = (Var *)LangElement::find("ibl"); if (!ibl) { - ibl = new Var("ibl", "float3"); + ibl = new Var("ibl", "float4"); } Var* eyePos = (Var*)LangElement::find("eyePosWorld"); @@ -3086,7 +3086,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList //Reflection vec String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t"); computeForwardProbes += String("@,@,@,@,@,@,\r\n\t\t"); - computeForwardProbes += String("@,@).rgb; \r\n"); + computeForwardProbes += String("@,@); \r\n"); meta->addStatement(new GenOp(computeForwardProbes.c_str(), new DecOp(ibl), surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos, skylightCubemapIdx, SkylightDamp, BRDFTexture, WetnessTexture, accumTime, dampness, @@ -3100,7 +3100,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList ambient->constSortPos = cspPass; } meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); - meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl)); + meta->addStatement(new GenOp(" @ = @;\r\n", curColor, ibl)); output = meta; } diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp index d65cced8f..9d6ea1923 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp @@ -3143,7 +3143,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList Var* ibl = (Var*)LangElement::find("ibl"); if (!ibl) { - ibl = new Var("ibl", "float3"); + ibl = new Var("ibl", "float4"); } Var* eyePos = (Var*)LangElement::find("eyePosWorld"); @@ -3174,7 +3174,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t"); computeForwardProbes += String("@,@,TORQUE_SAMPLER2D_MAKEARG(@),TORQUE_SAMPLER2D_MAKEARG(@), @, @,\r\n\t\t"); - computeForwardProbes += String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@)).rgb; \r\n"); + computeForwardProbes += String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@)); \r\n"); meta->addStatement(new GenOp(computeForwardProbes.c_str(), new DecOp(ibl), surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos, skylightCubemapIdx, SkylightDamp, BRDFTexture, WetnessTexture, accumTime, dampness, @@ -3188,7 +3188,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList ambient->constSortPos = cspPass; } meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); - meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl)); + meta->addStatement(new GenOp(" @ = @;\r\n", curColor, ibl)); output = meta; } diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index 5e0caa346..3daeb12c7 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -605,10 +605,11 @@ vec4 computeForwardProbes(Surface surface, finalColor *= surface.ao; if(isCapturing == 1) - return vec4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),0); + return vec4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),surface.baseColor.a); else { - return vec4(finalColor, 0); + float reflectionOpacity = min(max(surface.baseColor.a,length(specular+irradiance)),1.0); + return vec4(finalColor, reflectionOpacity); } } diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index 8a4c5be23..fc0abf7a1 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -610,10 +610,11 @@ float4 computeForwardProbes(Surface surface, finalColor *= surface.ao; if(isCapturing == 1) - return float4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),0); + return float4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),surface.baseColor.a); else { - return float4(finalColor, 0); + float reflectionOpacity = min(max(surface.baseColor.a,length(specular+irradiance)),1.0); + return float4(finalColor, reflectionOpacity); } }