From 452c35f11c91ea7d1c4cd4b3f9b80b558e4d8760 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Tue, 6 Nov 2018 20:07:09 -0600 Subject: [PATCH] further wipwork on the pointlight conversion. filled CreateSurfaceToLight out in a theoretically correct manner (spoiler, not actually correct) --- .../shaders/common/lighting/advanced/pointLightP.hlsl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Templates/Full/game/shaders/common/lighting/advanced/pointLightP.hlsl b/Templates/Full/game/shaders/common/lighting/advanced/pointLightP.hlsl index ce1527779..21d89d1db 100644 --- a/Templates/Full/game/shaders/common/lighting/advanced/pointLightP.hlsl +++ b/Templates/Full/game/shaders/common/lighting/advanced/pointLightP.hlsl @@ -154,7 +154,7 @@ LightTargetOutput main( ConvexConnectP IN ) // Eye ray - Eye -> Pixel float3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane ); - float3 viewSpacePos = eyeRay * normDepth.w; + float3 viewSpacePos = eyeRay * normDepth.w; // Build light vec, get length, clip pixel if needed float3 lightVec = lightPosition - viewSpacePos; @@ -179,8 +179,9 @@ LightTargetOutput main( ConvexConnectP IN ) // fillrate on pixels that are backfacing to the light. float nDotL = dot( lightVec, normDepth.xyz ); //DB_CLIP( nDotL < 0 ); - //create surface to light - SurfaceToLight surfaceToLight = CreateSurfaceToLight(surface, dot( lightVec, normDepth.xyz )); + //create surface to light + float3 wsLightDir = mul(cameraToWorld, float4(lightVec,0)).xyz; + SurfaceToLight surfaceToLight = CreateSurfaceToLight(surface, wsLightDir);//lightPosition - viewSpacePos); #ifdef NO_SHADOW @@ -206,7 +207,7 @@ LightTargetOutput main( ConvexConnectP IN ) shadowCoord, shadowSoftness, distToLight, - nDotL, + surfaceToLight.NdotL, lightParams.y); // Dynamic @@ -216,7 +217,7 @@ LightTargetOutput main( ConvexConnectP IN ) dynamicShadowCoord, shadowSoftness, distToLight, - nDotL, + surfaceToLight.NdotL, lightParams.y); float shadowed = min(static_shadowed, dynamic_shadowed);