mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
GLSL To match
Update the glsl side to match hlsl ies profile usage
This commit is contained in:
parent
4417462499
commit
39ec0305f9
2 changed files with 44 additions and 18 deletions
|
|
@ -108,11 +108,15 @@ uniform sampler2D deferredBuffer;
|
||||||
#include "softShadow.glsl"
|
#include "softShadow.glsl"
|
||||||
uniform sampler2D colorBuffer;
|
uniform sampler2D colorBuffer;
|
||||||
uniform sampler2D matInfoBuffer;
|
uniform sampler2D matInfoBuffer;
|
||||||
#ifdef USE_COOKIE_TEX
|
#ifdef SHADOW_CUBE
|
||||||
/// The texture for cookie rendering.
|
/// The texture for cookie rendering.
|
||||||
uniform samplerCube cookieMap;
|
uniform samplerCube cookieMap;
|
||||||
|
#else
|
||||||
|
uniform sampler2D cookieMap;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uniform sampler2D iesProfile;
|
||||||
|
|
||||||
uniform vec4 rtParams0;
|
uniform vec4 rtParams0;
|
||||||
|
|
||||||
uniform vec3 lightPosition;
|
uniform vec3 lightPosition;
|
||||||
|
|
@ -181,7 +185,12 @@ void main()
|
||||||
#ifdef USE_COOKIE_TEX
|
#ifdef USE_COOKIE_TEX
|
||||||
|
|
||||||
// Lookup the cookie sample.
|
// Lookup the cookie sample.
|
||||||
|
#ifdef SHADOW_CUBE
|
||||||
vec4 cookie = texture(cookieMap, tMul(worldToLightProj, -surfaceToLight.L));
|
vec4 cookie = texture(cookieMap, tMul(worldToLightProj, -surfaceToLight.L));
|
||||||
|
#else
|
||||||
|
vec2 cookieCoord = decodeShadowCoord( tMul( worldToLightProj, -surfaceToLight.L ) ).xy;
|
||||||
|
vec4 cookie = texture(cookieMap, cookieCoord);
|
||||||
|
#endif
|
||||||
// Multiply the light with the cookie tex.
|
// Multiply the light with the cookie tex.
|
||||||
lightCol *= cookie.rgb;
|
lightCol *= cookie.rgb;
|
||||||
// Use a maximum channel luminance to attenuate
|
// Use a maximum channel luminance to attenuate
|
||||||
|
|
@ -224,6 +233,15 @@ void main()
|
||||||
|
|
||||||
//get punctual light contribution
|
//get punctual light contribution
|
||||||
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
|
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;
|
||||||
|
// Multiply the light with the iesMask tex.
|
||||||
|
lighting *= iesMask;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OUT_col = vec4(lighting, 0);
|
OUT_col = vec4(lighting, 0);
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,8 @@ 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
|
|
||||||
/// The texture for cookie rendering.
|
|
||||||
uniform sampler2D cookieMap;
|
uniform sampler2D cookieMap;
|
||||||
#endif
|
uniform sampler2D iesProfile;
|
||||||
|
|
||||||
uniform vec4 rtParams0;
|
uniform vec4 rtParams0;
|
||||||
|
|
||||||
uniform float lightBrightness;
|
uniform float lightBrightness;
|
||||||
|
|
@ -91,7 +88,7 @@ void main()
|
||||||
if(dist < lightRange)
|
if(dist < lightRange)
|
||||||
{
|
{
|
||||||
SurfaceToLight surfaceToLight = createSurfaceToLight(surface, L);
|
SurfaceToLight surfaceToLight = createSurfaceToLight(surface, L);
|
||||||
vec3 lightCol = lightColor.rgb;
|
|
||||||
|
|
||||||
float shadow = 1.0;
|
float shadow = 1.0;
|
||||||
#ifndef NO_SHADOW
|
#ifndef NO_SHADOW
|
||||||
|
|
@ -105,19 +102,22 @@ void main()
|
||||||
//distance to light in shadow map space
|
//distance to light in shadow map space
|
||||||
float distToLight = pxlPosLightProj.z / lightRange;
|
float distToLight = pxlPosLightProj.z / lightRange;
|
||||||
shadow = softShadow_filter(shadowMap, ssPos.xy/ssPos.w, shadowCoord, shadowSoftness, distToLight, surfaceToLight.NdotL, lightParams.y);
|
shadow = softShadow_filter(shadowMap, ssPos.xy/ssPos.w, shadowCoord, shadowSoftness, distToLight, surfaceToLight.NdotL, lightParams.y);
|
||||||
#ifdef USE_COOKIE_TEX
|
|
||||||
// Lookup the cookie sample.
|
|
||||||
vec4 cookie = texture(cookieMap, shadowCoord);
|
|
||||||
// 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
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
vec3 lightCol = lightColor.rgb;
|
||||||
|
#ifdef USE_COOKIE_TEX
|
||||||
|
// Lookup the cookie sample.
|
||||||
|
vec4 cookie = texture(cookieMap, shadowCoord);
|
||||||
|
// 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
|
#ifdef DIFFUSE_LIGHT_VIZ
|
||||||
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
|
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
|
||||||
|
|
@ -156,6 +156,14 @@ void main()
|
||||||
|
|
||||||
//get spot light contribution
|
//get spot light contribution
|
||||||
lighting = getSpotlight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, lightDirection, lightSpotParams, shadow);
|
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;
|
||||||
|
// Multiply the light with the iesMask tex.
|
||||||
|
lighting *= iesMask;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
OUT_col = vec4(lighting, 0);
|
OUT_col = vec4(lighting, 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue