diff --git a/Templates/Full/game/shaders/common/lighting/advanced/reflectionProbeP.hlsl b/Templates/Full/game/shaders/common/lighting/advanced/reflectionProbeP.hlsl index 485d820bf..69ed63c1e 100644 --- a/Templates/Full/game/shaders/common/lighting/advanced/reflectionProbeP.hlsl +++ b/Templates/Full/game/shaders/common/lighting/advanced/reflectionProbeP.hlsl @@ -55,20 +55,6 @@ float3 boxProject(float3 wsPosition, float3 reflectDir, float3 boxWSPos, float3 return posonbox - boxWSPos; } -float3 iblBoxDiffuse(float3 normal, - float3 wsPos, - TORQUE_SAMPLERCUBE(irradianceCube), - float3 boxPos, - float3 boxMin, - float3 boxMax) -{ - // Irradiance (Diffuse) - float3 cubeN = normalize(normal); - float3 irradiance = TORQUE_TEXCUBE(irradianceCube, cubeN).xyz; - - return irradiance; -} - float3 iblBoxSpecular(float3 normal, float3 wsPos, float roughness, float3 surfToEye, TORQUE_SAMPLER2D(brdfTexture), TORQUE_SAMPLERCUBE(radianceCube), @@ -79,7 +65,7 @@ float3 iblBoxSpecular(float3 normal, float3 wsPos, float roughness, float3 surfT float ndotv = clamp(dot(normal, surfToEye), 0.0, 1.0); // BRDF - float2 brdf = TORQUE_TEX2D(brdfTexture, float2(roughness, ndotv)).xy; + float2 brdf = TORQUE_TEX2DLOD(brdfTexture, float4(roughness, ndotv,0.0,0.0)).xy; // Radiance (Specular) float maxmip = pow(cubeMips+1,2); @@ -172,15 +158,15 @@ float4 main( ConvexConnectP IN ) : SV_TARGET //render into the bound space defined above float3 surfToEye = normalize(surface.P - eyePosWorld); - float3 irradiance = iblBoxDiffuse(surface.N, surface.P, TORQUE_SAMPLERCUBE_MAKEARG(irradianceCubemap), probeWSPos, bbMin, bbMax); + float3 irradiance = TORQUE_TEXCUBELOD(irradianceCubemap, float4(surface.N,0)).xyz; float3 specular = iblBoxSpecular(surface.N, surface.P, surface.roughness, surfToEye, TORQUE_SAMPLER2D_MAKEARG(BRDFTexture), TORQUE_SAMPLERCUBE_MAKEARG(cubeMap), probeWSPos, bbMin, bbMax); - - //energy conservation float3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness); + specular *= F; + //energy conservation float3 kD = 1.0.xxx - F; kD *= 1.0 - surface.metalness; //final diffuse color float3 diffuse = kD * irradiance * surface.baseColor.rgb; - return float4((diffuse+specular) * surface.ao, blendVal); + return float4(diffuse + specular * surface.ao, blendVal); }