shift surface calcs to post-attenuation. no point if we're just gonna throw the vals out in the end

This commit is contained in:
Azaezel 2018-11-02 17:41:30 -05:00
parent 69a2dae3bb
commit 485edb5866
2 changed files with 19 additions and 20 deletions

View file

@ -154,14 +154,7 @@ LightTargetOutput main( ConvexConnectP IN )
// Eye ray - Eye -> Pixel
float3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane );
float3 viewSpacePos = eyeRay * normDepth.w;
//create surface
Surface surface = CreateSurface( normDepth, TORQUE_SAMPLER2D_MAKEARG(colorBuffer),TORQUE_SAMPLER2D_MAKEARG(matInfoBuffer),
uvScene, eyePosWorld, eyeRay, cameraToWorld);
//early out if emissive
if (getFlag(surface.matFlag, 0))
return Output;
float3 viewSpacePos = eyeRay * normDepth.w;
// Build light vec, get length, clip pixel if needed
float3 lightVec = lightPosition - viewSpacePos;
@ -175,6 +168,12 @@ LightTargetOutput main( ConvexConnectP IN )
// Normalize lightVec
lightVec /= lenLightV;
//create surface
Surface surface = CreateSurface( normDepth, TORQUE_SAMPLER2D_MAKEARG(colorBuffer),TORQUE_SAMPLER2D_MAKEARG(matInfoBuffer),
uvScene, eyePosWorld, eyeRay, cameraToWorld);
//early out if emissive
if (getFlag(surface.matFlag, 0))
return Output;
// If we can do dynamic branching then avoid wasting
// fillrate on pixels that are backfacing to the light.

View file

@ -89,18 +89,7 @@ LightTargetOutput main( ConvexConnectP IN )
// Eye ray - Eye -> Pixel
float3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane );
float3 viewSpacePos = eyeRay * normDepth.w;
//create surface
Surface surface = CreateSurface( normDepth, TORQUE_SAMPLER2D_MAKEARG(colorBuffer),TORQUE_SAMPLER2D_MAKEARG(matInfoBuffer),
uvScene, eyePosWorld, eyeRay, cameraToWorld);
//early out if emissive
if (getFlag(surface.matFlag, 0))
return Output;
//create surface to light
float3 wsLightDir = mul(cameraToWorld, float4(lightDirection,0)).xyz;
SurfaceToLight surfaceToLight = CreateSurfaceToLight(surface, -wsLightDir);
// Build light vec, get length, clip pixel if needed
float3 lightToPxlVec = viewSpacePos - lightPosition;
float lenLightV = length( lightToPxlVec );
@ -116,6 +105,17 @@ LightTargetOutput main( ConvexConnectP IN )
clip( atten - 1e-6 );
atten = saturate( atten );
//create surface
Surface surface = CreateSurface( normDepth, TORQUE_SAMPLER2D_MAKEARG(colorBuffer),TORQUE_SAMPLER2D_MAKEARG(matInfoBuffer),
uvScene, eyePosWorld, eyeRay, cameraToWorld);
//early out if emissive
if (getFlag(surface.matFlag, 0))
return Output;
//create surface to light
float3 wsLightDir = mul(cameraToWorld, float4(lightDirection,0)).xyz;
SurfaceToLight surfaceToLight = CreateSurfaceToLight(surface, -wsLightDir);
float nDotL = dot( normDepth.xyz, -lightToPxlVec );
// Get the shadow texture coordinate