a) use a 1d texture for this

b) if we're going to optionally assign iesProfiles via shadowMacros.push_back, should specify the entries for the samplers too
This commit is contained in:
AzaezelX 2024-02-22 17:53:53 -06:00
parent 0b7fd2f0b3
commit 14b6822e49
4 changed files with 46 additions and 22 deletions

View file

@ -108,6 +108,7 @@ uniform sampler2D deferredBuffer;
#include "softShadow.glsl"
uniform sampler2D colorBuffer;
uniform sampler2D matInfoBuffer;
#ifdef SHADOW_CUBE
/// The texture for cookie rendering.
uniform samplerCube cookieMap;
@ -115,7 +116,9 @@ uniform samplerCube cookieMap;
uniform sampler2D cookieMap;
#endif
uniform sampler2D iesProfile;
#ifdef UES_PHOTOMETRIC_MASK
uniform sampler1D iesProfile;
#endif
uniform vec4 rtParams0;
@ -231,17 +234,18 @@ void main()
OUT_col = vec4(final, 0);
return
#endif
//get punctual light contribution
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
#ifdef UES_PHOTOMETRIC_MASK
// Lookup the cookie sample.d
float cosTheta = dot(-surfaceToLight.L, lightDirection);
float angle = acos(cosTheta) * ( M_1OVER_PI_F);
float iesMask = texture(iesProfile, vec2(angle, 0.0)).r;
float iesMask = texture(iesProfile,angle).r;
// Multiply the light with the iesMask tex.
lighting *= iesMask;
shadow *= iesMask;
#endif
//get punctual light contribution
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
}

View file

@ -38,8 +38,15 @@ uniform sampler2D shadowMap;
#include "softShadow.glsl"
uniform sampler2D colorBuffer;
uniform sampler2D matInfoBuffer;
#ifdef USE_COOKIE_TEX
uniform sampler2D cookieMap;
uniform sampler2D iesProfile;
#endif
#ifdef UES_PHOTOMETRIC_MASK
uniform sampler1D iesProfile;
#endif
uniform vec4 rtParams0;
uniform float lightBrightness;
@ -154,16 +161,17 @@ void main()
return;
#endif
//get spot light contribution
lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow);
#ifdef UES_PHOTOMETRIC_MASK
// Lookup the cookie sample.d
float cosTheta = dot(-surfaceToLight.L, lightDirection);
float angle = acos(cosTheta) * ( M_1OVER_PI_F);
float iesMask = texture(iesProfile, vec2(angle, 0.0)).r;
float iesMask = texture(iesProfile, angle).r;
// Multiply the light with the iesMask tex.
lighting *= iesMask;
shadow *= iesMask;
#endif
//get spot light contribution
lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow);
}
OUT_col = vec4(lighting, 0);

View file

@ -107,13 +107,17 @@ TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
#include "softShadow.hlsl"
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3);
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4);
/// The texture for cookie rendering.
#ifdef SHADOW_CUBE
TORQUE_UNIFORM_SAMPLERCUBE(cookieMap, 5);
#else
TORQUE_UNIFORM_SAMPLER2D(cookieMap, 5);
#endif
TORQUE_UNIFORM_SAMPLER2D(iesProfile, 6);
#ifdef UES_PHOTOMETRIC_MASK
TORQUE_UNIFORM_SAMPLER1D(iesProfile, 6);
#endif
uniform float4 rtParams0;
uniform float4 lightColor;
@ -223,17 +227,18 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
return final;
#endif
//get punctual light contribution
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
#ifdef UES_PHOTOMETRIC_MASK
// Lookup the cookie sample.d
float cosTheta = dot(-surfaceToLight.L, lightDirection);
float angle = acos(cosTheta) * ( M_1OVER_PI_F);
float iesMask = TORQUE_TEX2D(iesProfile, float2(angle, 0.0)).r;
float iesMask = TORQUE_TEX2D(iesProfile, angle).r;
// Multiply the light with the iesMask tex.
lighting *= iesMask;
shadow *= iesMask;
#endif
//get punctual light contribution
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
}

View file

@ -43,8 +43,14 @@ TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3);
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4);
/// The texture for cookie rendering.
#ifdef USE_COOKIE_TEX
TORQUE_UNIFORM_SAMPLER2D(cookieMap, 5);
TORQUE_UNIFORM_SAMPLER2D(iesProfile, 6);
#endif
#ifdef UES_PHOTOMETRIC_MASK
TORQUE_UNIFORM_SAMPLER1D(iesProfile, 6);
#endif
uniform float4 rtParams0;
@ -153,16 +159,17 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
return final;
#endif
//get spot light contribution
lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow);
#ifdef UES_PHOTOMETRIC_MASK
// Lookup the cookie sample.d
float cosTheta = dot(-surfaceToLight.L, lightDirection);
float angle = acos(cosTheta) * ( M_1OVER_PI_F);
float iesMask = TORQUE_TEX2D(iesProfile, float2(angle, 0.0)).r;
float iesMask = TORQUE_TEX1D(iesProfile, angle).r;
// Multiply the light with the iesMask tex.
lighting *= iesMask;
shadow *= iesMask;
#endif
//get spot light contribution
lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow);
}
return float4(lighting, 0);