|
@@ -42,11 +42,10 @@ TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
|
|
|
#include "softShadow.hlsl"
|
|
|
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3);
|
|
|
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4);
|
|
|
-#ifdef USE_COOKIE_TEX
|
|
|
/// The texture for cookie rendering.
|
|
|
TORQUE_UNIFORM_SAMPLER2D(cookieMap, 5);
|
|
|
+TORQUE_UNIFORM_SAMPLER2D(iesProfile, 6);
|
|
|
|
|
|
-#endif
|
|
|
uniform float4 rtParams0;
|
|
|
|
|
|
uniform float lightBrightness;
|
|
@@ -96,8 +95,7 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
|
|
|
if(dist < lightRange)
|
|
|
{
|
|
|
SurfaceToLight surfaceToLight = createSurfaceToLight(surface, L);
|
|
|
- float3 lightCol = lightColor.rgb;
|
|
|
-
|
|
|
+
|
|
|
float shadow = 1.0;
|
|
|
#ifndef NO_SHADOW
|
|
|
if (getFlag(surface.matFlag, 0)) //also skip if we don't recieve shadows
|
|
@@ -109,10 +107,23 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
|
|
|
//distance to light in shadow map space
|
|
|
float distToLight = pxlPosLightProj.z / lightRange;
|
|
|
shadow = softShadow_filter(TORQUE_SAMPLER2D_MAKEARG(shadowMap), ssPos.xy, shadowCoord, shadowSoftness, distToLight, surfaceToLight.NdotL, lightParams.y);
|
|
|
-
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+ float3 lightCol = lightColor.rgb;
|
|
|
+ #ifdef USE_COOKIE_TEX
|
|
|
+ float4 pxlPosLightProj = mul( worldToLightProj, float4( surface.P, 1 ) );
|
|
|
+ float2 cookieCoord = ( ( pxlPosLightProj.xy / pxlPosLightProj.w ) * 0.5 ) + float2( 0.5, 0.5 );
|
|
|
+ // Lookup the cookie sample.
|
|
|
+ float4 cookie = TORQUE_TEX2D(cookieMap, cookieCoord);
|
|
|
+ // Multiply the light with the cookie tex.
|
|
|
+ lightCol *= cookie.rgb;
|
|
|
+ // Use a maximum channel luminance to attenuate
|
|
|
+ // the lighting else we get specular in the dark
|
|
|
+ // regions of the cookie texture.
|
|
|
+ lightCol *= max(cookie.r, max(cookie.g, cookie.b));
|
|
|
+ #endif
|
|
|
+
|
|
|
#ifdef DIFFUSE_LIGHT_VIZ
|
|
|
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
|
|
|
float3 factor = lightColor * max(surfaceToLight.NdotL, 0) * shadow * lightIntensity * attenuation;
|
|
@@ -144,13 +155,13 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
|
|
|
|
|
|
//get spot light contribution
|
|
|
lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow);
|
|
|
- #ifdef USE_COOKIE_TEX
|
|
|
+ #ifdef UES_PHOTOMETRIC_MASK
|
|
|
// Lookup the cookie sample.d
|
|
|
float cosTheta = dot(-surfaceToLight.L, lightDirection);
|
|
|
float angle = acos(cosTheta) * ( M_1OVER_PI_F);
|
|
|
- float cookie = TORQUE_TEX2D(cookieMap, float2(angle, 0.0)).r;
|
|
|
- // Multiply the light with the cookie tex.
|
|
|
- lighting *= cookie;
|
|
|
+ float iesMask = TORQUE_TEX2D(iesProfile, float2(angle, 0.0)).r;
|
|
|
+ // Multiply the light with the iesMask tex.
|
|
|
+ lighting *= iesMask;
|
|
|
#endif
|
|
|
}
|
|
|
|