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 508e9b4f27
commit 913fbef66d
2 changed files with 19 additions and 20 deletions

View file

@ -156,13 +156,6 @@ LightTargetOutput main( ConvexConnectP IN )
float3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane ); float3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane );
float3 viewSpacePos = eyeRay * normDepth.w; 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;
// Build light vec, get length, clip pixel if needed // Build light vec, get length, clip pixel if needed
float3 lightVec = lightPosition - viewSpacePos; float3 lightVec = lightPosition - viewSpacePos;
float lenLightV = length(lightVec); float lenLightV = length(lightVec);
@ -175,6 +168,12 @@ LightTargetOutput main( ConvexConnectP IN )
// Normalize lightVec // Normalize lightVec
lightVec /= lenLightV; 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 // If we can do dynamic branching then avoid wasting
// fillrate on pixels that are backfacing to the light. // fillrate on pixels that are backfacing to the light.

View file

@ -90,17 +90,6 @@ LightTargetOutput main( ConvexConnectP IN )
float3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane ); float3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane );
float3 viewSpacePos = eyeRay * normDepth.w; 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 // Build light vec, get length, clip pixel if needed
float3 lightToPxlVec = viewSpacePos - lightPosition; float3 lightToPxlVec = viewSpacePos - lightPosition;
float lenLightV = length( lightToPxlVec ); float lenLightV = length( lightToPxlVec );
@ -116,6 +105,17 @@ LightTargetOutput main( ConvexConnectP IN )
clip( atten - 1e-6 ); clip( atten - 1e-6 );
atten = saturate( atten ); 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 ); float nDotL = dot( normDepth.xyz, -lightToPxlVec );
// Get the shadow texture coordinate // Get the shadow texture coordinate