mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
Script:
by and large, Opengl branch compatibility alterations, though do again note the inclusion of sampler["lightBuffer"] = "#lightinfo"; sampler["colorBuffer"] = "#color"; sampler["matInfoBuffer"] = "#matinfo"; and samplerNames[5] = "$lightBuffer"; samplerNames[6] = "$colorBuffer"; samplerNames[7] = "$matInfoBuffer"; entries. This is where the engine knows to pass along a given rendertarget for input into a predefined shader, as opposed to the prior phase's output to targets within procedural ones. Shader: the XXXLight.hlsl/glsls account for alterations in inputs, check for emissive and translucency, apply Felix's Normal Mapped Ambient. and pass the results along to AL_DeferredOutput for final computation before returning the result. the lighting.hlsl/.glsl consissts of removal of the overridden engine-specific phong specular variant, and defines the AL_DeferredOutput method, which equates to the previously used pixspecular feature defined along the lines of http://books.google.com/books?id=GY-AAwAAQBAJ&pg=PA112&lpg=PA112&dq=blinn+phong+specular+gloss+hlsl&source=bl&ots=q9SKJkmWHB&sig=uLIHX10Zul0X0LL2ehSMq7IFBIM&hl=en&sa=X&ei=DbcsVPeWEdW1yASDy4LYDw&ved=0CB4Q6AEwAA#v=onepage&q=gloss%20&f=false also includes visualizers Long term impact: This area, along with the \game\shaders\common\lighting\advanced\lightingUtils.hlsl/.glsl pair will be where we plug in properly attenuated Cook-Torrence later, presuming the impact is not to hefty.
This commit is contained in:
parent
196b214eae
commit
5ed06fff9d
13 changed files with 203 additions and 50 deletions
|
|
@ -36,8 +36,11 @@ new GFXStateBlockData( AL_VectorLightState )
|
||||||
|
|
||||||
samplersDefined = true;
|
samplersDefined = true;
|
||||||
samplerStates[0] = SamplerClampPoint; // G-buffer
|
samplerStates[0] = SamplerClampPoint; // G-buffer
|
||||||
|
mSamplerNames[0] = "prePassBuffer";
|
||||||
samplerStates[1] = SamplerClampPoint; // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
|
samplerStates[1] = SamplerClampPoint; // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
|
||||||
|
mSamplerNames[1] = "shadowMap";
|
||||||
samplerStates[2] = SamplerClampLinear; // SSAO Mask
|
samplerStates[2] = SamplerClampLinear; // SSAO Mask
|
||||||
|
mSamplerNames[2] = "ssaoMask";
|
||||||
samplerStates[3] = SamplerWrapPoint; // Random Direction Map
|
samplerStates[3] = SamplerWrapPoint; // Random Direction Map
|
||||||
|
|
||||||
cullDefined = true;
|
cullDefined = true;
|
||||||
|
|
@ -66,7 +69,9 @@ new ShaderData( AL_VectorLightShader )
|
||||||
samplerNames[2] = "$dynamicShadowMap";
|
samplerNames[2] = "$dynamicShadowMap";
|
||||||
samplerNames[3] = "$ssaoMask";
|
samplerNames[3] = "$ssaoMask";
|
||||||
samplerNames[4] = "$gTapRotationTex";
|
samplerNames[4] = "$gTapRotationTex";
|
||||||
|
samplerNames[5] = "$lightBuffer";
|
||||||
|
samplerNames[6] = "$colorBuffer";
|
||||||
|
samplerNames[7] = "$matInfoBuffer";
|
||||||
pixVersion = 3.0;
|
pixVersion = 3.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -79,6 +84,9 @@ new CustomMaterial( AL_VectorLightMaterial )
|
||||||
sampler["shadowMap"] = "$dynamiclight";
|
sampler["shadowMap"] = "$dynamiclight";
|
||||||
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
||||||
sampler["ssaoMask"] = "#ssaoMask";
|
sampler["ssaoMask"] = "#ssaoMask";
|
||||||
|
sampler["lightBuffer"] = "#lightinfo";
|
||||||
|
sampler["colorBuffer"] = "#color";
|
||||||
|
sampler["matInfoBuffer"] = "#matinfo";
|
||||||
|
|
||||||
target = "lightinfo";
|
target = "lightinfo";
|
||||||
|
|
||||||
|
|
@ -103,7 +111,9 @@ new GFXStateBlockData( AL_ConvexLightState )
|
||||||
|
|
||||||
samplersDefined = true;
|
samplersDefined = true;
|
||||||
samplerStates[0] = SamplerClampPoint; // G-buffer
|
samplerStates[0] = SamplerClampPoint; // G-buffer
|
||||||
|
mSamplerNames[0] = "prePassBuffer";
|
||||||
samplerStates[1] = SamplerClampPoint; // Shadow Map (Do not use linear, these are perspective projections)
|
samplerStates[1] = SamplerClampPoint; // Shadow Map (Do not use linear, these are perspective projections)
|
||||||
|
mSamplerNames[1] = "shadowMap";
|
||||||
samplerStates[2] = SamplerClampLinear; // Cookie Map
|
samplerStates[2] = SamplerClampLinear; // Cookie Map
|
||||||
samplerStates[3] = SamplerWrapPoint; // Random Direction Map
|
samplerStates[3] = SamplerWrapPoint; // Random Direction Map
|
||||||
|
|
||||||
|
|
@ -133,6 +143,9 @@ new ShaderData( AL_PointLightShader )
|
||||||
samplerNames[2] = "$dynamicShadowMap";
|
samplerNames[2] = "$dynamicShadowMap";
|
||||||
samplerNames[3] = "$cookieMap";
|
samplerNames[3] = "$cookieMap";
|
||||||
samplerNames[4] = "$gTapRotationTex";
|
samplerNames[4] = "$gTapRotationTex";
|
||||||
|
samplerNames[5] = "$lightBuffer";
|
||||||
|
samplerNames[6] = "$colorBuffer";
|
||||||
|
samplerNames[7] = "$matInfoBuffer";
|
||||||
|
|
||||||
pixVersion = 3.0;
|
pixVersion = 3.0;
|
||||||
};
|
};
|
||||||
|
|
@ -146,6 +159,9 @@ new CustomMaterial( AL_PointLightMaterial )
|
||||||
sampler["shadowMap"] = "$dynamiclight";
|
sampler["shadowMap"] = "$dynamiclight";
|
||||||
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
||||||
sampler["cookieMap"] = "$dynamiclightmask";
|
sampler["cookieMap"] = "$dynamiclightmask";
|
||||||
|
sampler["lightBuffer"] = "#lightinfo";
|
||||||
|
sampler["colorBuffer"] = "#color";
|
||||||
|
sampler["matInfoBuffer"] = "#matinfo";
|
||||||
|
|
||||||
target = "lightinfo";
|
target = "lightinfo";
|
||||||
|
|
||||||
|
|
@ -166,6 +182,9 @@ new ShaderData( AL_SpotLightShader )
|
||||||
samplerNames[2] = "$dynamicShadowMap";
|
samplerNames[2] = "$dynamicShadowMap";
|
||||||
samplerNames[3] = "$cookieMap";
|
samplerNames[3] = "$cookieMap";
|
||||||
samplerNames[4] = "$gTapRotationTex";
|
samplerNames[4] = "$gTapRotationTex";
|
||||||
|
samplerNames[5] = "$lightBuffer";
|
||||||
|
samplerNames[6] = "$colorBuffer";
|
||||||
|
samplerNames[7] = "$matInfoBuffer";
|
||||||
|
|
||||||
pixVersion = 3.0;
|
pixVersion = 3.0;
|
||||||
};
|
};
|
||||||
|
|
@ -179,6 +198,9 @@ new CustomMaterial( AL_SpotLightMaterial )
|
||||||
sampler["shadowMap"] = "$dynamiclight";
|
sampler["shadowMap"] = "$dynamiclight";
|
||||||
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
||||||
sampler["cookieMap"] = "$dynamiclightmask";
|
sampler["cookieMap"] = "$dynamiclightmask";
|
||||||
|
sampler["lightBuffer"] = "#lightinfo";
|
||||||
|
sampler["colorBuffer"] = "#color";
|
||||||
|
sampler["matInfoBuffer"] = "#matinfo";
|
||||||
|
|
||||||
target = "lightinfo";
|
target = "lightinfo";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "./torque.glsl"
|
||||||
|
|
||||||
#ifndef TORQUE_SHADERGEN
|
#ifndef TORQUE_SHADERGEN
|
||||||
|
|
||||||
|
|
@ -207,14 +208,42 @@ void compute4Lights( vec3 wsView,
|
||||||
///
|
///
|
||||||
float AL_CalcSpecular( vec3 toLight, vec3 normal, vec3 toEye )
|
float AL_CalcSpecular( vec3 toLight, vec3 normal, vec3 toEye )
|
||||||
{
|
{
|
||||||
#ifdef PHONG_SPECULAR
|
// (R.V)^c
|
||||||
// (R.V)^c
|
float specVal = dot( normalize( -reflect( toLight, normal ) ), toEye );
|
||||||
float specVal = dot( normalize( -reflect( toLight, normal ) ), toEye );
|
|
||||||
#else
|
|
||||||
// (N.H)^c [Blinn-Phong, TGEA style, default]
|
|
||||||
float specVal = dot( normal, normalize( toLight + toEye ) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Return the specular factor.
|
// Return the specular factor.
|
||||||
return pow( max( specVal, 0.00001f ), AL_ConstantSpecularPower );
|
return pow( max( specVal, 0.00001f ), AL_ConstantSpecularPower );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The output for Deferred Lighting
|
||||||
|
///
|
||||||
|
/// @param toLight Normalized vector representing direction from the pixel
|
||||||
|
/// being lit, to the light source, in world space.
|
||||||
|
///
|
||||||
|
/// @param normal Normalized surface normal.
|
||||||
|
///
|
||||||
|
/// @param toEye The normalized vector representing direction from the pixel
|
||||||
|
/// being lit to the camera.
|
||||||
|
///
|
||||||
|
vec4 AL_DeferredOutput(
|
||||||
|
vec3 lightColor,
|
||||||
|
vec3 diffuseColor,
|
||||||
|
vec4 matInfo,
|
||||||
|
vec4 ambient,
|
||||||
|
float specular,
|
||||||
|
float shadowAttenuation)
|
||||||
|
{
|
||||||
|
vec3 specularColor = vec3(specular);
|
||||||
|
bool metalness = getFlag(matInfo.r, 3);
|
||||||
|
if ( metalness )
|
||||||
|
{
|
||||||
|
specularColor = 0.04 * (1 - specular) + diffuseColor * specular;
|
||||||
|
}
|
||||||
|
|
||||||
|
//specular = color * map * spec^gloss
|
||||||
|
float specularOut = (specularColor * matInfo.b * min(pow(max(specular,1.0f), max((matInfo.a / AL_ConstantSpecularPower),1.0f)),matInfo.a)).r;
|
||||||
|
|
||||||
|
lightColor *= vec3(shadowAttenuation);
|
||||||
|
lightColor += ambient.rgb;
|
||||||
|
return vec4(lightColor.rgb, specularOut);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "./torque.hlsl"
|
||||||
|
|
||||||
#ifndef TORQUE_SHADERGEN
|
#ifndef TORQUE_SHADERGEN
|
||||||
|
|
||||||
|
|
@ -207,14 +208,42 @@ void compute4Lights( float3 wsView,
|
||||||
///
|
///
|
||||||
float AL_CalcSpecular( float3 toLight, float3 normal, float3 toEye )
|
float AL_CalcSpecular( float3 toLight, float3 normal, float3 toEye )
|
||||||
{
|
{
|
||||||
#ifdef PHONG_SPECULAR
|
// (R.V)^c
|
||||||
// (R.V)^c
|
float specVal = dot( normalize( -reflect( toLight, normal ) ), toEye );
|
||||||
float specVal = dot( normalize( -reflect( toLight, normal ) ), toEye );
|
|
||||||
#else
|
|
||||||
// (N.H)^c [Blinn-Phong, TGEA style, default]
|
|
||||||
float specVal = dot( normal, normalize( toLight + toEye ) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Return the specular factor.
|
// Return the specular factor.
|
||||||
return pow( max( specVal, 0.00001f ), AL_ConstantSpecularPower );
|
return pow( max( specVal, 0.00001f ), AL_ConstantSpecularPower );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The output for Deferred Lighting
|
||||||
|
///
|
||||||
|
/// @param toLight Normalized vector representing direction from the pixel
|
||||||
|
/// being lit, to the light source, in world space.
|
||||||
|
///
|
||||||
|
/// @param normal Normalized surface normal.
|
||||||
|
///
|
||||||
|
/// @param toEye The normalized vector representing direction from the pixel
|
||||||
|
/// being lit to the camera.
|
||||||
|
///
|
||||||
|
float4 AL_DeferredOutput(
|
||||||
|
float3 lightColor,
|
||||||
|
float3 diffuseColor,
|
||||||
|
float4 matInfo,
|
||||||
|
float4 ambient,
|
||||||
|
float specular,
|
||||||
|
float shadowAttenuation)
|
||||||
|
{
|
||||||
|
float3 specularColor = float3(specular, specular, specular);
|
||||||
|
bool metalness = getFlag(matInfo.r, 3);
|
||||||
|
if ( metalness )
|
||||||
|
{
|
||||||
|
specularColor = 0.04 * (1 - specular) + diffuseColor * specular;
|
||||||
|
}
|
||||||
|
|
||||||
|
//specular = color * map * spec^gloss
|
||||||
|
float specularOut = (specularColor * matInfo.b * min(pow(specular, max(( matInfo.a/ AL_ConstantSpecularPower),1.0f)),matInfo.a)).r;
|
||||||
|
|
||||||
|
lightColor *= shadowAttenuation;
|
||||||
|
lightColor += ambient.rgb;
|
||||||
|
return float4(lightColor.rgb, specularOut);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,6 @@
|
||||||
float4 main( PFXVertToPix IN,
|
float4 main( PFXVertToPix IN,
|
||||||
uniform sampler2D lightPrePassTex : register(S0) ) : COLOR0
|
uniform sampler2D lightPrePassTex : register(S0) ) : COLOR0
|
||||||
{
|
{
|
||||||
float3 lightcolor;
|
float4 lightColor = tex2D( lightPrePassTex, IN.uv0 );
|
||||||
float nl_Att, specular;
|
return float4( lightColor.rgb, 1.0 );
|
||||||
lightinfoUncondition( tex2D( lightPrePassTex, IN.uv0 ), lightcolor, nl_Att, specular );
|
|
||||||
return float4( lightcolor, 1.0 );
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,6 @@
|
||||||
float4 main( PFXVertToPix IN,
|
float4 main( PFXVertToPix IN,
|
||||||
uniform sampler2D lightPrePassTex : register(S0) ) : COLOR0
|
uniform sampler2D lightPrePassTex : register(S0) ) : COLOR0
|
||||||
{
|
{
|
||||||
float3 lightcolor;
|
float specular = tex2D( lightPrePassTex, IN.uv0 ).a;
|
||||||
float nl_Att, specular;
|
|
||||||
lightinfoUncondition( tex2D( lightPrePassTex, IN.uv0 ), lightcolor, nl_Att, specular );
|
|
||||||
return float4( specular, specular, specular, 1.0 );
|
return float4( specular, specular, specular, 1.0 );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,14 +24,12 @@
|
||||||
#include "shadergen:/autogenConditioners.h"
|
#include "shadergen:/autogenConditioners.h"
|
||||||
|
|
||||||
in vec2 uv0;
|
in vec2 uv0;
|
||||||
uniform sampler2D lightInfoBuffer;
|
uniform sampler2D lightPrePassTex;
|
||||||
|
|
||||||
out vec4 OUT_col;
|
out vec4 OUT_col;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec3 lightcolor;
|
vec4 lightColor = texture( lightPrePassTex, uv0 );
|
||||||
float nl_Att, specular;
|
OUT_col = vec4( lightColor.rgb, 1.0 );
|
||||||
lightinfoUncondition( texture( lightInfoBuffer, uv0 ), lightcolor, nl_Att, specular );
|
|
||||||
OUT_col = vec4( lightcolor, 1.0 );
|
|
||||||
}
|
}
|
||||||
|
|
@ -24,14 +24,12 @@
|
||||||
#include "shadergen:/autogenConditioners.h"
|
#include "shadergen:/autogenConditioners.h"
|
||||||
|
|
||||||
in vec2 uv0;
|
in vec2 uv0;
|
||||||
uniform sampler2D lightInfoBuffer;
|
uniform sampler2D lightPrePassTex;
|
||||||
|
|
||||||
out vec4 OUT_col;
|
out vec4 OUT_col;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec3 lightcolor;
|
float specular = texture( lightPrePassTex, uv0 ).a;
|
||||||
float nl_Att, specular;
|
|
||||||
lightinfoUncondition( texture( lightInfoBuffer, uv0 ), lightcolor, nl_Att, specular );
|
|
||||||
OUT_col = vec4( specular, specular, specular, 1.0 );
|
OUT_col = vec4( specular, specular, specular, 1.0 );
|
||||||
}
|
}
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
in vec4 wsEyeDir;
|
in vec4 wsEyeDir;
|
||||||
in vec4 ssPos;
|
in vec4 ssPos;
|
||||||
in vec4 vsEyeDir;
|
in vec4 vsEyeDir;
|
||||||
|
in vec4 color;
|
||||||
|
|
||||||
#ifdef USE_COOKIE_TEX
|
#ifdef USE_COOKIE_TEX
|
||||||
|
|
||||||
|
|
@ -111,6 +112,10 @@ uniform sampler2D prePassBuffer;
|
||||||
uniform sampler2D dynamicShadowMap;
|
uniform sampler2D dynamicShadowMap;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uniform sampler2D lightBuffer;
|
||||||
|
uniform sampler2D colorBuffer;
|
||||||
|
uniform sampler2D matInfoBuffer;
|
||||||
|
|
||||||
uniform vec4 rtParams0;
|
uniform vec4 rtParams0;
|
||||||
|
|
||||||
uniform vec3 lightPosition;
|
uniform vec3 lightPosition;
|
||||||
|
|
@ -133,6 +138,15 @@ void main()
|
||||||
vec3 ssPos = ssPos.xyz / ssPos.w;
|
vec3 ssPos = ssPos.xyz / ssPos.w;
|
||||||
vec2 uvScene = getUVFromSSPos( ssPos, rtParams0 );
|
vec2 uvScene = getUVFromSSPos( ssPos, rtParams0 );
|
||||||
|
|
||||||
|
// Emissive.
|
||||||
|
vec4 matInfo = texture( matInfoBuffer, uvScene );
|
||||||
|
bool emissive = getFlag( matInfo.r, 0 );
|
||||||
|
if ( emissive )
|
||||||
|
{
|
||||||
|
OUT_col = vec4(0.0, 0.0, 0.0, 0.0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Sample/unpack the normal/z data
|
// Sample/unpack the normal/z data
|
||||||
vec4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
vec4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
||||||
vec3 normal = prepassSample.rgb;
|
vec3 normal = prepassSample.rgb;
|
||||||
|
|
@ -244,5 +258,6 @@ void main()
|
||||||
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
OUT_col = lightinfoCondition( lightColorOut, Sat_NL_Att, specular, addToResult );
|
vec4 colorSample = texture( colorBuffer, uvScene );
|
||||||
|
OUT_col = AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,12 @@
|
||||||
in vec4 wsEyeDir;
|
in vec4 wsEyeDir;
|
||||||
in vec4 ssPos;
|
in vec4 ssPos;
|
||||||
in vec4 vsEyeDir;
|
in vec4 vsEyeDir;
|
||||||
|
in vec4 color;
|
||||||
|
|
||||||
#define IN_wsEyeDir wsEyeDir
|
#define IN_wsEyeDir wsEyeDir
|
||||||
#define IN_ssPos ssPos
|
#define IN_ssPos ssPos
|
||||||
#define IN_vsEyeDir vsEyeDir
|
#define IN_vsEyeDir vsEyeDir
|
||||||
|
#define IN_color color
|
||||||
|
|
||||||
#ifdef USE_COOKIE_TEX
|
#ifdef USE_COOKIE_TEX
|
||||||
|
|
||||||
|
|
@ -48,6 +50,10 @@ uniform sampler2D prePassBuffer;
|
||||||
uniform sampler2D shadowMap;
|
uniform sampler2D shadowMap;
|
||||||
uniform sampler2D dynamicShadowMap;
|
uniform sampler2D dynamicShadowMap;
|
||||||
|
|
||||||
|
uniform sampler2D lightBuffer;
|
||||||
|
uniform sampler2D colorBuffer;
|
||||||
|
uniform sampler2D matInfoBuffer;
|
||||||
|
|
||||||
uniform vec4 rtParams0;
|
uniform vec4 rtParams0;
|
||||||
|
|
||||||
uniform vec3 lightPosition;
|
uniform vec3 lightPosition;
|
||||||
|
|
@ -74,6 +80,15 @@ void main()
|
||||||
vec3 ssPos = IN_ssPos.xyz / IN_ssPos.w;
|
vec3 ssPos = IN_ssPos.xyz / IN_ssPos.w;
|
||||||
vec2 uvScene = getUVFromSSPos( ssPos, rtParams0 );
|
vec2 uvScene = getUVFromSSPos( ssPos, rtParams0 );
|
||||||
|
|
||||||
|
// Emissive.
|
||||||
|
vec4 matInfo = texture( matInfoBuffer, uvScene );
|
||||||
|
bool emissive = getFlag( matInfo.r, 0 );
|
||||||
|
if ( emissive )
|
||||||
|
{
|
||||||
|
OUT_col = vec4(0.0, 0.0, 0.0, 0.0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Sample/unpack the normal/z data
|
// Sample/unpack the normal/z data
|
||||||
vec4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
vec4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
||||||
vec3 normal = prepassSample.rgb;
|
vec3 normal = prepassSample.rgb;
|
||||||
|
|
@ -180,5 +195,6 @@ void main()
|
||||||
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
OUT_col = lightinfoCondition( lightColorOut, Sat_NL_Att, specular, addToResult );
|
vec4 colorSample = texture( colorBuffer, uvScene );
|
||||||
|
OUT_col = AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,13 @@ uniform sampler2D dynamicShadowMap;
|
||||||
|
|
||||||
#ifdef USE_SSAO_MASK
|
#ifdef USE_SSAO_MASK
|
||||||
uniform sampler2D ssaoMask ;
|
uniform sampler2D ssaoMask ;
|
||||||
uniform vec4 rtParams2;
|
uniform vec4 rtParams3;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uniform sampler2D prePassBuffer;
|
uniform sampler2D prePassBuffer;
|
||||||
|
uniform sampler2D lightBuffer;
|
||||||
|
uniform sampler2D colorBuffer;
|
||||||
|
uniform sampler2D matInfoBuffer;
|
||||||
uniform vec3 lightDirection;
|
uniform vec3 lightDirection;
|
||||||
uniform vec4 lightColor;
|
uniform vec4 lightColor;
|
||||||
uniform float lightBrightness;
|
uniform float lightBrightness;
|
||||||
|
|
@ -190,6 +193,15 @@ vec4 AL_VectorLightShadowCast( sampler2D _sourceshadowMap,
|
||||||
out vec4 OUT_col;
|
out vec4 OUT_col;
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
// Emissive.
|
||||||
|
float4 matInfo = texture( matInfoBuffer, uv0 );
|
||||||
|
bool emissive = getFlag( matInfo.r, 0 );
|
||||||
|
if ( emissive )
|
||||||
|
{
|
||||||
|
OUT_col = vec4(1.0, 1.0, 1.0, 0.0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Sample/unpack the normal/z data
|
// Sample/unpack the normal/z data
|
||||||
vec4 prepassSample = prepassUncondition( prePassBuffer, uv0 );
|
vec4 prepassSample = prepassUncondition( prePassBuffer, uv0 );
|
||||||
vec3 normal = prepassSample.rgb;
|
vec3 normal = prepassSample.rgb;
|
||||||
|
|
@ -228,8 +240,6 @@ void main()
|
||||||
shadowSoftness,
|
shadowSoftness,
|
||||||
dotNL,
|
dotNL,
|
||||||
overDarkPSSM);
|
overDarkPSSM);
|
||||||
|
|
||||||
|
|
||||||
vec4 dynamic_shadowed_colors = AL_VectorLightShadowCast( dynamicShadowMap,
|
vec4 dynamic_shadowed_colors = AL_VectorLightShadowCast( dynamicShadowMap,
|
||||||
uv0.xy,
|
uv0.xy,
|
||||||
dynamicWorldToLightProj,
|
dynamicWorldToLightProj,
|
||||||
|
|
@ -242,7 +252,6 @@ void main()
|
||||||
shadowSoftness,
|
shadowSoftness,
|
||||||
dotNL,
|
dotNL,
|
||||||
overDarkPSSM);
|
overDarkPSSM);
|
||||||
|
|
||||||
float static_shadowed = static_shadowed_colors.a;
|
float static_shadowed = static_shadowed_colors.a;
|
||||||
float dynamic_shadowed = dynamic_shadowed_colors.a;
|
float dynamic_shadowed = dynamic_shadowed_colors.a;
|
||||||
|
|
||||||
|
|
@ -295,7 +304,7 @@ void main()
|
||||||
|
|
||||||
// Sample the AO texture.
|
// Sample the AO texture.
|
||||||
#ifdef USE_SSAO_MASK
|
#ifdef USE_SSAO_MASK
|
||||||
float ao = 1.0 - texture( ssaoMask, viewportCoordToRenderTarget( uv0.xy, rtParams2 ) ).r;
|
float ao = 1.0 - texture( ssaoMask, viewportCoordToRenderTarget( uv0.xy, rtParams3 ) ).r;
|
||||||
addToResult *= ao;
|
addToResult *= ao;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -303,6 +312,6 @@ void main()
|
||||||
lightColorOut = debugColor;
|
lightColorOut = debugColor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OUT_col = lightinfoCondition( lightColorOut, Sat_NL_Att, specular, addToResult );
|
vec4 colorSample = texture( colorBuffer, uv0 );
|
||||||
|
OUT_col = AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ struct ConvexConnectP
|
||||||
float4 wsEyeDir : TEXCOORD0;
|
float4 wsEyeDir : TEXCOORD0;
|
||||||
float4 ssPos : TEXCOORD1;
|
float4 ssPos : TEXCOORD1;
|
||||||
float4 vsEyeDir : TEXCOORD2;
|
float4 vsEyeDir : TEXCOORD2;
|
||||||
|
float4 color : COLOR0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -117,6 +118,10 @@ float4 main( ConvexConnectP IN,
|
||||||
uniform sampler2D dynamicShadowMap : register(S2),
|
uniform sampler2D dynamicShadowMap : register(S2),
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uniform sampler2D lightBuffer : register(S5),
|
||||||
|
uniform sampler2D colorBuffer : register(S6),
|
||||||
|
uniform sampler2D matInfoBuffer : register(S7),
|
||||||
|
|
||||||
uniform float4 rtParams0,
|
uniform float4 rtParams0,
|
||||||
|
|
||||||
uniform float3 lightPosition,
|
uniform float3 lightPosition,
|
||||||
|
|
@ -137,6 +142,14 @@ float4 main( ConvexConnectP IN,
|
||||||
float3 ssPos = IN.ssPos.xyz / IN.ssPos.w;
|
float3 ssPos = IN.ssPos.xyz / IN.ssPos.w;
|
||||||
float2 uvScene = getUVFromSSPos( ssPos, rtParams0 );
|
float2 uvScene = getUVFromSSPos( ssPos, rtParams0 );
|
||||||
|
|
||||||
|
// Emissive.
|
||||||
|
float4 matInfo = tex2D( matInfoBuffer, uvScene );
|
||||||
|
bool emissive = getFlag( matInfo.r, 0 );
|
||||||
|
if ( emissive )
|
||||||
|
{
|
||||||
|
return float4(0.0, 0.0, 0.0, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
// Sample/unpack the normal/z data
|
// Sample/unpack the normal/z data
|
||||||
float4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
float4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
||||||
float3 normal = prepassSample.rgb;
|
float3 normal = prepassSample.rgb;
|
||||||
|
|
@ -250,5 +263,6 @@ float4 main( ConvexConnectP IN,
|
||||||
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
return lightinfoCondition( lightColorOut, Sat_NL_Att, specular, addToResult );
|
float4 colorSample = tex2D( colorBuffer, uvScene );
|
||||||
|
return AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ struct ConvexConnectP
|
||||||
float4 wsEyeDir : TEXCOORD0;
|
float4 wsEyeDir : TEXCOORD0;
|
||||||
float4 ssPos : TEXCOORD1;
|
float4 ssPos : TEXCOORD1;
|
||||||
float4 vsEyeDir : TEXCOORD2;
|
float4 vsEyeDir : TEXCOORD2;
|
||||||
|
float4 color : COLOR0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_COOKIE_TEX
|
#ifdef USE_COOKIE_TEX
|
||||||
|
|
@ -50,6 +51,10 @@ float4 main( ConvexConnectP IN,
|
||||||
uniform sampler2D shadowMap : register(S1),
|
uniform sampler2D shadowMap : register(S1),
|
||||||
uniform sampler2D dynamicShadowMap : register(S2),
|
uniform sampler2D dynamicShadowMap : register(S2),
|
||||||
|
|
||||||
|
uniform sampler2D lightBuffer : register(S5),
|
||||||
|
uniform sampler2D colorBuffer : register(S6),
|
||||||
|
uniform sampler2D matInfoBuffer : register(S7),
|
||||||
|
|
||||||
uniform float4 rtParams0,
|
uniform float4 rtParams0,
|
||||||
|
|
||||||
uniform float3 lightPosition,
|
uniform float3 lightPosition,
|
||||||
|
|
@ -72,6 +77,14 @@ float4 main( ConvexConnectP IN,
|
||||||
float3 ssPos = IN.ssPos.xyz / IN.ssPos.w;
|
float3 ssPos = IN.ssPos.xyz / IN.ssPos.w;
|
||||||
float2 uvScene = getUVFromSSPos( ssPos, rtParams0 );
|
float2 uvScene = getUVFromSSPos( ssPos, rtParams0 );
|
||||||
|
|
||||||
|
// Emissive.
|
||||||
|
float4 matInfo = tex2D( matInfoBuffer, uvScene );
|
||||||
|
bool emissive = getFlag( matInfo.r, 0 );
|
||||||
|
if ( emissive )
|
||||||
|
{
|
||||||
|
return float4(0.0, 0.0, 0.0, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
// Sample/unpack the normal/z data
|
// Sample/unpack the normal/z data
|
||||||
float4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
float4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
||||||
float3 normal = prepassSample.rgb;
|
float3 normal = prepassSample.rgb;
|
||||||
|
|
@ -179,5 +192,6 @@ float4 main( ConvexConnectP IN,
|
||||||
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
return lightinfoCondition( lightColorOut, Sat_NL_Att, specular, addToResult );
|
float4 colorSample = tex2D( colorBuffer, uvScene );
|
||||||
|
return AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,10 @@ float4 main( FarFrustumQuadConnectP IN,
|
||||||
|
|
||||||
uniform sampler2D prePassBuffer : register(S0),
|
uniform sampler2D prePassBuffer : register(S0),
|
||||||
|
|
||||||
|
uniform sampler2D lightBuffer : register(S5),
|
||||||
|
uniform sampler2D colorBuffer : register(S6),
|
||||||
|
uniform sampler2D matInfoBuffer : register(S7),
|
||||||
|
|
||||||
uniform float3 lightDirection,
|
uniform float3 lightDirection,
|
||||||
uniform float4 lightColor,
|
uniform float4 lightColor,
|
||||||
uniform float lightBrightness,
|
uniform float lightBrightness,
|
||||||
|
|
@ -191,6 +195,14 @@ float4 main( FarFrustumQuadConnectP IN,
|
||||||
|
|
||||||
) : COLOR0
|
) : COLOR0
|
||||||
{
|
{
|
||||||
|
// Emissive.
|
||||||
|
float4 matInfo = tex2D( matInfoBuffer, IN.uv0 );
|
||||||
|
bool emissive = getFlag( matInfo.r, 0 );
|
||||||
|
if ( emissive )
|
||||||
|
{
|
||||||
|
return float4(1.0, 1.0, 1.0, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
// Sample/unpack the normal/z data
|
// Sample/unpack the normal/z data
|
||||||
float4 prepassSample = prepassUncondition( prePassBuffer, IN.uv0 );
|
float4 prepassSample = prepassUncondition( prePassBuffer, IN.uv0 );
|
||||||
float3 normal = prepassSample.rgb;
|
float3 normal = prepassSample.rgb;
|
||||||
|
|
@ -229,7 +241,6 @@ float4 main( FarFrustumQuadConnectP IN,
|
||||||
shadowSoftness,
|
shadowSoftness,
|
||||||
dotNL,
|
dotNL,
|
||||||
overDarkPSSM);
|
overDarkPSSM);
|
||||||
|
|
||||||
float4 dynamic_shadowed_colors = AL_VectorLightShadowCast( dynamicShadowMap,
|
float4 dynamic_shadowed_colors = AL_VectorLightShadowCast( dynamicShadowMap,
|
||||||
IN.uv0.xy,
|
IN.uv0.xy,
|
||||||
dynamicWorldToLightProj,
|
dynamicWorldToLightProj,
|
||||||
|
|
@ -276,6 +287,7 @@ float4 main( FarFrustumQuadConnectP IN,
|
||||||
|
|
||||||
float Sat_NL_Att = saturate( dotNL * shadowed ) * lightBrightness;
|
float Sat_NL_Att = saturate( dotNL * shadowed ) * lightBrightness;
|
||||||
float3 lightColorOut = lightMapParams.rgb * lightColor.rgb;
|
float3 lightColorOut = lightMapParams.rgb * lightColor.rgb;
|
||||||
|
|
||||||
float4 addToResult = (lightAmbient * (1 - ambientCameraFactor)) + ( lightAmbient * ambientCameraFactor * saturate(dot(normalize(-IN.vsEyeRay), normal)) );
|
float4 addToResult = (lightAmbient * (1 - ambientCameraFactor)) + ( lightAmbient * ambientCameraFactor * saturate(dot(normalize(-IN.vsEyeRay), normal)) );
|
||||||
|
|
||||||
// TODO: This needs to be removed when lightmapping is disabled
|
// TODO: This needs to be removed when lightmapping is disabled
|
||||||
|
|
@ -303,5 +315,6 @@ float4 main( FarFrustumQuadConnectP IN,
|
||||||
lightColorOut = debugColor;
|
lightColorOut = debugColor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return lightinfoCondition( lightColorOut, Sat_NL_Att, specular, addToResult );
|
float4 colorSample = tex2D( colorBuffer, IN.uv0 );
|
||||||
|
return AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue