Merge pull request #1612 from Azaezel/alpha41/translucentReflectionOpacity
Some checks are pending
Linux Build / ${{matrix.config.name}} (map[build_type:Release cc:gcc cxx:g++ generator:Ninja name:Ubuntu Latest GCC]) (push) Waiting to run
MacOSX Build / ${{matrix.config.name}} (map[build_type:Release cc:clang cxx:clang++ generator:Ninja name:MacOSX Latest Clang]) (push) Waiting to run
Windows Build / ${{matrix.config.name}} (map[build_type:Release cc:cl cxx:cl environment_script:C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat generator:Visual Studio 17 2022 name:Windows Latest MSVC]) (push) Waiting to run

take ibl amount into account for translucent opacity
This commit is contained in:
Brian Roberts 2025-12-15 10:06:41 -06:00 committed by GitHub
commit e9a8961543
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 15 deletions

View file

@ -3055,7 +3055,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
Var *ibl = (Var *)LangElement::find("ibl"); Var *ibl = (Var *)LangElement::find("ibl");
if (!ibl) if (!ibl)
{ {
ibl = new Var("ibl", "float3"); ibl = new Var("ibl", "float4");
} }
Var* eyePos = (Var*)LangElement::find("eyePosWorld"); Var* eyePos = (Var*)LangElement::find("eyePosWorld");
@ -3086,7 +3086,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
//Reflection vec //Reflection vec
String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t"); String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
computeForwardProbes += String("@,@,@,@,@,@,\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, 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, skylightCubemapIdx, SkylightDamp, BRDFTexture, WetnessTexture, accumTime, dampness,
@ -3100,7 +3100,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
ambient->constSortPos = cspPass; ambient->constSortPos = cspPass;
} }
meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); 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; output = meta;
} }

View file

@ -3143,7 +3143,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
Var* ibl = (Var*)LangElement::find("ibl"); Var* ibl = (Var*)LangElement::find("ibl");
if (!ibl) if (!ibl)
{ {
ibl = new Var("ibl", "float3"); ibl = new Var("ibl", "float4");
} }
Var* eyePos = (Var*)LangElement::find("eyePosWorld"); Var* eyePos = (Var*)LangElement::find("eyePosWorld");
@ -3174,7 +3174,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t"); String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
computeForwardProbes += String("@,@,TORQUE_SAMPLER2D_MAKEARG(@),TORQUE_SAMPLER2D_MAKEARG(@), @, @,\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, 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, skylightCubemapIdx, SkylightDamp, BRDFTexture, WetnessTexture, accumTime, dampness,
@ -3188,7 +3188,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
ambient->constSortPos = cspPass; ambient->constSortPos = cspPass;
} }
meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient)); 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; output = meta;
} }

View file

@ -226,9 +226,11 @@ float getDistanceAtt( vec3 unormalizedLightVector , float invSqrAttRadius )
vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight) vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
{ {
if (surface.depth >= 0.9999f)
return float3(0.0,0.0,0.0);
// Compute Fresnel term // Compute Fresnel term
vec3 F = F_Schlick(surface.f0, surfaceToLight.HdotV); vec3 F = F_Schlick(surface.f0, surfaceToLight.HdotV);
F += lerp(vec3(0.04f,0.04f,0.04f), surface.baseColor.rgb, surface.metalness);
// GGX Normal Distribution Function // GGX Normal Distribution Function
float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughness); float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughness);
@ -592,9 +594,12 @@ vec4 computeForwardProbes(Surface surface,
specular = mix(specular,textureLod(specularCubemapAR, vec4(surface.R, skylightCubemapIdx), lod).xyz, alpha); specular = mix(specular,textureLod(specularCubemapAR, vec4(surface.R, skylightCubemapIdx), lod).xyz, alpha);
} }
float reflectionOpacity = clamp(surface.baseColor.a, max(length(specular),length(irradiance))*surface.roughness,1.0);
surface.baseColor.rgb = lerp(surface.baseColor.rgb, vec3(reflectionOpacity,reflectionOpacity,reflectionOpacity), surface.roughness);
updateSurface(surface);
vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg; vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg;
vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), surface.metalness); vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), surface.metalness);
vec3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness; vec3 specularCol = ((specular * surface.f0) * envBRDF.x + envBRDF.y)*surface.metalness;
float horizonOcclusion = 1.3; float horizonOcclusion = 1.3;
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N)); float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
@ -605,10 +610,10 @@ vec4 computeForwardProbes(Surface surface,
finalColor *= surface.ao; finalColor *= surface.ao;
if(isCapturing == 1) 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 else
{ {
return vec4(finalColor, 0); return vec4(finalColor, reflectionOpacity);
} }
} }

View file

@ -226,9 +226,11 @@ float getDistanceAtt( float3 unormalizedLightVector , float invSqrAttRadius )
float3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight) float3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
{ {
if (surface.depth >= 0.9999f)
return float3(0.0,0.0,0.0);
// Compute Fresnel term // Compute Fresnel term
float3 F = F_Schlick(surface.f0, surfaceToLight.HdotV); float3 F = F_Schlick(surface.f0, surfaceToLight.HdotV);
F += lerp(0.04f, surface.baseColor.rgb, surface.metalness);
// GGX Normal Distribution Function // GGX Normal Distribution Function
float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughness); float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughness);
@ -597,23 +599,26 @@ float4 computeForwardProbes(Surface surface,
specular = lerp(specular,TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, surface.R, skylightCubemapIdx, lod).xyz,alpha); specular = lerp(specular,TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, surface.R, skylightCubemapIdx, lod).xyz,alpha);
} }
float reflectionOpacity = clamp(surface.baseColor.a, max(length(specular),length(irradiance))*surface.roughness,1.0);
surface.baseColor.rgb = lerp(surface.baseColor.rgb, float3(reflectionOpacity,reflectionOpacity,reflectionOpacity), surface.roughness);
surface.Update();
float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg; float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg;
float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, surface.metalness); float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, surface.metalness);
float3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness; float3 specularCol = ((specular * surface.f0) * envBRDF.x + envBRDF.y)*surface.metalness;
float horizonOcclusion = 1.3; float horizonOcclusion = 1.3;
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N)); float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
horizon *= horizon; horizon *= horizon;
// Final color output after environment lighting // Final color output after environment lighting
float3 finalColor = diffuse + specularCol; float3 finalColor = diffuse + specularCol* horizon;
finalColor *= surface.ao; finalColor *= surface.ao;
if(isCapturing == 1) 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 else
{ {
return float4(finalColor, 0); return float4(finalColor, reflectionOpacity);
} }
} }