mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 16:25:42 +00:00
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:
parent
0b7fd2f0b3
commit
14b6822e49
4 changed files with 46 additions and 22 deletions
|
|
@ -108,6 +108,7 @@ uniform sampler2D deferredBuffer;
|
||||||
#include "softShadow.glsl"
|
#include "softShadow.glsl"
|
||||||
uniform sampler2D colorBuffer;
|
uniform sampler2D colorBuffer;
|
||||||
uniform sampler2D matInfoBuffer;
|
uniform sampler2D matInfoBuffer;
|
||||||
|
|
||||||
#ifdef SHADOW_CUBE
|
#ifdef SHADOW_CUBE
|
||||||
/// The texture for cookie rendering.
|
/// The texture for cookie rendering.
|
||||||
uniform samplerCube cookieMap;
|
uniform samplerCube cookieMap;
|
||||||
|
|
@ -115,7 +116,9 @@ uniform samplerCube cookieMap;
|
||||||
uniform sampler2D cookieMap;
|
uniform sampler2D cookieMap;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uniform sampler2D iesProfile;
|
#ifdef UES_PHOTOMETRIC_MASK
|
||||||
|
uniform sampler1D iesProfile;
|
||||||
|
#endif
|
||||||
|
|
||||||
uniform vec4 rtParams0;
|
uniform vec4 rtParams0;
|
||||||
|
|
||||||
|
|
@ -231,17 +234,18 @@ void main()
|
||||||
OUT_col = vec4(final, 0);
|
OUT_col = vec4(final, 0);
|
||||||
return
|
return
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//get punctual light contribution
|
|
||||||
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
|
|
||||||
#ifdef UES_PHOTOMETRIC_MASK
|
#ifdef UES_PHOTOMETRIC_MASK
|
||||||
// Lookup the cookie sample.d
|
// Lookup the cookie sample.d
|
||||||
float cosTheta = dot(-surfaceToLight.L, lightDirection);
|
float cosTheta = dot(-surfaceToLight.L, lightDirection);
|
||||||
float angle = acos(cosTheta) * ( M_1OVER_PI_F);
|
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.
|
// Multiply the light with the iesMask tex.
|
||||||
lighting *= iesMask;
|
shadow *= iesMask;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//get punctual light contribution
|
||||||
|
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,15 @@ uniform sampler2D shadowMap;
|
||||||
#include "softShadow.glsl"
|
#include "softShadow.glsl"
|
||||||
uniform sampler2D colorBuffer;
|
uniform sampler2D colorBuffer;
|
||||||
uniform sampler2D matInfoBuffer;
|
uniform sampler2D matInfoBuffer;
|
||||||
|
|
||||||
|
#ifdef USE_COOKIE_TEX
|
||||||
uniform sampler2D cookieMap;
|
uniform sampler2D cookieMap;
|
||||||
uniform sampler2D iesProfile;
|
#endif
|
||||||
|
|
||||||
|
#ifdef UES_PHOTOMETRIC_MASK
|
||||||
|
uniform sampler1D iesProfile;
|
||||||
|
#endif
|
||||||
|
|
||||||
uniform vec4 rtParams0;
|
uniform vec4 rtParams0;
|
||||||
|
|
||||||
uniform float lightBrightness;
|
uniform float lightBrightness;
|
||||||
|
|
@ -154,16 +161,17 @@ void main()
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//get spot light contribution
|
|
||||||
lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow);
|
|
||||||
#ifdef UES_PHOTOMETRIC_MASK
|
#ifdef UES_PHOTOMETRIC_MASK
|
||||||
// Lookup the cookie sample.d
|
// Lookup the cookie sample.d
|
||||||
float cosTheta = dot(-surfaceToLight.L, lightDirection);
|
float cosTheta = dot(-surfaceToLight.L, lightDirection);
|
||||||
float angle = acos(cosTheta) * ( M_1OVER_PI_F);
|
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.
|
// Multiply the light with the iesMask tex.
|
||||||
lighting *= iesMask;
|
shadow *= iesMask;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//get spot light contribution
|
||||||
|
lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
OUT_col = vec4(lighting, 0);
|
OUT_col = vec4(lighting, 0);
|
||||||
|
|
|
||||||
|
|
@ -107,13 +107,17 @@ TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
|
||||||
#include "softShadow.hlsl"
|
#include "softShadow.hlsl"
|
||||||
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3);
|
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4);
|
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4);
|
||||||
|
|
||||||
/// The texture for cookie rendering.
|
/// The texture for cookie rendering.
|
||||||
#ifdef SHADOW_CUBE
|
#ifdef SHADOW_CUBE
|
||||||
TORQUE_UNIFORM_SAMPLERCUBE(cookieMap, 5);
|
TORQUE_UNIFORM_SAMPLERCUBE(cookieMap, 5);
|
||||||
#else
|
#else
|
||||||
TORQUE_UNIFORM_SAMPLER2D(cookieMap, 5);
|
TORQUE_UNIFORM_SAMPLER2D(cookieMap, 5);
|
||||||
#endif
|
#endif
|
||||||
TORQUE_UNIFORM_SAMPLER2D(iesProfile, 6);
|
|
||||||
|
#ifdef UES_PHOTOMETRIC_MASK
|
||||||
|
TORQUE_UNIFORM_SAMPLER1D(iesProfile, 6);
|
||||||
|
#endif
|
||||||
|
|
||||||
uniform float4 rtParams0;
|
uniform float4 rtParams0;
|
||||||
uniform float4 lightColor;
|
uniform float4 lightColor;
|
||||||
|
|
@ -223,17 +227,18 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
|
||||||
return final;
|
return final;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//get punctual light contribution
|
|
||||||
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
|
|
||||||
|
|
||||||
#ifdef UES_PHOTOMETRIC_MASK
|
#ifdef UES_PHOTOMETRIC_MASK
|
||||||
// Lookup the cookie sample.d
|
// Lookup the cookie sample.d
|
||||||
float cosTheta = dot(-surfaceToLight.L, lightDirection);
|
float cosTheta = dot(-surfaceToLight.L, lightDirection);
|
||||||
float angle = acos(cosTheta) * ( M_1OVER_PI_F);
|
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.
|
// Multiply the light with the iesMask tex.
|
||||||
lighting *= iesMask;
|
shadow *= iesMask;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//get punctual light contribution
|
||||||
|
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,14 @@ TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3);
|
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4);
|
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4);
|
||||||
/// The texture for cookie rendering.
|
/// The texture for cookie rendering.
|
||||||
|
|
||||||
|
#ifdef USE_COOKIE_TEX
|
||||||
TORQUE_UNIFORM_SAMPLER2D(cookieMap, 5);
|
TORQUE_UNIFORM_SAMPLER2D(cookieMap, 5);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(iesProfile, 6);
|
#endif
|
||||||
|
|
||||||
|
#ifdef UES_PHOTOMETRIC_MASK
|
||||||
|
TORQUE_UNIFORM_SAMPLER1D(iesProfile, 6);
|
||||||
|
#endif
|
||||||
|
|
||||||
uniform float4 rtParams0;
|
uniform float4 rtParams0;
|
||||||
|
|
||||||
|
|
@ -153,16 +159,17 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
|
||||||
return final;
|
return final;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//get spot light contribution
|
|
||||||
lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow);
|
|
||||||
#ifdef UES_PHOTOMETRIC_MASK
|
#ifdef UES_PHOTOMETRIC_MASK
|
||||||
// Lookup the cookie sample.d
|
// Lookup the cookie sample.d
|
||||||
float cosTheta = dot(-surfaceToLight.L, lightDirection);
|
float cosTheta = dot(-surfaceToLight.L, lightDirection);
|
||||||
float angle = acos(cosTheta) * ( M_1OVER_PI_F);
|
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.
|
// Multiply the light with the iesMask tex.
|
||||||
lighting *= iesMask;
|
shadow *= iesMask;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//get spot light contribution
|
||||||
|
lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
return float4(lighting, 0);
|
return float4(lighting, 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue