From a44d8858854bbc683be4d615abf01be5a4706166 Mon Sep 17 00:00:00 2001 From: Tim Barnes Date: Sun, 28 Oct 2018 20:52:32 +1000 Subject: [PATCH] oops forgot poor skylight shader --- .../common/lighting/advanced/skylightP.hlsl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Templates/Full/game/shaders/common/lighting/advanced/skylightP.hlsl b/Templates/Full/game/shaders/common/lighting/advanced/skylightP.hlsl index 2eb678b0f..aeee9fb7e 100644 --- a/Templates/Full/game/shaders/common/lighting/advanced/skylightP.hlsl +++ b/Templates/Full/game/shaders/common/lighting/advanced/skylightP.hlsl @@ -24,7 +24,7 @@ uniform float4 rtParams0; uniform float4 vsFarPlane; -uniform float4x4 invViewMat; +uniform float4x4 cameraToWorld; uniform float3 eyePosWorld; @@ -117,20 +117,20 @@ PS_OUTPUT main( ConvexConnectP IN ) return Output; // Need world-space normal. - float3 wsNormal = mul(float4(normal, 1), invViewMat).rgb; + float3 wsNormal = mul(cameraToWorld, float4(normal, 0)).xyz; - float3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane ); + float3 vsEyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane ); + float3 vsPos = vsEyeRay * depth; - float3 wsEyeRay = mul(float4(eyeRay, 1), invViewMat).rgb; + float3 wsEyeRay = mul(cameraToWorld, float4(vsEyeRay, 0)).xyz; + // calculate world space position + float3 wsPos = float3(eyePosWorld + wsEyeRay * depth); - // Use eye ray to get ws pos - float3 worldPos = float3(eyePosWorld + wsEyeRay * depth); - - float3 reflectionVec = reflect(IN.wsEyeDir, float4(wsNormal,1)).xyz; + float3 reflectionVec = reflect(IN.wsEyeDir, float4(wsNormal,0)).xyz; float roughness = 1 - matInfo.b; - float3 v = normalize(eyePosWorld - worldPos); + float3 v = normalize(eyePosWorld - wsPos); float3 irradiance = TORQUE_TEXCUBE(irradianceCubemap, wsNormal).rgb;