diff --git a/Engine/source/renderInstance/renderProbeMgr.cpp b/Engine/source/renderInstance/renderProbeMgr.cpp index e3f1e7e6a..3eda07362 100644 --- a/Engine/source/renderInstance/renderProbeMgr.cpp +++ b/Engine/source/renderInstance/renderProbeMgr.cpp @@ -238,7 +238,7 @@ bool RenderProbeMgr::onAdd() mCubeSlotCount = PROBE_ARRAY_SLOT_BUFFER_SIZE; String brdfTexturePath = GFXTextureManager::getBRDFTexturePath(); - if (!mBRDFTexture.set(brdfTexturePath, &GFXTexturePersistentProfile, "BRDFTexture")) + if (!mBRDFTexture.set(brdfTexturePath, &GFXTexturePersistentSRGBProfile, "BRDFTexture")) { Con::errorf("RenderProbeMgr::onAdd: Failed to load BRDF Texture"); return false; diff --git a/Templates/BaseGame/game/core/rendering/images/brdfTexture.dds b/Templates/BaseGame/game/core/rendering/images/brdfTexture.dds index 8f59c0a45..851bd0eaf 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 2d24c8003..a4775b919 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -584,9 +584,8 @@ vec4 computeForwardProbes(Surface surface, vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg; vec3 diffuse = irradiance * surface.baseColor.rgb * (1.0 - surface.metalness); - - vec3 specularCol = specular * (F_Schlick(surface.f0, surface.NdotV) * envBRDF.x + envBRDF.y); - specularCol *= surface.metalness + (1.0 - surface.roughness); + vec3 specularCol = specular * lerp(envBRDF.y, envBRDF.x, surface.metalness * (1.0 - surface.roughness)); + // Final color output after environment lighting vec3 finalColor = diffuse + specularCol; finalColor *= surface.ao; @@ -737,8 +736,8 @@ vec4 debugVizForwardProbes(Surface surface, vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg; vec3 diffuse = irradiance * surface.baseColor.rgb * (1.0 - surface.metalness); - - vec3 specularCol = specular * (F_Schlick(surface.f0, surface.NdotV) * envBRDF.x + envBRDF.y); + vec3 specularCol = specular * lerp(envBRDF.y, envBRDF.x, surface.metalness * (1.0 - surface.roughness)); + specularCol *= surface.metalness + (1.0 - surface.roughness); // Final color output after environment lighting vec3 finalColor = diffuse + specularCol; diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index 4afc3cabd..2d1c7a983 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -588,11 +588,10 @@ float4 computeForwardProbes(Surface surface, specular = lerp(specular,TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, surface.R, skylightCubemapIdx, lod).xyz,alpha); } - float2 envBRDF = TORQUE_TEX2D(BRDFTexture, float2(surface.NdotV, surface.roughness)).rg; + float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg; float3 diffuse = irradiance * surface.baseColor.rgb * (1.0 - surface.metalness); - - float3 specularCol = specular * (F_Schlick(surface.f0, surface.NdotV) * envBRDF.x + envBRDF.y); - specularCol *= surface.metalness + (1.0 - surface.roughness); + float3 specularCol = specular * lerp(envBRDF.y, envBRDF.x, surface.metalness * (1.0 - surface.roughness)); + // Final color output after environment lighting float3 finalColor = diffuse + specularCol; finalColor *= surface.ao; @@ -741,10 +740,10 @@ float4 debugVizForwardProbes(Surface surface, return float4(irradiance, 0); } - float2 envBRDF = TORQUE_TEX2D(BRDFTexture, float2(surface.NdotV, surface.roughness)).rg; + float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg; float3 diffuse = irradiance * surface.baseColor.rgb * (1.0 - surface.metalness); - - float3 specularCol = specular * (F_Schlick(surface.f0, surface.NdotV) * envBRDF.x + envBRDF.y); + float3 specularCol = specular * lerp(envBRDF.y, envBRDF.x, surface.metalness * (1.0 - surface.roughness)); + specularCol *= surface.metalness + (1.0 - surface.roughness); // Final color output after environment lighting float3 finalColor = diffuse + specularCol; 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 725202b26..4860be006 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,9 +206,8 @@ void main() vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg; vec3 diffuse = irradiance * surface.baseColor.rgb * (1.0 - surface.metalness); - - vec3 specularCol = specular * (F_Schlick(surface.f0, surface.NdotV) * envBRDF.x + envBRDF.y); - specularCol *= surface.metalness + (1.0 - surface.roughness); + vec3 specularCol = specular * lerp(envBRDF.y, envBRDF.x, surface.metalness * (1.0 - surface.roughness)); + // Final color output after environment lighting vec3 finalColor = diffuse + specularCol; finalColor *= surface.ao; 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 40ebbac4b..8785ada1d 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl @@ -192,16 +192,15 @@ float4 main(PFXVertToPix IN) : SV_TARGET return float4(irradiance, 1); #endif - float2 envBRDF = TORQUE_TEX2D(BRDFTexture, float2(surface.NdotV, surface.roughness)).rg; + float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg; float3 diffuse = irradiance * surface.baseColor.rgb * (1.0 - surface.metalness); + float3 specularCol = specular * lerp(envBRDF.y, envBRDF.x, surface.metalness * (1.0 - surface.roughness)); - float3 specularCol = specular * (F_Schlick(surface.f0, surface.NdotV) * envBRDF.x + envBRDF.y); - specularCol *= surface.metalness + (1.0 - surface.roughness); // Final color output after environment lighting float3 finalColor = diffuse + specularCol; - finalColor *= surface.ao; - if(isCapturing == 1) - return float4(lerp((finalColor), surface.baseColor.rgb,surface.metalness),0); + finalColor *= surface.ao; + if(isCapturing == 1) + return float4(lerp(finalColor, surface.baseColor.rgb,surface.metalness),0); else { return float4((finalColor*ambientColor), 0);