瀏覽代碼

Merge pull request #379 from Azaezel/alpha40_lightreview

light review (hdr and metalness vs direct lighting)
Brian Roberts 4 年之前
父節點
當前提交
d8e82d1ba6

+ 1 - 1
Templates/BaseGame/game/core/postFX/scripts/HDR/brightPassFilterP.glsl

@@ -61,5 +61,5 @@ void main()
       average = vec4( 0.0f, 0.0f, 0.0f, 1.0f );
 
    // Write the colour to the bright-pass render target
-   OUT_col = hdrEncode( average );
+   OUT_col = hdrEncode( saturate(average) );
 }

+ 1 - 1
Templates/BaseGame/game/core/postFX/scripts/HDR/brightPassFilterP.hlsl

@@ -58,5 +58,5 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
       average = float4( 0.0f, 0.0f, 0.0f, 1.0f );
 
    // Write the colour to the bright-pass render target
-   return hdrEncode( average );
+   return hdrEncode( saturate(average) );
 }

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

@@ -231,24 +231,24 @@ vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
    float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughnessSq);
    vec3 Fr = D * F * Vis;
 
-#if (CAPTURING == 1)
-   return mix(Fd + Fr,surface.f0,surface.metalness);
+#ifdef CAPTURING
+   return saturate(mix(Fd + Fr,surface.f0,surface.metalness));
 #else
-   return Fd + Fr;
+   return saturate(Fd + Fr);
 #endif
 
 }
 
 vec3 getDirectionalLight(Surface surface, SurfaceToLight surfaceToLight, vec3 lightColor, float lightIntensity, float shadow)
 {
-   vec3 factor = lightColor * max(surfaceToLight.NdotL, 0.0f) * shadow * lightIntensity;
+   vec3 factor = lightColor * max(surfaceToLight.NdotL * shadow * lightIntensity*(1.0-surface.metalness), 0.0f);
    return evaluateStandardBRDF(surface,surfaceToLight) * factor;
 }
 
 vec3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, vec3 lightColor, float lightIntensity, float radius, float shadow)
 {
    float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
-   vec3 factor = lightColor * max(surfaceToLight.NdotL, 0.0f) * shadow * lightIntensity * attenuation;
+   vec3 factor = lightColor * max(surfaceToLight.NdotL * shadow * lightIntensity * attenuation*(1.0-surface.metalness), 0.0f);
    return evaluateStandardBRDF(surface,surfaceToLight) * factor;
 }
 

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

@@ -232,24 +232,24 @@ float3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
    float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughnessSq);
    float3 Fr = D * F * Vis;
    
-#if CAPTURING == true
-    return lerp(Fd + Fr,surface.f0,surface.metalness);
+#ifdef CAPTURING
+    return saturate(lerp(Fd + Fr,surface.f0,surface.metalness));
 #else
-   return Fd + Fr;
+   return saturate(Fd + Fr);
 #endif
 
 }
 
 float3 getDirectionalLight(Surface surface, SurfaceToLight surfaceToLight, float3 lightColor, float lightIntensity, float shadow)
 {
-   float3 factor = lightColor * max(surfaceToLight.NdotL, 0.0f) * shadow * lightIntensity;
+   float3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity*(1.0-surface.metalness), 0.0f) ;
    return evaluateStandardBRDF(surface,surfaceToLight) * factor;
 }
 
 float3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, float3 lightColor, float lightIntensity, float radius, float shadow)
 {
    float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
-   float3 factor = lightColor * max(surfaceToLight.NdotL, 0.0f) * shadow * lightIntensity * attenuation;
+   float3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity * attenuation*(1.0-surface.metalness), 0.0f) ;
    return evaluateStandardBRDF(surface,surfaceToLight) * factor;
 }