Просмотр исходного кода

Merge pull request #1615 from TorqueGameEngines/revert-1612-alpha41/translucentReflectionOpacity

Revert "take ibl amount into account for translucent opacity"
Brian Roberts 1 месяц назад
Родитель
Сommit
37ef090137

+ 3 - 3
Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp

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

+ 3 - 3
Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp

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

+ 4 - 9
Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl

@@ -226,11 +226,9 @@ float getDistanceAtt( vec3 unormalizedLightVector , float invSqrAttRadius )
 
 vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
 {
-   if (surface.depth >= 0.9999f)
-      return float3(0.0,0.0,0.0);
-      
    // Compute Fresnel term
    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
    float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughness);
@@ -594,12 +592,9 @@ vec4 computeForwardProbes(Surface surface,
       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;
    vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), surface.metalness);
-   vec3 specularCol = ((specular * surface.f0) * envBRDF.x + envBRDF.y)*surface.metalness;
+   vec3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness;
    
    float horizonOcclusion = 1.3;
    float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
@@ -610,10 +605,10 @@ vec4 computeForwardProbes(Surface surface,
    finalColor *= surface.ao;
    
    if(isCapturing == 1)
-      return vec4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),surface.baseColor.a);
+      return vec4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),0);
    else
    {
-      return vec4(finalColor, reflectionOpacity);
+      return vec4(finalColor, 0);
    }
 }
 

+ 5 - 10
Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl

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