diff --git a/Templates/BaseGame/game/core/rendering/images/brdfTexture.dds b/Templates/BaseGame/game/core/rendering/images/brdfTexture.dds index 851bd0eaf..8f59c0a45 100644 Binary files a/Templates/BaseGame/game/core/rendering/images/brdfTexture.dds and b/Templates/BaseGame/game/core/rendering/images/brdfTexture.dds differ diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index 315e3434c..8f67787b3 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -319,7 +319,7 @@ float computeSpecOcclusion( float NdotV , float AO , float roughness ) float roughnessToMipLevel(float roughness, float numMips) { - return saturate((roughness * numMips) - (pow(roughness, 6.0) * (numMips * 0.125))); + return roughness * (numMips+1.0); } vec4 compute4Lights( Surface surface, @@ -585,10 +585,14 @@ vec4 computeForwardProbes(Surface 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.baseColor.rgb) * 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)); + horizon *= horizon; // Final color output after environment lighting - vec3 finalColor = diffuse + specularCol; + vec3 finalColor = diffuse + specularCol * horizon; finalColor *= surface.ao; if(isCapturing == 1) @@ -738,10 +742,14 @@ vec4 debugVizForwardProbes(Surface 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.baseColor.rgb) * 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)); + horizon *= horizon; // Final color output after environment lighting - vec3 finalColor = diffuse + specularCol; + vec3 finalColor = diffuse + specularCol * horizon; finalColor *= surface.ao; if(isCapturing == 1) diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index c125fe9e6..b263d0250 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -320,7 +320,7 @@ float computeSpecOcclusion( float NdotV , float AO , float roughness ) float roughnessToMipLevel(float roughness, float numMips) { - return saturate((roughness * numMips) - (pow(roughness, 6.0) * (numMips * 0.125))); + return roughness * (numMips+1.0); } float4 compute4Lights( Surface surface, @@ -591,7 +591,7 @@ float4 computeForwardProbes(Surface surface, 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.baseColor.rgb) * 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)); @@ -748,7 +748,7 @@ float4 debugVizForwardProbes(Surface surface, 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.baseColor.rgb) * 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)); diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/reflectionProbeArrayP.glsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/reflectionProbeArrayP.glsl index 7a6869352..4eb3770ac 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/reflectionProbeArrayP.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/reflectionProbeArrayP.glsl @@ -206,10 +206,14 @@ void main() 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.baseColor.rgb) * 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)); + horizon *= horizon; // Final color output after environment lighting - vec3 finalColor = diffuse + specularCol; + vec3 finalColor = diffuse + specularCol * horizon; finalColor *= surface.ao; if(isCapturing == 1) diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl index 258b0bd78..d26511959 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl @@ -194,14 +194,14 @@ float4 main(PFXVertToPix IN) : SV_TARGET 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.baseColor.rgb) * 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; + float3 finalColor = diffuse + specularCol*horizon; finalColor *= surface.ao; if(isCapturing == 1)