Merge pull request #1519 from Azaezel/deferredShading

Deferred shading
This commit is contained in:
Areloch 2016-02-27 15:08:20 -06:00
commit 908be4818f
112 changed files with 2645 additions and 680 deletions

View file

@ -42,10 +42,11 @@ uniform vec3 g_fBlueShiftColor;
uniform float g_fBloomScale;
uniform float g_fOneOverGamma;
uniform float Brightness;
uniform float Contrast;
out vec4 OUT_col;
void main()
{
vec4 _sample = hdrDecode( texture( sceneTex, IN_uv0 ) );
@ -94,5 +95,11 @@ void main()
// Apply gamma correction
_sample.rgb = pow( abs(_sample.rgb), vec3(g_fOneOverGamma) );
// Apply contrast
_sample.rgb = ((_sample.rgb - 0.5f) * Contrast) + 0.5f;
// Apply brightness
_sample.rgb += Brightness;
OUT_col = _sample;
}

View file

@ -0,0 +1,49 @@
//--- OBJECT WRITE BEGIN ---
$ThisPrefab = new SimGroup() {
canSave = "1";
canSaveDynamicFields = "1";
new ParticleEmitterNode() {
active = "1";
emitter = "FireEmitter";
velocity = "1";
dataBlock = "EmberNode";
position = "0 0 0";
rotation = "1 0 0 0";
scale = "1 1 1";
canSave = "1";
canSaveDynamicFields = "1";
};
new PointLight() {
radius = "10";
isEnabled = "1";
color = "1 0.603922 0 1";
brightness = "1";
castShadows = "1";
staticRefreshFreq = "250";
dynamicRefreshFreq = "8";
priority = "1";
animate = "1";
animationPeriod = "1";
animationPhase = "1";
flareScale = "1";
attenuationRatio = "0 1 1";
shadowType = "DualParaboloidSinglePass";
texSize = "512";
overDarkFactor = "2000 1000 500 100";
shadowDistance = "400";
shadowSoftness = "0.15";
numSplits = "1";
logWeight = "0.91";
fadeStartDistance = "0";
lastSplitTerrainOnly = "0";
representedInLightmap = "0";
shadowDarkenColor = "0 0 0 -1";
includeLightmappedGeometryInShadow = "0";
position = "0 0 0";
rotation = "1 0 0 0";
canSave = "1";
canSaveDynamicFields = "1";
};
};
//--- OBJECT WRITE END ---

View file

@ -27,7 +27,6 @@ singleton Material(defaultTree_bark_material)
diffuseMap[0] = "art/shapes/trees/defaulttree/defaulttree_bark_diffuse.dds";
normalMap[0] = "art/shapes/trees/defaulttree/defaulttree_bark_normal_specular.dds";
specularMap[0] = "";
diffuseColor[0] = "1 1 1 1";
specular[0] = "0.9 0.9 0.9 1";
@ -37,6 +36,7 @@ singleton Material(defaultTree_bark_material)
translucent = false;
translucentBlendOp = "None";
pixelSpecular[0] = "1";
castDynamicShadows = "0";
};
singleton Material(defaulttree_material)
@ -45,7 +45,6 @@ singleton Material(defaulttree_material)
diffuseMap[0] = "art/shapes/trees/defaulttree/defaulttree_diffuse_transparency.dds";
normalMap[0] = "art/shapes/trees/defaulttree/defaulttree_normal_specular.dds";
specularMap[0] = "";
diffuseColor[0] = "1 1 1 1";
specular[0] = "0.9 0.9 0.9 1";
@ -57,6 +56,7 @@ singleton Material(defaulttree_material)
pixelSpecular[0] = "1";
alphaTest = "1";
alphaRef = "127";
castDynamicShadows = "0";
};
singleton Material(defaultTree_fronds_material)
@ -71,6 +71,7 @@ singleton Material(defaultTree_fronds_material)
alphaTest = "1";
alphaRef = "114";
translucent = "1";
castDynamicShadows = "0";
};
singleton Material(defaulttree_ColorEffectR27G177B88_material)
@ -79,4 +80,6 @@ singleton Material(defaulttree_ColorEffectR27G177B88_material)
diffuseColor[0] = "0.105882 0.694118 0.345098 1";
specularPower[0] = "10";
translucentBlendOp = "None";
castDynamicShadows = "0";
castShadows = "0";
};

View file

@ -34,4 +34,5 @@ singleton Material( DesertSkyMat )
{
cubemap = DesertSkyCubemap;
materialTag0 = "Skies";
isSky = true;
};

View file

@ -34,6 +34,7 @@ singleton Material( NightSkyMat )
{
cubemap = NightCubemap;
materialTag0 = "Skies";
isSky = true;
};
singleton Material( Moon_Glow_Mat )
@ -50,4 +51,5 @@ singleton Material( Moon_Mat )
emissive = true;
translucent = true;
vertColor[ 0 ] = true;
isSky = true;
};

View file

@ -34,6 +34,7 @@ singleton Material( BlackSkyMat )
{
cubemap = BlackSkyCubemap;
materialTag0 = "Skies";
isSky = true;
};
singleton CubemapData( BlueSkyCubemap )
@ -50,6 +51,7 @@ singleton Material( BlueSkyMat )
{
cubemap = BlueSkyCubemap;
materialTag0 = "Skies";
isSky = true;
};
singleton CubemapData( GreySkyCubemap )
@ -66,4 +68,5 @@ singleton Material( GreySkyMat )
{
cubemap = GreySkyCubemap;
materialTag0 = "Skies";
isSky = true;
};

View file

@ -0,0 +1,147 @@
singleton ShaderData( ClearGBufferShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/lighting/advanced/deferredClearGBufferP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/deferredClearGBufferP.glsl";
pixVersion = 2.0;
};
singleton ShaderData( DeferredColorShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/lighting/advanced/deferredColorShaderP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/deferredColorShaderP.glsl";
pixVersion = 2.0;
};
// Primary Deferred Shader
new GFXStateBlockData( AL_DeferredShadingState : PFX_DefaultStateBlock )
{
cullMode = GFXCullNone;
blendDefined = true;
blendEnable = true;
blendSrc = GFXBlendSrcAlpha;
blendDest = GFXBlendInvSrcAlpha;
samplersDefined = true;
samplerStates[0] = SamplerWrapLinear;
samplerStates[1] = SamplerWrapLinear;
samplerStates[2] = SamplerWrapLinear;
samplerStates[3] = SamplerWrapLinear;
};
new ShaderData( AL_DeferredShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/lighting/advanced/deferredShadingP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/deferredShadingP.glsl";
samplerNames[0] = "colorBufferTex";
samplerNames[1] = "lightPrePassTex";
samplerNames[2] = "matInfoTex";
samplerNames[3] = "prepassTex";
pixVersion = 2.0;
};
singleton PostEffect( AL_DeferredShading )
{
renderTime = "PFXBeforeBin";
renderBin = "SkyBin";
shader = AL_DeferredShader;
stateBlock = AL_DeferredShadingState;
texture[0] = "#color";
texture[1] = "#lightinfo";
texture[2] = "#matinfo";
texture[3] = "#prepass";
target = "$backBuffer";
renderPriority = 10000;
allowReflectPass = true;
};
// Debug Shaders.
new ShaderData( AL_ColorBufferShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/lighting/advanced/dbgColorBufferP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgColorBufferP.glsl";
samplerNames[0] = "colorBufferTex";
pixVersion = 2.0;
};
singleton PostEffect( AL_ColorBufferVisualize )
{
shader = AL_ColorBufferShader;
stateBlock = AL_DefaultVisualizeState;
texture[0] = "#color";
target = "$backBuffer";
renderPriority = 9999;
};
/// Toggles the visualization of the AL lighting specular power buffer.
function toggleColorBufferViz( %enable )
{
if ( %enable $= "" )
{
$AL_ColorBufferShaderVar = AL_ColorBufferVisualize.isEnabled() ? false : true;
AL_ColorBufferVisualize.toggle();
}
else if ( %enable )
{
AL_DeferredShading.disable();
AL_ColorBufferVisualize.enable();
}
else if ( !%enable )
{
AL_ColorBufferVisualize.disable();
AL_DeferredShading.enable();
}
}
new ShaderData( AL_SpecMapShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/lighting/advanced/dbgSpecMapVisualizeP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgSpecMapVisualizeP.glsl";
samplerNames[0] = "matinfoTex";
pixVersion = 2.0;
};
singleton PostEffect( AL_SpecMapVisualize )
{
shader = AL_SpecMapShader;
stateBlock = AL_DefaultVisualizeState;
texture[0] = "#matinfo";
target = "$backBuffer";
renderPriority = 9999;
};
/// Toggles the visualization of the AL lighting specular power buffer.
function toggleSpecMapViz( %enable )
{
if ( %enable $= "" )
{
$AL_SpecMapShaderVar = AL_SpecMapVisualize.isEnabled() ? false : true;
AL_SpecMapVisualize.toggle();
}
else if ( %enable )
AL_SpecMapVisualize.enable();
else if ( !%enable )
AL_SpecMapVisualize.disable();
}

View file

@ -43,6 +43,7 @@ exec( "./shaders.cs" );
exec( "./lightViz.cs" );
exec( "./shadowViz.cs" );
exec( "./shadowViz.gui" );
exec( "./deferredShading.cs" );
function onActivateAdvancedLM()
{
@ -58,12 +59,18 @@ function onActivateAdvancedLM()
// Enable the offscreen target so that AL will work
// with MSAA back buffers and for HDR rendering.
AL_FormatToken.enable();
// Activate Deferred Shading
AL_DeferredShading.enable();
}
function onDeactivateAdvancedLM()
{
// Disable the offscreen render target.
AL_FormatToken.disable();
// Deactivate Deferred Shading
AL_DeferredShading.disable();
}
function setAdvancedLighting()

View file

@ -56,7 +56,7 @@ new ShaderData( AL_DepthVisualizeShader )
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgDepthVisualizeP.glsl";
samplerNames[0] = "prepassBuffer";
samplerNames[0] = "prepassTex";
samplerNames[1] = "depthViz";
pixVersion = 2.0;
@ -113,7 +113,7 @@ new ShaderData( AL_NormalsVisualizeShader )
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgNormalVisualizeP.glsl";
samplerNames[0] = "prepassBuffer";
samplerNames[0] = "prepassTex";
pixVersion = 2.0;
};
@ -149,7 +149,7 @@ new ShaderData( AL_LightColorVisualizeShader )
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgLightColorVisualizeP.glsl";
samplerNames[0] = "lightInfoBuffer";
samplerNames[0] = "lightPrePassTex";
pixVersion = 2.0;
};
@ -184,7 +184,7 @@ new ShaderData( AL_LightSpecularVisualizeShader )
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgLightSpecularVisualizeP.glsl";
samplerNames[0] = "lightInfoBuffer";
samplerNames[0] = "lightPrePassTex";
pixVersion = 2.0;
};
@ -280,3 +280,16 @@ function toggleLightSpecularViz( %enable )
AL_LightSpecularVisualize.disable();
}
function toggleBackbufferViz( %enable )
{
if ( %enable $= "" )
{
$AL_BackbufferVisualizeVar = AL_DeferredShading.isEnabled() ? true : false;
AL_DeferredShading.toggle();
}
else if ( %enable )
AL_DeferredShading.disable();
else if ( !%enable )
AL_DeferredShading.enable();
}

View file

@ -36,8 +36,11 @@ new GFXStateBlockData( AL_VectorLightState )
samplersDefined = true;
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.)
mSamplerNames[1] = "shadowMap";
samplerStates[2] = SamplerClampLinear; // SSAO Mask
mSamplerNames[2] = "ssaoMask";
samplerStates[3] = SamplerWrapPoint; // Random Direction Map
cullDefined = true;
@ -66,7 +69,9 @@ new ShaderData( AL_VectorLightShader )
samplerNames[2] = "$dynamicShadowMap";
samplerNames[3] = "$ssaoMask";
samplerNames[4] = "$gTapRotationTex";
samplerNames[5] = "$lightBuffer";
samplerNames[6] = "$colorBuffer";
samplerNames[7] = "$matInfoBuffer";
pixVersion = 3.0;
};
@ -78,7 +83,10 @@ new CustomMaterial( AL_VectorLightMaterial )
sampler["prePassBuffer"] = "#prepass";
sampler["shadowMap"] = "$dynamiclight";
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
sampler["ssaoMask"] = "#ssaoMask";
sampler["ssaoMask"] = "#ssaoMask";
sampler["lightBuffer"] = "#lightinfo";
sampler["colorBuffer"] = "#color";
sampler["matInfoBuffer"] = "#matinfo";
target = "lightinfo";
@ -103,7 +111,9 @@ new GFXStateBlockData( AL_ConvexLightState )
samplersDefined = true;
samplerStates[0] = SamplerClampPoint; // G-buffer
mSamplerNames[0] = "prePassBuffer";
samplerStates[1] = SamplerClampPoint; // Shadow Map (Do not use linear, these are perspective projections)
mSamplerNames[1] = "shadowMap";
samplerStates[2] = SamplerClampLinear; // Cookie Map
samplerStates[3] = SamplerWrapPoint; // Random Direction Map
@ -133,6 +143,9 @@ new ShaderData( AL_PointLightShader )
samplerNames[2] = "$dynamicShadowMap";
samplerNames[3] = "$cookieMap";
samplerNames[4] = "$gTapRotationTex";
samplerNames[5] = "$lightBuffer";
samplerNames[6] = "$colorBuffer";
samplerNames[7] = "$matInfoBuffer";
pixVersion = 3.0;
};
@ -146,6 +159,9 @@ new CustomMaterial( AL_PointLightMaterial )
sampler["shadowMap"] = "$dynamiclight";
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
sampler["cookieMap"] = "$dynamiclightmask";
sampler["lightBuffer"] = "#lightinfo";
sampler["colorBuffer"] = "#color";
sampler["matInfoBuffer"] = "#matinfo";
target = "lightinfo";
@ -166,6 +182,9 @@ new ShaderData( AL_SpotLightShader )
samplerNames[2] = "$dynamicShadowMap";
samplerNames[3] = "$cookieMap";
samplerNames[4] = "$gTapRotationTex";
samplerNames[5] = "$lightBuffer";
samplerNames[6] = "$colorBuffer";
samplerNames[7] = "$matInfoBuffer";
pixVersion = 3.0;
};
@ -179,6 +198,9 @@ new CustomMaterial( AL_SpotLightMaterial )
sampler["shadowMap"] = "$dynamiclight";
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
sampler["cookieMap"] = "$dynamiclightmask";
sampler["lightBuffer"] = "#lightinfo";
sampler["colorBuffer"] = "#color";
sampler["matInfoBuffer"] = "#matinfo";
target = "lightinfo";

View file

@ -51,7 +51,7 @@ singleton ShaderData( PFX_CausticsShader )
singleton PostEffect( CausticsPFX )
{
isEnabled = false;
renderTime = "PFXBeforeBin";
renderTime = "PFXAfterDiffuse";
renderBin = "ObjTranslucentBin";
//renderPriority = 0.1;

View file

@ -172,6 +172,8 @@ singleton ShaderData( HDR_CombineShader )
samplerNames[2] = "$bloomTex";
samplerNames[3] = "$colorCorrectionTex";
samplerNames[4] = "prepassTex";
pixVersion = 3.0;
};
@ -469,6 +471,7 @@ singleton PostEffect( HDRPostFX )
texture[1] = "#adaptedLum";
texture[2] = "#bloomFinal";
texture[3] = $HDRPostFX::colorCorrectionRamp;
texture[4] = "#prepass";
target = "$backBuffer";
};
};

View file

@ -47,7 +47,7 @@ singleton PostEffect( TurbulenceFx )
isEnabled = false;
allowReflectPass = true;
renderTime = "PFXAfterBin";
renderTime = "PFXAfterDiffuse";
renderBin = "GlowBin";
renderPriority = 0.5; // Render after the glows themselves

View file

@ -55,8 +55,8 @@ function initRenderManager()
DiffuseRenderPassManager.addManager( new RenderObjectMgr(BeginBin) { bintype = "Begin"; renderOrder = 0.2; processAddOrder = 0.2; } );
// Normal mesh rendering.
DiffuseRenderPassManager.addManager( new RenderTerrainMgr(TerrainBin) { renderOrder = 0.4; processAddOrder = 0.4; } );
DiffuseRenderPassManager.addManager( new RenderMeshMgr(MeshBin) { bintype = "Mesh"; renderOrder = 0.5; processAddOrder = 0.5; } );
DiffuseRenderPassManager.addManager( new RenderTerrainMgr(TerrainBin) { renderOrder = 0.4; processAddOrder = 0.4; basicOnly = true; } );
DiffuseRenderPassManager.addManager( new RenderMeshMgr(MeshBin) { bintype = "Mesh"; renderOrder = 0.5; processAddOrder = 0.5; basicOnly = true; } );
DiffuseRenderPassManager.addManager( new RenderImposterMgr(ImposterBin) { renderOrder = 0.56; processAddOrder = 0.56; } );
DiffuseRenderPassManager.addManager( new RenderObjectMgr(ObjectBin) { bintype = "Object"; renderOrder = 0.6; processAddOrder = 0.6; } );

View file

@ -22,13 +22,13 @@
new GFXStateBlockData( ScatterSkySBData )
{
cullDefined = true;
//cullDefined = true;
cullMode = "GFXCullNone";
zDefined = true;
zEnable = true;
zWriteEnable = false;
zFunc = "GFXCmpLessEqual";
//zFunc = "GFXCmpLessEqual";
samplersDefined = true;
samplerStates[0] = SamplerClampLinear;

View file

@ -46,6 +46,7 @@ ConnectData main( CloudVert IN )
ConnectData OUT;
OUT.hpos = mul(modelview, IN.pos);
OUT.hpos.w = OUT.hpos.z;
float2 uv = IN.uv0;
uv += texOffset;

View file

@ -60,8 +60,8 @@ uniform float3 texScale;
ConnectData main( CloudVert IN )
{
ConnectData OUT;
OUT.hpos = mul(modelview, IN.pos);
OUT.hpos.w = OUT.hpos.z;
// Offset the uv so we don't have a seam directly over our head.
float2 uv = IN.uv0 + float2( 0.5, 0.5 );

View file

@ -41,6 +41,7 @@ out vec2 texCoord;
void main()
{
gl_Position = tMul(modelview, IN_pos);
gl_Position.w = gl_Position.z;
vec2 uv = IN_uv0;
uv += texOffset;

View file

@ -62,6 +62,7 @@ void main()
vec2 IN_uv0 = vTexCoord0.st;
gl_Position = modelview * IN_pos;
gl_Position.w = gl_Position.z;
// Offset the uv so we don't have a seam directly over our head.
vec2 uv = IN_uv0 + vec2( 0.5, 0.5 );

View file

@ -20,6 +20,7 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "./torque.glsl"
#ifndef TORQUE_SHADERGEN
@ -207,14 +208,42 @@ void compute4Lights( vec3 wsView,
///
float AL_CalcSpecular( vec3 toLight, vec3 normal, vec3 toEye )
{
#ifdef PHONG_SPECULAR
// (R.V)^c
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
// (R.V)^c
float specVal = dot( normalize( -reflect( toLight, normal ) ), toEye );
// Return the specular factor.
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);
}

View file

@ -73,5 +73,8 @@ void main()
discard;
OUT_col.a = 1;
OUT_col = clamp(OUT_col, 0.0, 1.0);
OUT_col = hdrEncode( OUT_col );
}

View file

@ -20,6 +20,7 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "./torque.hlsl"
#ifndef TORQUE_SHADERGEN
@ -207,14 +208,42 @@ void compute4Lights( float3 wsView,
///
float AL_CalcSpecular( float3 toLight, float3 normal, float3 toEye )
{
#ifdef PHONG_SPECULAR
// (R.V)^c
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
// (R.V)^c
float specVal = dot( normalize( -reflect( toLight, normal ) ), toEye );
// Return the specular factor.
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);
}

View file

@ -0,0 +1,31 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../postfx/postFx.hlsl"
float4 main( PFXVertToPix IN,
uniform sampler2D colorBufferTex : register(S0) ) : COLOR0
{
return float4(tex2D( colorBufferTex, IN.uv0 ).rgb, 1.0);
}

View file

@ -27,8 +27,6 @@
float4 main( PFXVertToPix IN,
uniform sampler2D lightPrePassTex : register(S0) ) : COLOR0
{
float3 lightcolor;
float nl_Att, specular;
lightinfoUncondition( tex2D( lightPrePassTex, IN.uv0 ), lightcolor, nl_Att, specular );
return float4( lightcolor, 1.0 );
float4 lightColor = tex2D( lightPrePassTex, IN.uv0 );
return float4( lightColor.rgb, 1.0 );
}

View file

@ -27,8 +27,6 @@
float4 main( PFXVertToPix IN,
uniform sampler2D lightPrePassTex : register(S0) ) : COLOR0
{
float3 lightcolor;
float nl_Att, specular;
lightinfoUncondition( tex2D( lightPrePassTex, IN.uv0 ), lightcolor, nl_Att, specular );
float specular = tex2D( lightPrePassTex, IN.uv0 ).a;
return float4( specular, specular, specular, 1.0 );
}

View file

@ -0,0 +1,32 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../postfx/postFx.hlsl"
float4 main( PFXVertToPix IN,
uniform sampler2D matinfoTex : register(S0) ) : COLOR0
{
float specular = tex2D( matinfoTex, IN.uv0 ).b;
return float4( specular, specular, specular, 1.0 );
}

View file

@ -0,0 +1,47 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
struct Fragout
{
float4 col : COLOR0;
float4 col1 : COLOR1;
float4 col2 : COLOR2;
};
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
Fragout main( )
{
Fragout OUT;
// Clear Prepass Buffer ( Normals/Depth );
OUT.col = float4(1.0, 1.0, 1.0, 1.0);
// Clear Color Buffer.
OUT.col1 = float4(0.0, 0.0, 0.0, 1.0);
// Clear Material Info Buffer.
OUT.col2 = float4(0.0, 0.0, 0.0, 1.0);
return OUT;
}

View file

@ -0,0 +1,44 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
struct Fragout
{
float4 col : COLOR0;
float4 col1 : COLOR1;
float4 col2 : COLOR2;
};
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
Fragout main( )
{
Fragout OUT;
OUT.col = float4(0.0, 0.0, 0.0, 0.0);
OUT.col1 = float4(1.0, 1.0, 1.0, 1.0);
// Draw on color buffer.
OUT.col2 = float4(1.0, 0.0, 0.0, 1.0);
return OUT;
}

View file

@ -0,0 +1,54 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../postfx/postFx.hlsl"
#include "shaders/common/torque.hlsl"
float4 main( PFXVertToPix IN,
uniform sampler2D colorBufferTex : register(S0),
uniform sampler2D lightPrePassTex : register(S1),
uniform sampler2D matInfoTex : register(S2),
uniform sampler2D prepassTex : register(S3)) : COLOR0
{
float4 lightBuffer = tex2D( lightPrePassTex, IN.uv0 );
float4 colorBuffer = tex2D( colorBufferTex, IN.uv0 );
float4 matInfo = tex2D( matInfoTex, IN.uv0 );
float specular = saturate(lightBuffer.a);
float depth = prepassUncondition( prepassTex, IN.uv0 ).w;
if (depth>0.9999)
return float4(0,0,0,0);
// Diffuse Color Altered by Metalness
bool metalness = getFlag(matInfo.r, 3);
if ( metalness )
{
colorBuffer *= (1.0 - colorBuffer.a);
}
colorBuffer *= float4(lightBuffer.rgb, 1.0);
colorBuffer += float4(specular, specular, specular, 1.0);
return hdrEncode( float4(colorBuffer.rgb, 1.0) );
}

View file

@ -0,0 +1,34 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h"
#include "../../../postfx/gl/postFx.glsl"
uniform sampler2D colorBufferTex;
out vec4 OUT_FragColor0;
void main()
{
OUT_FragColor0 = vec4(texture( colorBufferTex, uv0 ).rgb, 1.0);
}

View file

@ -24,13 +24,13 @@
#include "shadergen:/autogenConditioners.h"
in vec2 uv0;
uniform sampler2D prepassBuffer;
uniform sampler2D prepassTex;
uniform sampler1D depthViz;
out vec4 OUT_col;
void main()
{
float depth = prepassUncondition( prepassBuffer, uv0 ).w;
float depth = prepassUncondition( prepassTex, uv0 ).w;
OUT_col = vec4( texture( depthViz, depth ).rgb, 1.0 );
}

View file

@ -24,14 +24,12 @@
#include "shadergen:/autogenConditioners.h"
in vec2 uv0;
uniform sampler2D lightInfoBuffer;
uniform sampler2D lightPrePassTex;
out vec4 OUT_col;
void main()
{
vec3 lightcolor;
float nl_Att, specular;
lightinfoUncondition( texture( lightInfoBuffer, uv0 ), lightcolor, nl_Att, specular );
OUT_col = vec4( lightcolor, 1.0 );
vec4 lightColor = texture( lightPrePassTex, uv0 );
OUT_col = vec4( lightColor.rgb, 1.0 );
}

View file

@ -24,14 +24,12 @@
#include "shadergen:/autogenConditioners.h"
in vec2 uv0;
uniform sampler2D lightInfoBuffer;
uniform sampler2D lightPrePassTex;
out vec4 OUT_col;
void main()
{
vec3 lightcolor;
float nl_Att, specular;
lightinfoUncondition( texture( lightInfoBuffer, uv0 ), lightcolor, nl_Att, specular );
float specular = texture( lightPrePassTex, uv0 ).a;
OUT_col = vec4( specular, specular, specular, 1.0 );
}

View file

@ -24,12 +24,12 @@
#include "shadergen:/autogenConditioners.h"
in vec2 uv0;
uniform sampler2D prepassBuffer;
uniform sampler2D prepassTex;
out vec4 OUT_col;
void main()
{
vec3 normal = prepassUncondition( prepassBuffer, uv0 ).xyz;
vec3 normal = prepassUncondition( prepassTex, uv0 ).xyz;
OUT_col = vec4( ( normal + 1.0 ) * 0.5, 1.0 );
}

View file

@ -0,0 +1,34 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h"
#include "../../../postfx/gl/postFx.glsl"
uniform sampler2D matinfoTex;
out vec4 OUT_FragColor0;
void main()
{
float specular = texture( matinfoTex, uv0 ).a;
OUT_FragColor0 = vec4( specular, specular, specular, 1.0 );
}

View file

@ -0,0 +1,40 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
out vec4 OUT_col;
out vec4 OUT_col1;
out vec4 OUT_col2;
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
void main()
{
// Clear Prepass Buffer ( Normals/Depth );
OUT_col = vec4(1.0, 1.0, 1.0, 1.0);
// Clear Color Buffer.
OUT_col1 = vec4(0.0, 0.0, 0.0, 1.0);
// Clear Material Info Buffer.
OUT_col2 = vec4(0.0, 0.0, 0.0, 1.0);
}

View file

@ -0,0 +1,37 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
layout (location = 0) out vec4 col;
layout (location = 1) out vec4 col1;
layout (location = 2) out vec4 col2;
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
void main()
{
col = vec4(0.0, 0.0, 0.0, 0.0);
col1 = vec4(1.0, 1.0, 1.0, 1.0);
// Draw on color buffer.
col2 = vec4(1.0, 0.0, 0.0, 1.0);
}

View file

@ -0,0 +1,59 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h"
#include "../../../postfx/gl/postFx.glsl"
#include "../../../gl/torque.glsl"
uniform sampler2D colorBufferTex;
uniform sampler2D lightPrePassTex;
uniform sampler2D matInfoTex;
uniform sampler2D prepassTex;
out vec4 OUT_col;
void main()
{
float depth = prepassUncondition( prepassTex, uv0 ).w;
if (depth>0.9999)
{
OUT_col = vec4(0.0);
return;
}
vec4 lightBuffer = texture( lightPrePassTex, uv0 );
vec4 colorBuffer = texture( colorBufferTex, uv0 );
vec4 matInfo = texture( matInfoTex, uv0 );
float specular = clamp(lightBuffer.a,0.0,1.0);
// Diffuse Color Altered by Metalness
bool metalness = getFlag(matInfo.r, 3);
if ( metalness )
{
colorBuffer *= (1.0 - colorBuffer.a);
}
colorBuffer *= vec4(lightBuffer.rgb, 1.0);
colorBuffer += vec4(specular, specular, specular, 1.0);
OUT_col = hdrEncode( vec4(colorBuffer.rgb, 1.0) );
}

View file

@ -33,6 +33,7 @@
in vec4 wsEyeDir;
in vec4 ssPos;
in vec4 vsEyeDir;
in vec4 color;
#ifdef USE_COOKIE_TEX
@ -111,6 +112,10 @@ uniform sampler2D prePassBuffer;
uniform sampler2D dynamicShadowMap;
#endif
uniform sampler2D lightBuffer;
uniform sampler2D colorBuffer;
uniform sampler2D matInfoBuffer;
uniform vec4 rtParams0;
uniform vec3 lightPosition;
@ -133,6 +138,15 @@ void main()
vec3 ssPos = ssPos.xyz / ssPos.w;
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
vec4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
vec3 normal = prepassSample.rgb;
@ -244,5 +258,6 @@ void main()
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);
}

View file

@ -32,10 +32,12 @@
in vec4 wsEyeDir;
in vec4 ssPos;
in vec4 vsEyeDir;
in vec4 color;
#define IN_wsEyeDir wsEyeDir
#define IN_ssPos ssPos
#define IN_vsEyeDir vsEyeDir
#define IN_color color
#ifdef USE_COOKIE_TEX
@ -48,6 +50,10 @@ uniform sampler2D prePassBuffer;
uniform sampler2D shadowMap;
uniform sampler2D dynamicShadowMap;
uniform sampler2D lightBuffer;
uniform sampler2D colorBuffer;
uniform sampler2D matInfoBuffer;
uniform vec4 rtParams0;
uniform vec3 lightPosition;
@ -74,6 +80,15 @@ void main()
vec3 ssPos = IN_ssPos.xyz / IN_ssPos.w;
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
vec4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
vec3 normal = prepassSample.rgb;
@ -180,5 +195,6 @@ void main()
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);
}

View file

@ -39,10 +39,13 @@ uniform sampler2D dynamicShadowMap;
#ifdef USE_SSAO_MASK
uniform sampler2D ssaoMask ;
uniform vec4 rtParams2;
uniform vec4 rtParams3;
#endif
uniform sampler2D prePassBuffer;
uniform sampler2D prePassBuffer;
uniform sampler2D lightBuffer;
uniform sampler2D colorBuffer;
uniform sampler2D matInfoBuffer;
uniform vec3 lightDirection;
uniform vec4 lightColor;
uniform float lightBrightness;
@ -189,7 +192,16 @@ vec4 AL_VectorLightShadowCast( sampler2D _sourceshadowMap,
out vec4 OUT_col;
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
vec4 prepassSample = prepassUncondition( prePassBuffer, uv0 );
vec3 normal = prepassSample.rgb;
@ -228,8 +240,6 @@ void main()
shadowSoftness,
dotNL,
overDarkPSSM);
vec4 dynamic_shadowed_colors = AL_VectorLightShadowCast( dynamicShadowMap,
uv0.xy,
dynamicWorldToLightProj,
@ -242,14 +252,13 @@ void main()
shadowSoftness,
dotNL,
overDarkPSSM);
float static_shadowed = static_shadowed_colors.a;
float dynamic_shadowed = dynamic_shadowed_colors.a;
#ifdef PSSM_DEBUG_RENDER
debugColor = static_shadowed_colors.rgb*0.5+dynamic_shadowed_colors.rgb*0.5;
#endif
// Fade out the shadow at the end of the range.
vec4 zDist = vec4(zNearFarInvNearFar.x + zNearFarInvNearFar.y * depth);
float fadeOutAmt = ( zDist.x - fadeStartLength.x ) * fadeStartLength.y;
@ -295,7 +304,7 @@ void main()
// Sample the AO texture.
#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;
#endif
@ -303,6 +312,6 @@ void main()
lightColorOut = debugColor;
#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);
}

View file

@ -34,6 +34,7 @@ struct ConvexConnectP
float4 wsEyeDir : TEXCOORD0;
float4 ssPos : TEXCOORD1;
float4 vsEyeDir : TEXCOORD2;
float4 color : COLOR0;
};
@ -117,6 +118,10 @@ float4 main( ConvexConnectP IN,
uniform sampler2D dynamicShadowMap : register(S2),
#endif
uniform sampler2D lightBuffer : register(S5),
uniform sampler2D colorBuffer : register(S6),
uniform sampler2D matInfoBuffer : register(S7),
uniform float4 rtParams0,
uniform float3 lightPosition,
@ -136,7 +141,15 @@ float4 main( ConvexConnectP IN,
// Compute scene UV
float3 ssPos = IN.ssPos.xyz / IN.ssPos.w;
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
float4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
float3 normal = prepassSample.rgb;
@ -250,5 +263,6 @@ float4 main( ConvexConnectP IN,
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);
}

View file

@ -34,6 +34,7 @@ struct ConvexConnectP
float4 wsEyeDir : TEXCOORD0;
float4 ssPos : TEXCOORD1;
float4 vsEyeDir : TEXCOORD2;
float4 color : COLOR0;
};
#ifdef USE_COOKIE_TEX
@ -50,6 +51,10 @@ float4 main( ConvexConnectP IN,
uniform sampler2D shadowMap : register(S1),
uniform sampler2D dynamicShadowMap : register(S2),
uniform sampler2D lightBuffer : register(S5),
uniform sampler2D colorBuffer : register(S6),
uniform sampler2D matInfoBuffer : register(S7),
uniform float4 rtParams0,
uniform float3 lightPosition,
@ -72,6 +77,14 @@ float4 main( ConvexConnectP IN,
float3 ssPos = IN.ssPos.xyz / IN.ssPos.w;
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
float4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
float3 normal = prepassSample.rgb;
@ -179,5 +192,6 @@ float4 main( ConvexConnectP IN,
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);
}

View file

@ -157,6 +157,10 @@ float4 main( FarFrustumQuadConnectP IN,
uniform sampler2D prePassBuffer : register(S0),
uniform sampler2D lightBuffer : register(S5),
uniform sampler2D colorBuffer : register(S6),
uniform sampler2D matInfoBuffer : register(S7),
uniform float3 lightDirection,
uniform float4 lightColor,
uniform float lightBrightness,
@ -190,7 +194,15 @@ float4 main( FarFrustumQuadConnectP IN,
uniform float4 dynamicFarPlaneScalePSSM
) : 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
float4 prepassSample = prepassUncondition( prePassBuffer, IN.uv0 );
float3 normal = prepassSample.rgb;
@ -229,7 +241,6 @@ float4 main( FarFrustumQuadConnectP IN,
shadowSoftness,
dotNL,
overDarkPSSM);
float4 dynamic_shadowed_colors = AL_VectorLightShadowCast( dynamicShadowMap,
IN.uv0.xy,
dynamicWorldToLightProj,
@ -276,6 +287,7 @@ float4 main( FarFrustumQuadConnectP IN,
float Sat_NL_Att = saturate( dotNL * shadowed ) * lightBrightness;
float3 lightColorOut = lightMapParams.rgb * lightColor.rgb;
float4 addToResult = (lightAmbient * (1 - ambientCameraFactor)) + ( lightAmbient * ambientCameraFactor * saturate(dot(normalize(-IN.vsEyeRay), normal)) );
// TODO: This needs to be removed when lightmapping is disabled
@ -303,5 +315,6 @@ float4 main( FarFrustumQuadConnectP IN,
lightColorOut = debugColor;
#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);
}

View file

@ -20,6 +20,7 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../torque.hlsl"
#include "../postFx.hlsl"
@ -27,6 +28,7 @@ uniform sampler2D sceneTex : register( s0 );
uniform sampler2D luminanceTex : register( s1 );
uniform sampler2D bloomTex : register( s2 );
uniform sampler1D colorCorrectionTex : register( s3 );
uniform sampler2D prepassTex : register(S4);
uniform float2 texSize0;
uniform float2 texSize2;
@ -83,13 +85,16 @@ float4 main( PFXVertToPix IN ) : COLOR0
}
// Add the bloom effect.
sample += g_fBloomScale * bloom;
float depth = prepassUncondition( prepassTex, IN.uv0 ).w;
if (depth>0.9999)
sample += g_fBloomScale * bloom;
// Apply the color correction.
sample.r = tex1D( colorCorrectionTex, sample.r ).r;
sample.g = tex1D( colorCorrectionTex, sample.g ).g;
sample.b = tex1D( colorCorrectionTex, sample.b ).b;
// Apply gamma correction
sample.rgb = pow( abs(sample.rgb), g_fOneOverGamma );

View file

@ -23,11 +23,13 @@
#include "../../../gl/torque.glsl"
#include "../../../gl/hlslCompat.glsl"
#include "../../gl/postFX.glsl"
#include "shadergen:/autogenConditioners.h"
uniform sampler2D sceneTex;
uniform sampler2D luminanceTex;
uniform sampler2D bloomTex;
uniform sampler1D colorCorrectionTex;
uniform sampler2D prepassTex;
uniform vec2 texSize0;
uniform vec2 texSize2;
@ -86,7 +88,9 @@ void main()
}
// Add the bloom effect.
_sample += g_fBloomScale * bloom;
float depth = prepassUncondition( prepassTex, IN_uv0 ).w;
if (depth>0.9999)
_sample += g_fBloomScale * bloom;
// Apply the color correction.
_sample.r = texture( colorCorrectionTex, _sample.r ).r;

View file

@ -62,6 +62,6 @@ float4 main( Conn In ) : COLOR0
Out = lerp( color, nightSkyColor, nightInterpAndExposure.y );
Out.a = 1;
Out = saturate(Out);
return hdrEncode( Out );
}

View file

@ -32,6 +32,7 @@ float calcBlend( float texId, vec2 layerCoord, float layerSize, vec4 layerSample
vec4 diff = clamp( abs( layerSample - texId ), 0.0, 1.0 );
float noBlend = float(any( bvec4(1 - diff) ));
// Check if any of the layer samples
// match the current texture id.
vec4 factors = vec4(0);
for(int i = 0; i < 4; i++)

View file

@ -295,7 +295,7 @@ void main()
foamColor.rgb *= FOAM_OPACITY * foamAmt * foamColor.a;
// Get reflection map color.
vec4 refMapColor = hdrDecode( texture( reflectMap, reflectCoord ) );
vec4 refMapColor = texture( reflectMap, reflectCoord );
// If we do not have a reflection texture then we use the cubemap.
refMapColor = mix( refMapColor, texture( skyMap, reflectionVec ), NO_REFLECT );

View file

@ -282,7 +282,7 @@ float4 main( ConnectData IN ) : COLOR
foamColor.rgb *= FOAM_OPACITY * foamAmt * foamColor.a;
// Get reflection map color.
float4 refMapColor = hdrDecode( tex2D( reflectMap, reflectCoord ) );
float4 refMapColor = tex2D( reflectMap, reflectCoord );
// If we do not have a reflection texture then we use the cubemap.
refMapColor = lerp( refMapColor, texCUBE( skyMap, reflectionVec ), NO_REFLECT );

View file

@ -1354,132 +1354,6 @@
bitmap = "tools/gui/images/delete";
};
};
new GuiBitmapCtrl(){
position="6 357";
extent ="175 2";
HorizSizing = "width";
bitmap ="tools/gui/images/separator-v";
};
new GuiContainer(){ // Environment Map
profile="ToolsGuiDefaultProfile";
isContainer = "1";
position = "6 359";
Extent = "185 52";
HorizSizing = "width";
new GuiBitmapCtrl() {
canSaveDynamicFields = "0";
internalName = "envMapDisplayBitmap";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiDefaultProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "1 1";
Extent = "48 48";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
bitmap = "tools/materialeditor/gui/unknownImage";
wrap = "0";
};
new GuiTextCtrl() {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
Profile = "EditorTextProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "56 -3";
Extent = "72 18";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
text = "Env Map";
maxLength = "1024";
};
new GuiBitmapButtonCtrl() {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiDefaultProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "1 1";
Extent = "48 48";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.updateTextureMap(\"env\", 1);";
tooltipprofile = "ToolsGuiDefaultProfile";
ToolTip = "Change the active Environment Map for this layer.";
hovertime = "1000";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
bitmap = "tools/materialEditor/gui/cubemapBtnBorder";
};
new GuiTextCtrl() {
canSaveDynamicFields = "0";
internalName = "envMapNameText";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiTextProfile";
HorizSizing = "width";
VertSizing = "bottom";
position = "56 16";
Extent = "143 17";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
text = "None";
maxLength = "1024";
};
new GuiButtonCtrl(){
profile="ToolsGuiButtonProfile";
text ="Edit";
HorizSizing = "left";
VertSizing = "bottom";
position = "134 34";
Extent = "40 16";
buttonType = "PushButton";
command="MaterialEditorGui.updateTextureMap(\"env\", 1);";
};
new GuiBitmapButtonCtrl() {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiDefaultProfile";
HorizSizing = "left";
VertSizing = "bottom";
position = "177 34";
Extent = "16 16";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.updateTextureMap(\"env\", 0);";
hovertime = "1000";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
bitmap = "tools/gui/images/delete";
};
};
};
};
new GuiRolloutCtrl() {
@ -1491,6 +1365,7 @@
Position = "0 0";
Extent = "195 0";
Caption = "Accumulation Properties";
Expanded = false;
Margin = "-1 0 0 0";
DragSizable = false;
container = true;
@ -1967,6 +1842,7 @@
Position = "0 0";
Extent = "185 0";
Caption = "Lighting Properties";
Expanded = false;
Margin = "-1 0 0 0";
DragSizable = false;
container = true;
@ -2364,101 +2240,6 @@
useMouseEvents = "0";
useInactiveState = "0";
};
new GuiCheckBoxCtrl() {
canSaveDynamicFields = "0";
internalName = "subSurfaceCheckbox";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiCheckBoxProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "8 46";
Extent = "79 16";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.updateActiveMaterial(\"subSurface[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());";
tooltipprofile = "ToolsGuiDefaultProfile";
ToolTip = "Enables the use of subsurface scattering for this layer.";
hovertime = "1000";
text = "Sub Surface";
groupNum = "-1";
buttonType = "ToggleButton";
useMouseEvents = "0";
useInactiveState = "0";
};
new GuiSwatchButtonCtrl() {
canSaveDynamicFields = "0";
internalName = "subSurfaceColorSwatch";
Enabled = "1";
isContainer = "0";
Profile = "GuiInspectorSwatchButtonProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "90 46";
Extent = "16 16";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "getColorF(materialEd_PreviewMaterial.subSurfaceColor[MaterialEditorGui.currentLayer], \"MaterialEditorGui.updateSubSurfaceColor\");";
tooltip = "Set the subsurface scattering color";
hovertime = "1000";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
};
new GuiTextEditCtrl() {
canSaveDynamicFields = "0";
internalName = "subSurfaceRolloffTextEdit";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiTextEditProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "114 45";
Extent = "29 18";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltip = "Set the subsurface rolloff factor";
Command = "MaterialEditorGui.updateActiveMaterial(\"subSurfaceRolloff[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getText());";
hovertime = "1000";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
text = "32";
maxLength = "5";
};
new GuiTextCtrl() {
HorizSizing = "right";
VertSizing = "bottom";
position = "9 65";
Extent = "89 16";
text = "Minnaert constant";
};
new GuiTextEditCtrl() {
canSaveDynamicFields = "0";
internalName = "minnaertTextEdit";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiTextEditProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "114 65";
Extent = "29 18";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.updateActiveMaterial(\"minnaertConstant[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getText());";
hovertime = "1000";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
text = "32";
maxLength = "3";
};
};
};
};
@ -2471,9 +2252,9 @@
Position = "0 0";
Extent = "185 0";
Caption = "Animation Properties";
Expanded = false;
Margin = "-1 0 0 0";
DragSizable = false;
Expanded = false;
container = true;
parentRollout = %this.rollout;
object = %behavior;
@ -3283,6 +3064,7 @@
Position = "0 0";
Extent = "202 0";
Caption = "Advanced (all layers)";
Expanded = false;
Margin = "4 4 4 0";
DragSizable = false;
container = true;
@ -3519,7 +3301,7 @@
Profile = "ToolsGuiCheckBoxProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "100 56";
position = "105 55";
Extent = "85 16";
MinExtent = "8 2";
canSave = "1";

View file

@ -120,6 +120,9 @@ function initializeWorldEditor()
EVisibility.addOption( "AL: Light Specular Viz", "$AL_LightSpecularVisualizeVar", "toggleLightSpecularViz" );
EVisibility.addOption( "AL: Normals Viz", "$AL_NormalsVisualizeVar", "toggleNormalsViz" );
EVisibility.addOption( "AL: Depth Viz", "$AL_DepthVisualizeVar", "toggleDepthViz" );
EVisibility.addOption( "AL: Color Buffer", "$AL_ColorBufferShaderVar", "toggleColorBufferViz" );
EVisibility.addOption( "AL: Spec Map", "$AL_SpecMapShaderVar", "toggleSpecMapViz");
EVisibility.addOption( "AL: Backbuffer", "$AL_BackbufferVisualizeVar", "toggleBackbufferViz" );
EVisibility.addOption( "AL: Glow Buffer", "$AL_GlowVisualizeVar", "toggleGlowViz" );
EVisibility.addOption( "AL: PSSM Cascade Viz", "$AL::PSSMDebugRender", "" );
EVisibility.addOption( "Frustum Lock", "$Scene::lockCull", "" );