mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 08:15:44 +00:00
Move the common shader and postFX stuff to core, and moved the debug visualizers to the world editor, where they're actually used.
This commit is contained in:
parent
d680dc9934
commit
6f09e8e3e7
335 changed files with 500 additions and 510 deletions
|
|
@ -72,7 +72,7 @@ $pref::Video::autoDetect = 1;
|
|||
|
||||
// This is the path used by ShaderGen to cache procedural shaders. If left
|
||||
// blank ShaderGen will only cache shaders to memory and not to disk.
|
||||
$shaderGen::cachePath = "";
|
||||
$shaderGen::cachePath = "data/shaders";
|
||||
|
||||
// Uncomment to disable ShaderGen, useful when debugging
|
||||
//$ShaderGen::GenNewShaders = false;
|
||||
|
|
|
|||
BIN
Templates/BaseGame/game/core/images/AreaMap33.dds
Normal file
BIN
Templates/BaseGame/game/core/images/AreaMap33.dds
Normal file
Binary file not shown.
BIN
Templates/BaseGame/game/core/images/caustics_1.png
Normal file
BIN
Templates/BaseGame/game/core/images/caustics_1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
BIN
Templates/BaseGame/game/core/images/caustics_2.png
Normal file
BIN
Templates/BaseGame/game/core/images/caustics_2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
BIN
Templates/BaseGame/game/core/images/noise.png
Normal file
BIN
Templates/BaseGame/game/core/images/noise.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
Templates/BaseGame/game/core/images/null_color_ramp.png
Normal file
BIN
Templates/BaseGame/game/core/images/null_color_ramp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
|
|
@ -1,21 +1,21 @@
|
|||
singleton ShaderData( ClearGBufferShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/deferredClearGBufferP.hlsl";
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/deferredClearGBufferP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/deferredClearGBufferP.glsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/deferredClearGBufferP.glsl";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( DeferredColorShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/lighting/advanced/deferredClearGBufferV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/deferredColorShaderP.hlsl";
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/deferredClearGBufferV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/deferredColorShaderP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/deferredColorShaderP.glsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/deferredColorShaderP.glsl";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
|
@ -39,11 +39,11 @@ new GFXStateBlockData( AL_DeferredShadingState : PFX_DefaultStateBlock )
|
|||
|
||||
new ShaderData( AL_DeferredShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/deferredShadingP.hlsl";
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/deferredShadingP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/deferredShadingP.glsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/deferredShadingP.glsl";
|
||||
|
||||
samplerNames[0] = "colorBufferTex";
|
||||
samplerNames[1] = "lightPrePassTex";
|
||||
|
|
@ -67,81 +67,4 @@ singleton PostEffect( AL_DeferredShading )
|
|||
target = "$backBuffer";
|
||||
renderPriority = 10000;
|
||||
allowReflectPass = true;
|
||||
};
|
||||
|
||||
// Debug Shaders.
|
||||
new ShaderData( AL_ColorBufferShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgColorBufferP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/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 = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgSpecMapVisualizeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/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();
|
||||
}
|
||||
};
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 551 B |
|
|
@ -40,9 +40,6 @@ $pref::LightManager::sgUseToneMapping = "";
|
|||
*/
|
||||
|
||||
exec( "./shaders.cs" );
|
||||
exec( "./lightViz.cs" );
|
||||
exec( "./shadowViz.cs" );
|
||||
exec( "./shadowViz.gui" );
|
||||
exec( "./deferredShading.cs" );
|
||||
|
||||
function onActivateAdvancedLM()
|
||||
|
|
|
|||
|
|
@ -1,294 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
new GFXStateBlockData( AL_DepthVisualizeState )
|
||||
{
|
||||
zDefined = true;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint; // depth
|
||||
samplerStates[1] = SamplerClampLinear; // viz color lookup
|
||||
};
|
||||
|
||||
new GFXStateBlockData( AL_DefaultVisualizeState )
|
||||
{
|
||||
blendDefined = true;
|
||||
blendEnable = true;
|
||||
blendSrc = GFXBlendSrcAlpha;
|
||||
blendDest = GFXBlendInvSrcAlpha;
|
||||
|
||||
zDefined = true;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint; // #prepass
|
||||
samplerStates[1] = SamplerClampLinear; // depthviz
|
||||
};
|
||||
|
||||
new ShaderData( AL_DepthVisualizeShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgDepthVisualizeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/dbgDepthVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "prepassTex";
|
||||
samplerNames[1] = "depthViz";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_DepthVisualize )
|
||||
{
|
||||
shader = AL_DepthVisualizeShader;
|
||||
stateBlock = AL_DefaultVisualizeState;
|
||||
texture[0] = "#prepass";
|
||||
texture[1] = "core/lighting/advanced/depthviz";
|
||||
target = "$backBuffer";
|
||||
renderPriority = 9999;
|
||||
};
|
||||
|
||||
function AL_DepthVisualize::onEnabled( %this )
|
||||
{
|
||||
AL_NormalsVisualize.disable();
|
||||
AL_LightColorVisualize.disable();
|
||||
AL_LightSpecularVisualize.disable();
|
||||
$AL_NormalsVisualizeVar = false;
|
||||
$AL_LightColorVisualizeVar = false;
|
||||
$AL_LightSpecularVisualizeVar = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
new ShaderData( AL_GlowVisualizeShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgGlowVisualizeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/dbgGlowVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "glowBuffer";
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_GlowVisualize )
|
||||
{
|
||||
shader = AL_GlowVisualizeShader;
|
||||
stateBlock = AL_DefaultVisualizeState;
|
||||
texture[0] = "#glowbuffer";
|
||||
target = "$backBuffer";
|
||||
renderPriority = 9999;
|
||||
};
|
||||
|
||||
new ShaderData( AL_NormalsVisualizeShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgNormalVisualizeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/dbgNormalVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "prepassTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_NormalsVisualize )
|
||||
{
|
||||
shader = AL_NormalsVisualizeShader;
|
||||
stateBlock = AL_DefaultVisualizeState;
|
||||
texture[0] = "#prepass";
|
||||
target = "$backBuffer";
|
||||
renderPriority = 9999;
|
||||
};
|
||||
|
||||
function AL_NormalsVisualize::onEnabled( %this )
|
||||
{
|
||||
AL_DepthVisualize.disable();
|
||||
AL_LightColorVisualize.disable();
|
||||
AL_LightSpecularVisualize.disable();
|
||||
$AL_DepthVisualizeVar = false;
|
||||
$AL_LightColorVisualizeVar = false;
|
||||
$AL_LightSpecularVisualizeVar = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
new ShaderData( AL_LightColorVisualizeShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgLightColorVisualizeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/dbgLightColorVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "lightPrePassTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_LightColorVisualize )
|
||||
{
|
||||
shader = AL_LightColorVisualizeShader;
|
||||
stateBlock = AL_DefaultVisualizeState;
|
||||
texture[0] = "#lightinfo";
|
||||
target = "$backBuffer";
|
||||
renderPriority = 9999;
|
||||
};
|
||||
|
||||
function AL_LightColorVisualize::onEnabled( %this )
|
||||
{
|
||||
AL_NormalsVisualize.disable();
|
||||
AL_DepthVisualize.disable();
|
||||
AL_LightSpecularVisualize.disable();
|
||||
$AL_NormalsVisualizeVar = false;
|
||||
$AL_DepthVisualizeVar = false;
|
||||
$AL_LightSpecularVisualizeVar = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
new ShaderData( AL_LightSpecularVisualizeShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgLightSpecularVisualizeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/dbgLightSpecularVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "lightPrePassTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_LightSpecularVisualize )
|
||||
{
|
||||
shader = AL_LightSpecularVisualizeShader;
|
||||
stateBlock = AL_DefaultVisualizeState;
|
||||
texture[0] = "#lightinfo";
|
||||
target = "$backBuffer";
|
||||
renderPriority = 9999;
|
||||
};
|
||||
|
||||
function AL_LightSpecularVisualize::onEnabled( %this )
|
||||
{
|
||||
AL_NormalsVisualize.disable();
|
||||
AL_DepthVisualize.disable();
|
||||
AL_LightColorVisualize.disable();
|
||||
$AL_NormalsVisualizeVar = false;
|
||||
$AL_DepthVisualizeVar = false;
|
||||
$AL_LightColorVisualizeVar = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Toggles the visualization of the AL depth buffer.
|
||||
function toggleDepthViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_DepthVisualizeVar = AL_DepthVisualize.isEnabled() ? false : true;
|
||||
AL_DepthVisualize.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
AL_DepthVisualize.enable();
|
||||
else if ( !%enable )
|
||||
AL_DepthVisualize.disable();
|
||||
}
|
||||
|
||||
/// Toggles the visualization of the AL depth buffer.
|
||||
function toggleGlowViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_GlowVisualizeVar = AL_GlowVisualize.isEnabled() ? false : true;
|
||||
AL_GlowVisualize.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
AL_GlowVisualize.enable();
|
||||
else if ( !%enable )
|
||||
AL_GlowVisualize.disable();
|
||||
}
|
||||
|
||||
/// Toggles the visualization of the AL normals buffer.
|
||||
function toggleNormalsViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_NormalsVisualizeVar = AL_NormalsVisualize.isEnabled() ? false : true;
|
||||
AL_NormalsVisualize.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
AL_NormalsVisualize.enable();
|
||||
else if ( !%enable )
|
||||
AL_NormalsVisualize.disable();
|
||||
}
|
||||
|
||||
/// Toggles the visualization of the AL lighting color buffer.
|
||||
function toggleLightColorViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_LightColorVisualizeVar = AL_LightColorVisualize.isEnabled() ? false : true;
|
||||
AL_LightColorVisualize.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
AL_LightColorVisualize.enable();
|
||||
else if ( !%enable )
|
||||
AL_LightColorVisualize.disable();
|
||||
}
|
||||
|
||||
/// Toggles the visualization of the AL lighting specular power buffer.
|
||||
function toggleLightSpecularViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_LightSpecularVisualizeVar = AL_LightSpecularVisualize.isEnabled() ? false : true;
|
||||
AL_LightSpecularVisualize.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
AL_LightSpecularVisualize.enable();
|
||||
else if ( !%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();
|
||||
}
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
new ShaderData( AL_ShadowVisualizeShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/guiMaterialV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgShadowVisualizeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/gl/guiMaterialV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/dbgShadowVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "$shadowMap";
|
||||
samplerNames[1] = "$depthViz";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
new CustomMaterial( AL_ShadowVisualizeMaterial )
|
||||
{
|
||||
shader = AL_ShadowVisualizeShader;
|
||||
stateBlock = AL_DepthVisualizeState;
|
||||
|
||||
sampler["shadowMap"] = "#AL_ShadowVizTexture";
|
||||
sampler["depthViz"] = "depthviz";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton GuiControlProfile( AL_ShadowLabelTextProfile )
|
||||
{
|
||||
fontColor = "0 0 0";
|
||||
autoSizeWidth = true;
|
||||
autoSizeHeight = true;
|
||||
justify = "left";
|
||||
fontSize = 14;
|
||||
};
|
||||
|
||||
/// Toggles the visualization of the pre-pass lighting buffer.
|
||||
function toggleShadowViz()
|
||||
{
|
||||
if ( AL_ShadowVizOverlayCtrl.isAwake() )
|
||||
{
|
||||
setShadowVizLight( 0 );
|
||||
Canvas.popDialog( AL_ShadowVizOverlayCtrl );
|
||||
}
|
||||
else
|
||||
{
|
||||
Canvas.pushDialog( AL_ShadowVizOverlayCtrl, 100 );
|
||||
_setShadowVizLight( EWorldEditor.getSelectedObject( 0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
/// Called from the WorldEditor when an object is selected.
|
||||
function _setShadowVizLight( %light, %force )
|
||||
{
|
||||
if ( !AL_ShadowVizOverlayCtrl.isAwake() )
|
||||
return;
|
||||
|
||||
if ( AL_ShadowVizOverlayCtrl.isLocked() && !%force )
|
||||
return;
|
||||
|
||||
// Resolve the object to the client side.
|
||||
if ( isObject( %light ) )
|
||||
{
|
||||
%clientLight = serverToClientObject( %light );
|
||||
%sizeAndAspect = setShadowVizLight( %clientLight );
|
||||
}
|
||||
|
||||
AL_ShadowVizOverlayCtrl-->MatCtrl.setMaterial( "AL_ShadowVisualizeMaterial" );
|
||||
|
||||
%text = "ShadowViz";
|
||||
if ( isObject( %light ) )
|
||||
%text = %text @ " : " @ getWord( %sizeAndAspect, 0 ) @ " x " @ getWord( %sizeAndAspect, 1 );
|
||||
|
||||
AL_ShadowVizOverlayCtrl-->WindowCtrl.text = %text;
|
||||
}
|
||||
|
||||
/// For convenience, push the viz dialog and set the light manually from the console.
|
||||
function showShadowVizForLight( %light )
|
||||
{
|
||||
if ( !AL_ShadowVizOverlayCtrl.isAwake() )
|
||||
Canvas.pushDialog( AL_ShadowVizOverlayCtrl, 100 );
|
||||
_setShadowVizLight( %light, true );
|
||||
}
|
||||
|
||||
// Prevent shadowViz from changing lights in response to editor selection
|
||||
// events until unlock is called. The only way a vis light will change while locked
|
||||
// is if showShadowVizForLight is explicitly called by the user.
|
||||
function lockShadowViz()
|
||||
{
|
||||
AL_ShadowVizOverlayCtrl.islocked = true;
|
||||
}
|
||||
|
||||
function unlockShadowViz()
|
||||
{
|
||||
AL_ShadowVizOverlayCtrl.islocked = false;
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
//---------------------------------------------------------------------------------------------
|
||||
// Torque 3D
|
||||
// Copyright (C) GarageGames.com, Inc.
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
//--- OBJECT WRITE BEGIN ---
|
||||
%guiContent = new GuiControl(AL_ShadowVizOverlayCtrl) {
|
||||
canSaveDynamicFields = "0";
|
||||
isContainer = "1";
|
||||
Profile = "GuiModelessDialogProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "0 0";
|
||||
Extent = "1024 768";
|
||||
MinExtent = "8 8";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
noCursor = true;
|
||||
|
||||
new GuiWindowCtrl() {
|
||||
internalName = "WindowCtrl";
|
||||
canSaveDynamicFields = "0";
|
||||
isContainer = "1";
|
||||
Profile = "GuiWindowProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "50 50";
|
||||
Extent = "347 209";
|
||||
MinExtent = "150 100";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
Margin = "0 0 0 0";
|
||||
Padding = "0 0 0 0";
|
||||
AnchorTop = "1";
|
||||
AnchorBottom = "0";
|
||||
AnchorLeft = "1";
|
||||
AnchorRight = "0";
|
||||
resizeWidth = "1";
|
||||
resizeHeight = "1";
|
||||
canMove = "1";
|
||||
canClose = "1";
|
||||
canMinimize = "0";
|
||||
canMaximize = "1";
|
||||
minSize = "50 50";
|
||||
EdgeSnap = "1";
|
||||
text = "ShadowViz";
|
||||
closeCommand = "toggleShadowViz();";
|
||||
|
||||
new GuiMaterialCtrl() {
|
||||
internalName = "MatCtrl";
|
||||
canSaveDynamicFields = "0";
|
||||
isContainer = "0";
|
||||
Profile = "GuiDefaultProfile";
|
||||
HorizSizing = "width";
|
||||
VertSizing = "height";
|
||||
Position = "3 23";
|
||||
Extent = "341 181";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
Docking = "Client";
|
||||
Margin = "2 2 2 2";
|
||||
Padding = "0 0 0 0";
|
||||
AnchorTop = "1";
|
||||
AnchorBottom = "0";
|
||||
AnchorLeft = "1";
|
||||
AnchorRight = "0";
|
||||
materialName = "AL_ShadowVisualizeMaterial";
|
||||
};
|
||||
};
|
||||
};
|
||||
//--- OBJECT WRITE END ---
|
||||
|
|
@ -40,11 +40,11 @@ singleton GFXStateBlockData( BL_ProjectedShadowSBData )
|
|||
|
||||
singleton ShaderData( BL_ProjectedShadowShaderData )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/projectedShadowV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/projectedShadowP.hlsl";
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/projectedShadowV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/projectedShadowP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/gl/projectedShadowV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/gl/projectedShadowP.glsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/projectedShadowV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/projectedShadowP.glsl";
|
||||
|
||||
samplerNames[0] = "inputTex";
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@
|
|||
|
||||
singleton ShaderData( BL_ShadowFilterShaderV )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/lighting/basic/shadowFilterV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/basic/shadowFilterP.hlsl";
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/basic/shadowFilterV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/basic/shadowFilterP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/lighting/basic/gl/shadowFilterV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/basic/gl/shadowFilterP.glsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/basic/gl/shadowFilterV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/basic/gl/shadowFilterP.glsl";
|
||||
|
||||
samplerNames[0] = "$diffuseMap";
|
||||
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@
|
|||
|
||||
new ShaderData(BlurDepthShader)
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/lighting/shadowMap/boxFilterV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/shadowMap/boxFilterP.hlsl";
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/shadowMap/boxFilterV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/shadowMap/boxFilterP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/lighting/shadowMap/gl/boxFilterV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/shadowMap/gl/boxFilterP.glsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/shadowMap/gl/boxFilterV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/shadowMap/gl/boxFilterP.glsl";
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
$Core::MissingTexturePath = "core/images/missingTexture";
|
||||
$Core::UnAvailableTexturePath = "core/images/unavailable";
|
||||
$Core::WarningTexturePath = "core/images/warnMat";
|
||||
$Core::CommonShaderPath = "data/shaders/common";
|
||||
$Core::CommonShaderPath = "core/shaders";
|
||||
|
||||
/// This is the path used by ShaderGen to cache procedural
|
||||
/// shaders. If left blank ShaderGen will only cache shaders
|
||||
|
|
|
|||
74
Templates/BaseGame/game/core/postFX/GammaPostFX.cs
Normal file
74
Templates/BaseGame/game/core/postFX/GammaPostFX.cs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton ShaderData( GammaShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gammaP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/gammaP.glsl";
|
||||
|
||||
samplerNames[0] = "$backBuffer";
|
||||
samplerNames[1] = "$colorCorrectionTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( GammaStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
samplerStates[1] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
singleton PostEffect( GammaPostFX )
|
||||
{
|
||||
isEnabled = true;
|
||||
allowReflectPass = true;
|
||||
|
||||
renderTime = "PFXBeforeBin";
|
||||
renderBin = "EditorBin";
|
||||
renderPriority = 9999;
|
||||
|
||||
shader = GammaShader;
|
||||
stateBlock = GammaStateBlock;
|
||||
|
||||
texture[0] = "$backBuffer";
|
||||
texture[1] = $HDRPostFX::colorCorrectionRamp;
|
||||
|
||||
targetFormat = getBestHDRFormat();
|
||||
};
|
||||
|
||||
function GammaPostFX::preProcess( %this )
|
||||
{
|
||||
if ( %this.texture[1] !$= $HDRPostFX::colorCorrectionRamp )
|
||||
%this.setTexture( 1, $HDRPostFX::colorCorrectionRamp );
|
||||
}
|
||||
|
||||
function GammaPostFX::setShaderConsts( %this )
|
||||
{
|
||||
%clampedGamma = mClamp( $pref::Video::Gamma, 2.0, 2.5);
|
||||
%this.setShaderConst( "$OneOverGamma", 1 / %clampedGamma );
|
||||
%this.setShaderConst( "$Brightness", $pref::Video::Brightness );
|
||||
%this.setShaderConst( "$Contrast", $pref::Video::Contrast );
|
||||
}
|
||||
186
Templates/BaseGame/game/core/postFX/MLAA.cs
Normal file
186
Templates/BaseGame/game/core/postFX/MLAA.cs
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// An implementation of "Practical Morphological Anti-Aliasing" from
|
||||
// GPU Pro 2 by Jorge Jimenez, Belen Masia, Jose I. Echevarria,
|
||||
// Fernando Navarro, and Diego Gutierrez.
|
||||
//
|
||||
// http://www.iryoku.com/mlaa/
|
||||
|
||||
// NOTE: This is currently disabled in favor of FXAA. See
|
||||
// core\scripts\client\canvas.cs if you want to re-enable it.
|
||||
|
||||
singleton GFXStateBlockData( MLAA_EdgeDetectStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
// Mark the edge pixels in stencil.
|
||||
stencilDefined = true;
|
||||
stencilEnable = true;
|
||||
stencilPassOp = GFXStencilOpReplace;
|
||||
stencilFunc = GFXCmpAlways;
|
||||
stencilRef = 1;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
singleton ShaderData( MLAA_EdgeDetectionShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/offsetV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/edgeDetectionP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/offsetV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/edgeDetectionP.glsl";
|
||||
|
||||
samplerNames[0] = "$colorMapG";
|
||||
samplerNames[1] = "$prepassMap";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( MLAA_BlendWeightCalculationStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
// Here we want to process only marked pixels.
|
||||
stencilDefined = true;
|
||||
stencilEnable = true;
|
||||
stencilPassOp = GFXStencilOpKeep;
|
||||
stencilFunc = GFXCmpEqual;
|
||||
stencilRef = 1;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint;
|
||||
samplerStates[1] = SamplerClampLinear;
|
||||
samplerStates[2] = SamplerClampPoint;
|
||||
};
|
||||
|
||||
singleton ShaderData( MLAA_BlendWeightCalculationShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/passthruV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/blendWeightCalculationP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/passthruV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/blendWeightCalculationP.glsl";
|
||||
|
||||
samplerNames[0] = "$edgesMap";
|
||||
samplerNames[1] = "$edgesMapL";
|
||||
samplerNames[2] = "$areaMap";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( MLAA_NeighborhoodBlendingStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
// Here we want to process only marked pixels too.
|
||||
stencilDefined = true;
|
||||
stencilEnable = true;
|
||||
stencilPassOp = GFXStencilOpKeep;
|
||||
stencilFunc = GFXCmpEqual;
|
||||
stencilRef = 1;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint;
|
||||
samplerStates[1] = SamplerClampLinear;
|
||||
samplerStates[2] = SamplerClampPoint;
|
||||
};
|
||||
|
||||
singleton ShaderData( MLAA_NeighborhoodBlendingShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/offsetV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/neighborhoodBlendingP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/offsetV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/neighborhoodBlendingP.glsl";
|
||||
|
||||
samplerNames[0] = "$blendMap";
|
||||
samplerNames[1] = "$colorMapL";
|
||||
samplerNames[2] = "$colorMap";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
|
||||
singleton PostEffect( MLAAFx )
|
||||
{
|
||||
isEnabled = false;
|
||||
|
||||
allowReflectPass = false;
|
||||
renderTime = "PFXAfterDiffuse";
|
||||
|
||||
texture[0] = "$backBuffer"; //colorMapG
|
||||
texture[1] = "#prepass"; // Used for depth detection
|
||||
|
||||
target = "$outTex";
|
||||
targetClear = PFXTargetClear_OnDraw;
|
||||
targetClearColor = "0 0 0 0";
|
||||
|
||||
stateBlock = MLAA_EdgeDetectStateBlock;
|
||||
shader = MLAA_EdgeDetectionShader;
|
||||
|
||||
// The luma calculation weights which can be user adjustable
|
||||
// per-scene if nessasary. The default value of...
|
||||
//
|
||||
// 0.2126 0.7152 0.0722
|
||||
//
|
||||
// ... is the HDTV ITU-R Recommendation BT. 709.
|
||||
lumaCoefficients = "0.2126 0.7152 0.0722";
|
||||
|
||||
// The tweakable color threshold used to select
|
||||
// the range of edge pixels to blend.
|
||||
threshold = 0.1;
|
||||
|
||||
// The depth delta threshold used to select
|
||||
// the range of edge pixels to blend.
|
||||
depthThreshold = 0.01;
|
||||
|
||||
new PostEffect()
|
||||
{
|
||||
internalName = "blendingWeightsCalculation";
|
||||
|
||||
target = "$outTex";
|
||||
targetClear = PFXTargetClear_OnDraw;
|
||||
|
||||
shader = MLAA_BlendWeightCalculationShader;
|
||||
stateBlock = MLAA_BlendWeightCalculationStateBlock;
|
||||
|
||||
texture[0] = "$inTex"; // Edges mask
|
||||
texture[1] = "$inTex"; // Edges mask
|
||||
texture[2] = "core/images/AreaMap33.dds";
|
||||
};
|
||||
|
||||
new PostEffect()
|
||||
{
|
||||
internalName = "neighborhoodBlending";
|
||||
|
||||
shader = MLAA_NeighborhoodBlendingShader;
|
||||
stateBlock = MLAA_NeighborhoodBlendingStateBlock;
|
||||
|
||||
texture[0] = "$inTex"; // Blend weights
|
||||
texture[1] = "$backBuffer";
|
||||
texture[2] = "$backBuffer";
|
||||
};
|
||||
};
|
||||
|
||||
function MLAAFx::setShaderConsts(%this)
|
||||
{
|
||||
%this.setShaderConst("$lumaCoefficients", %this.lumaCoefficients);
|
||||
%this.setShaderConst("$threshold", %this.threshold);
|
||||
%this.setShaderConst("$depthThreshold", %this.depthThreshold);
|
||||
}
|
||||
53
Templates/BaseGame/game/core/postFX/MotionBlurFx.cs
Normal file
53
Templates/BaseGame/game/core/postFX/MotionBlurFx.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton ShaderData( PFX_MotionBlurShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; //we use the bare-bones postFxV.hlsl
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/motionBlurP.hlsl"; //new pixel shader
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/motionBlurP.glsl";
|
||||
|
||||
samplerNames[0] = "$backBuffer";
|
||||
samplerNames[1] = "$prepassTex";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton PostEffect(MotionBlurFX)
|
||||
{
|
||||
isEnabled = false;
|
||||
|
||||
renderTime = "PFXAfterDiffuse";
|
||||
|
||||
shader = PFX_MotionBlurShader;
|
||||
stateBlock = PFX_DefaultStateBlock;
|
||||
texture[0] = "$backbuffer";
|
||||
texture[1] = "#prepass";
|
||||
target = "$backBuffer";
|
||||
};
|
||||
|
||||
function MotionBlurFX::setShaderConsts(%this)
|
||||
{
|
||||
%this.setShaderConst( "$velocityMultiplier", 3000 );
|
||||
}
|
||||
64
Templates/BaseGame/game/core/postFX/caustics.cs
Normal file
64
Templates/BaseGame/game/core/postFX/caustics.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton GFXStateBlockData( PFX_CausticsStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
blendDefined = true;
|
||||
blendEnable = true;
|
||||
blendSrc = GFXBlendOne;
|
||||
blendDest = GFXBlendOne;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
samplerStates[1] = SamplerWrapLinear;
|
||||
samplerStates[2] = SamplerWrapLinear;
|
||||
};
|
||||
|
||||
singleton ShaderData( PFX_CausticsShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/caustics/causticsP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/caustics/gl/causticsP.glsl";
|
||||
|
||||
samplerNames[0] = "$prepassTex";
|
||||
samplerNames[1] = "$causticsTex0";
|
||||
samplerNames[2] = "$causticsTex1";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( CausticsPFX )
|
||||
{
|
||||
isEnabled = false;
|
||||
renderTime = "PFXAfterDiffuse";
|
||||
renderBin = "ObjTranslucentBin";
|
||||
//renderPriority = 0.1;
|
||||
|
||||
shader = PFX_CausticsShader;
|
||||
stateBlock = PFX_CausticsStateBlock;
|
||||
texture[0] = "#prepass";
|
||||
texture[1] = "core/images/caustics_1";
|
||||
texture[2] = "core/images/caustics_2";
|
||||
target = "$backBuffer";
|
||||
};
|
||||
77
Templates/BaseGame/game/core/postFX/chromaticLens.cs
Normal file
77
Templates/BaseGame/game/core/postFX/chromaticLens.cs
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
///
|
||||
$CAPostFx::enabled = false;
|
||||
|
||||
/// The lens distortion coefficient.
|
||||
$CAPostFx::distCoeffecient = -0.05;
|
||||
|
||||
/// The cubic distortion value.
|
||||
$CAPostFx::cubeDistortionFactor = -0.1;
|
||||
|
||||
/// The amount and direction of the maxium shift for
|
||||
/// the red, green, and blue channels.
|
||||
$CAPostFx::colorDistortionFactor = "0.005 -0.005 0.01";
|
||||
|
||||
|
||||
singleton GFXStateBlockData( PFX_DefaultChromaticLensStateBlock )
|
||||
{
|
||||
zDefined = true;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint;
|
||||
};
|
||||
|
||||
singleton ShaderData( PFX_ChromaticLensShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/chromaticLens.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/chromaticLens.glsl";
|
||||
|
||||
samplerNames[0] = "$backBuffer";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( ChromaticLensPostFX )
|
||||
{
|
||||
renderTime = "PFXAfterDiffuse";
|
||||
renderPriority = 0.2;
|
||||
isEnabled = false;
|
||||
allowReflectPass = false;
|
||||
|
||||
shader = PFX_ChromaticLensShader;
|
||||
stateBlock = PFX_DefaultChromaticLensStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
target = "$backBuffer";
|
||||
};
|
||||
|
||||
function ChromaticLensPostFX::setShaderConsts( %this )
|
||||
{
|
||||
%this.setShaderConst( "$distCoeff", $CAPostFx::distCoeffecient );
|
||||
%this.setShaderConst( "$cubeDistort", $CAPostFx::cubeDistortionFactor );
|
||||
%this.setShaderConst( "$colorDistort", $CAPostFx::colorDistortionFactor );
|
||||
}
|
||||
72
Templates/BaseGame/game/core/postFX/default.postfxpreset.cs
Normal file
72
Templates/BaseGame/game/core/postFX/default.postfxpreset.cs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
$PostFXManager::Settings::EnableVignette = "1";
|
||||
$PostFXManager::Settings::EnableDOF = "1";
|
||||
$PostFXManager::Settings::EnabledSSAO = "1";
|
||||
$PostFXManager::Settings::EnableHDR = "1";
|
||||
$PostFXManager::Settings::EnableLightRays = "1";
|
||||
$PostFXManager::Settings::EnablePostFX = "1";
|
||||
$PostFXManager::Settings::Vignette::VMax = "0.6";
|
||||
$PostFXManager::Settings::DOF::BlurCurveFar = "";
|
||||
$PostFXManager::Settings::DOF::BlurCurveNear = "";
|
||||
$PostFXManager::Settings::DOF::BlurMax = "";
|
||||
$PostFXManager::Settings::DOF::BlurMin = "";
|
||||
$PostFXManager::Settings::DOF::EnableAutoFocus = "";
|
||||
$PostFXManager::Settings::DOF::EnableDOF = "";
|
||||
$PostFXManager::Settings::DOF::FocusRangeMax = "";
|
||||
$PostFXManager::Settings::DOF::FocusRangeMin = "";
|
||||
$PostFXManager::Settings::HDR::adaptRate = "2";
|
||||
$PostFXManager::Settings::HDR::blueShiftColor = "1.05 0.97 1.27";
|
||||
$PostFXManager::Settings::HDR::brightPassThreshold = "1";
|
||||
$PostFXManager::Settings::HDR::enableBloom = "1";
|
||||
$PostFXManager::Settings::HDR::enableBlueShift = "0";
|
||||
$PostFXManager::Settings::HDR::enableToneMapping = "0.5";
|
||||
$PostFXManager::Settings::HDR::gaussMean = "0";
|
||||
$PostFXManager::Settings::HDR::gaussMultiplier = "0.3";
|
||||
$PostFXManager::Settings::HDR::gaussStdDev = "0.8";
|
||||
$PostFXManager::Settings::HDR::keyValue = "0.18";
|
||||
$PostFXManager::Settings::HDR::minLuminace = "0.001";
|
||||
$PostFXManager::Settings::HDR::whiteCutoff = "1";
|
||||
$PostFXManager::Settings::LightRays::brightScalar = "0.75";
|
||||
$PostFXManager::Settings::LightRays::decay = "1.0";
|
||||
$PostFXManager::Settings::LightRays::density = "0.94";
|
||||
$PostFXManager::Settings::LightRays::numSamples = "40";
|
||||
$PostFXManager::Settings::LightRays::weight = "5.65";
|
||||
$PostFXManager::Settings::SSAO::blurDepthTol = "0.001";
|
||||
$PostFXManager::Settings::SSAO::blurNormalTol = "0.95";
|
||||
$PostFXManager::Settings::SSAO::lDepthMax = "2";
|
||||
$PostFXManager::Settings::SSAO::lDepthMin = "0.2";
|
||||
$PostFXManager::Settings::SSAO::lDepthPow = "0.2";
|
||||
$PostFXManager::Settings::SSAO::lNormalPow = "2";
|
||||
$PostFXManager::Settings::SSAO::lNormalTol = "-0.5";
|
||||
$PostFXManager::Settings::SSAO::lRadius = "1";
|
||||
$PostFXManager::Settings::SSAO::lStrength = "10";
|
||||
$PostFXManager::Settings::SSAO::overallStrength = "2";
|
||||
$PostFXManager::Settings::SSAO::quality = "0";
|
||||
$PostFXManager::Settings::SSAO::sDepthMax = "1";
|
||||
$PostFXManager::Settings::SSAO::sDepthMin = "0.1";
|
||||
$PostFXManager::Settings::SSAO::sDepthPow = "1";
|
||||
$PostFXManager::Settings::SSAO::sNormalPow = "1";
|
||||
$PostFXManager::Settings::SSAO::sNormalTol = "0";
|
||||
$PostFXManager::Settings::SSAO::sRadius = "0.1";
|
||||
$PostFXManager::Settings::SSAO::sStrength = "6";
|
||||
$PostFXManager::Settings::ColorCorrectionRamp = "core/images/null_color_ramp.png";
|
||||
599
Templates/BaseGame/game/core/postFX/dof.cs
Normal file
599
Templates/BaseGame/game/core/postFX/dof.cs
Normal file
|
|
@ -0,0 +1,599 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
|
||||
================================================================================
|
||||
The DOFPostEffect API
|
||||
================================================================================
|
||||
|
||||
DOFPostEffect::setFocalDist( %dist )
|
||||
|
||||
@summary
|
||||
This method is for manually controlling the focus distance. It will have no
|
||||
effect if auto focus is currently enabled. Makes use of the parameters set by
|
||||
setFocusParams.
|
||||
|
||||
@param dist
|
||||
float distance in meters
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
DOFPostEffect::setAutoFocus( %enabled )
|
||||
|
||||
@summary
|
||||
This method sets auto focus enabled or disabled. Makes use of the parameters set
|
||||
by setFocusParams. When auto focus is enabled it determines the focal depth
|
||||
by performing a raycast at the screen-center.
|
||||
|
||||
@param enabled
|
||||
bool
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
DOFPostEffect::setFocusParams( %nearBlurMax, %farBlurMax, %minRange, %maxRange, %nearSlope, %farSlope )
|
||||
|
||||
Set the parameters that control how the near and far equations are calculated
|
||||
from the focal distance. If you are not using auto focus you will need to call
|
||||
setFocusParams PRIOR to calling setFocalDist.
|
||||
|
||||
@param nearBlurMax
|
||||
float between 0.0 and 1.0
|
||||
The max allowed value of near blur.
|
||||
|
||||
@param farBlurMax
|
||||
float between 0.0 and 1.0
|
||||
The max allowed value of far blur.
|
||||
|
||||
@param minRange/maxRange
|
||||
float in meters
|
||||
The distance range around the focal distance that remains in focus is a lerp
|
||||
between the min/maxRange using the normalized focal distance as the parameter.
|
||||
The point is to allow the focal range to expand as you focus farther away since this is
|
||||
visually appealing.
|
||||
|
||||
Note: since min/maxRange are lerped by the "normalized" focal distance it is
|
||||
dependant on the visible distance set in your level.
|
||||
|
||||
@param nearSlope
|
||||
float less than zero
|
||||
The slope of the near equation. A small number causes bluriness to increase gradually
|
||||
at distances closer than the focal distance. A large number causes bluriness to
|
||||
increase quickly.
|
||||
|
||||
@param farSlope
|
||||
float greater than zero
|
||||
The slope of the far equation. A small number causes bluriness to increase gradually
|
||||
at distances farther than the focal distance. A large number causes bluriness to
|
||||
increase quickly.
|
||||
|
||||
Note: To rephrase, the min/maxRange parameters control how much area around the
|
||||
focal distance is completely in focus where the near/farSlope parameters control
|
||||
how quickly or slowly bluriness increases at distances outside of that range.
|
||||
|
||||
================================================================================
|
||||
Examples
|
||||
================================================================================
|
||||
|
||||
Example1: Turn on DOF while zoomed in with a weapon.
|
||||
|
||||
NOTE: These are not real callbacks! Hook these up to your code where appropriate!
|
||||
|
||||
function onSniperZoom()
|
||||
{
|
||||
// Parameterize how you want DOF to look.
|
||||
DOFPostEffect.setFocusParams( 0.3, 0.3, 50, 500, -5, 5 );
|
||||
|
||||
// Turn on auto focus
|
||||
DOFPostEffect.setAutoFocus( true );
|
||||
|
||||
// Turn on the PostEffect
|
||||
DOFPostEffect.enable();
|
||||
}
|
||||
|
||||
function onSniperUnzoom()
|
||||
{
|
||||
// Turn off the PostEffect
|
||||
DOFPostEffect.disable();
|
||||
}
|
||||
|
||||
Example2: Manually control DOF with the mouse wheel.
|
||||
|
||||
// Somewhere on startup...
|
||||
|
||||
// Parameterize how you want DOF to look.
|
||||
DOFPostEffect.setFocusParams( 0.3, 0.3, 50, 500, -5, 5 );
|
||||
|
||||
// Turn off auto focus
|
||||
DOFPostEffect.setAutoFocus( false );
|
||||
|
||||
// Turn on the PostEffect
|
||||
DOFPostEffect.enable();
|
||||
|
||||
|
||||
NOTE: These are not real callbacks! Hook these up to your code where appropriate!
|
||||
|
||||
function onMouseWheelUp()
|
||||
{
|
||||
// Since setFocalDist is really just a wrapper to assign to the focalDist
|
||||
// dynamic field we can shortcut and increment it directly.
|
||||
DOFPostEffect.focalDist += 8;
|
||||
}
|
||||
|
||||
function onMouseWheelDown()
|
||||
{
|
||||
DOFPostEffect.focalDist -= 8;
|
||||
}
|
||||
*/
|
||||
|
||||
/// This method is for manually controlling the focal distance. It will have no
|
||||
/// effect if auto focus is currently enabled. Makes use of the parameters set by
|
||||
/// setFocusParams.
|
||||
function DOFPostEffect::setFocalDist( %this, %dist )
|
||||
{
|
||||
%this.focalDist = %dist;
|
||||
}
|
||||
|
||||
/// This method sets auto focus enabled or disabled. Makes use of the parameters set
|
||||
/// by setFocusParams. When auto focus is enabled it determine the focal depth
|
||||
/// by performing a raycast at the screen-center.
|
||||
function DOFPostEffect::setAutoFocus( %this, %enabled )
|
||||
{
|
||||
%this.autoFocusEnabled = %enabled;
|
||||
}
|
||||
|
||||
/// Set the parameters that control how the near and far equations are calculated
|
||||
/// from the focal distance. If you are not using auto focus you will need to call
|
||||
/// setFocusParams PRIOR to calling setFocalDist.
|
||||
function DOFPostEffect::setFocusParams( %this, %nearBlurMax, %farBlurMax, %minRange, %maxRange, %nearSlope, %farSlope )
|
||||
{
|
||||
%this.nearBlurMax = %nearBlurMax;
|
||||
%this.farBlurMax = %farBlurMax;
|
||||
%this.minRange = %minRange;
|
||||
%this.maxRange = %maxRange;
|
||||
%this.nearSlope = %nearSlope;
|
||||
%this.farSlope = %farSlope;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
More information...
|
||||
|
||||
This DOF technique is based on this paper:
|
||||
http://http.developer.nvidia.com/GPUGems3/gpugems3_ch28.html
|
||||
|
||||
================================================================================
|
||||
1. Overview of how we represent "Depth of Field"
|
||||
================================================================================
|
||||
|
||||
DOF is expressed as an amount of bluriness per pixel according to its depth.
|
||||
We represented this by a piecewise linear curve depicted below.
|
||||
|
||||
Note: we also refer to "bluriness" as CoC ( circle of confusion ) which is the term
|
||||
used in the basis paper and in photography.
|
||||
|
||||
|
||||
X-axis (depth)
|
||||
x = 0.0----------------------------------------------x = 1.0
|
||||
|
||||
Y-axis (bluriness)
|
||||
y = 1.0
|
||||
|
|
||||
| ____(x1,y1) (x4,y4)____
|
||||
| (ns,nb)\ <--Line1 line2---> /(fe,fb)
|
||||
| \ /
|
||||
| \(x2,y2) (x3,y3)/
|
||||
| (ne,0)------(fs,0)
|
||||
y = 0.0
|
||||
|
||||
|
||||
I have labeled the "corners" of this graph with (Xn,Yn) to illustrate that
|
||||
this is in fact a collection of line segments where the x/y of each point
|
||||
corresponds to the key below.
|
||||
|
||||
key:
|
||||
ns - (n)ear blur (s)tart distance
|
||||
nb - (n)ear (b)lur amount (max value)
|
||||
ne - (n)ear blur (e)nd distance
|
||||
fs - (f)ar blur (s)tart distance
|
||||
fe - (f)ar blur (e)nd distance
|
||||
fb - (f)ar (b)lur amount (max value)
|
||||
|
||||
Of greatest importance in this graph is Line1 and Line2. Where...
|
||||
L1 { (x1,y1), (x2,y2) }
|
||||
L2 { (x3,y3), (x4,y4) }
|
||||
|
||||
Line one represents the amount of "near" blur given a pixels depth and line two
|
||||
represents the amount of "far" blur at that depth.
|
||||
|
||||
Both these equations are evaluated for each pixel and then the larger of the two
|
||||
is kept. Also the output blur (for each equation) is clamped between 0 and its
|
||||
maximum allowable value.
|
||||
|
||||
Therefore, to specify a DOF "qualify" you need to specify the near-blur-line,
|
||||
far-blur-line, and maximum near and far blur value.
|
||||
|
||||
================================================================================
|
||||
2. Abstracting a "focal depth"
|
||||
================================================================================
|
||||
|
||||
Although the shader(s) work in terms of a near and far equation it is more
|
||||
useful to express DOF as an adjustable focal depth and derive the other parameters
|
||||
"under the hood".
|
||||
|
||||
Given a maximum near/far blur amount and a near/far slope we can calculate the
|
||||
near/far equations for any focal depth. We extend this to also support a range
|
||||
of depth around the focal depth that is also in focus and for that range to
|
||||
shrink or grow as the focal depth moves closer or farther.
|
||||
|
||||
Keep in mind this is only one implementation and depending on the effect you
|
||||
desire you may which to express the relationship between focal depth and
|
||||
the shader paramaters different.
|
||||
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// GFXStateBlockData / ShaderData
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton GFXStateBlockData( PFX_DefaultDOFStateBlock )
|
||||
{
|
||||
zDefined = true;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint;
|
||||
samplerStates[1] = SamplerClampPoint;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( PFX_DOFCalcCoCStateBlock )
|
||||
{
|
||||
zDefined = true;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
samplerStates[1] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( PFX_DOFDownSampleStateBlock )
|
||||
{
|
||||
zDefined = true;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
samplerStates[1] = SamplerClampPoint;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( PFX_DOFBlurStateBlock )
|
||||
{
|
||||
zDefined = true;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( PFX_DOFFinalStateBlock )
|
||||
{
|
||||
zDefined = true;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
samplerStates[1] = SamplerClampLinear;
|
||||
samplerStates[2] = SamplerClampLinear;
|
||||
samplerStates[3] = SamplerClampPoint;
|
||||
|
||||
blendDefined = true;
|
||||
blendEnable = true;
|
||||
blendDest = GFXBlendInvSrcAlpha;
|
||||
blendSrc = GFXBlendOne;
|
||||
};
|
||||
|
||||
singleton ShaderData( PFX_DOFDownSampleShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_DownSample_V.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_DownSample_P.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_DownSample_V.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_DownSample_P.glsl";
|
||||
|
||||
samplerNames[0] = "$colorSampler";
|
||||
samplerNames[1] = "$depthSampler";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( PFX_DOFBlurYShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_Gausian_V.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_Gausian_P.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Gausian_V.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Gausian_P.glsl";
|
||||
|
||||
samplerNames[0] = "$diffuseMap";
|
||||
|
||||
pixVersion = 2.0;
|
||||
defines = "BLUR_DIR=float2(0.0,1.0)";
|
||||
};
|
||||
|
||||
singleton ShaderData( PFX_DOFBlurXShader : PFX_DOFBlurYShader )
|
||||
{
|
||||
defines = "BLUR_DIR=float2(1.0,0.0)";
|
||||
};
|
||||
|
||||
singleton ShaderData( PFX_DOFCalcCoCShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_CalcCoC_V.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_CalcCoC_P.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_CalcCoC_V.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_CalcCoC_P.glsl";
|
||||
|
||||
samplerNames[0] = "$shrunkSampler";
|
||||
samplerNames[1] = "$blurredSampler";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( PFX_DOFSmallBlurShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_SmallBlur_V.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_SmallBlur_P.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_SmallBlur_V.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_SmallBlur_P.glsl";
|
||||
|
||||
samplerNames[0] = "$colorSampler";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( PFX_DOFFinalShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_Final_V.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/DOF_Final_P.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Final_V.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/dof/gl/DOF_Final_P.glsl";
|
||||
|
||||
samplerNames[0] = "$colorSampler";
|
||||
samplerNames[1] = "$smallBlurSampler";
|
||||
samplerNames[2] = "$largeBlurSampler";
|
||||
samplerNames[3] = "$depthSampler";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// PostEffects
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function DOFPostEffect::onAdd( %this )
|
||||
{
|
||||
// The weighted distribution of CoC value to the three blur textures
|
||||
// in the order small, medium, large. Most likely you will not need to
|
||||
// change this value.
|
||||
%this.setLerpDist( 0.2, 0.3, 0.5 );
|
||||
|
||||
// Fill out some default values but DOF really should not be turned on
|
||||
// without actually specifying your own parameters!
|
||||
%this.autoFocusEnabled = false;
|
||||
%this.focalDist = 0.0;
|
||||
%this.nearBlurMax = 0.5;
|
||||
%this.farBlurMax = 0.5;
|
||||
%this.minRange = 50;
|
||||
%this.maxRange = 500;
|
||||
%this.nearSlope = -5.0;
|
||||
%this.farSlope = 5.0;
|
||||
}
|
||||
|
||||
function DOFPostEffect::setLerpDist( %this, %d0, %d1, %d2 )
|
||||
{
|
||||
%this.lerpScale = -1.0 / %d0 SPC -1.0 / %d1 SPC -1.0 / %d2 SPC 1.0 / %d2;
|
||||
%this.lerpBias = 1.0 SPC ( 1.0 - %d2 ) / %d1 SPC 1.0 / %d2 SPC ( %d2 - 1.0 ) / %d2;
|
||||
}
|
||||
|
||||
singleton PostEffect( DOFPostEffect )
|
||||
{
|
||||
renderTime = "PFXAfterBin";
|
||||
renderBin = "GlowBin";
|
||||
renderPriority = 0.1;
|
||||
|
||||
shader = PFX_DOFDownSampleShader;
|
||||
stateBlock = PFX_DOFDownSampleStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
texture[1] = "#prepass";
|
||||
target = "#shrunk";
|
||||
targetScale = "0.25 0.25";
|
||||
|
||||
isEnabled = false;
|
||||
};
|
||||
|
||||
singleton PostEffect( DOFBlurY )
|
||||
{
|
||||
shader = PFX_DOFBlurYShader;
|
||||
stateBlock = PFX_DOFBlurStateBlock;
|
||||
texture[0] = "#shrunk";
|
||||
target = "$outTex";
|
||||
};
|
||||
|
||||
DOFPostEffect.add( DOFBlurY );
|
||||
|
||||
singleton PostEffect( DOFBlurX )
|
||||
{
|
||||
shader = PFX_DOFBlurXShader;
|
||||
stateBlock = PFX_DOFBlurStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "#largeBlur";
|
||||
};
|
||||
|
||||
DOFPostEffect.add( DOFBlurX );
|
||||
|
||||
singleton PostEffect( DOFCalcCoC )
|
||||
{
|
||||
shader = PFX_DOFCalcCoCShader;
|
||||
stateBlock = PFX_DOFCalcCoCStateBlock;
|
||||
texture[0] = "#shrunk";
|
||||
texture[1] = "#largeBlur";
|
||||
target = "$outTex";
|
||||
};
|
||||
|
||||
DOFPostEffect.add( DOFCalcCoc );
|
||||
|
||||
singleton PostEffect( DOFSmallBlur )
|
||||
{
|
||||
shader = PFX_DOFSmallBlurShader;
|
||||
stateBlock = PFX_DefaultDOFStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "$outTex";
|
||||
};
|
||||
|
||||
DOFPostEffect.add( DOFSmallBlur );
|
||||
|
||||
singleton PostEffect( DOFFinalPFX )
|
||||
{
|
||||
shader = PFX_DOFFinalShader;
|
||||
stateBlock = PFX_DOFFinalStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
texture[1] = "$inTex";
|
||||
texture[2] = "#largeBlur";
|
||||
texture[3] = "#prepass";
|
||||
target = "$backBuffer";
|
||||
};
|
||||
|
||||
DOFPostEffect.add( DOFFinalPFX );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Scripts
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function DOFPostEffect::setShaderConsts( %this )
|
||||
{
|
||||
if ( %this.autoFocusEnabled )
|
||||
%this.autoFocus();
|
||||
|
||||
%fd = %this.focalDist / $Param::FarDist;
|
||||
|
||||
%range = mLerp( %this.minRange, %this.maxRange, %fd ) / $Param::FarDist * 0.5;
|
||||
|
||||
// We work in "depth" space rather than real-world units for the
|
||||
// rest of this method...
|
||||
|
||||
// Given the focal distance and the range around it we want in focus
|
||||
// we can determine the near-end-distance and far-start-distance
|
||||
|
||||
%ned = getMax( %fd - %range, 0.0 );
|
||||
%fsd = getMin( %fd + %range, 1.0 );
|
||||
|
||||
// near slope
|
||||
%nsl = %this.nearSlope;
|
||||
|
||||
// Given slope of near blur equation and the near end dist and amount (x2,y2)
|
||||
// solve for the y-intercept
|
||||
// y = mx + b
|
||||
// so...
|
||||
// y - mx = b
|
||||
|
||||
%b = 0.0 - %nsl * %ned;
|
||||
|
||||
%eqNear = %nsl SPC %b SPC 0.0;
|
||||
|
||||
// Do the same for the far blur equation...
|
||||
|
||||
%fsl = %this.farSlope;
|
||||
|
||||
%b = 0.0 - %fsl * %fsd;
|
||||
|
||||
%eqFar = %fsl SPC %b SPC 1.0;
|
||||
|
||||
%this.setShaderConst( "$dofEqWorld", %eqNear );
|
||||
DOFFinalPFX.setShaderConst( "$dofEqFar", %eqFar );
|
||||
|
||||
%this.setShaderConst( "$maxWorldCoC", %this.nearBlurMax );
|
||||
DOFFinalPFX.setShaderConst( "$maxFarCoC", %this.farBlurMax );
|
||||
|
||||
DOFFinalPFX.setShaderConst( "$dofLerpScale", %this.lerpScale );
|
||||
DOFFinalPFX.setShaderConst( "$dofLerpBias", %this.lerpBias );
|
||||
}
|
||||
|
||||
function DOFPostEffect::autoFocus( %this )
|
||||
{
|
||||
if ( !isObject( ServerConnection ) ||
|
||||
!isObject( ServerConnection.getCameraObject() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
%mask = $TypeMasks::StaticObjectType | $TypeMasks::TerrainObjectType;
|
||||
%control = ServerConnection.getCameraObject();
|
||||
|
||||
%fvec = %control.getEyeVector();
|
||||
%start = %control.getEyePoint();
|
||||
|
||||
%end = VectorAdd( %start, VectorScale( %fvec, $Param::FarDist ) );
|
||||
|
||||
// Use the client container for this ray cast.
|
||||
%result = containerRayCast( %start, %end, %mask, %control, true );
|
||||
|
||||
%hitPos = getWords( %result, 1, 3 );
|
||||
|
||||
if ( %hitPos $= "" )
|
||||
%focDist = $Param::FarDist;
|
||||
else
|
||||
%focDist = VectorDist( %hitPos, %start );
|
||||
|
||||
// For debuging
|
||||
//$DOF::debug_dist = %focDist;
|
||||
//$DOF::debug_depth = %focDist / $Param::FarDist;
|
||||
//echo( "F: " @ %focDist SPC "D: " @ %delta );
|
||||
|
||||
%this.focalDist = %focDist;
|
||||
}
|
||||
|
||||
|
||||
// For debugging
|
||||
/*
|
||||
function reloadDOF()
|
||||
{
|
||||
exec( "./dof.cs" );
|
||||
DOFPostEffect.reload();
|
||||
DOFPostEffect.disable();
|
||||
DOFPostEffect.enable();
|
||||
}
|
||||
|
||||
function dofMetricsCallback()
|
||||
{
|
||||
return " | DOF |" @
|
||||
" Dist: " @ $DOF::debug_dist @
|
||||
" Depth: " @ $DOF::debug_depth;
|
||||
}
|
||||
*/
|
||||
113
Templates/BaseGame/game/core/postFX/edgeAA.cs
Normal file
113
Templates/BaseGame/game/core/postFX/edgeAA.cs
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
singleton GFXStateBlockData( PFX_DefaultEdgeAAStateBlock )
|
||||
{
|
||||
zDefined = true;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint;
|
||||
//samplerStates[1] = SamplerWrapPoint;
|
||||
};
|
||||
|
||||
singleton ShaderData( PFX_EdgeAADetectShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/edgeDetectP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeDetectP.glsl";
|
||||
|
||||
samplerNames[0] = "$prepassBuffer";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( PFX_EdgeAAShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/edgeAAV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/edgeAAP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeAAV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeAAP.glsl";
|
||||
|
||||
samplerNames[0] = "$edgeBuffer";
|
||||
samplerNames[1] = "$backBuffer";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( PFX_EdgeAADebugShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/dbgEdgeDisplayP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/dbgEdgeDisplayP.glsl";
|
||||
|
||||
samplerNames[0] = "$edgeBuffer";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( EdgeDetectPostEffect )
|
||||
{
|
||||
renderTime = "PFXBeforeBin";
|
||||
renderBin = "ObjTranslucentBin";
|
||||
//renderPriority = 0.1;
|
||||
targetScale = "0.5 0.5";
|
||||
|
||||
shader = PFX_EdgeAADetectShader;
|
||||
stateBlock = PFX_DefaultEdgeAAStateBlock;
|
||||
texture[0] = "#prepass";
|
||||
target = "#edge";
|
||||
|
||||
isEnabled = true;
|
||||
};
|
||||
|
||||
singleton PostEffect( EdgeAAPostEffect )
|
||||
{
|
||||
renderTime = "PFXAfterDiffuse";
|
||||
//renderBin = "ObjTranslucentBin";
|
||||
//renderPriority = 0.1;
|
||||
|
||||
shader = PFX_EdgeAAShader;
|
||||
stateBlock = PFX_DefaultEdgeAAStateBlock;
|
||||
texture[0] = "#edge";
|
||||
texture[1] = "$backBuffer";
|
||||
target = "$backBuffer";
|
||||
};
|
||||
|
||||
singleton PostEffect( Debug_EdgeAAPostEffect )
|
||||
{
|
||||
renderTime = "PFXAfterDiffuse";
|
||||
//renderBin = "ObjTranslucentBin";
|
||||
//renderPriority = 0.1;
|
||||
|
||||
shader = PFX_EdgeAADebugShader;
|
||||
stateBlock = PFX_DefaultEdgeAAStateBlock;
|
||||
texture[0] = "#edge";
|
||||
target = "$backBuffer";
|
||||
};
|
||||
63
Templates/BaseGame/game/core/postFX/flash.cs
Normal file
63
Templates/BaseGame/game/core/postFX/flash.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton ShaderData( PFX_FlashShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/flashP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/flashP.glsl";
|
||||
|
||||
samplerNames[0] = "$backBuffer";
|
||||
|
||||
defines = "WHITE_COLOR=float4(1.0,1.0,1.0,0.0);MUL_COLOR=float4(1.0,0.25,0.25,0.0)";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( FlashFx )
|
||||
{
|
||||
isEnabled = false;
|
||||
allowReflectPass = false;
|
||||
|
||||
renderTime = "PFXAfterDiffuse";
|
||||
|
||||
shader = PFX_FlashShader;
|
||||
texture[0] = "$backBuffer";
|
||||
renderPriority = 10;
|
||||
stateBlock = PFX_DefaultStateBlock;
|
||||
};
|
||||
|
||||
function FlashFx::setShaderConsts( %this )
|
||||
{
|
||||
if ( isObject( ServerConnection ) )
|
||||
{
|
||||
%this.setShaderConst( "$damageFlash", ServerConnection.getDamageFlash() );
|
||||
%this.setShaderConst( "$whiteOut", ServerConnection.getWhiteOut() );
|
||||
}
|
||||
else
|
||||
{
|
||||
%this.setShaderConst( "$damageFlash", 0 );
|
||||
%this.setShaderConst( "$whiteOut", 0 );
|
||||
}
|
||||
}
|
||||
135
Templates/BaseGame/game/core/postFX/fog.cs
Normal file
135
Templates/BaseGame/game/core/postFX/fog.cs
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Fog
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
singleton ShaderData( FogPassShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/fogP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/fogP.glsl";
|
||||
|
||||
samplerNames[0] = "$prepassTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
|
||||
singleton GFXStateBlockData( FogPassStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
blendDefined = true;
|
||||
blendEnable = true;
|
||||
blendSrc = GFXBlendSrcAlpha;
|
||||
blendDest = GFXBlendInvSrcAlpha;
|
||||
};
|
||||
|
||||
|
||||
singleton PostEffect( FogPostFx )
|
||||
{
|
||||
// We forward render the reflection pass
|
||||
// so it does its own fogging.
|
||||
allowReflectPass = false;
|
||||
|
||||
renderTime = "PFXBeforeBin";
|
||||
renderBin = "ObjTranslucentBin";
|
||||
|
||||
shader = FogPassShader;
|
||||
stateBlock = FogPassStateBlock;
|
||||
texture[0] = "#prepass";
|
||||
|
||||
renderPriority = 5;
|
||||
|
||||
targetFormat = getBestHDRFormat();
|
||||
isEnabled = true;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// UnderwaterFog
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
singleton ShaderData( UnderwaterFogPassShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/underwaterFogP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/underwaterFogP.glsl";
|
||||
|
||||
samplerNames[0] = "$prepassTex";
|
||||
samplerNames[1] = "$backbuffer";
|
||||
samplerNames[2] = "$waterDepthGradMap";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
|
||||
singleton GFXStateBlockData( UnderwaterFogPassStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint;
|
||||
samplerStates[1] = SamplerClampPoint;
|
||||
samplerStates[2] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
|
||||
singleton PostEffect( UnderwaterFogPostFx )
|
||||
{
|
||||
oneFrameOnly = true;
|
||||
onThisFrame = false;
|
||||
|
||||
// Let the fog effect render during the
|
||||
// reflection pass.
|
||||
allowReflectPass = true;
|
||||
|
||||
renderTime = "PFXBeforeBin";
|
||||
renderBin = "ObjTranslucentBin";
|
||||
|
||||
shader = UnderwaterFogPassShader;
|
||||
stateBlock = UnderwaterFogPassStateBlock;
|
||||
texture[0] = "#prepass";
|
||||
texture[1] = "$backBuffer";
|
||||
texture[2] = "#waterDepthGradMap";
|
||||
|
||||
// Needs to happen after the FogPostFx
|
||||
renderPriority = 4;
|
||||
|
||||
isEnabled = true;
|
||||
};
|
||||
|
||||
function UnderwaterFogPostFx::onEnabled( %this )
|
||||
{
|
||||
TurbulenceFx.enable();
|
||||
CausticsPFX.enable();
|
||||
return true;
|
||||
}
|
||||
|
||||
function UnderwaterFogPostFx::onDisabled( %this )
|
||||
{
|
||||
TurbulenceFx.disable();
|
||||
CausticsPFX.disable();
|
||||
return false;
|
||||
}
|
||||
64
Templates/BaseGame/game/core/postFX/fxaa.cs
Normal file
64
Templates/BaseGame/game/core/postFX/fxaa.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// An implementation of "NVIDIA FXAA 3.11" by TIMOTHY LOTTES
|
||||
//
|
||||
// http://timothylottes.blogspot.com/
|
||||
//
|
||||
// The shader is tuned for the defaul quality and good performance.
|
||||
// See shaders\common\postFx\fxaa\fxaaP.hlsl to tweak the internal
|
||||
// quality and performance settings.
|
||||
|
||||
singleton GFXStateBlockData( FXAA_StateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
singleton ShaderData( FXAA_ShaderData )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/fxaa/fxaaV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/fxaa/fxaaP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/fxaa/gl/fxaaV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/fxaa/gl/fxaaP.glsl";
|
||||
|
||||
samplerNames[0] = "$colorTex";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( FXAA_PostEffect )
|
||||
{
|
||||
isEnabled = false;
|
||||
|
||||
allowReflectPass = false;
|
||||
renderTime = "PFXAfterDiffuse";
|
||||
|
||||
texture[0] = "$backBuffer";
|
||||
|
||||
target = "$backBuffer";
|
||||
|
||||
stateBlock = FXAA_StateBlock;
|
||||
shader = FXAA_ShaderData;
|
||||
};
|
||||
|
||||
184
Templates/BaseGame/game/core/postFX/glow.cs
Normal file
184
Templates/BaseGame/game/core/postFX/glow.cs
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
singleton ShaderData( PFX_GlowBlurVertShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/glowBlurV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/glowBlurP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/glowBlurV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/glowBlurP.glsl";
|
||||
|
||||
defines = "BLUR_DIR=float2(0.0,1.0)";
|
||||
|
||||
samplerNames[0] = "$diffuseMap";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
|
||||
singleton ShaderData( PFX_GlowBlurHorzShader : PFX_GlowBlurVertShader )
|
||||
{
|
||||
defines = "BLUR_DIR=float2(1.0,0.0)";
|
||||
};
|
||||
|
||||
|
||||
singleton GFXStateBlockData( PFX_GlowCombineStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
// Use alpha test to save some fillrate
|
||||
// on the non-glowing areas of the scene.
|
||||
alphaDefined = true;
|
||||
alphaTestEnable = true;
|
||||
alphaTestRef = 1;
|
||||
alphaTestFunc = GFXCmpGreaterEqual;
|
||||
|
||||
// Do a one to one blend.
|
||||
blendDefined = true;
|
||||
blendEnable = true;
|
||||
blendSrc = GFXBlendOne;
|
||||
blendDest = GFXBlendOne;
|
||||
};
|
||||
|
||||
|
||||
singleton PostEffect( GlowPostFx )
|
||||
{
|
||||
// Do not allow the glow effect to work in reflection
|
||||
// passes by default so we don't do the extra drawing.
|
||||
allowReflectPass = false;
|
||||
|
||||
renderTime = "PFXAfterBin";
|
||||
renderBin = "GlowBin";
|
||||
renderPriority = 1;
|
||||
|
||||
// First we down sample the glow buffer.
|
||||
shader = PFX_PassthruShader;
|
||||
stateBlock = PFX_DefaultStateBlock;
|
||||
texture[0] = "#glowbuffer";
|
||||
target = "$outTex";
|
||||
targetScale = "0.5 0.5";
|
||||
|
||||
isEnabled = true;
|
||||
|
||||
// Blur vertically
|
||||
new PostEffect()
|
||||
{
|
||||
shader = PFX_GlowBlurVertShader;
|
||||
stateBlock = PFX_DefaultStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "$outTex";
|
||||
};
|
||||
|
||||
// Blur horizontally
|
||||
new PostEffect()
|
||||
{
|
||||
shader = PFX_GlowBlurHorzShader;
|
||||
stateBlock = PFX_DefaultStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "$outTex";
|
||||
};
|
||||
|
||||
// Upsample and combine with the back buffer.
|
||||
new PostEffect()
|
||||
{
|
||||
shader = PFX_PassthruShader;
|
||||
stateBlock = PFX_GlowCombineStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "$backBuffer";
|
||||
};
|
||||
};
|
||||
|
||||
singleton ShaderData( PFX_VolFogGlowBlurVertShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/glowBlurV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/VolFogGlowP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/glowBlurV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/VolFogGlowP.glsl";
|
||||
|
||||
defines = "BLUR_DIR=float2(0.0,1.0)";
|
||||
samplerNames[0] = "$diffuseMap";
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
singleton ShaderData( PFX_VolFogGlowBlurHorzShader : PFX_VolFogGlowBlurVertShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/glowBlurV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/VolFogGlowP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/glowBlurV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/VolFogGlowP.glsl";
|
||||
|
||||
defines = "BLUR_DIR=float2(1.0,0.0)";
|
||||
};
|
||||
|
||||
$VolFogGlowPostFx::glowStrength = 0.3;
|
||||
|
||||
singleton PostEffect( VolFogGlowPostFx )
|
||||
{
|
||||
// Do not allow the glow effect to work in reflection
|
||||
// passes by default so we don't do the extra drawing.
|
||||
allowReflectPass = false;
|
||||
renderTime = "PFXAfterBin";
|
||||
renderBin = "FogBin";
|
||||
renderPriority = 1;
|
||||
// First we down sample the glow buffer.
|
||||
shader = PFX_PassthruShader;
|
||||
stateBlock = PFX_DefaultStateBlock;
|
||||
texture[0] = "$backbuffer";
|
||||
target = "$outTex";
|
||||
targetScale = "0.5 0.5";
|
||||
isEnabled = true;
|
||||
// Blur vertically
|
||||
new PostEffect()
|
||||
{
|
||||
shader = PFX_VolFogGlowBlurVertShader;
|
||||
stateBlock = PFX_DefaultStateBlock;
|
||||
internalName = "vert";
|
||||
texture[0] = "$inTex";
|
||||
target = "$outTex";
|
||||
};
|
||||
// Blur horizontally
|
||||
new PostEffect()
|
||||
{
|
||||
shader = PFX_VolFogGlowBlurHorzShader;
|
||||
stateBlock = PFX_DefaultStateBlock;
|
||||
internalName = "hor";
|
||||
texture[0] = "$inTex";
|
||||
target = "$outTex";
|
||||
};
|
||||
// Upsample and combine with the back buffer.
|
||||
new PostEffect()
|
||||
{
|
||||
shader = PFX_PassthruShader;
|
||||
stateBlock = PFX_GlowCombineStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "$backBuffer";
|
||||
};
|
||||
};
|
||||
|
||||
function VolFogGlowPostFx::setShaderConsts( %this )
|
||||
{
|
||||
%vp=%this-->vert;
|
||||
%vp.setShaderConst( "$strength", $VolFogGlowPostFx::glowStrength );
|
||||
%vp=%this-->hor;
|
||||
%vp.setShaderConst( "$strength", $VolFogGlowPostFx::glowStrength );
|
||||
}
|
||||
533
Templates/BaseGame/game/core/postFX/hdr.cs
Normal file
533
Templates/BaseGame/game/core/postFX/hdr.cs
Normal file
|
|
@ -0,0 +1,533 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/// Blends between the scene and the tone mapped scene.
|
||||
$HDRPostFX::enableToneMapping = 0.5;
|
||||
|
||||
/// The tone mapping middle grey or exposure value used
|
||||
/// to adjust the overall "balance" of the image.
|
||||
///
|
||||
/// 0.18 is fairly common value.
|
||||
///
|
||||
$HDRPostFX::keyValue = 0.18;
|
||||
|
||||
/// The minimum luninace value to allow when tone mapping
|
||||
/// the scene. Is particularly useful if your scene very
|
||||
/// dark or has a black ambient color in places.
|
||||
$HDRPostFX::minLuminace = 0.001;
|
||||
|
||||
/// The lowest luminance value which is mapped to white. This
|
||||
/// is usually set to the highest visible luminance in your
|
||||
/// scene. By setting this to smaller values you get a contrast
|
||||
/// enhancement.
|
||||
$HDRPostFX::whiteCutoff = 1.0;
|
||||
|
||||
/// The rate of adaptation from the previous and new
|
||||
/// average scene luminance.
|
||||
$HDRPostFX::adaptRate = 2.0;
|
||||
|
||||
/// Blends between the scene and the blue shifted version
|
||||
/// of the scene for a cinematic desaturated night effect.
|
||||
$HDRPostFX::enableBlueShift = 0.0;
|
||||
|
||||
/// The blue shift color value.
|
||||
$HDRPostFX::blueShiftColor = "1.05 0.97 1.27";
|
||||
|
||||
|
||||
/// Blends between the scene and the bloomed scene.
|
||||
$HDRPostFX::enableBloom = 1.0;
|
||||
|
||||
/// The threshold luminace value for pixels which are
|
||||
/// considered "bright" and need to be bloomed.
|
||||
$HDRPostFX::brightPassThreshold = 1.0;
|
||||
|
||||
/// These are used in the gaussian blur of the
|
||||
/// bright pass for the bloom effect.
|
||||
$HDRPostFX::gaussMultiplier = 0.3;
|
||||
$HDRPostFX::gaussMean = 0.0;
|
||||
$HDRPostFX::gaussStdDev = 0.8;
|
||||
|
||||
/// The 1x255 color correction ramp texture used
|
||||
/// by both the HDR shader and the GammaPostFx shader
|
||||
/// for doing full screen color correction.
|
||||
$HDRPostFX::colorCorrectionRamp = "core/images/null_color_ramp.png";
|
||||
|
||||
|
||||
singleton ShaderData( HDR_BrightPassShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/brightPassFilterP.hlsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/brightPassFilterP.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
samplerNames[1] = "$luminanceTex";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( HDR_DownScale4x4Shader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/downScale4x4V.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/downScale4x4P.hlsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/downScale4x4V.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/downScale4x4P.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( HDR_BloomGaussBlurHShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/bloomGaussBlurHP.hlsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/bloomGaussBlurHP.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( HDR_BloomGaussBlurVShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/bloomGaussBlurVP.hlsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/bloomGaussBlurVP.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( HDR_SampleLumShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/sampleLumInitialP.hlsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/sampleLumInitialP.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( HDR_DownSampleLumShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/sampleLumIterativeP.hlsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/sampleLumIterativeP.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( HDR_CalcAdaptedLumShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/calculateAdaptedLumP.hlsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/calculateAdaptedLumP.glsl";
|
||||
|
||||
samplerNames[0] = "$currLum";
|
||||
samplerNames[1] = "$lastAdaptedLum";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( HDR_CombineShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/finalPassCombineP.hlsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/finalPassCombineP.glsl";
|
||||
|
||||
samplerNames[0] = "$sceneTex";
|
||||
samplerNames[1] = "$luminanceTex";
|
||||
samplerNames[2] = "$bloomTex";
|
||||
samplerNames[3] = "$colorCorrectionTex";
|
||||
samplerNames[4] = "prepassTex";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
|
||||
singleton GFXStateBlockData( HDR_SampleStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint;
|
||||
samplerStates[1] = SamplerClampPoint;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( HDR_DownSampleStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
samplerStates[1] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( HDR_CombineStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint;
|
||||
samplerStates[1] = SamplerClampLinear;
|
||||
samplerStates[2] = SamplerClampLinear;
|
||||
samplerStates[3] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( HDRStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
samplerStates[1] = SamplerClampLinear;
|
||||
samplerStates[2] = SamplerClampLinear;
|
||||
samplerStates[3] = SamplerClampLinear;
|
||||
|
||||
blendDefined = true;
|
||||
blendDest = GFXBlendOne;
|
||||
blendSrc = GFXBlendZero;
|
||||
|
||||
zDefined = true;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
cullDefined = true;
|
||||
cullMode = GFXCullNone;
|
||||
};
|
||||
|
||||
|
||||
function HDRPostFX::setShaderConsts( %this )
|
||||
{
|
||||
%this.setShaderConst( "$brightPassThreshold", $HDRPostFX::brightPassThreshold );
|
||||
%this.setShaderConst( "$g_fMiddleGray", $HDRPostFX::keyValue );
|
||||
|
||||
%bloomH = %this-->bloomH;
|
||||
%bloomH.setShaderConst( "$gaussMultiplier", $HDRPostFX::gaussMultiplier );
|
||||
%bloomH.setShaderConst( "$gaussMean", $HDRPostFX::gaussMean );
|
||||
%bloomH.setShaderConst( "$gaussStdDev", $HDRPostFX::gaussStdDev );
|
||||
|
||||
%bloomV = %this-->bloomV;
|
||||
%bloomV.setShaderConst( "$gaussMultiplier", $HDRPostFX::gaussMultiplier );
|
||||
%bloomV.setShaderConst( "$gaussMean", $HDRPostFX::gaussMean );
|
||||
%bloomV.setShaderConst( "$gaussStdDev", $HDRPostFX::gaussStdDev );
|
||||
|
||||
%minLuminace = $HDRPostFX::minLuminace;
|
||||
if ( %minLuminace <= 0.0 )
|
||||
{
|
||||
// The min should never be pure zero else the
|
||||
// log() in the shader will generate INFs.
|
||||
%minLuminace = 0.00001;
|
||||
}
|
||||
%this-->adaptLum.setShaderConst( "$g_fMinLuminace", %minLuminace );
|
||||
|
||||
%this-->finalLum.setShaderConst( "$adaptRate", $HDRPostFX::adaptRate );
|
||||
|
||||
%combinePass = %this-->combinePass;
|
||||
%combinePass.setShaderConst( "$g_fEnableToneMapping", $HDRPostFX::enableToneMapping );
|
||||
%combinePass.setShaderConst( "$g_fMiddleGray", $HDRPostFX::keyValue );
|
||||
%combinePass.setShaderConst( "$g_fBloomScale", $HDRPostFX::enableBloom );
|
||||
%combinePass.setShaderConst( "$g_fEnableBlueShift", $HDRPostFX::enableBlueShift );
|
||||
%combinePass.setShaderConst( "$g_fBlueShiftColor", $HDRPostFX::blueShiftColor );
|
||||
|
||||
%clampedGamma = mClamp( $pref::Video::Gamma, 2.0, 2.5);
|
||||
%combinePass.setShaderConst( "$g_fOneOverGamma", 1 / %clampedGamma );
|
||||
%combinePass.setShaderConst( "$Brightness", $pref::Video::Brightness );
|
||||
%combinePass.setShaderConst( "$Contrast", $pref::Video::Contrast );
|
||||
|
||||
%whiteCutoff = ( $HDRPostFX::whiteCutoff * $HDRPostFX::whiteCutoff ) *
|
||||
( $HDRPostFX::whiteCutoff * $HDRPostFX::whiteCutoff );
|
||||
%combinePass.setShaderConst( "$g_fWhiteCutoff", %whiteCutoff );
|
||||
}
|
||||
|
||||
function HDRPostFX::preProcess( %this )
|
||||
{
|
||||
%combinePass = %this-->combinePass;
|
||||
|
||||
if ( %combinePass.texture[3] !$= $HDRPostFX::colorCorrectionRamp )
|
||||
%combinePass.setTexture( 3, $HDRPostFX::colorCorrectionRamp );
|
||||
}
|
||||
|
||||
function HDRPostFX::onEnabled( %this )
|
||||
{
|
||||
// We don't allow hdr on OSX yet.
|
||||
if ( $platform $= "macos" )
|
||||
return false;
|
||||
|
||||
// See what HDR format would be best.
|
||||
%format = getBestHDRFormat();
|
||||
if ( %format $= "" || %format $= "GFXFormatR8G8B8A8" )
|
||||
{
|
||||
// We didn't get a valid HDR format... so fail.
|
||||
return false;
|
||||
}
|
||||
|
||||
// HDR does it's own gamma calculation so
|
||||
// disable this postFx.
|
||||
GammaPostFX.disable();
|
||||
|
||||
// Set the right global shader define for HDR.
|
||||
if ( %format $= "GFXFormatR10G10B10A2" )
|
||||
addGlobalShaderMacro( "TORQUE_HDR_RGB10" );
|
||||
else if ( %format $= "GFXFormatR16G16B16A16" )
|
||||
addGlobalShaderMacro( "TORQUE_HDR_RGB16" );
|
||||
|
||||
echo( "HDR FORMAT: " @ %format );
|
||||
|
||||
// Change the format of the offscreen surface
|
||||
// to an HDR compatible format.
|
||||
AL_FormatToken.format = %format;
|
||||
setReflectFormat( %format );
|
||||
|
||||
// Reset the light manager which will ensure the new
|
||||
// hdr encoding takes effect in all the shaders and
|
||||
// that the offscreen surface is enabled.
|
||||
resetLightManager();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function HDRPostFX::onDisabled( %this )
|
||||
{
|
||||
// Enable a special GammaCorrection PostFX when this is disabled.
|
||||
GammaPostFX.enable();
|
||||
|
||||
// Restore the non-HDR offscreen surface format.
|
||||
%format = getBestHDRFormat();
|
||||
AL_FormatToken.format = %format;
|
||||
setReflectFormat( %format );
|
||||
|
||||
removeGlobalShaderMacro( "TORQUE_HDR_RGB10" );
|
||||
removeGlobalShaderMacro( "TORQUE_HDR_RGB16" );
|
||||
|
||||
// Reset the light manager which will ensure the new
|
||||
// hdr encoding takes effect in all the shaders.
|
||||
resetLightManager();
|
||||
}
|
||||
|
||||
singleton PostEffect( HDRPostFX )
|
||||
{
|
||||
isEnabled = false;
|
||||
allowReflectPass = false;
|
||||
|
||||
// Resolve the HDR before we render any editor stuff
|
||||
// and before we resolve the scene to the backbuffer.
|
||||
renderTime = "PFXBeforeBin";
|
||||
renderBin = "EditorBin";
|
||||
renderPriority = 9999;
|
||||
|
||||
// The bright pass generates a bloomed version of
|
||||
// the scene for pixels which are brighter than a
|
||||
// fixed threshold value.
|
||||
//
|
||||
// This is then used in the final HDR combine pass
|
||||
// at the end of this post effect chain.
|
||||
//
|
||||
|
||||
shader = HDR_BrightPassShader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
texture[1] = "#adaptedLum";
|
||||
target = "$outTex";
|
||||
targetFormat = "GFXFormatR16G16B16A16F";
|
||||
targetScale = "0.5 0.5";
|
||||
|
||||
new PostEffect()
|
||||
{
|
||||
allowReflectPass = false;
|
||||
shader = HDR_DownScale4x4Shader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "$outTex";
|
||||
targetFormat = "GFXFormatR16G16B16A16F";
|
||||
targetScale = "0.25 0.25";
|
||||
};
|
||||
|
||||
new PostEffect()
|
||||
{
|
||||
allowReflectPass = false;
|
||||
internalName = "bloomH";
|
||||
|
||||
shader = HDR_BloomGaussBlurHShader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "$outTex";
|
||||
targetFormat = "GFXFormatR16G16B16A16F";
|
||||
};
|
||||
|
||||
new PostEffect()
|
||||
{
|
||||
allowReflectPass = false;
|
||||
internalName = "bloomV";
|
||||
|
||||
shader = HDR_BloomGaussBlurVShader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "#bloomFinal";
|
||||
targetFormat = "GFXFormatR16G16B16A16F";
|
||||
};
|
||||
|
||||
// BrightPass End
|
||||
|
||||
// Now calculate the adapted luminance.
|
||||
new PostEffect()
|
||||
{
|
||||
allowReflectPass = false;
|
||||
internalName = "adaptLum";
|
||||
|
||||
shader = HDR_SampleLumShader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
target = "$outTex";
|
||||
targetScale = "0.0625 0.0625"; // 1/16th
|
||||
targetFormat = "GFXFormatR16F";
|
||||
|
||||
new PostEffect()
|
||||
{
|
||||
allowReflectPass = false;
|
||||
shader = HDR_DownSampleLumShader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "$outTex";
|
||||
targetScale = "0.25 0.25"; // 1/4
|
||||
targetFormat = "GFXFormatR16F";
|
||||
};
|
||||
|
||||
new PostEffect()
|
||||
{
|
||||
allowReflectPass = false;
|
||||
shader = HDR_DownSampleLumShader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "$outTex";
|
||||
targetScale = "0.25 0.25"; // 1/4
|
||||
targetFormat = "GFXFormatR16F";
|
||||
};
|
||||
|
||||
new PostEffect()
|
||||
{
|
||||
allowReflectPass = false;
|
||||
shader = HDR_DownSampleLumShader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "$outTex";
|
||||
targetScale = "0.25 0.25"; // At this point the target should be 1x1.
|
||||
targetFormat = "GFXFormatR16F";
|
||||
};
|
||||
|
||||
// Note that we're reading the adapted luminance
|
||||
// from the previous frame when generating this new
|
||||
// one... PostEffect takes care to manage that.
|
||||
new PostEffect()
|
||||
{
|
||||
allowReflectPass = false;
|
||||
internalName = "finalLum";
|
||||
shader = HDR_CalcAdaptedLumShader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
texture[1] = "#adaptedLum";
|
||||
target = "#adaptedLum";
|
||||
targetFormat = "GFXFormatR16F";
|
||||
targetClear = "PFXTargetClear_OnCreate";
|
||||
targetClearColor = "1 1 1 1";
|
||||
};
|
||||
};
|
||||
|
||||
// Output the combined bloom and toned mapped
|
||||
// version of the scene.
|
||||
new PostEffect()
|
||||
{
|
||||
allowReflectPass = false;
|
||||
internalName = "combinePass";
|
||||
|
||||
shader = HDR_CombineShader;
|
||||
stateBlock = HDR_CombineStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
texture[1] = "#adaptedLum";
|
||||
texture[2] = "#bloomFinal";
|
||||
texture[3] = $HDRPostFX::colorCorrectionRamp;
|
||||
target = "$backBuffer";
|
||||
};
|
||||
};
|
||||
|
||||
singleton ShaderData( LuminanceVisShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/luminanceVisP.hlsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/hdr/gl/luminanceVisP.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( LuminanceVisStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
function LuminanceVisPostFX::setShaderConsts( %this )
|
||||
{
|
||||
%this.setShaderConst( "$brightPassThreshold", $HDRPostFX::brightPassThreshold );
|
||||
}
|
||||
|
||||
singleton PostEffect( LuminanceVisPostFX )
|
||||
{
|
||||
isEnabled = false;
|
||||
allowReflectPass = false;
|
||||
|
||||
// Render before we do any editor rendering.
|
||||
renderTime = "PFXBeforeBin";
|
||||
renderBin = "EditorBin";
|
||||
renderPriority = 9999;
|
||||
|
||||
shader = LuminanceVisShader;
|
||||
stateBlock = LuminanceVisStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
target = "$backBuffer";
|
||||
//targetScale = "0.0625 0.0625"; // 1/16th
|
||||
//targetFormat = "GFXFormatR16F";
|
||||
};
|
||||
|
||||
function LuminanceVisPostFX::onEnabled( %this )
|
||||
{
|
||||
if ( !HDRPostFX.isEnabled() )
|
||||
{
|
||||
HDRPostFX.enable();
|
||||
}
|
||||
|
||||
HDRPostFX.skip = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function LuminanceVisPostFX::onDisabled( %this )
|
||||
{
|
||||
HDRPostFX.skip = false;
|
||||
}
|
||||
|
||||
110
Templates/BaseGame/game/core/postFX/lightRay.cs
Normal file
110
Templates/BaseGame/game/core/postFX/lightRay.cs
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
$LightRayPostFX::brightScalar = 0.75;
|
||||
$LightRayPostFX::numSamples = 40;
|
||||
$LightRayPostFX::density = 0.94;
|
||||
$LightRayPostFX::weight = 5.65;
|
||||
$LightRayPostFX::decay = 1.0;
|
||||
$LightRayPostFX::exposure = 0.0005;
|
||||
$LightRayPostFX::resolutionScale = 1.0;
|
||||
|
||||
|
||||
singleton ShaderData( LightRayOccludeShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/lightRay/lightRayOccludeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/lightRay/gl/lightRayOccludeP.glsl";
|
||||
|
||||
samplerNames[0] = "$backBuffer";
|
||||
samplerNames[1] = "$prepassTex";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( LightRayShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/lightRay/lightRayP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/lightRay/gl/lightRayP.glsl";
|
||||
|
||||
samplerNames[0] = "$frameSampler";
|
||||
samplerNames[1] = "$backBuffer";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( LightRayStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
samplerStates[1] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
singleton PostEffect( LightRayPostFX )
|
||||
{
|
||||
isEnabled = false;
|
||||
allowReflectPass = false;
|
||||
|
||||
renderTime = "PFXBeforeBin";
|
||||
renderBin = "EditorBin";
|
||||
renderPriority = 10;
|
||||
|
||||
shader = LightRayOccludeShader;
|
||||
stateBlock = LightRayStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
texture[1] = "#prepass";
|
||||
target = "$outTex";
|
||||
targetFormat = "GFXFormatR16G16B16A16F";
|
||||
|
||||
new PostEffect()
|
||||
{
|
||||
shader = LightRayShader;
|
||||
stateBlock = LightRayStateBlock;
|
||||
internalName = "final";
|
||||
texture[0] = "$inTex";
|
||||
texture[1] = "$backBuffer";
|
||||
target = "$backBuffer";
|
||||
};
|
||||
};
|
||||
|
||||
function LightRayPostFX::preProcess( %this )
|
||||
{
|
||||
%this.targetScale = $LightRayPostFX::resolutionScale SPC $LightRayPostFX::resolutionScale;
|
||||
}
|
||||
|
||||
function LightRayPostFX::setShaderConsts( %this )
|
||||
{
|
||||
%this.setShaderConst( "$brightScalar", $LightRayPostFX::brightScalar );
|
||||
|
||||
%pfx = %this-->final;
|
||||
%pfx.setShaderConst( "$numSamples", $LightRayPostFX::numSamples );
|
||||
%pfx.setShaderConst( "$density", $LightRayPostFX::density );
|
||||
%pfx.setShaderConst( "$weight", $LightRayPostFX::weight );
|
||||
%pfx.setShaderConst( "$decay", $LightRayPostFX::decay );
|
||||
%pfx.setShaderConst( "$exposure", $LightRayPostFX::exposure );
|
||||
}
|
||||
167
Templates/BaseGame/game/core/postFX/ovrBarrelDistortion.cs
Normal file
167
Templates/BaseGame/game/core/postFX/ovrBarrelDistortion.cs
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Only load these shaders if an Oculus VR device is present
|
||||
if(!isFunction(isOculusVRDeviceActive))
|
||||
return;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Shader data
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton ShaderData( OVRMonoToStereoShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/oculusvr/monoToStereoP.hlsl";
|
||||
|
||||
//OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.hlsl";
|
||||
//OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/oculusvr/gl/monoToStereoP.glsl";
|
||||
|
||||
samplerNames[0] = "$backBuffer";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( OVRBarrelDistortionShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/oculusvr/barrelDistortionP.hlsl";
|
||||
|
||||
//OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||
//OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/oculusvr/gl/barrelDistortionP.glsl";
|
||||
|
||||
samplerNames[0] = "$backBuffer";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( OVRBarrelDistortionChromaShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/oculusvr/barrelDistortionChromaP.hlsl";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// GFX state blocks
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton GFXStateBlockData( OVRBarrelDistortionStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Barrel Distortion PostFx
|
||||
//
|
||||
// To be used with the Oculus Rift.
|
||||
// Expects a stereo pair to exist on the back buffer and then applies the
|
||||
// appropriate barrel distortion.
|
||||
//-----------------------------------------------------------------------------
|
||||
singleton BarrelDistortionPostEffect( OVRBarrelDistortionPostFX )
|
||||
{
|
||||
isEnabled = false;
|
||||
allowReflectPass = false;
|
||||
|
||||
renderTime = "PFXAfterDiffuse";
|
||||
renderPriority = 100;
|
||||
|
||||
// The barrel distortion
|
||||
shader = OVRBarrelDistortionShader;
|
||||
stateBlock = OVRBarrelDistortionStateBlock;
|
||||
|
||||
texture[0] = "$backBuffer";
|
||||
|
||||
scaleOutput = 1.25;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Barrel Distortion with Chromatic Aberration Correction PostFx
|
||||
//
|
||||
// To be used with the Oculus Rift.
|
||||
// Expects a stereo pair to exist on the back buffer and then applies the
|
||||
// appropriate barrel distortion.
|
||||
// This version applies a chromatic aberration correction during the
|
||||
// barrel distortion.
|
||||
//-----------------------------------------------------------------------------
|
||||
singleton BarrelDistortionPostEffect( OVRBarrelDistortionChromaPostFX )
|
||||
{
|
||||
isEnabled = false;
|
||||
allowReflectPass = false;
|
||||
|
||||
renderTime = "PFXAfterDiffuse";
|
||||
renderPriority = 100;
|
||||
|
||||
// The barrel distortion
|
||||
shader = OVRBarrelDistortionChromaShader;
|
||||
stateBlock = OVRBarrelDistortionStateBlock;
|
||||
|
||||
texture[0] = "$backBuffer";
|
||||
|
||||
scaleOutput = 1.25;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Barrel Distortion Mono PostFx
|
||||
//
|
||||
// To be used with the Oculus Rift.
|
||||
// Takes a non-stereo image and turns it into a stereo pair with barrel
|
||||
// distortion applied. Only a vertical slice around the center of the back
|
||||
// buffer is used to generate the pseudo stereo pair.
|
||||
//-----------------------------------------------------------------------------
|
||||
singleton PostEffect( OVRBarrelDistortionMonoPostFX )
|
||||
{
|
||||
isEnabled = false;
|
||||
allowReflectPass = false;
|
||||
|
||||
renderTime = "PFXAfterDiffuse";
|
||||
renderPriority = 100;
|
||||
|
||||
// Converts the mono display to a stereo one
|
||||
shader = OVRMonoToStereoShader;
|
||||
stateBlock = OVRBarrelDistortionStateBlock;
|
||||
|
||||
texture[0] = "$backBuffer";
|
||||
target = "$outTex";
|
||||
|
||||
// The actual barrel distortion
|
||||
new BarrelDistortionPostEffect(OVRBarrelDistortionMonoStage2PostFX)
|
||||
{
|
||||
shader = OVRBarrelDistortionShader;
|
||||
stateBlock = OVRBarrelDistortionStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "$backBuffer";
|
||||
|
||||
scaleOutput = 1.25;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
function OVRBarrelDistortionMonoPostFX::setShaderConsts( %this )
|
||||
{
|
||||
%HMDIndex = 0;
|
||||
|
||||
%xOffsets = getOVRHMDEyeXOffsets(%HMDIndex);
|
||||
%this.setShaderConst( "$LensXOffsets", %xOffsets );
|
||||
}
|
||||
2755
Templates/BaseGame/game/core/postFX/postFxManager.gui
Normal file
2755
Templates/BaseGame/game/core/postFX/postFxManager.gui
Normal file
File diff suppressed because it is too large
Load diff
446
Templates/BaseGame/game/core/postFX/postFxManager.gui.cs
Normal file
446
Templates/BaseGame/game/core/postFX/postFxManager.gui.cs
Normal file
|
|
@ -0,0 +1,446 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$PostFXManager::vebose = true;
|
||||
function postVerbose(%string)
|
||||
{
|
||||
if($PostFXManager::vebose == true)
|
||||
{
|
||||
echo(%string);
|
||||
}
|
||||
}
|
||||
|
||||
function PostFXManager::onDialogPush( %this )
|
||||
{
|
||||
//Apply the settings to the controls
|
||||
postVerbose("% - PostFX Manager - Loading GUI.");
|
||||
|
||||
%this.settingsRefreshAll();
|
||||
}
|
||||
|
||||
// :: Controls for the overall postFX manager dialog
|
||||
function ppOptionsEnable::onAction(%this)
|
||||
{
|
||||
//Disable / Enable all PostFX
|
||||
|
||||
if(ppOptionsEnable.getValue())
|
||||
{
|
||||
%toEnable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
%toEnable = false;
|
||||
}
|
||||
|
||||
PostFXManager.settingsSetEnabled(%toEnable);
|
||||
|
||||
}
|
||||
|
||||
function PostFXManager::getEnableResultFromControl(%this, %control)
|
||||
{
|
||||
%toEnable = -1;
|
||||
%bTest = %control.getValue();
|
||||
if(%bTest == 1)
|
||||
{
|
||||
%toEnable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
%toEnable = false;
|
||||
}
|
||||
|
||||
return %toEnable;
|
||||
}
|
||||
|
||||
function ppOptionsEnableSSAO::onAction(%this)
|
||||
{
|
||||
%toEnable = PostFXManager.getEnableResultFromControl(%this);
|
||||
PostFXManager.settingsEffectSetEnabled("SSAO", %toEnable);
|
||||
}
|
||||
|
||||
function ppOptionsEnableHDR::onAction(%this)
|
||||
{
|
||||
%toEnable = PostFXManager.getEnableResultFromControl(%this);
|
||||
PostFXManager.settingsEffectSetEnabled("HDR", %toEnable);
|
||||
}
|
||||
|
||||
function ppOptionsEnableLightRays::onAction(%this)
|
||||
{
|
||||
%toEnable = PostFXManager.getEnableResultFromControl(%this);
|
||||
PostFXManager.settingsEffectSetEnabled("LightRays", %toEnable);
|
||||
}
|
||||
|
||||
function ppOptionsEnableDOF::onAction(%this)
|
||||
{
|
||||
%toEnable = PostFXManager.getEnableResultFromControl(%this);
|
||||
PostFXManager.settingsEffectSetEnabled("DOF", %toEnable);
|
||||
}
|
||||
|
||||
function ppOptionsEnableVignette::onAction(%this)
|
||||
{
|
||||
%toEnable = PostFXManager.getEnableResultFromControl(%this);
|
||||
PostFXManager.settingsEffectSetEnabled("Vignette", %toEnable);
|
||||
}
|
||||
|
||||
function ppOptionsSavePreset::onClick(%this)
|
||||
{
|
||||
//Stores the current settings into a preset file for loading and use later on
|
||||
}
|
||||
|
||||
function ppOptionsLoadPreset::onClick(%this)
|
||||
{
|
||||
//Loads and applies the settings from a postfxpreset file
|
||||
}
|
||||
|
||||
|
||||
//Other controls, Quality dropdown
|
||||
function ppOptionsSSAOQuality::onSelect( %this, %id, %text )
|
||||
{
|
||||
if(%id > -1 && %id < 3)
|
||||
{
|
||||
$SSAOPostFx::quality = %id;
|
||||
}
|
||||
}
|
||||
|
||||
//SSAO Slider controls
|
||||
//General Tab
|
||||
function ppOptionsSSAOOverallStrength::onMouseDragged(%this)
|
||||
{
|
||||
$SSAOPostFx::overallStrength = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
function ppOptionsSSAOBlurDepth::onMouseDragged(%this)
|
||||
{
|
||||
$SSAOPostFx::blurDepthTol = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
function ppOptionsSSAOBlurNormal::onMouseDragged(%this)
|
||||
{
|
||||
$SSAOPostFx::blurNormalTol = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
//Near Tab
|
||||
function ppOptionsSSAONearRadius::onMouseDragged(%this)
|
||||
{
|
||||
$SSAOPostFx::sRadius = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
function ppOptionsSSAONearStrength::onMouseDragged(%this)
|
||||
{
|
||||
$SSAOPostFx::sStrength = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
function ppOptionsSSAONearDepthMin::onMouseDragged(%this)
|
||||
{
|
||||
$SSAOPostFx::sDepthMin = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
function ppOptionsSSAONearDepthMax::onMouseDragged(%this)
|
||||
{
|
||||
$SSAOPostFx::sDepthMax = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
function ppOptionsSSAONearToleranceNormal::onMouseDragged(%this)
|
||||
{
|
||||
$SSAOPostFx::sNormalTol = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
function ppOptionsSSAONearTolerancePower::onMouseDragged(%this)
|
||||
{
|
||||
$SSAOPostFx::sNormalPow = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
//Far Tab
|
||||
function ppOptionsSSAOFarRadius::onMouseDragged(%this)
|
||||
{
|
||||
$SSAOPostFx::lRadius = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
function ppOptionsSSAOFarStrength::onMouseDragged(%this)
|
||||
{
|
||||
$SSAOPostFx::lStrength = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
function ppOptionsSSAOFarDepthMin::onMouseDragged(%this)
|
||||
{
|
||||
$SSAOPostFx::lDepthMin = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
function ppOptionsSSAOFarDepthMax::onMouseDragged(%this)
|
||||
{
|
||||
$SSAOPostFx::lDepthMax = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
function ppOptionsSSAOFarToleranceNormal::onMouseDragged(%this)
|
||||
{
|
||||
$SSAOPostFx::lNormalTol = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
function ppOptionsSSAOFarTolerancePower::onMouseDragged(%this)
|
||||
{
|
||||
$SSAOPostFx::lNormalPow = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
//HDR Slider Controls
|
||||
//Brighness tab
|
||||
|
||||
function ppOptionsHDRToneMappingAmount::onMouseDragged(%this)
|
||||
{
|
||||
|
||||
$HDRPostFX::enableToneMapping = %this.value;
|
||||
%this.ToolTip = "value : " @ %this.value;
|
||||
}
|
||||
|
||||
function ppOptionsHDRKeyValue::onMouseDragged(%this)
|
||||
{
|
||||
$HDRPostFX::keyValue = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
function ppOptionsHDRMinLuminance::onMouseDragged(%this)
|
||||
{
|
||||
$HDRPostFX::minLuminace = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
function ppOptionsHDRWhiteCutoff::onMouseDragged(%this)
|
||||
{
|
||||
$HDRPostFX::whiteCutoff = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
function ppOptionsHDRBrightnessAdaptRate::onMouseDragged(%this)
|
||||
{
|
||||
$HDRPostFX::adaptRate = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
//Blur tab
|
||||
function ppOptionsHDRBloomBlurBrightPassThreshold::onMouseDragged(%this)
|
||||
{
|
||||
$HDRPostFX::brightPassThreshold = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
function ppOptionsHDRBloomBlurMultiplier::onMouseDragged(%this)
|
||||
{
|
||||
$HDRPostFX::gaussMultiplier = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
function ppOptionsHDRBloomBlurMean::onMouseDragged(%this)
|
||||
{
|
||||
$HDRPostFX::gaussMean = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
function ppOptionsHDRBloomBlurStdDev::onMouseDragged(%this)
|
||||
{
|
||||
$HDRPostFX::gaussStdDev = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
function ppOptionsHDRBloom::onAction(%this)
|
||||
{
|
||||
$HDRPostFX::enableBloom = %this.getValue();
|
||||
}
|
||||
|
||||
function ppOptionsHDRToneMapping::onAction(%this)
|
||||
{
|
||||
//$HDRPostFX::enableToneMapping = %this.getValue();
|
||||
}
|
||||
|
||||
function ppOptionsHDREffectsBlueShift::onAction(%this)
|
||||
{
|
||||
$HDRPostFX::enableBlueShift = %this.getValue();
|
||||
}
|
||||
|
||||
|
||||
//Controls for color range in blue Shift dialog
|
||||
|
||||
function ppOptionsHDREffectsBlueShiftColorBlend::onAction(%this)
|
||||
{
|
||||
$HDRPostFX::blueShiftColor = %this.PickColor;
|
||||
%this.ToolTip = "Color Values : " @ %this.PickColor;
|
||||
}
|
||||
|
||||
function ppOptionsHDREffectsBlueShiftColorBaseColor::onAction(%this)
|
||||
{
|
||||
//This one feeds the one above
|
||||
ppOptionsHDREffectsBlueShiftColorBlend.baseColor = %this.PickColor;
|
||||
%this.ToolTip = "Color Values : " @ %this.PickColor;
|
||||
}
|
||||
|
||||
|
||||
//Light rays Brightness Slider Controls
|
||||
function ppOptionsLightRaysBrightScalar::onMouseDragged(%this)
|
||||
{
|
||||
$LightRayPostFX::brightScalar = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
//Light rays Number of Samples Slider Control
|
||||
function ppOptionsLightRaysSampleScalar::onMouseDragged(%this)
|
||||
{
|
||||
$LightRayPostFX::numSamples = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
//Light rays Density Slider Control
|
||||
function ppOptionsLightRaysDensityScalar::onMouseDragged(%this)
|
||||
{
|
||||
$LightRayPostFX::density = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
//Light rays Weight Slider Control
|
||||
function ppOptionsLightRaysWeightScalar::onMouseDragged(%this)
|
||||
{
|
||||
$LightRayPostFX::weight = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
//Light rays Decay Slider Control
|
||||
function ppOptionsLightRaysDecayScalar::onMouseDragged(%this)
|
||||
{
|
||||
$LightRayPostFX::decay = %this.value;
|
||||
%this.ToolTip = "Value : " @ %this.value;
|
||||
}
|
||||
|
||||
|
||||
function ppOptionsUpdateDOFSettings()
|
||||
{
|
||||
DOFPostEffect.setFocusParams( $DOFPostFx::BlurMin, $DOFPostFx::BlurMax, $DOFPostFx::FocusRangeMin, $DOFPostFx::FocusRangeMax, -($DOFPostFx::BlurCurveNear), $DOFPostFx::BlurCurveFar );
|
||||
|
||||
DOFPostEffect.setAutoFocus( $DOFPostFx::EnableAutoFocus );
|
||||
DOFPostEffect.setFocalDist(0);
|
||||
|
||||
if($PostFXManager::PostFX::EnableDOF)
|
||||
{
|
||||
DOFPostEffect.enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
DOFPostEffect.disable();
|
||||
}
|
||||
}
|
||||
|
||||
//DOF General Tab
|
||||
//DOF Toggles
|
||||
function ppOptionsDOFEnableDOF::onAction(%this)
|
||||
{
|
||||
$PostFXManager::PostFX::EnableDOF = %this.getValue();
|
||||
ppOptionsUpdateDOFSettings();
|
||||
}
|
||||
|
||||
|
||||
function ppOptionsDOFEnableAutoFocus::onAction(%this)
|
||||
{
|
||||
$DOFPostFx::EnableAutoFocus = %this.getValue();
|
||||
DOFPostEffect.setAutoFocus( %this.getValue() );
|
||||
}
|
||||
|
||||
//DOF AutoFocus Slider controls
|
||||
function ppOptionsDOFFarBlurMinSlider::onMouseDragged(%this)
|
||||
{
|
||||
$DOFPostFx::BlurMin = %this.value;
|
||||
ppOptionsUpdateDOFSettings();
|
||||
}
|
||||
|
||||
function ppOptionsDOFFarBlurMaxSlider::onMouseDragged(%this)
|
||||
{
|
||||
$DOFPostFx::BlurMax = %this.value;
|
||||
ppOptionsUpdateDOFSettings();
|
||||
}
|
||||
|
||||
function ppOptionsDOFFocusRangeMinSlider::onMouseDragged(%this)
|
||||
{
|
||||
$DOFPostFx::FocusRangeMin = %this.value;
|
||||
ppOptionsUpdateDOFSettings();
|
||||
}
|
||||
|
||||
function ppOptionsDOFFocusRangeMaxSlider::onMouseDragged(%this)
|
||||
{
|
||||
$DOFPostFx::FocusRangeMax = %this.value;
|
||||
ppOptionsUpdateDOFSettings();
|
||||
}
|
||||
|
||||
function ppOptionsDOFBlurCurveNearSlider::onMouseDragged(%this)
|
||||
{
|
||||
$DOFPostFx::BlurCurveNear = %this.value;
|
||||
ppOptionsUpdateDOFSettings();
|
||||
}
|
||||
|
||||
function ppOptionsDOFBlurCurveFarSlider::onMouseDragged(%this)
|
||||
{
|
||||
$DOFPostFx::BlurCurveFar = %this.value;
|
||||
ppOptionsUpdateDOFSettings();
|
||||
}
|
||||
|
||||
function ppOptionsEnableHDRDebug::onAction(%this)
|
||||
{
|
||||
if ( %this.getValue() )
|
||||
LuminanceVisPostFX.enable();
|
||||
else
|
||||
LuminanceVisPostFX.disable();
|
||||
}
|
||||
|
||||
function ppOptionsUpdateVignetteSettings()
|
||||
{
|
||||
if($PostFXManager::PostFX::EnableVignette)
|
||||
{
|
||||
VignettePostEffect.enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
VignettePostEffect.disable();
|
||||
}
|
||||
}
|
||||
|
||||
function ppOptionsVignetteEnableVignette::onAction(%this)
|
||||
{
|
||||
$PostFXManager::PostFX::EnableVignette = %this.getValue();
|
||||
ppOptionsUpdateVignetteSettings();
|
||||
}
|
||||
|
||||
function ppColorCorrection_selectFile()
|
||||
{
|
||||
%filter = "Image Files (*.png, *.jpg, *.dds, *.bmp, *.gif, *.jng. *.tga)|*.png;*.jpg;*.dds;*.bmp;*.gif;*.jng;*.tga|All Files (*.*)|*.*|";
|
||||
getLoadFilename( %filter, "ppColorCorrection_selectFileHandler");
|
||||
}
|
||||
|
||||
function ppColorCorrection_selectFileHandler( %filename )
|
||||
{
|
||||
if ( %filename $= "" || !isFile( %filename ) )
|
||||
%filename = "core/images/null_color_ramp.png";
|
||||
else
|
||||
%filename = makeRelativePath( %filename, getMainDotCsDir() );
|
||||
|
||||
$HDRPostFX::colorCorrectionRamp = %filename;
|
||||
PostFXManager-->ColorCorrectionFileName.Text = %filename;
|
||||
}
|
||||
|
|
@ -0,0 +1,439 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$PostFXManager::defaultPreset = "core/postFX/default.postfxpreset.cs";
|
||||
|
||||
function PostFXManager::settingsSetEnabled(%this, %bEnablePostFX)
|
||||
{
|
||||
$PostFXManager::PostFX::Enabled = %bEnablePostFX;
|
||||
|
||||
//if to enable the postFX, apply the ones that are enabled
|
||||
if ( %bEnablePostFX )
|
||||
{
|
||||
//SSAO, HDR, LightRays, DOF
|
||||
|
||||
if ( $PostFXManager::PostFX::EnableSSAO )
|
||||
SSAOPostFx.enable();
|
||||
else
|
||||
SSAOPostFx.disable();
|
||||
|
||||
if ( $PostFXManager::PostFX::EnableHDR )
|
||||
HDRPostFX.enable();
|
||||
else
|
||||
HDRPostFX.disable();
|
||||
|
||||
if ( $PostFXManager::PostFX::EnableLightRays )
|
||||
LightRayPostFX.enable();
|
||||
else
|
||||
LightRayPostFX.disable();
|
||||
|
||||
if ( $PostFXManager::PostFX::EnableDOF )
|
||||
DOFPostEffect.enable();
|
||||
else
|
||||
DOFPostEffect.disable();
|
||||
|
||||
if ( $PostFXManager::PostFX::EnableVignette )
|
||||
VignettePostEffect.enable();
|
||||
else
|
||||
VignettePostEffect.disable();
|
||||
|
||||
postVerbose("% - PostFX Manager - PostFX enabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Disable all postFX
|
||||
|
||||
SSAOPostFx.disable();
|
||||
HDRPostFX.disable();
|
||||
LightRayPostFX.disable();
|
||||
DOFPostEffect.disable();
|
||||
VignettePostEffect.disable();
|
||||
|
||||
postVerbose("% - PostFX Manager - PostFX disabled");
|
||||
}
|
||||
|
||||
VolFogGlowPostFx.disable();
|
||||
}
|
||||
|
||||
function PostFXManager::settingsEffectSetEnabled(%this, %sName, %bEnable)
|
||||
{
|
||||
%postEffect = 0;
|
||||
|
||||
//Determine the postFX to enable, and apply the boolean
|
||||
if(%sName $= "SSAO")
|
||||
{
|
||||
%postEffect = SSAOPostFx;
|
||||
$PostFXManager::PostFX::EnableSSAO = %bEnable;
|
||||
//$pref::PostFX::SSAO::Enabled = %bEnable;
|
||||
}
|
||||
else if(%sName $= "HDR")
|
||||
{
|
||||
%postEffect = HDRPostFX;
|
||||
$PostFXManager::PostFX::EnableHDR = %bEnable;
|
||||
//$pref::PostFX::HDR::Enabled = %bEnable;
|
||||
}
|
||||
else if(%sName $= "LightRays")
|
||||
{
|
||||
%postEffect = LightRayPostFX;
|
||||
$PostFXManager::PostFX::EnableLightRays = %bEnable;
|
||||
//$pref::PostFX::LightRays::Enabled = %bEnable;
|
||||
}
|
||||
else if(%sName $= "DOF")
|
||||
{
|
||||
%postEffect = DOFPostEffect;
|
||||
$PostFXManager::PostFX::EnableDOF = %bEnable;
|
||||
//$pref::PostFX::DOF::Enabled = %bEnable;
|
||||
}
|
||||
else if(%sName $= "Vignette")
|
||||
{
|
||||
%postEffect = VignettePostEffect;
|
||||
$PostFXManager::PostFX::EnableVignette = %bEnable;
|
||||
//$pref::PostFX::Vignette::Enabled = %bEnable;
|
||||
}
|
||||
|
||||
// Apply the change
|
||||
if ( %bEnable == true )
|
||||
{
|
||||
%postEffect.enable();
|
||||
postVerbose("% - PostFX Manager - " @ %sName @ " enabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
%postEffect.disable();
|
||||
postVerbose("% - PostFX Manager - " @ %sName @ " disabled");
|
||||
}
|
||||
}
|
||||
|
||||
function PostFXManager::settingsRefreshSSAO(%this)
|
||||
{
|
||||
//Apply the enabled flag
|
||||
ppOptionsEnableSSAO.setValue($PostFXManager::PostFX::EnableSSAO);
|
||||
|
||||
//Add the items we need to display
|
||||
ppOptionsSSAOQuality.clear();
|
||||
ppOptionsSSAOQuality.add("Low", 0);
|
||||
ppOptionsSSAOQuality.add("Medium", 1);
|
||||
ppOptionsSSAOQuality.add("High", 2);
|
||||
|
||||
//Set the selected, after adding the items!
|
||||
ppOptionsSSAOQuality.setSelected($SSAOPostFx::quality);
|
||||
|
||||
//SSAO - Set the values of the sliders, General Tab
|
||||
ppOptionsSSAOOverallStrength.setValue($SSAOPostFx::overallStrength);
|
||||
ppOptionsSSAOBlurDepth.setValue($SSAOPostFx::blurDepthTol);
|
||||
ppOptionsSSAOBlurNormal.setValue($SSAOPostFx::blurNormalTol);
|
||||
|
||||
//SSAO - Set the values for the near tab
|
||||
ppOptionsSSAONearDepthMax.setValue($SSAOPostFx::sDepthMax);
|
||||
ppOptionsSSAONearDepthMin.setValue($SSAOPostFx::sDepthMin);
|
||||
ppOptionsSSAONearRadius.setValue($SSAOPostFx::sRadius);
|
||||
ppOptionsSSAONearStrength.setValue($SSAOPostFx::sStrength);
|
||||
ppOptionsSSAONearToleranceNormal.setValue($SSAOPostFx::sNormalTol);
|
||||
ppOptionsSSAONearTolerancePower.setValue($SSAOPostFx::sNormalPow);
|
||||
|
||||
//SSAO - Set the values for the far tab
|
||||
ppOptionsSSAOFarDepthMax.setValue($SSAOPostFx::lDepthMax);
|
||||
ppOptionsSSAOFarDepthMin.setValue($SSAOPostFx::lDepthMin);
|
||||
ppOptionsSSAOFarRadius.setValue($SSAOPostFx::lRadius);
|
||||
ppOptionsSSAOFarStrength.setValue($SSAOPostFx::lStrength);
|
||||
ppOptionsSSAOFarToleranceNormal.setValue($SSAOPostFx::lNormalTol);
|
||||
ppOptionsSSAOFarTolerancePower.setValue($SSAOPostFx::lNormalPow);
|
||||
}
|
||||
|
||||
function PostFXManager::settingsRefreshHDR(%this)
|
||||
{
|
||||
//Apply the enabled flag
|
||||
ppOptionsEnableHDR.setValue($PostFXManager::PostFX::EnableHDR);
|
||||
|
||||
ppOptionsHDRBloom.setValue($HDRPostFX::enableBloom);
|
||||
ppOptionsHDRBloomBlurBrightPassThreshold.setValue($HDRPostFX::brightPassThreshold);
|
||||
ppOptionsHDRBloomBlurMean.setValue($HDRPostFX::gaussMean);
|
||||
ppOptionsHDRBloomBlurMultiplier.setValue($HDRPostFX::gaussMultiplier);
|
||||
ppOptionsHDRBloomBlurStdDev.setValue($HDRPostFX::gaussStdDev);
|
||||
ppOptionsHDRBrightnessAdaptRate.setValue($HDRPostFX::adaptRate);
|
||||
ppOptionsHDREffectsBlueShift.setValue($HDRPostFX::enableBlueShift);
|
||||
ppOptionsHDREffectsBlueShiftColor.BaseColor = $HDRPostFX::blueShiftColor;
|
||||
ppOptionsHDREffectsBlueShiftColor.PickColor = $HDRPostFX::blueShiftColor;
|
||||
ppOptionsHDRKeyValue.setValue($HDRPostFX::keyValue);
|
||||
ppOptionsHDRMinLuminance.setValue($HDRPostFX::minLuminace);
|
||||
ppOptionsHDRToneMapping.setValue($HDRPostFX::enableToneMapping);
|
||||
ppOptionsHDRToneMappingAmount.setValue($HDRPostFX::enableToneMapping);
|
||||
ppOptionsHDRWhiteCutoff.setValue($HDRPostFX::whiteCutoff);
|
||||
|
||||
%this-->ColorCorrectionFileName.Text = $HDRPostFX::colorCorrectionRamp;
|
||||
}
|
||||
|
||||
function PostFXManager::settingsRefreshLightrays(%this)
|
||||
{
|
||||
//Apply the enabled flag
|
||||
ppOptionsEnableLightRays.setValue($PostFXManager::PostFX::EnableLightRays);
|
||||
|
||||
ppOptionsLightRaysBrightScalar.setValue($LightRayPostFX::brightScalar);
|
||||
|
||||
ppOptionsLightRaysSampleScalar.setValue($LightRayPostFX::numSamples);
|
||||
ppOptionsLightRaysDensityScalar.setValue($LightRayPostFX::density);
|
||||
ppOptionsLightRaysWeightScalar.setValue($LightRayPostFX::weight);
|
||||
ppOptionsLightRaysDecayScalar.setValue($LightRayPostFX::decay);
|
||||
}
|
||||
|
||||
function PostFXManager::settingsRefreshDOF(%this)
|
||||
{
|
||||
//Apply the enabled flag
|
||||
ppOptionsEnableDOF.setValue($PostFXManager::PostFX::EnableDOF);
|
||||
|
||||
|
||||
//ppOptionsDOFEnableDOF.setValue($PostFXManager::PostFX::EnableDOF);
|
||||
ppOptionsDOFEnableAutoFocus.setValue($DOFPostFx::EnableAutoFocus);
|
||||
|
||||
ppOptionsDOFFarBlurMinSlider.setValue($DOFPostFx::BlurMin);
|
||||
ppOptionsDOFFarBlurMaxSlider.setValue($DOFPostFx::BlurMax);
|
||||
|
||||
ppOptionsDOFFocusRangeMinSlider.setValue($DOFPostFx::FocusRangeMin);
|
||||
ppOptionsDOFFocusRangeMaxSlider.setValue($DOFPostFx::FocusRangeMax);
|
||||
|
||||
ppOptionsDOFBlurCurveNearSlider.setValue($DOFPostFx::BlurCurveNear);
|
||||
ppOptionsDOFBlurCurveFarSlider.setValue($DOFPostFx::BlurCurveFar);
|
||||
|
||||
}
|
||||
|
||||
function PostFXManager::settingsRefreshVignette(%this)
|
||||
{
|
||||
//Apply the enabled flag
|
||||
ppOptionsEnableVignette.setValue($PostFXManager::PostFX::EnableVignette);
|
||||
|
||||
}
|
||||
|
||||
function PostFXManager::settingsRefreshAll(%this)
|
||||
{
|
||||
$PostFXManager::PostFX::Enabled = $pref::enablePostEffects;
|
||||
$PostFXManager::PostFX::EnableSSAO = SSAOPostFx.isEnabled();
|
||||
$PostFXManager::PostFX::EnableHDR = HDRPostFX.isEnabled();
|
||||
$PostFXManager::PostFX::EnableLightRays = LightRayPostFX.isEnabled();
|
||||
$PostFXManager::PostFX::EnableDOF = DOFPostEffect.isEnabled();
|
||||
$PostFXManager::PostFX::EnableVignette = VignettePostEffect.isEnabled();
|
||||
|
||||
//For all the postFX here, apply the active settings in the system
|
||||
//to the gui controls.
|
||||
|
||||
%this.settingsRefreshSSAO();
|
||||
%this.settingsRefreshHDR();
|
||||
%this.settingsRefreshLightrays();
|
||||
%this.settingsRefreshDOF();
|
||||
%this.settingsRefreshVignette();
|
||||
|
||||
ppOptionsEnable.setValue($PostFXManager::PostFX::Enabled);
|
||||
|
||||
postVerbose("% - PostFX Manager - GUI values updated.");
|
||||
}
|
||||
|
||||
function PostFXManager::settingsApplyFromPreset(%this)
|
||||
{
|
||||
postVerbose("% - PostFX Manager - Applying from preset");
|
||||
|
||||
//SSAO Settings
|
||||
$SSAOPostFx::blurDepthTol = $PostFXManager::Settings::SSAO::blurDepthTol;
|
||||
$SSAOPostFx::blurNormalTol = $PostFXManager::Settings::SSAO::blurNormalTol;
|
||||
$SSAOPostFx::lDepthMax = $PostFXManager::Settings::SSAO::lDepthMax;
|
||||
$SSAOPostFx::lDepthMin = $PostFXManager::Settings::SSAO::lDepthMin;
|
||||
$SSAOPostFx::lDepthPow = $PostFXManager::Settings::SSAO::lDepthPow;
|
||||
$SSAOPostFx::lNormalPow = $PostFXManager::Settings::SSAO::lNormalPow;
|
||||
$SSAOPostFx::lNormalTol = $PostFXManager::Settings::SSAO::lNormalTol;
|
||||
$SSAOPostFx::lRadius = $PostFXManager::Settings::SSAO::lRadius;
|
||||
$SSAOPostFx::lStrength = $PostFXManager::Settings::SSAO::lStrength;
|
||||
$SSAOPostFx::overallStrength = $PostFXManager::Settings::SSAO::overallStrength;
|
||||
$SSAOPostFx::quality = $PostFXManager::Settings::SSAO::quality;
|
||||
$SSAOPostFx::sDepthMax = $PostFXManager::Settings::SSAO::sDepthMax;
|
||||
$SSAOPostFx::sDepthMin = $PostFXManager::Settings::SSAO::sDepthMin;
|
||||
$SSAOPostFx::sDepthPow = $PostFXManager::Settings::SSAO::sDepthPow;
|
||||
$SSAOPostFx::sNormalPow = $PostFXManager::Settings::SSAO::sNormalPow;
|
||||
$SSAOPostFx::sNormalTol = $PostFXManager::Settings::SSAO::sNormalTol;
|
||||
$SSAOPostFx::sRadius = $PostFXManager::Settings::SSAO::sRadius;
|
||||
$SSAOPostFx::sStrength = $PostFXManager::Settings::SSAO::sStrength;
|
||||
|
||||
//HDR settings
|
||||
$HDRPostFX::adaptRate = $PostFXManager::Settings::HDR::adaptRate;
|
||||
$HDRPostFX::blueShiftColor = $PostFXManager::Settings::HDR::blueShiftColor;
|
||||
$HDRPostFX::brightPassThreshold = $PostFXManager::Settings::HDR::brightPassThreshold;
|
||||
$HDRPostFX::enableBloom = $PostFXManager::Settings::HDR::enableBloom;
|
||||
$HDRPostFX::enableBlueShift = $PostFXManager::Settings::HDR::enableBlueShift;
|
||||
$HDRPostFX::enableToneMapping = $PostFXManager::Settings::HDR::enableToneMapping;
|
||||
$HDRPostFX::gaussMean = $PostFXManager::Settings::HDR::gaussMean;
|
||||
$HDRPostFX::gaussMultiplier = $PostFXManager::Settings::HDR::gaussMultiplier;
|
||||
$HDRPostFX::gaussStdDev = $PostFXManager::Settings::HDR::gaussStdDev;
|
||||
$HDRPostFX::keyValue = $PostFXManager::Settings::HDR::keyValue;
|
||||
$HDRPostFX::minLuminace = $PostFXManager::Settings::HDR::minLuminace;
|
||||
$HDRPostFX::whiteCutoff = $PostFXManager::Settings::HDR::whiteCutoff;
|
||||
$HDRPostFX::colorCorrectionRamp = $PostFXManager::Settings::ColorCorrectionRamp;
|
||||
|
||||
//Light rays settings
|
||||
$LightRayPostFX::brightScalar = $PostFXManager::Settings::LightRays::brightScalar;
|
||||
|
||||
$LightRayPostFX::numSamples = $PostFXManager::Settings::LightRays::numSamples;
|
||||
$LightRayPostFX::density = $PostFXManager::Settings::LightRays::density;
|
||||
$LightRayPostFX::weight = $PostFXManager::Settings::LightRays::weight;
|
||||
$LightRayPostFX::decay = $PostFXManager::Settings::LightRays::decay;
|
||||
|
||||
//DOF settings
|
||||
$DOFPostFx::EnableAutoFocus = $PostFXManager::Settings::DOF::EnableAutoFocus;
|
||||
$DOFPostFx::BlurMin = $PostFXManager::Settings::DOF::BlurMin;
|
||||
$DOFPostFx::BlurMax = $PostFXManager::Settings::DOF::BlurMax;
|
||||
$DOFPostFx::FocusRangeMin = $PostFXManager::Settings::DOF::FocusRangeMin;
|
||||
$DOFPostFx::FocusRangeMax = $PostFXManager::Settings::DOF::FocusRangeMax;
|
||||
$DOFPostFx::BlurCurveNear = $PostFXManager::Settings::DOF::BlurCurveNear;
|
||||
$DOFPostFx::BlurCurveFar = $PostFXManager::Settings::DOF::BlurCurveFar;
|
||||
|
||||
//Vignette settings
|
||||
$VignettePostEffect::VMax = $PostFXManager::Settings::Vignette::VMax;
|
||||
$VignettePostEffect::VMin = $PostFXManager::Settings::Vignette::VMin;
|
||||
|
||||
if ( $PostFXManager::forceEnableFromPresets )
|
||||
{
|
||||
$PostFXManager::PostFX::Enabled = $PostFXManager::Settings::EnablePostFX;
|
||||
$PostFXManager::PostFX::EnableDOF = $pref::PostFX::EnableDOF ? $PostFXManager::Settings::EnableDOF : false;
|
||||
$PostFXManager::PostFX::EnableVignette = $pref::PostFX::EnableVignette ? $PostFXManager::Settings::EnableVignette : false;
|
||||
$PostFXManager::PostFX::EnableLightRays = $pref::PostFX::EnableLightRays ? $PostFXManager::Settings::EnableLightRays : false;
|
||||
$PostFXManager::PostFX::EnableHDR = $pref::PostFX::EnableHDR ? $PostFXManager::Settings::EnableHDR : false;
|
||||
$PostFXManager::PostFX::EnableSSAO = $pref::PostFX::EnabledSSAO ? $PostFXManager::Settings::EnableSSAO : false;
|
||||
|
||||
%this.settingsSetEnabled( true );
|
||||
}
|
||||
|
||||
//make sure we apply the correct settings to the DOF
|
||||
ppOptionsUpdateDOFSettings();
|
||||
|
||||
// Update the actual GUI controls if its awake ( otherwise it will when opened ).
|
||||
if ( PostFXManager.isAwake() )
|
||||
%this.settingsRefreshAll();
|
||||
}
|
||||
|
||||
function PostFXManager::settingsApplySSAO(%this)
|
||||
{
|
||||
$PostFXManager::Settings::SSAO::blurDepthTol = $SSAOPostFx::blurDepthTol;
|
||||
$PostFXManager::Settings::SSAO::blurNormalTol = $SSAOPostFx::blurNormalTol;
|
||||
$PostFXManager::Settings::SSAO::lDepthMax = $SSAOPostFx::lDepthMax;
|
||||
$PostFXManager::Settings::SSAO::lDepthMin = $SSAOPostFx::lDepthMin;
|
||||
$PostFXManager::Settings::SSAO::lDepthPow = $SSAOPostFx::lDepthPow;
|
||||
$PostFXManager::Settings::SSAO::lNormalPow = $SSAOPostFx::lNormalPow;
|
||||
$PostFXManager::Settings::SSAO::lNormalTol = $SSAOPostFx::lNormalTol;
|
||||
$PostFXManager::Settings::SSAO::lRadius = $SSAOPostFx::lRadius;
|
||||
$PostFXManager::Settings::SSAO::lStrength = $SSAOPostFx::lStrength;
|
||||
$PostFXManager::Settings::SSAO::overallStrength = $SSAOPostFx::overallStrength;
|
||||
$PostFXManager::Settings::SSAO::quality = $SSAOPostFx::quality;
|
||||
$PostFXManager::Settings::SSAO::sDepthMax = $SSAOPostFx::sDepthMax;
|
||||
$PostFXManager::Settings::SSAO::sDepthMin = $SSAOPostFx::sDepthMin;
|
||||
$PostFXManager::Settings::SSAO::sDepthPow = $SSAOPostFx::sDepthPow;
|
||||
$PostFXManager::Settings::SSAO::sNormalPow = $SSAOPostFx::sNormalPow;
|
||||
$PostFXManager::Settings::SSAO::sNormalTol = $SSAOPostFx::sNormalTol;
|
||||
$PostFXManager::Settings::SSAO::sRadius = $SSAOPostFx::sRadius;
|
||||
$PostFXManager::Settings::SSAO::sStrength = $SSAOPostFx::sStrength;
|
||||
|
||||
postVerbose("% - PostFX Manager - Settings Saved - SSAO");
|
||||
|
||||
}
|
||||
|
||||
function PostFXManager::settingsApplyHDR(%this)
|
||||
{
|
||||
$PostFXManager::Settings::HDR::adaptRate = $HDRPostFX::adaptRate;
|
||||
$PostFXManager::Settings::HDR::blueShiftColor = $HDRPostFX::blueShiftColor;
|
||||
$PostFXManager::Settings::HDR::brightPassThreshold = $HDRPostFX::brightPassThreshold;
|
||||
$PostFXManager::Settings::HDR::enableBloom = $HDRPostFX::enableBloom;
|
||||
$PostFXManager::Settings::HDR::enableBlueShift = $HDRPostFX::enableBlueShift;
|
||||
$PostFXManager::Settings::HDR::enableToneMapping = $HDRPostFX::enableToneMapping;
|
||||
$PostFXManager::Settings::HDR::gaussMean = $HDRPostFX::gaussMean;
|
||||
$PostFXManager::Settings::HDR::gaussMultiplier = $HDRPostFX::gaussMultiplier;
|
||||
$PostFXManager::Settings::HDR::gaussStdDev = $HDRPostFX::gaussStdDev;
|
||||
$PostFXManager::Settings::HDR::keyValue = $HDRPostFX::keyValue;
|
||||
$PostFXManager::Settings::HDR::minLuminace = $HDRPostFX::minLuminace;
|
||||
$PostFXManager::Settings::HDR::whiteCutoff = $HDRPostFX::whiteCutoff;
|
||||
$PostFXManager::Settings::ColorCorrectionRamp = $HDRPostFX::colorCorrectionRamp;
|
||||
|
||||
postVerbose("% - PostFX Manager - Settings Saved - HDR");
|
||||
}
|
||||
|
||||
function PostFXManager::settingsApplyLightRays(%this)
|
||||
{
|
||||
$PostFXManager::Settings::LightRays::brightScalar = $LightRayPostFX::brightScalar;
|
||||
|
||||
$PostFXManager::Settings::LightRays::numSamples = $LightRayPostFX::numSamples;
|
||||
$PostFXManager::Settings::LightRays::density = $LightRayPostFX::density;
|
||||
$PostFXManager::Settings::LightRays::weight = $LightRayPostFX::weight;
|
||||
$PostFXManager::Settings::LightRays::decay = $LightRayPostFX::decay;
|
||||
|
||||
postVerbose("% - PostFX Manager - Settings Saved - Light Rays");
|
||||
|
||||
}
|
||||
|
||||
function PostFXManager::settingsApplyDOF(%this)
|
||||
{
|
||||
$PostFXManager::Settings::DOF::EnableAutoFocus = $DOFPostFx::EnableAutoFocus;
|
||||
$PostFXManager::Settings::DOF::BlurMin = $DOFPostFx::BlurMin;
|
||||
$PostFXManager::Settings::DOF::BlurMax = $DOFPostFx::BlurMax;
|
||||
$PostFXManager::Settings::DOF::FocusRangeMin = $DOFPostFx::FocusRangeMin;
|
||||
$PostFXManager::Settings::DOF::FocusRangeMax = $DOFPostFx::FocusRangeMax;
|
||||
$PostFXManager::Settings::DOF::BlurCurveNear = $DOFPostFx::BlurCurveNear;
|
||||
$PostFXManager::Settings::DOF::BlurCurveFar = $DOFPostFx::BlurCurveFar;
|
||||
|
||||
postVerbose("% - PostFX Manager - Settings Saved - DOF");
|
||||
|
||||
}
|
||||
|
||||
function PostFXManager::settingsApplyVignette(%this)
|
||||
{
|
||||
$PostFXManager::Settings::Vignette::VMax = $VignettePostEffect::VMax;
|
||||
$PostFXManager::Settings::Vignette::VMin = $VignettePostEffect::VMin;
|
||||
|
||||
postVerbose("% - PostFX Manager - Settings Saved - Vignette");
|
||||
|
||||
}
|
||||
|
||||
function PostFXManager::settingsApplyAll(%this, %sFrom)
|
||||
{
|
||||
// Apply settings which control if effects are on/off altogether.
|
||||
$PostFXManager::Settings::EnablePostFX = $PostFXManager::PostFX::Enabled;
|
||||
$PostFXManager::Settings::EnableDOF = $PostFXManager::PostFX::EnableDOF;
|
||||
$PostFXManager::Settings::EnableVignette = $PostFXManager::PostFX::EnableVignette;
|
||||
$PostFXManager::Settings::EnableLightRays = $PostFXManager::PostFX::EnableLightRays;
|
||||
$PostFXManager::Settings::EnableHDR = $PostFXManager::PostFX::EnableHDR;
|
||||
$PostFXManager::Settings::EnableSSAO = $PostFXManager::PostFX::EnableSSAO;
|
||||
|
||||
// Apply settings should save the values in the system to the
|
||||
// the preset structure ($PostFXManager::Settings::*)
|
||||
|
||||
// SSAO Settings
|
||||
%this.settingsApplySSAO();
|
||||
// HDR settings
|
||||
%this.settingsApplyHDR();
|
||||
// Light rays settings
|
||||
%this.settingsApplyLightRays();
|
||||
// DOF
|
||||
%this.settingsApplyDOF();
|
||||
// Vignette
|
||||
%this.settingsApplyVignette();
|
||||
|
||||
postVerbose("% - PostFX Manager - All Settings applied to $PostFXManager::Settings");
|
||||
}
|
||||
|
||||
function PostFXManager::settingsApplyDefaultPreset(%this)
|
||||
{
|
||||
PostFXManager::loadPresetHandler($PostFXManager::defaultPreset);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Used to name the saved files.
|
||||
$PostFXManager::fileExtension = ".postfxpreset.cs";
|
||||
|
||||
// The filter string for file open/save dialogs.
|
||||
$PostFXManager::fileFilter = "Post Effect Presets|*.postfxpreset.cs";
|
||||
|
||||
// Enable / disable PostFX when loading presets or just apply the settings?
|
||||
$PostFXManager::forceEnableFromPresets = true;
|
||||
|
||||
//Load a preset file from the disk, and apply the settings to the
|
||||
//controls. If bApplySettings is true - the actual values in the engine
|
||||
//will be changed to reflect the settings from the file.
|
||||
function PostFXManager::loadPresetFile()
|
||||
{
|
||||
//Show the dialog and set the flag
|
||||
getLoadFilename($PostFXManager::fileFilter, "PostFXManager::loadPresetHandler");
|
||||
}
|
||||
|
||||
function PostFXManager::loadPresetHandler( %filename )
|
||||
{
|
||||
//Check the validity of the file
|
||||
if ( isScriptFile( %filename ) )
|
||||
{
|
||||
%filename = expandFilename(%filename);
|
||||
postVerbose("% - PostFX Manager - Executing " @ %filename);
|
||||
exec(%filename);
|
||||
|
||||
PostFXManager.settingsApplyFromPreset();
|
||||
}
|
||||
}
|
||||
|
||||
//Save a preset file to the specified file. The extension used
|
||||
//is specified by $PostFXManager::fileExtension for on the fly
|
||||
//name changes to the extension used.
|
||||
|
||||
function PostFXManager::savePresetFile(%this)
|
||||
{
|
||||
%defaultFile = filePath($Client::MissionFile) @ "/" @ fileBase($Client::MissionFile);
|
||||
getSaveFilename($PostFXManager::fileFilter, "PostFXManager::savePresetHandler", %defaultFile);
|
||||
}
|
||||
|
||||
//Called from the PostFXManager::savePresetFile() function
|
||||
function PostFXManager::savePresetHandler( %filename )
|
||||
{
|
||||
%filename = makeRelativePath( %filename, getMainDotCsDir() );
|
||||
if(strStr(%filename, ".") == -1)
|
||||
%filename = %filename @ $PostFXManager::fileExtension;
|
||||
|
||||
//Apply the current settings to the preset
|
||||
PostFXManager.settingsApplyAll();
|
||||
|
||||
export("$PostFXManager::Settings::*", %filename, false);
|
||||
|
||||
postVerbose("% - PostFX Manager - Save complete. Preset saved at : " @ %filename);
|
||||
}
|
||||
|
||||
302
Templates/BaseGame/game/core/postFX/ssao.cs
Normal file
302
Templates/BaseGame/game/core/postFX/ssao.cs
Normal file
|
|
@ -0,0 +1,302 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
///
|
||||
$SSAOPostFx::overallStrength = 2.0;
|
||||
|
||||
// TODO: Add small/large param docs.
|
||||
|
||||
// The small radius SSAO settings.
|
||||
$SSAOPostFx::sRadius = 0.1;
|
||||
$SSAOPostFx::sStrength = 6.0;
|
||||
$SSAOPostFx::sDepthMin = 0.1;
|
||||
$SSAOPostFx::sDepthMax = 1.0;
|
||||
$SSAOPostFx::sDepthPow = 1.0;
|
||||
$SSAOPostFx::sNormalTol = 0.0;
|
||||
$SSAOPostFx::sNormalPow = 1.0;
|
||||
|
||||
// The large radius SSAO settings.
|
||||
$SSAOPostFx::lRadius = 1.0;
|
||||
$SSAOPostFx::lStrength = 10.0;
|
||||
$SSAOPostFx::lDepthMin = 0.2;
|
||||
$SSAOPostFx::lDepthMax = 2.0;
|
||||
$SSAOPostFx::lDepthPow = 0.2;
|
||||
$SSAOPostFx::lNormalTol = -0.5;
|
||||
$SSAOPostFx::lNormalPow = 2.0;
|
||||
|
||||
/// Valid values: 0, 1, 2
|
||||
$SSAOPostFx::quality = 0;
|
||||
|
||||
///
|
||||
$SSAOPostFx::blurDepthTol = 0.001;
|
||||
|
||||
///
|
||||
$SSAOPostFx::blurNormalTol = 0.95;
|
||||
|
||||
///
|
||||
$SSAOPostFx::targetScale = "0.5 0.5";
|
||||
|
||||
|
||||
function SSAOPostFx::onAdd( %this )
|
||||
{
|
||||
%this.wasVis = "Uninitialized";
|
||||
%this.quality = "Uninitialized";
|
||||
}
|
||||
|
||||
function SSAOPostFx::preProcess( %this )
|
||||
{
|
||||
if ( $SSAOPostFx::quality !$= %this.quality )
|
||||
{
|
||||
%this.quality = mClamp( mRound( $SSAOPostFx::quality ), 0, 2 );
|
||||
|
||||
%this.setShaderMacro( "QUALITY", %this.quality );
|
||||
}
|
||||
|
||||
%this.targetScale = $SSAOPostFx::targetScale;
|
||||
}
|
||||
|
||||
function SSAOPostFx::setShaderConsts( %this )
|
||||
{
|
||||
%this.setShaderConst( "$overallStrength", $SSAOPostFx::overallStrength );
|
||||
|
||||
// Abbreviate is s-small l-large.
|
||||
|
||||
%this.setShaderConst( "$sRadius", $SSAOPostFx::sRadius );
|
||||
%this.setShaderConst( "$sStrength", $SSAOPostFx::sStrength );
|
||||
%this.setShaderConst( "$sDepthMin", $SSAOPostFx::sDepthMin );
|
||||
%this.setShaderConst( "$sDepthMax", $SSAOPostFx::sDepthMax );
|
||||
%this.setShaderConst( "$sDepthPow", $SSAOPostFx::sDepthPow );
|
||||
%this.setShaderConst( "$sNormalTol", $SSAOPostFx::sNormalTol );
|
||||
%this.setShaderConst( "$sNormalPow", $SSAOPostFx::sNormalPow );
|
||||
|
||||
%this.setShaderConst( "$lRadius", $SSAOPostFx::lRadius );
|
||||
%this.setShaderConst( "$lStrength", $SSAOPostFx::lStrength );
|
||||
%this.setShaderConst( "$lDepthMin", $SSAOPostFx::lDepthMin );
|
||||
%this.setShaderConst( "$lDepthMax", $SSAOPostFx::lDepthMax );
|
||||
%this.setShaderConst( "$lDepthPow", $SSAOPostFx::lDepthPow );
|
||||
%this.setShaderConst( "$lNormalTol", $SSAOPostFx::lNormalTol );
|
||||
%this.setShaderConst( "$lNormalPow", $SSAOPostFx::lNormalPow );
|
||||
|
||||
%blur = %this->blurY;
|
||||
%blur.setShaderConst( "$blurDepthTol", $SSAOPostFx::blurDepthTol );
|
||||
%blur.setShaderConst( "$blurNormalTol", $SSAOPostFx::blurNormalTol );
|
||||
|
||||
%blur = %this->blurX;
|
||||
%blur.setShaderConst( "$blurDepthTol", $SSAOPostFx::blurDepthTol );
|
||||
%blur.setShaderConst( "$blurNormalTol", $SSAOPostFx::blurNormalTol );
|
||||
|
||||
%blur = %this->blurY2;
|
||||
%blur.setShaderConst( "$blurDepthTol", $SSAOPostFx::blurDepthTol );
|
||||
%blur.setShaderConst( "$blurNormalTol", $SSAOPostFx::blurNormalTol );
|
||||
|
||||
%blur = %this->blurX2;
|
||||
%blur.setShaderConst( "$blurDepthTol", $SSAOPostFx::blurDepthTol );
|
||||
%blur.setShaderConst( "$blurNormalTol", $SSAOPostFx::blurNormalTol );
|
||||
}
|
||||
|
||||
function SSAOPostFx::onEnabled( %this )
|
||||
{
|
||||
// This tells the AL shaders to reload and sample
|
||||
// from our #ssaoMask texture target.
|
||||
$AL::UseSSAOMask = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function SSAOPostFx::onDisabled( %this )
|
||||
{
|
||||
$AL::UseSSAOMask = false;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// GFXStateBlockData / ShaderData
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton GFXStateBlockData( SSAOStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint;
|
||||
samplerStates[1] = SamplerWrapLinear;
|
||||
samplerStates[2] = SamplerClampPoint;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( SSAOBlurStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
samplerStates[1] = SamplerClampPoint;
|
||||
};
|
||||
|
||||
singleton ShaderData( SSAOShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/SSAO_P.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/gl/SSAO_P.glsl";
|
||||
|
||||
samplerNames[0] = "$prepassMap";
|
||||
samplerNames[1] = "$randNormalTex";
|
||||
samplerNames[2] = "$powTable";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( SSAOBlurYShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/SSAO_Blur_V.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/SSAO_Blur_P.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/gl/SSAO_Blur_V.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/gl/SSAO_Blur_P.glsl";
|
||||
|
||||
samplerNames[0] = "$occludeMap";
|
||||
samplerNames[1] = "$prepassMap";
|
||||
|
||||
pixVersion = 3.0;
|
||||
|
||||
defines = "BLUR_DIR=float2(0.0,1.0)";
|
||||
};
|
||||
|
||||
singleton ShaderData( SSAOBlurXShader : SSAOBlurYShader )
|
||||
{
|
||||
defines = "BLUR_DIR=float2(1.0,0.0)";
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// PostEffects
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton PostEffect( SSAOPostFx )
|
||||
{
|
||||
allowReflectPass = false;
|
||||
|
||||
renderTime = "PFXBeforeBin";
|
||||
renderBin = "AL_LightBinMgr";
|
||||
renderPriority = 10;
|
||||
|
||||
shader = SSAOShader;
|
||||
stateBlock = SSAOStateBlock;
|
||||
|
||||
texture[0] = "#prepass";
|
||||
texture[1] = "core/images/noise.png";
|
||||
texture[2] = "#ssao_pow_table";
|
||||
|
||||
target = "$outTex";
|
||||
targetScale = "0.5 0.5";
|
||||
targetViewport = "PFXTargetViewport_NamedInTexture0";
|
||||
|
||||
singleton PostEffect()
|
||||
{
|
||||
internalName = "blurY";
|
||||
|
||||
shader = SSAOBlurYShader;
|
||||
stateBlock = SSAOBlurStateBlock;
|
||||
|
||||
texture[0] = "$inTex";
|
||||
texture[1] = "#prepass";
|
||||
|
||||
target = "$outTex";
|
||||
};
|
||||
|
||||
singleton PostEffect()
|
||||
{
|
||||
internalName = "blurX";
|
||||
|
||||
shader = SSAOBlurXShader;
|
||||
stateBlock = SSAOBlurStateBlock;
|
||||
|
||||
texture[0] = "$inTex";
|
||||
texture[1] = "#prepass";
|
||||
|
||||
target = "$outTex";
|
||||
};
|
||||
|
||||
singleton PostEffect()
|
||||
{
|
||||
internalName = "blurY2";
|
||||
|
||||
shader = SSAOBlurYShader;
|
||||
stateBlock = SSAOBlurStateBlock;
|
||||
|
||||
texture[0] = "$inTex";
|
||||
texture[1] = "#prepass";
|
||||
|
||||
target = "$outTex";
|
||||
};
|
||||
|
||||
singleton PostEffect()
|
||||
{
|
||||
internalName = "blurX2";
|
||||
|
||||
shader = SSAOBlurXShader;
|
||||
stateBlock = SSAOBlurStateBlock;
|
||||
|
||||
texture[0] = "$inTex";
|
||||
texture[1] = "#prepass";
|
||||
|
||||
// We write to a mask texture which is then
|
||||
// read by the lighting shaders to mask ambient.
|
||||
target = "#ssaoMask";
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/// Just here for debug visualization of the
|
||||
/// SSAO mask texture used during lighting.
|
||||
singleton PostEffect( SSAOVizPostFx )
|
||||
{
|
||||
allowReflectPass = false;
|
||||
|
||||
shader = PFX_PassthruShader;
|
||||
stateBlock = PFX_DefaultStateBlock;
|
||||
|
||||
texture[0] = "#ssaoMask";
|
||||
|
||||
target = "$backbuffer";
|
||||
};
|
||||
|
||||
singleton ShaderData( SSAOPowTableShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/SSAO_PowerTable_V.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/SSAO_PowerTable_P.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/gl/SSAO_PowerTable_V.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/gl/SSAO_PowerTable_P.glsl";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( SSAOPowTablePostFx )
|
||||
{
|
||||
shader = SSAOPowTableShader;
|
||||
stateBlock = PFX_DefaultStateBlock;
|
||||
|
||||
renderTime = "PFXTexGenOnDemand";
|
||||
|
||||
target = "#ssao_pow_table";
|
||||
|
||||
targetFormat = "GFXFormatR16F";
|
||||
targetSize = "256 1";
|
||||
};
|
||||
57
Templates/BaseGame/game/core/postFX/turbulence.cs
Normal file
57
Templates/BaseGame/game/core/postFX/turbulence.cs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton GFXStateBlockData( PFX_TurbulenceStateBlock : PFX_DefaultStateBlock)
|
||||
{
|
||||
zDefined = false;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
singleton ShaderData( PFX_TurbulenceShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/turbulenceP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/turbulenceP.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( TurbulenceFx )
|
||||
{
|
||||
isEnabled = false;
|
||||
allowReflectPass = true;
|
||||
|
||||
renderTime = "PFXAfterDiffuse";
|
||||
renderBin = "GlowBin";
|
||||
renderPriority = 0.5; // Render after the glows themselves
|
||||
|
||||
shader = PFX_TurbulenceShader;
|
||||
stateBlock=PFX_TurbulenceStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
};
|
||||
55
Templates/BaseGame/game/core/postFX/vignette.cs
Normal file
55
Templates/BaseGame/game/core/postFX/vignette.cs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$VignettePostEffect::VMax = 0.6;
|
||||
$VignettePostEffect::VMin = 0.2;
|
||||
|
||||
singleton ShaderData( VignetteShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/vignette/VignetteP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/vignette/gl/VignetteP.glsl";
|
||||
|
||||
samplerNames[0] = "$backBuffer";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( VignettePostEffect )
|
||||
{
|
||||
isEnabled = false;
|
||||
allowReflectPass = false;
|
||||
renderTime = "PFXAfterBin";
|
||||
renderBin = "GlowBin";
|
||||
shader = VignetteShader;
|
||||
stateBlock = PFX_DefaultStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
renderPriority = 10;
|
||||
};
|
||||
|
||||
function VignettePostEffect::setShaderConsts(%this)
|
||||
{
|
||||
%this.setShaderConst("$Vmax", $VignettePostEffect::VMax);
|
||||
%this.setShaderConst("$Vmin", $VignettePostEffect::VMin);
|
||||
}
|
||||
|
|
@ -22,17 +22,42 @@
|
|||
|
||||
singleton ShaderData( PFX_PassthruShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFx/passthruP.hlsl";
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFX/passthruP.hlsl";
|
||||
|
||||
// OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFx/postFxV.glsl";
|
||||
// OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFx/gl/passthruP.glsl";
|
||||
// OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.glsl";
|
||||
// OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/passthruP.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
function postFXInit()
|
||||
{
|
||||
exec("./postFX/postFxManager.gui");
|
||||
|
||||
//Load the core postFX files themselves
|
||||
if (!$Server::Dedicated)
|
||||
{
|
||||
//init the postFX
|
||||
%pattern = "core/postFX/*.cs";
|
||||
%file = findFirstFile( %pattern );
|
||||
if ( %file $= "" )
|
||||
{
|
||||
// Try for DSOs next.
|
||||
%pattern = "core/postFX/*.cs.dso";
|
||||
%file = findFirstFile( %pattern );
|
||||
}
|
||||
|
||||
while( %file !$= "" )
|
||||
{
|
||||
exec( %file );
|
||||
%file = findNextFile( %pattern );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function PostEffect::inspectVars( %this )
|
||||
{
|
||||
%name = %this.getName();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,87 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Volumetric Fog final pixel shader V2.00
|
||||
#include "../shaderModel.hlsl"
|
||||
#include "../shaderModelAutoGen.hlsl"
|
||||
#include "../torque.hlsl"
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 0);
|
||||
TORQUE_UNIFORM_SAMPLER2D(depthBuffer, 1);
|
||||
TORQUE_UNIFORM_SAMPLER2D(frontBuffer, 2);
|
||||
TORQUE_UNIFORM_SAMPLER2D(density, 3);
|
||||
|
||||
uniform float3 ambientColor;
|
||||
uniform float accumTime;
|
||||
uniform float4 fogColor;
|
||||
uniform float4 modspeed;//xy speed layer 1, zw speed layer 2
|
||||
uniform float2 viewpoint;
|
||||
uniform float2 texscale;
|
||||
uniform float fogDensity;
|
||||
uniform float preBias;
|
||||
uniform float textured;
|
||||
uniform float modstrength;
|
||||
uniform float numtiles;
|
||||
uniform float fadesize;
|
||||
uniform float2 PixelSize;
|
||||
|
||||
struct ConnectData
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
float4 htpos : TEXCOORD0;
|
||||
float2 uv0 : TEXCOORD1;
|
||||
};
|
||||
|
||||
float4 main( ConnectData IN ) : TORQUE_TARGET0
|
||||
{
|
||||
float2 uvscreen=((IN.htpos.xy/IN.htpos.w) + 1.0 ) / 2.0;
|
||||
uvscreen.y = 1.0 - uvscreen.y;
|
||||
|
||||
float obj_test = TORQUE_PREPASS_UNCONDITION(prepassTex, uvscreen).w * preBias;
|
||||
float depth = TORQUE_TEX2D(depthBuffer, uvscreen).r;
|
||||
float front = TORQUE_TEX2D(frontBuffer, uvscreen).r;
|
||||
|
||||
if (depth <= front)
|
||||
return float4(0,0,0,0);
|
||||
else if ( obj_test < depth )
|
||||
depth = obj_test;
|
||||
if ( front >= 0.0)
|
||||
depth -= front;
|
||||
|
||||
float diff = 1.0;
|
||||
float3 col = fogColor.rgb;
|
||||
if (textured != 0.0)
|
||||
{
|
||||
float2 offset = viewpoint + ((-0.5 + (texscale * uvscreen)) * numtiles);
|
||||
|
||||
float2 mod1 = TORQUE_TEX2D(density, (offset + (modspeed.xy*accumTime))).rg;
|
||||
float2 mod2 = TORQUE_TEX2D(density, (offset + (modspeed.zw*accumTime))).rg;
|
||||
diff = (mod2.r + mod1.r) * modstrength;
|
||||
col *= (2.0 - ((mod1.g + mod2.g) * fadesize))/2.0;
|
||||
}
|
||||
|
||||
col *= ambientColor;
|
||||
|
||||
float4 resultColor = float4(col, 1.0 - saturate(exp(-fogDensity * depth * diff * fadesize)));
|
||||
|
||||
return hdrEncode(resultColor);
|
||||
}
|
||||
|
|
@ -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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Volumetric Fog prepass pixel shader V1.00
|
||||
#include "../shaderModel.hlsl"
|
||||
|
||||
struct ConnectData
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
float4 pos : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 main( ConnectData IN ) : TORQUE_TARGET0
|
||||
{
|
||||
float OUT;
|
||||
|
||||
clip( IN.pos.w );
|
||||
OUT = IN.pos.w;
|
||||
|
||||
return float4(OUT,0,0,1);
|
||||
}
|
||||
|
|
@ -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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Volumetric Fog prepass vertex shader V1.00
|
||||
|
||||
#include "../shaderModel.hlsl"
|
||||
#include "../hlslStructs.hlsl"
|
||||
|
||||
struct ConnectData
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
float4 pos : TEXCOORD0;
|
||||
};
|
||||
|
||||
uniform float4x4 modelView;
|
||||
|
||||
ConnectData main( VertexIn_P IN)
|
||||
{
|
||||
ConnectData OUT;
|
||||
|
||||
OUT.hpos = mul(modelView, float4(IN.pos, 1.0));
|
||||
OUT.pos = OUT.hpos;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Volumetric Fog Reflection pixel shader V1.00
|
||||
#include "../shaderModel.hlsl"
|
||||
uniform float4 fogColor;
|
||||
uniform float fogDensity;
|
||||
uniform float reflStrength;
|
||||
|
||||
struct ConnectData
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
float4 pos : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 main( ConnectData IN ) : TORQUE_TARGET0
|
||||
{
|
||||
return float4(fogColor.rgb,saturate(fogDensity*reflStrength));
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Volumetric Fog final vertex shader V1.00
|
||||
|
||||
#include "../shaderModel.hlsl"
|
||||
#include "../hlslStructs.hlsl"
|
||||
|
||||
struct ConnectData
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
float4 htpos : TEXCOORD0;
|
||||
float2 uv0 : TEXCOORD1;
|
||||
};
|
||||
|
||||
uniform float4x4 modelView;
|
||||
|
||||
ConnectData main( VertexIn_PNTT IN)
|
||||
{
|
||||
ConnectData OUT;
|
||||
|
||||
OUT.hpos = mul(modelView, float4(IN.pos,1.0));
|
||||
OUT.htpos = OUT.hpos;
|
||||
OUT.uv0 = IN.uv0;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "../../gl/torque.glsl"
|
||||
|
||||
uniform sampler2D prepassTex;
|
||||
uniform sampler2D depthBuffer;
|
||||
uniform sampler2D frontBuffer;
|
||||
uniform sampler2D density;
|
||||
|
||||
uniform float accumTime;
|
||||
uniform vec4 fogColor;
|
||||
uniform float fogDensity;
|
||||
uniform float preBias;
|
||||
uniform float textured;
|
||||
uniform float modstrength;
|
||||
uniform vec4 modspeed;//xy speed layer 1, zw speed layer 2
|
||||
uniform vec2 viewpoint;
|
||||
uniform vec2 texscale;
|
||||
uniform vec3 ambientColor;
|
||||
uniform float numtiles;
|
||||
uniform float fadesize;
|
||||
uniform vec2 PixelSize;
|
||||
|
||||
in vec4 _hpos;
|
||||
#define IN_hpos _hpos
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 uvscreen=((IN_hpos.xy/IN_hpos.w) + 1.0 ) / 2.0;
|
||||
uvscreen.y = 1.0 - uvscreen.y;
|
||||
|
||||
float obj_test = prepassUncondition( prepassTex, uvscreen).w * preBias;
|
||||
float depth = tex2D(depthBuffer,uvscreen).r;
|
||||
float front = tex2D(frontBuffer,uvscreen).r;
|
||||
|
||||
if (depth <= front)
|
||||
{
|
||||
OUT_col = vec4(0,0,0,0);
|
||||
return;
|
||||
}
|
||||
|
||||
else if ( obj_test < depth )
|
||||
depth = obj_test;
|
||||
if ( front >= 0.0)
|
||||
depth -= front;
|
||||
|
||||
float diff = 1.0;
|
||||
vec3 col = fogColor.rgb;
|
||||
if (textured != 0.0)
|
||||
{
|
||||
vec2 offset = viewpoint + ((-0.5 + (texscale * uvscreen)) * numtiles);
|
||||
|
||||
vec2 mod1 = tex2D(density,(offset + (modspeed.xy*accumTime))).rg;
|
||||
vec2 mod2= tex2D(density,(offset + (modspeed.zw*accumTime))).rg;
|
||||
diff = (mod2.r + mod1.r) * modstrength;
|
||||
col *= (2.0 - ((mod1.g + mod2.g) * fadesize))/2.0;
|
||||
}
|
||||
|
||||
col *= ambientColor;
|
||||
|
||||
vec4 returnColor = vec4(col, 1.0 - saturate(exp(-fogDensity * depth * diff * fadesize)));
|
||||
|
||||
OUT_col = hdrEncode(returnColor);
|
||||
}
|
||||
|
|
@ -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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "../../gl/hlslCompat.glsl"
|
||||
|
||||
in vec4 _hpos;
|
||||
#define IN_hpos _hpos
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
float OUT;
|
||||
clip( IN_hpos.w );
|
||||
OUT = IN_hpos.w;
|
||||
|
||||
OUT_col = vec4(OUT,0,0,1);
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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"
|
||||
|
||||
in vec4 vPosition;
|
||||
#define IN_position vPosition
|
||||
|
||||
out vec4 _hpos;
|
||||
#define OUT_hpos _hpos
|
||||
|
||||
uniform mat4 modelView;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 inPos = IN_position;
|
||||
inPos.w = 1.0;
|
||||
|
||||
OUT_hpos = tMul( modelView, inPos );
|
||||
|
||||
gl_Position = OUT_hpos;
|
||||
correctSSP(gl_Position);
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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"
|
||||
|
||||
uniform vec4 fogColor;
|
||||
uniform float fogDensity;
|
||||
uniform float reflStrength;
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
OUT_col = vec4(fogColor.rgb,saturate(fogDensity*reflStrength));
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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"
|
||||
|
||||
in vec4 vPosition;
|
||||
#define IN_position vPosition
|
||||
|
||||
out vec4 _hpos;
|
||||
#define OUT_hpos _hpos
|
||||
|
||||
uniform mat4 modelView;
|
||||
|
||||
void main()
|
||||
{
|
||||
OUT_hpos = tMul(modelView, IN_position);
|
||||
gl_Position = OUT_hpos;
|
||||
correctSSP(gl_Position);
|
||||
}
|
||||
37
Templates/BaseGame/game/core/shaders/basicCloudsP.hlsl
Normal file
37
Templates/BaseGame/game/core/shaders/basicCloudsP.hlsl
Normal 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "torque.hlsl"
|
||||
|
||||
struct ConnectData
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
|
||||
|
||||
float4 main( ConnectData IN ) : TORQUE_TARGET0
|
||||
{
|
||||
float4 col = TORQUE_TEX2D(diffuseMap, IN.texCoord);
|
||||
return hdrEncode( col );
|
||||
}
|
||||
58
Templates/BaseGame/game/core/shaders/basicCloudsV.hlsl
Normal file
58
Templates/BaseGame/game/core/shaders/basicCloudsV.hlsl
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "shaderModel.hlsl"
|
||||
|
||||
struct CloudVert
|
||||
{
|
||||
float3 pos : POSITION;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct ConnectData
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
uniform float4x4 modelview;
|
||||
uniform float2 texDirection;
|
||||
uniform float2 texOffset;
|
||||
uniform float accumTime;
|
||||
uniform float texScale;
|
||||
|
||||
|
||||
ConnectData main( CloudVert IN )
|
||||
{
|
||||
ConnectData OUT;
|
||||
|
||||
OUT.hpos = mul(modelview, float4(IN.pos,1.0));
|
||||
|
||||
float2 uv = IN.uv0;
|
||||
uv += texOffset;
|
||||
uv *= texScale;
|
||||
uv += accumTime * texDirection;
|
||||
|
||||
OUT.texCoord = uv;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
146
Templates/BaseGame/game/core/shaders/cloudLayerP.hlsl
Normal file
146
Templates/BaseGame/game/core/shaders/cloudLayerP.hlsl
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "shaderModel.hlsl"
|
||||
#include "torque.hlsl"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Structures
|
||||
//-----------------------------------------------------------------------------
|
||||
struct ConnectData
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
float4 texCoord12 : TEXCOORD0;
|
||||
float4 texCoord34 : TEXCOORD1;
|
||||
float3 vLightTS : TEXCOORD2; // light vector in tangent space, denormalized
|
||||
float3 vViewTS : TEXCOORD3; // view vector in tangent space, denormalized
|
||||
float worldDist : TEXCOORD4;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Uniforms
|
||||
//-----------------------------------------------------------------------------
|
||||
TORQUE_UNIFORM_SAMPLER2D(normalHeightMap, 0);
|
||||
uniform float3 ambientColor;
|
||||
uniform float3 sunColor;
|
||||
uniform float cloudCoverage;
|
||||
uniform float3 cloudBaseColor;
|
||||
uniform float cloudExposure;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Globals
|
||||
//-----------------------------------------------------------------------------
|
||||
// The per-color weighting to be used for luminance calculations in RGB order.
|
||||
static const float3 LUMINANCE_VECTOR = float3(0.2125f, 0.7154f, 0.0721f);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Calculates the Rayleigh phase function
|
||||
float getRayleighPhase( float angle )
|
||||
{
|
||||
return 0.75 * ( 1.0 + pow( angle, 2 ) );
|
||||
}
|
||||
|
||||
// Returns the output rgb color given a texCoord and parameters it uses
|
||||
// for lighting calculation.
|
||||
float3 ComputeIllumination( float2 texCoord,
|
||||
float3 vLightTS,
|
||||
float3 vViewTS,
|
||||
float3 vNormalTS )
|
||||
{
|
||||
//return noiseNormal;
|
||||
//return vNormalTS;
|
||||
|
||||
float3 vLightTSAdj = float3( -vLightTS.x, -vLightTS.y, vLightTS.z );
|
||||
|
||||
float dp = dot( vNormalTS, vLightTSAdj );
|
||||
|
||||
// Calculate the amount of illumination (lightTerm)...
|
||||
|
||||
// We do both a rim lighting effect and a halfLambertian lighting effect
|
||||
// and combine the result.
|
||||
float halfLambertTerm = saturate( pow( dp * 0.5 + 0.5, 1 ) );
|
||||
float rimLightTerm = pow( ( 1.0 - dp ), 1.0 );
|
||||
float lightTerm = saturate( halfLambertTerm * 1.0 + rimLightTerm * dp );
|
||||
lightTerm *= 0.5;
|
||||
|
||||
// Use a simple RayleighPhase function to simulate single scattering towards
|
||||
// the camera.
|
||||
float angle = dot( vLightTS, vViewTS );
|
||||
lightTerm *= getRayleighPhase( angle );
|
||||
|
||||
// Combine terms and colors into the output color.
|
||||
//float3 lightColor = ( lightTerm * sunColor * fOcclusionShadow ) + ambientColor;
|
||||
float3 lightColor = lerp( ambientColor, sunColor, lightTerm );
|
||||
//lightColor = lerp( lightColor, ambientColor, cloudCoverage );
|
||||
float3 finalColor = cloudBaseColor * lightColor;
|
||||
|
||||
return finalColor;
|
||||
}
|
||||
|
||||
float4 main( ConnectData IN ) : TORQUE_TARGET0
|
||||
{
|
||||
// Normalize the interpolated vectors:
|
||||
float3 vViewTS = normalize( IN.vViewTS );
|
||||
float3 vLightTS = normalize( IN.vLightTS );
|
||||
|
||||
float4 cResultColor = float4( 0, 0, 0, 1 );
|
||||
|
||||
float2 texSample = IN.texCoord12.xy;
|
||||
|
||||
float4 noise1 = TORQUE_TEX2D( normalHeightMap, IN.texCoord12.zw );
|
||||
noise1 = normalize( ( noise1 - 0.5 ) * 2.0 );
|
||||
//return noise1;
|
||||
|
||||
float4 noise2 = TORQUE_TEX2D(normalHeightMap, IN.texCoord34.xy);
|
||||
noise2 = normalize( ( noise2 - 0.5 ) * 2.0 );
|
||||
//return noise2;
|
||||
|
||||
float3 noiseNormal = normalize( noise1 + noise2 ).xyz;
|
||||
//return float4( noiseNormal, 1.0 );
|
||||
|
||||
float noiseHeight = noise1.a * noise2.a * ( cloudCoverage / 2.0 + 0.5 );
|
||||
|
||||
float3 vNormalTS = normalize( TORQUE_TEX2D(normalHeightMap, texSample).xyz * 2.0 - 1.0);
|
||||
vNormalTS += noiseNormal;
|
||||
vNormalTS = normalize( vNormalTS );
|
||||
|
||||
// Compute resulting color for the pixel:
|
||||
cResultColor.rgb = ComputeIllumination( texSample, vLightTS, vViewTS, vNormalTS );
|
||||
|
||||
float coverage = ( cloudCoverage - 0.5 ) * 2.0;
|
||||
cResultColor.a = TORQUE_TEX2D(normalHeightMap, texSample).a + coverage + noiseHeight;
|
||||
|
||||
if ( cloudCoverage > -1.0 )
|
||||
cResultColor.a /= 1.0 + coverage;
|
||||
|
||||
cResultColor.a = saturate( cResultColor.a * pow( saturate(cloudCoverage), 0.25 ) );
|
||||
|
||||
cResultColor.a = lerp( cResultColor.a, 0.0, 1.0 - pow(IN.worldDist,2.0) );
|
||||
|
||||
cResultColor.rgb *= cloudExposure;
|
||||
|
||||
return hdrEncode( cResultColor );
|
||||
}
|
||||
106
Templates/BaseGame/game/core/shaders/cloudLayerV.hlsl
Normal file
106
Templates/BaseGame/game/core/shaders/cloudLayerV.hlsl
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Structures
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "shaderModel.hlsl"
|
||||
|
||||
struct CloudVert
|
||||
{
|
||||
float3 pos : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float3 binormal : BINORMAL;
|
||||
float3 tangent : TANGENT;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct ConnectData
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
float4 texCoord12 : TEXCOORD0;
|
||||
float4 texCoord34 : TEXCOORD1;
|
||||
float3 vLightTS : TEXCOORD2; // light vector in tangent space, denormalized
|
||||
float3 vViewTS : TEXCOORD3; // view vector in tangent space, denormalized
|
||||
float worldDist : TEXCOORD4;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Uniforms
|
||||
//-----------------------------------------------------------------------------
|
||||
uniform float4x4 modelview;
|
||||
uniform float3 eyePosWorld;
|
||||
uniform float3 sunVec;
|
||||
uniform float2 texOffset0;
|
||||
uniform float2 texOffset1;
|
||||
uniform float2 texOffset2;
|
||||
uniform float3 texScale;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
ConnectData main( CloudVert IN )
|
||||
{
|
||||
ConnectData OUT;
|
||||
|
||||
OUT.hpos = mul(modelview, float4(IN.pos,1.0));
|
||||
// Offset the uv so we don't have a seam directly over our head.
|
||||
float2 uv = IN.uv0 + float2( 0.5, 0.5 );
|
||||
|
||||
OUT.texCoord12.xy = uv * texScale.x;
|
||||
OUT.texCoord12.xy += texOffset0;
|
||||
|
||||
OUT.texCoord12.zw = uv * texScale.y;
|
||||
OUT.texCoord12.zw += texOffset1;
|
||||
|
||||
OUT.texCoord34.xy = uv * texScale.z;
|
||||
OUT.texCoord34.xy += texOffset2;
|
||||
|
||||
OUT.texCoord34.z = IN.pos.z;
|
||||
OUT.texCoord34.w = 0.0;
|
||||
|
||||
// Transform the normal, tangent and binormal vectors from object space to
|
||||
// homogeneous projection space:
|
||||
float3 vNormalWS = -IN.normal;
|
||||
float3 vTangentWS = -IN.tangent;
|
||||
float3 vBinormalWS = -IN.binormal;
|
||||
|
||||
// Compute position in world space:
|
||||
float4 vPositionWS = float4(IN.pos, 1.0) + float4(eyePosWorld, 1); //mul( IN.pos, objTrans );
|
||||
|
||||
// Compute and output the world view vector (unnormalized):
|
||||
float3 vViewWS = eyePosWorld - vPositionWS.xyz;
|
||||
|
||||
// Compute denormalized light vector in world space:
|
||||
float3 vLightWS = -sunVec;
|
||||
|
||||
// Normalize the light and view vectors and transform it to the tangent space:
|
||||
float3x3 mWorldToTangent = float3x3( vTangentWS, vBinormalWS, vNormalWS );
|
||||
|
||||
// Propagate the view and the light vectors (in tangent space):
|
||||
OUT.vLightTS = mul( vLightWS, mWorldToTangent );
|
||||
OUT.vViewTS = mul( mWorldToTangent, vViewWS );
|
||||
|
||||
OUT.worldDist = saturate( pow( max( IN.pos.z, 0 ), 2 ) );
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
|
@ -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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "../shaderModel.hlsl"
|
||||
|
||||
struct Conn
|
||||
{
|
||||
float4 HPOS : TORQUE_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
|
||||
|
||||
float4 main( Conn IN ) : TORQUE_TARGET0
|
||||
{
|
||||
return float4(IN.color.rgb, IN.color.a * TORQUE_TEX2D(diffuseMap, IN.texCoord).a);
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "../shaderModel.hlsl"
|
||||
|
||||
struct Appdata
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Conn
|
||||
{
|
||||
float4 HPOS : TORQUE_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
uniform float4x4 modelview;
|
||||
|
||||
Conn main( Appdata In )
|
||||
{
|
||||
Conn Out;
|
||||
Out.HPOS = mul(modelview, float4(In.position,1.0));
|
||||
Out.color = In.color;
|
||||
Out.texCoord = In.texCoord;
|
||||
return Out;
|
||||
}
|
||||
|
|
@ -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 "../shaderModel.hlsl"
|
||||
|
||||
struct Conn
|
||||
{
|
||||
float4 HPOS : TORQUE_POSITION;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
float4 main(Conn IN) : TORQUE_TARGET0
|
||||
{
|
||||
return IN.color;
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "../shaderModel.hlsl"
|
||||
|
||||
struct Appdata
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct Conn
|
||||
{
|
||||
float4 HPOS : TORQUE_POSITION;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
uniform float4x4 modelview;
|
||||
|
||||
Conn main( Appdata In )
|
||||
{
|
||||
Conn Out;
|
||||
Out.HPOS = mul(modelview, float4(In.position,1.0));
|
||||
Out.color = In.color;
|
||||
return Out;
|
||||
}
|
||||
|
|
@ -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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
uniform sampler2D diffuseMap;
|
||||
in vec4 color;
|
||||
in vec2 texCoord;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
OUT_col = vec4(color.rgb, color.a * texture(diffuseMap, texCoord).a);
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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"
|
||||
|
||||
in vec4 vPosition;
|
||||
in vec4 vColor;
|
||||
in vec2 vTexCoord0;
|
||||
|
||||
uniform mat4 modelview;
|
||||
out vec4 color;
|
||||
out vec2 texCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = tMul(modelview, vPosition);
|
||||
correctSSP(gl_Position);
|
||||
color = vColor;
|
||||
texCoord = vTexCoord0.st;
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
in vec4 color;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
OUT_col = color;
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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"
|
||||
|
||||
in vec4 vPosition;
|
||||
in vec4 vColor;
|
||||
|
||||
uniform mat4 modelview;
|
||||
out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = tMul(modelview, vPosition);
|
||||
correctSSP(gl_Position);
|
||||
color = vColor;
|
||||
}
|
||||
|
|
@ -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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
uniform sampler2D diffuseMap;
|
||||
in vec4 color;
|
||||
in vec2 texCoord;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
OUT_col = texture(diffuseMap, texCoord) * color;
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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"
|
||||
|
||||
in vec4 vPosition;
|
||||
in vec4 vColor;
|
||||
in vec2 vTexCoord0;
|
||||
|
||||
uniform mat4 modelview;
|
||||
out vec4 color;
|
||||
out vec2 texCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = tMul(modelview, vPosition);
|
||||
correctSSP(gl_Position);
|
||||
color = vColor;
|
||||
texCoord = vTexCoord0.st;
|
||||
}
|
||||
|
|
@ -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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
uniform sampler2D colorTarget0Texture ;
|
||||
|
||||
vec4 main( vec2 ScreenPos : VPOS ) : COLOR0
|
||||
{
|
||||
vec2 TexCoord = ScreenPos;
|
||||
vec4 diffuse;
|
||||
asm { tfetch2D diffuse, TexCoord, colorTarget0Texture, UnnormalizedTextureCoords = true };
|
||||
return diffuse;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
uniform sampler2D diffuseMap;
|
||||
in vec2 texCoord;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
OUT_col = texture(diffuseMap, texCoord);
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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"
|
||||
|
||||
in vec4 vPosition;
|
||||
in vec2 vTexCoord0;
|
||||
|
||||
uniform mat4 modelview;
|
||||
out vec2 texCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = tMul(modelview, vPosition);
|
||||
correctSSP(gl_Position);
|
||||
texCoord = vTexCoord0.st;
|
||||
}
|
||||
|
|
@ -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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "../shaderModel.hlsl"
|
||||
|
||||
struct Conn
|
||||
{
|
||||
float4 HPOS : TORQUE_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
|
||||
|
||||
float4 main( Conn IN ) : TORQUE_TARGET0
|
||||
{
|
||||
return TORQUE_TEX2D(diffuseMap, IN.texCoord) * IN.color;
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "../shaderModel.hlsl"
|
||||
|
||||
struct Appdata
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Conn
|
||||
{
|
||||
float4 HPOS : TORQUE_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
uniform float4x4 modelview;
|
||||
|
||||
Conn main( Appdata In )
|
||||
{
|
||||
Conn Out;
|
||||
Out.HPOS = mul(modelview, float4(In.position,1.0));
|
||||
Out.color = In.color;
|
||||
Out.texCoord = In.texCoord;
|
||||
return Out;
|
||||
}
|
||||
|
|
@ -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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
uniform sampler2D colorTarget0Texture : register(s0);
|
||||
|
||||
float4 main( float2 ScreenPos : VPOS ) : COLOR0
|
||||
{
|
||||
float2 TexCoord = ScreenPos;
|
||||
float4 diffuse;
|
||||
asm { tfetch2D diffuse, TexCoord, colorTarget0Texture, UnnormalizedTextureCoords = true };
|
||||
return diffuse;
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
float4 main( const float2 inPosition : POSITION ) : POSITION
|
||||
{
|
||||
return float4( inPosition, 0, 1 );
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "../shaderModel.hlsl"
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
|
||||
|
||||
struct Conn
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 main(Conn IN) : TORQUE_TARGET0
|
||||
{
|
||||
return TORQUE_TEX2D(diffuseMap, IN.texCoord);
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "../shaderModel.hlsl"
|
||||
|
||||
struct Appdata
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Conn
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
uniform float4x4 modelview;
|
||||
|
||||
Conn main( Appdata In )
|
||||
{
|
||||
Conn Out;
|
||||
Out.hpos = mul(modelview, float4(In.position, 1.0));
|
||||
Out.texCoord = In.texCoord;
|
||||
return Out;
|
||||
}
|
||||
186
Templates/BaseGame/game/core/shaders/foliage.hlsl
Normal file
186
Templates/BaseGame/game/core/shaders/foliage.hlsl
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// CornerId corresponds to this arrangement
|
||||
// from the perspective of the camera.
|
||||
//
|
||||
// 3 ---- 2
|
||||
// | |
|
||||
// 0 ---- 1
|
||||
//
|
||||
|
||||
#define MAX_COVERTYPES 8
|
||||
|
||||
uniform float2 gc_fadeParams;
|
||||
uniform float2 gc_windDir;
|
||||
uniform float3 gc_camRight;
|
||||
uniform float3 gc_camUp;
|
||||
uniform float4 gc_typeRects[MAX_COVERTYPES];
|
||||
|
||||
// .x = gust length
|
||||
// .y = premultiplied simulation time and gust frequency
|
||||
// .z = gust strength
|
||||
uniform float3 gc_gustInfo;
|
||||
|
||||
// .x = premultiplied simulation time and turbulance frequency
|
||||
// .y = turbulance strength
|
||||
uniform float2 gc_turbInfo;
|
||||
|
||||
|
||||
static float sCornerRight[4] = { -0.5, 0.5, 0.5, -0.5 };
|
||||
|
||||
static float sCornerUp[4] = { 0, 0, 1, 1 };
|
||||
|
||||
static float sMovableCorner[4] = { 0, 0, 1, 1 };
|
||||
|
||||
static float2 sUVCornerExtent[4] =
|
||||
{
|
||||
float2( 0, 1 ),
|
||||
float2( 1, 1 ),
|
||||
float2( 1, 0 ),
|
||||
float2( 0, 0 )
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// The following wind effect was derived from the GPU Gems 3 chapter...
|
||||
//
|
||||
// "Vegetation Procedural Animation and Shading in Crysis"
|
||||
// by Tiago Sousa, Crytek
|
||||
//
|
||||
|
||||
float2 smoothCurve( float2 x )
|
||||
{
|
||||
return x * x * ( 3.0 - 2.0 * x );
|
||||
}
|
||||
|
||||
float2 triangleWave( float2 x )
|
||||
{
|
||||
return abs( frac( x + 0.5 ) * 2.0 - 1.0 );
|
||||
}
|
||||
|
||||
float2 smoothTriangleWave( float2 x )
|
||||
{
|
||||
return smoothCurve( triangleWave( x ) );
|
||||
}
|
||||
|
||||
float windTurbulence( float bbPhase, float frequency, float strength )
|
||||
{
|
||||
// We create the input value for wave generation from the frequency and phase.
|
||||
float2 waveIn = bbPhase.xx + frequency.xx;
|
||||
|
||||
// We use two square waves to generate the effect which
|
||||
// is then scaled by the overall strength.
|
||||
float2 waves = ( frac( waveIn.xy * float2( 1.975, 0.793 ) ) * 2.0 - 1.0 );
|
||||
waves = smoothTriangleWave( waves );
|
||||
|
||||
// Sum up the two waves into a single wave.
|
||||
return ( waves.x + waves.y ) * strength;
|
||||
}
|
||||
|
||||
float2 windEffect( float bbPhase,
|
||||
float2 windDirection,
|
||||
float gustLength,
|
||||
float gustFrequency,
|
||||
float gustStrength,
|
||||
float turbFrequency,
|
||||
float turbStrength )
|
||||
{
|
||||
// Calculate the ambient wind turbulence.
|
||||
float turbulence = windTurbulence( bbPhase, turbFrequency, turbStrength );
|
||||
|
||||
// We simulate the overall gust via a sine wave.
|
||||
float gustPhase = clamp( sin( ( bbPhase - gustFrequency ) / gustLength ) , 0, 1 );
|
||||
float gustOffset = ( gustPhase * gustStrength ) + ( ( 0.2 + gustPhase ) * turbulence );
|
||||
|
||||
// Return the final directional wind effect.
|
||||
return gustOffset.xx * windDirection.xy;
|
||||
}
|
||||
|
||||
void foliageProcessVert( inout float3 position,
|
||||
inout float4 diffuse,
|
||||
inout float4 texCoord,
|
||||
inout float3 normal,
|
||||
inout float3 T,
|
||||
in float3 eyePos )
|
||||
{
|
||||
// Assign the normal and tagent values.
|
||||
//normal = float3( 0, 0, 1 );//cross( gc_camUp, gc_camRight );
|
||||
T = gc_camRight;
|
||||
|
||||
// Pull out local vars we need for work.
|
||||
int corner = ( diffuse.a * 255.0f ) + 0.5f;
|
||||
float2 size = texCoord.xy;
|
||||
int type = texCoord.z;
|
||||
|
||||
// The billboarding is based on the camera direction.
|
||||
float3 rightVec = gc_camRight * sCornerRight[corner];
|
||||
float3 upVec = gc_camUp * sCornerUp[corner];
|
||||
|
||||
// Figure out the corner position.
|
||||
float3 outPos = ( upVec * size.y ) + ( rightVec * size.x );
|
||||
float len = length( outPos.xyz );
|
||||
|
||||
// We derive the billboard phase used for wind calculations from its position.
|
||||
float bbPhase = dot( position.xyz, 1 );
|
||||
|
||||
// Get the overall wind gust and turbulence effects.
|
||||
float3 wind;
|
||||
wind.xy = windEffect( bbPhase,
|
||||
gc_windDir,
|
||||
gc_gustInfo.x, gc_gustInfo.y, gc_gustInfo.z,
|
||||
gc_turbInfo.x, gc_turbInfo.y );
|
||||
wind.z = 0;
|
||||
|
||||
// Add the summed wind effect into the point.
|
||||
outPos.xyz += wind.xyz * texCoord.w;
|
||||
|
||||
// Do a simple spherical clamp to keep the foliage
|
||||
// from stretching too much by wind effect.
|
||||
outPos.xyz = normalize( outPos.xyz ) * len;
|
||||
|
||||
// Move the point into world space.
|
||||
position += outPos;
|
||||
|
||||
// Grab the uv set and setup the texture coord.
|
||||
float4 uvSet = gc_typeRects[type];
|
||||
texCoord.x = uvSet.x + ( uvSet.z * sUVCornerExtent[corner].x );
|
||||
texCoord.y = uvSet.y + ( uvSet.w * sUVCornerExtent[corner].y );
|
||||
|
||||
// Animate the normal to get lighting changes
|
||||
// across the the wind swept foliage.
|
||||
//
|
||||
// TODO: Expose the 10x as a factor to control
|
||||
// how much the wind effects the lighting on the grass.
|
||||
//
|
||||
normal.xy += wind.xy * ( 10.0 * texCoord.w );
|
||||
normal = normalize( normal );
|
||||
|
||||
// Get the alpha fade value.
|
||||
|
||||
float fadeStart = gc_fadeParams.x;
|
||||
float fadeEnd = gc_fadeParams.y;
|
||||
const float fadeRange = fadeEnd - fadeStart;
|
||||
|
||||
float dist = distance( eyePos, position.xyz ) - fadeStart;
|
||||
diffuse.a = 1 - clamp( dist / fadeRange, 0, 1 );
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "shdrConsts.h"
|
||||
#include "shaderModel.hlsl"
|
||||
//-----------------------------------------------------------------------------
|
||||
// Structures
|
||||
//-----------------------------------------------------------------------------
|
||||
struct ConnectData
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
float2 outTexCoord : TEXCOORD0;
|
||||
float4 color : COLOR0;
|
||||
float4 groundAlphaCoeff : COLOR1;
|
||||
float2 alphaLookup : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct Fragout
|
||||
{
|
||||
float4 col : TORQUE_TARGET0;
|
||||
};
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
|
||||
TORQUE_UNIFORM_SAMPLER2D(alphaMap, 1);
|
||||
|
||||
uniform float4 groundAlpha;
|
||||
uniform float4 ambient;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
Fragout main( ConnectData IN )
|
||||
{
|
||||
Fragout OUT;
|
||||
|
||||
float4 alpha = TORQUE_TEX2D(alphaMap, IN.alphaLookup);
|
||||
OUT.col = float4( ambient.rgb * IN.lum.rgb, 1.0 ) * TORQUE_TEX2D(diffuseMap, IN.texCoord);
|
||||
OUT.col.a = OUT.col.a * min(alpha, groundAlpha + IN.groundAlphaCoeff.x).x;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
129
Templates/BaseGame/game/core/shaders/fxFoliageReplicatorV.hlsl
Normal file
129
Templates/BaseGame/game/core/shaders/fxFoliageReplicatorV.hlsl
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Structures
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "shaderModel.hlsl"
|
||||
|
||||
struct VertData
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
float2 waveScale : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct ConnectData
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
float2 outTexCoord : TEXCOORD0;
|
||||
float4 color : COLOR0;
|
||||
float4 groundAlphaCoeff : COLOR1;
|
||||
float2 alphaLookup : TEXCOORD1;
|
||||
};
|
||||
|
||||
uniform float4x4 projection : register(C0);
|
||||
uniform float4x4 world : register(C4);
|
||||
uniform float GlobalSwayPhase : register(C8);
|
||||
uniform float SwayMagnitudeSide : register(C9);
|
||||
uniform float SwayMagnitudeFront : register(C10);
|
||||
uniform float GlobalLightPhase : register(C11);
|
||||
uniform float LuminanceMagnitude : register(C12);
|
||||
uniform float LuminanceMidpoint : register(C13);
|
||||
uniform float DistanceRange : register(C14);
|
||||
uniform float3 CameraPos : register(C15);
|
||||
uniform float TrueBillboard : register(C16);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
ConnectData main( VertData IN )
|
||||
{
|
||||
ConnectData OUT;
|
||||
|
||||
// Init a transform matrix to be used in the following steps
|
||||
float4x4 trans = 0;
|
||||
trans[0][0] = 1;
|
||||
trans[1][1] = 1;
|
||||
trans[2][2] = 1;
|
||||
trans[3][3] = 1;
|
||||
trans[0][3] = IN.position.x;
|
||||
trans[1][3] = IN.position.y;
|
||||
trans[2][3] = IN.position.z;
|
||||
|
||||
// Billboard transform * world matrix
|
||||
float4x4 o = world;
|
||||
o = mul(o, trans);
|
||||
|
||||
// Keep only the up axis result and position transform.
|
||||
// This gives us "cheating" cylindrical billboarding.
|
||||
o[0][0] = 1;
|
||||
o[1][0] = 0;
|
||||
o[2][0] = 0;
|
||||
o[3][0] = 0;
|
||||
o[0][1] = 0;
|
||||
o[1][1] = 1;
|
||||
o[2][1] = 0;
|
||||
o[3][1] = 0;
|
||||
|
||||
// Unless the user specified TrueBillboard,
|
||||
// in which case we want the z axis to also be camera facing.
|
||||
|
||||
#ifdef TRUE_BILLBOARD
|
||||
|
||||
o[0][2] = 0;
|
||||
o[1][2] = 0;
|
||||
o[2][2] = 1;
|
||||
o[3][2] = 0;
|
||||
|
||||
#endif
|
||||
|
||||
// Handle sway. Sway is stored in a texture coord. The x coordinate is the sway phase multiplier,
|
||||
// the y coordinate determines if this vertex actually sways or not.
|
||||
float xSway, ySway;
|
||||
float wavePhase = GlobalSwayPhase * IN.waveScale.x;
|
||||
sincos(wavePhase, ySway, xSway);
|
||||
xSway = xSway * IN.waveScale.y * SwayMagnitudeSide;
|
||||
ySway = ySway * IN.waveScale.y * SwayMagnitudeFront;
|
||||
float4 p;
|
||||
p = mul(o, float4(IN.normal.x + xSway, ySway, IN.normal.z, 1));
|
||||
|
||||
// Project the point
|
||||
OUT.hpos = mul(projection, p);
|
||||
|
||||
// Lighting
|
||||
float Luminance = LuminanceMidpoint + LuminanceMagnitude * cos(GlobalLightPhase + IN.normal.y);
|
||||
|
||||
// Alpha
|
||||
float3 worldPos = IN.position;
|
||||
float alpha = abs(distance(worldPos, CameraPos)) / DistanceRange;
|
||||
alpha = clamp(alpha, 0.0f, 1.0f); //pass it through
|
||||
|
||||
OUT.alphaLookup = float2(alpha, 0.0f);
|
||||
OUT.groundAlphaCoeff = all(IN.normal.z);
|
||||
OUT.outTexCoord = IN.texCoord;
|
||||
OUT.color = float4(Luminance, Luminance, Luminance, 1.0f);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
39
Templates/BaseGame/game/core/shaders/gl/basicCloudsP.glsl
Normal file
39
Templates/BaseGame/game/core/shaders/gl/basicCloudsP.glsl
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "torque.glsl"
|
||||
#include "hlslCompat.glsl"
|
||||
|
||||
//ConnectData
|
||||
in vec2 texCoord;
|
||||
#define IN_texCoord texCoord
|
||||
|
||||
|
||||
uniform sampler2D diffuseMap ;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 col = texture( diffuseMap, IN_texCoord );
|
||||
OUT_col = hdrEncode( col );
|
||||
}
|
||||
53
Templates/BaseGame/game/core/shaders/gl/basicCloudsV.glsl
Normal file
53
Templates/BaseGame/game/core/shaders/gl/basicCloudsV.glsl
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "hlslCompat.glsl"
|
||||
|
||||
//CloudVert
|
||||
in vec4 vPosition;
|
||||
in vec2 vTexCoord0;
|
||||
|
||||
#define IN_pos vPosition
|
||||
#define IN_uv0 vTexCoord0
|
||||
|
||||
uniform mat4 modelview;
|
||||
uniform float accumTime;
|
||||
uniform float texScale;
|
||||
uniform vec2 texDirection;
|
||||
uniform vec2 texOffset;
|
||||
|
||||
out vec2 texCoord;
|
||||
#define OUT_texCoord texCoord
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = tMul(modelview, IN_pos);
|
||||
|
||||
vec2 uv = IN_uv0;
|
||||
uv += texOffset;
|
||||
uv *= texScale;
|
||||
uv += accumTime * texDirection;
|
||||
|
||||
OUT_texCoord = uv;
|
||||
|
||||
correctSSP(gl_Position);
|
||||
}
|
||||
39
Templates/BaseGame/game/core/shaders/gl/blurP.glsl
Normal file
39
Templates/BaseGame/game/core/shaders/gl/blurP.glsl
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//*****************************************************************************
|
||||
// Glow Shader
|
||||
//*****************************************************************************
|
||||
uniform vec4 kernel;
|
||||
uniform sampler2D diffuseMap;
|
||||
|
||||
in vec2 texc0, texc1, texc2, texc3;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
OUT_col = texture(diffuseMap, texc0) * kernel.x;
|
||||
OUT_col += texture(diffuseMap, texc1) * kernel.y;
|
||||
OUT_col += texture(diffuseMap, texc2) * kernel.z;
|
||||
OUT_col += texture(diffuseMap, texc3) * kernel.w;
|
||||
}
|
||||
48
Templates/BaseGame/game/core/shaders/gl/blurV.glsl
Normal file
48
Templates/BaseGame/game/core/shaders/gl/blurV.glsl
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//*****************************************************************************
|
||||
// Glow shader
|
||||
//*****************************************************************************
|
||||
|
||||
in vec4 vPosition;
|
||||
in vec4 vColor;
|
||||
in vec2 vTexCoord0;
|
||||
|
||||
uniform mat4 modelview;
|
||||
uniform vec2 offset0, offset1, offset2, offset3;
|
||||
|
||||
out vec2 texc0, texc1, texc2, texc3;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = modelview * vPosition;
|
||||
|
||||
vec2 tc = vTexCoord0.st;
|
||||
tc.y = 1.0 - tc.y;
|
||||
|
||||
texc0 = tc + offset0;
|
||||
texc1 = tc + offset1;
|
||||
texc2 = tc + offset2;
|
||||
texc3 = tc + offset3;
|
||||
gl_Position.y *= -1;
|
||||
}
|
||||
147
Templates/BaseGame/game/core/shaders/gl/cloudLayerP.glsl
Normal file
147
Templates/BaseGame/game/core/shaders/gl/cloudLayerP.glsl
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "hlslCompat.glsl"
|
||||
#include "torque.glsl"
|
||||
//-----------------------------------------------------------------------------
|
||||
// Structures
|
||||
//-----------------------------------------------------------------------------
|
||||
//ConnectData
|
||||
in vec4 texCoord12;
|
||||
#define IN_texCoord12 texCoord12
|
||||
in vec4 texCoord34;
|
||||
#define IN_texCoord34 texCoord34
|
||||
in vec3 vLightTS; // light vector in tangent space, denormalized
|
||||
#define IN_vLightTS vLightTS
|
||||
in vec3 vViewTS; // view vector in tangent space, denormalized
|
||||
#define IN_vViewTS vViewTS
|
||||
in float worldDist;
|
||||
#define IN_worldDist worldDist
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Uniforms
|
||||
//-----------------------------------------------------------------------------
|
||||
uniform sampler2D normalHeightMap;
|
||||
uniform vec3 ambientColor;
|
||||
uniform vec3 sunColor;
|
||||
uniform float cloudCoverage;
|
||||
uniform vec3 cloudBaseColor;
|
||||
uniform float cloudExposure;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Globals
|
||||
//-----------------------------------------------------------------------------
|
||||
// The per-color weighting to be used for luminance calculations in RGB order.
|
||||
const vec3 LUMINANCE_VECTOR = vec3(0.2125f, 0.7154f, 0.0721f);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Calculates the Rayleigh phase function
|
||||
float getRayleighPhase( float angle )
|
||||
{
|
||||
return 0.75 * ( 1.0 + pow( angle, 2.0 ) );
|
||||
}
|
||||
|
||||
// Returns the output rgb color given a texCoord and parameters it uses
|
||||
// for lighting calculation.
|
||||
vec3 ComputeIllumination( vec2 texCoord,
|
||||
vec3 vLightTS,
|
||||
vec3 vViewTS,
|
||||
vec3 vNormalTS )
|
||||
{
|
||||
//return noiseNormal;
|
||||
//return vNormalTS;
|
||||
|
||||
vec3 vLightTSAdj = vec3( -vLightTS.x, -vLightTS.y, vLightTS.z );
|
||||
|
||||
float dp = dot( vNormalTS, vLightTSAdj );
|
||||
|
||||
// Calculate the amount of illumination (lightTerm)...
|
||||
|
||||
// We do both a rim lighting effect and a halfLambertian lighting effect
|
||||
// and combine the result.
|
||||
float halfLambertTerm = clamp( pow( dp * 0.5 + 0.5, 1.0 ), 0.0, 1.0 );
|
||||
float rimLightTerm = pow( ( 1.0 - dp ), 1.0 );
|
||||
float lightTerm = clamp( halfLambertTerm * 1.0 + rimLightTerm * dp, 0.0, 1.0 );
|
||||
lightTerm *= 0.5;
|
||||
|
||||
// Use a simple RayleighPhase function to simulate single scattering towards
|
||||
// the camera.
|
||||
float angle = dot( vLightTS, vViewTS );
|
||||
lightTerm *= getRayleighPhase( angle );
|
||||
|
||||
// Combine terms and colors into the output color.
|
||||
//vec3 lightColor = ( lightTerm * sunColor * fOcclusionShadow ) + ambientColor;
|
||||
vec3 lightColor = mix( ambientColor, sunColor, lightTerm );
|
||||
//lightColor = mix( lightColor, ambientColor, cloudCoverage );
|
||||
vec3 finalColor = cloudBaseColor * lightColor;
|
||||
|
||||
return finalColor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// Normalize the interpolated vectors:
|
||||
vec3 vViewTS = normalize( vViewTS );
|
||||
vec3 vLightTS = normalize( vLightTS );
|
||||
|
||||
vec4 cResultColor = vec4( 0, 0, 0, 1 );
|
||||
|
||||
vec2 texSample = IN_texCoord12.xy;
|
||||
|
||||
vec4 noise1 = texture( normalHeightMap, IN_texCoord12.zw );
|
||||
noise1 = normalize( ( noise1 - 0.5 ) * 2.0 );
|
||||
//return noise1;
|
||||
|
||||
vec4 noise2 = texture( normalHeightMap, IN_texCoord34.xy );
|
||||
noise2 = normalize( ( noise2 - 0.5 ) * 2.0 );
|
||||
//return noise2;
|
||||
|
||||
vec3 noiseNormal = normalize( noise1 + noise2 ).xyz;
|
||||
//return vec4( noiseNormal, 1.0 );
|
||||
|
||||
float noiseHeight = noise1.a * noise2.a * ( cloudCoverage / 2.0 + 0.5 );
|
||||
|
||||
vec3 vNormalTS = normalize( texture( normalHeightMap, texSample ).xyz * 2.0 - 1.0 );
|
||||
vNormalTS += noiseNormal;
|
||||
vNormalTS = normalize( vNormalTS );
|
||||
|
||||
// Compute resulting color for the pixel:
|
||||
cResultColor.rgb = ComputeIllumination( texSample, vLightTS, vViewTS, vNormalTS );
|
||||
|
||||
float coverage = ( cloudCoverage - 0.5 ) * 2.0;
|
||||
cResultColor.a = texture( normalHeightMap, texSample ).a + coverage + noiseHeight;
|
||||
|
||||
if ( cloudCoverage > -1.0 )
|
||||
cResultColor.a /= 1.0 + coverage;
|
||||
|
||||
cResultColor.a = clamp( cResultColor.a * pow( saturate(cloudCoverage), 0.25 ), 0.0, 1.0 );
|
||||
|
||||
cResultColor.a = mix( cResultColor.a, 0.0, 1.0 - pow(IN_worldDist,2.0) );
|
||||
|
||||
OUT_col = hdrEncode(cResultColor);
|
||||
}
|
||||
106
Templates/BaseGame/game/core/shaders/gl/cloudLayerV.glsl
Normal file
106
Templates/BaseGame/game/core/shaders/gl/cloudLayerV.glsl
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "hlslCompat.glsl"
|
||||
|
||||
in vec4 vPosition;
|
||||
in vec3 vNormal;
|
||||
in vec3 vBinormal;
|
||||
in vec3 vTangent;
|
||||
in vec2 vTexCoord0;
|
||||
|
||||
out vec4 texCoord12;
|
||||
#define OUT_texCoord12 texCoord12
|
||||
out vec4 texCoord34;
|
||||
#define OUT_texCoord34 texCoord34
|
||||
out vec3 vLightTS; // light vector in tangent space, denormalized
|
||||
#define OUT_vLightTS vLightTS
|
||||
out vec3 vViewTS; // view vector in tangent space, denormalized
|
||||
#define OUT_vViewTS vViewTS
|
||||
out float worldDist;
|
||||
#define OUT_worldDist worldDist
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Uniforms
|
||||
//-----------------------------------------------------------------------------
|
||||
uniform mat4 modelview;
|
||||
uniform vec3 eyePosWorld;
|
||||
uniform vec3 sunVec;
|
||||
uniform vec2 texOffset0;
|
||||
uniform vec2 texOffset1;
|
||||
uniform vec2 texOffset2;
|
||||
uniform vec3 texScale;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
void main()
|
||||
{
|
||||
vec4 IN_pos = vPosition;
|
||||
vec3 IN_normal = vNormal;
|
||||
vec3 IN_binormal = vBinormal;
|
||||
vec3 IN_tangent = vTangent;
|
||||
vec2 IN_uv0 = vTexCoord0.st;
|
||||
|
||||
gl_Position = modelview * IN_pos;
|
||||
|
||||
// Offset the uv so we don't have a seam directly over our head.
|
||||
vec2 uv = IN_uv0 + vec2( 0.5, 0.5 );
|
||||
|
||||
OUT_texCoord12.xy = uv * texScale.x;
|
||||
OUT_texCoord12.xy += texOffset0;
|
||||
|
||||
OUT_texCoord12.zw = uv * texScale.y;
|
||||
OUT_texCoord12.zw += texOffset1;
|
||||
|
||||
OUT_texCoord34.xy = uv * texScale.z;
|
||||
OUT_texCoord34.xy += texOffset2;
|
||||
|
||||
OUT_texCoord34.z = IN_pos.z;
|
||||
OUT_texCoord34.w = 0.0;
|
||||
|
||||
// Transform the normal, tangent and binormal vectors from object space to
|
||||
// homogeneous projection space:
|
||||
vec3 vNormalWS = -IN_normal;
|
||||
vec3 vTangentWS = -IN_tangent;
|
||||
vec3 vBinormalWS = -IN_binormal;
|
||||
|
||||
// Compute position in world space:
|
||||
vec4 vPositionWS = IN_pos + vec4( eyePosWorld, 1 ); //tMul( IN_pos, objTrans );
|
||||
|
||||
// Compute and output the world view vector (unnormalized):
|
||||
vec3 vViewWS = eyePosWorld - vPositionWS.xyz;
|
||||
|
||||
// Compute denormalized light vector in world space:
|
||||
vec3 vLightWS = -sunVec;
|
||||
|
||||
// Normalize the light and view vectors and transform it to the IN_tangent space:
|
||||
mat3 mWorldToTangent = mat3( vTangentWS, vBinormalWS, vNormalWS );
|
||||
|
||||
// Propagate the view and the light vectors (in tangent space):
|
||||
OUT_vLightTS = vLightWS * mWorldToTangent;
|
||||
OUT_vViewTS = mWorldToTangent * vViewWS;
|
||||
|
||||
OUT_worldDist = clamp( pow( max( IN_pos.z, 0 ), 2 ), 0.0, 1.0 );
|
||||
|
||||
correctSSP(gl_Position);
|
||||
}
|
||||
186
Templates/BaseGame/game/core/shaders/gl/foliage.glsl
Normal file
186
Templates/BaseGame/game/core/shaders/gl/foliage.glsl
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// CornerId corresponds to this arrangement
|
||||
// from the perspective of the camera.
|
||||
//
|
||||
// 3 ---- 2
|
||||
// | |
|
||||
// 0 ---- 1
|
||||
//
|
||||
|
||||
#define MAX_COVERTYPES 8
|
||||
|
||||
uniform vec3 gc_camRight;
|
||||
uniform vec3 gc_camUp;
|
||||
uniform vec4 gc_typeRects[MAX_COVERTYPES];
|
||||
uniform vec2 gc_fadeParams;
|
||||
uniform vec2 gc_windDir;
|
||||
|
||||
// .x = gust length
|
||||
// .y = premultiplied simulation time and gust frequency
|
||||
// .z = gust strength
|
||||
uniform vec3 gc_gustInfo;
|
||||
|
||||
// .x = premultiplied simulation time and turbulance frequency
|
||||
// .y = turbulance strength
|
||||
uniform vec2 gc_turbInfo;
|
||||
|
||||
|
||||
const float sCornerRight[4] = float[]( -0.5, 0.5, 0.5, -0.5 );
|
||||
|
||||
const float sCornerUp[4] = float[]( 0, 0, 1, 1 );
|
||||
|
||||
const float sMovableCorner[4] = float[]( 0, 0, 1, 1 );
|
||||
|
||||
const vec2 sUVCornerExtent[4] = vec2[]
|
||||
(
|
||||
vec2( 0, 1 ),
|
||||
vec2( 1, 1 ),
|
||||
vec2( 1, 0 ),
|
||||
vec2( 0, 0 )
|
||||
);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// The following wind effect was derived from the GPU Gems 3 chapter...
|
||||
//
|
||||
// "Vegetation Procedural Animation and Shading in Crysis"
|
||||
// by Tiago Sousa, Crytek
|
||||
//
|
||||
|
||||
vec2 smoothCurve( vec2 x )
|
||||
{
|
||||
return x * x * ( 3.0 - 2.0 * x );
|
||||
}
|
||||
|
||||
vec2 triangleWave( vec2 x )
|
||||
{
|
||||
return abs( fract( x + 0.5 ) * 2.0 - 1.0 );
|
||||
}
|
||||
|
||||
vec2 smoothTriangleWave( vec2 x )
|
||||
{
|
||||
return smoothCurve( triangleWave( x ) );
|
||||
}
|
||||
|
||||
float windTurbulence( float bbPhase, float frequency, float strength )
|
||||
{
|
||||
// We create the input value for wave generation from the frequency and phase.
|
||||
vec2 waveIn = vec2( bbPhase + frequency );
|
||||
|
||||
// We use two square waves to generate the effect which
|
||||
// is then scaled by the overall strength.
|
||||
vec2 waves = ( fract( waveIn.xy * vec2( 1.975, 0.793 ) ) * 2.0 - 1.0 );
|
||||
waves = smoothTriangleWave( waves );
|
||||
|
||||
// Sum up the two waves into a single wave.
|
||||
return ( waves.x + waves.y ) * strength;
|
||||
}
|
||||
|
||||
vec2 windEffect( float bbPhase,
|
||||
vec2 windDirection,
|
||||
float gustLength,
|
||||
float gustFrequency,
|
||||
float gustStrength,
|
||||
float turbFrequency,
|
||||
float turbStrength )
|
||||
{
|
||||
// Calculate the ambient wind turbulence.
|
||||
float turbulence = windTurbulence( bbPhase, turbFrequency, turbStrength );
|
||||
|
||||
// We simulate the overall gust via a sine wave.
|
||||
float gustPhase = clamp( sin( ( bbPhase - gustFrequency ) / gustLength ) , 0.0, 1.0 );
|
||||
float gustOffset = ( gustPhase * gustStrength ) + ( ( 0.2 + gustPhase ) * turbulence );
|
||||
|
||||
// Return the final directional wind effect.
|
||||
return vec2(gustOffset) * windDirection.xy;
|
||||
}
|
||||
|
||||
void foliageProcessVert( inout vec3 position,
|
||||
inout vec4 diffuse,
|
||||
inout vec4 texCoord,
|
||||
inout vec3 normal,
|
||||
inout vec3 T,
|
||||
in vec3 eyePos )
|
||||
{
|
||||
// Assign the normal and tagent values.
|
||||
//normal = vec3( 0, 0, 1 );//cross( gc_camUp, gc_camRight );
|
||||
T = gc_camRight;
|
||||
|
||||
// Pull out local vars we need for work.
|
||||
int corner = int( ( diffuse.a * 255.0 ) + 0.5 );
|
||||
vec2 size = texCoord.xy;
|
||||
int type = int( texCoord.z );
|
||||
|
||||
// The billboarding is based on the camera direction.
|
||||
vec3 rightVec = gc_camRight * sCornerRight[corner];
|
||||
vec3 upVec = gc_camUp * sCornerUp[corner];
|
||||
|
||||
// Figure out the corner position.
|
||||
vec3 outPos = ( upVec * size.y ) + ( rightVec * size.x );
|
||||
float len = length( outPos.xyz );
|
||||
|
||||
// We derive the billboard phase used for wind calculations from its position.
|
||||
float bbPhase = dot( position.xyz, vec3( 1.0 ) );
|
||||
|
||||
// Get the overall wind gust and turbulence effects.
|
||||
vec3 wind;
|
||||
wind.xy = windEffect( bbPhase,
|
||||
gc_windDir,
|
||||
gc_gustInfo.x, gc_gustInfo.y, gc_gustInfo.z,
|
||||
gc_turbInfo.x, gc_turbInfo.y );
|
||||
wind.z = 0.0;
|
||||
|
||||
// Add the summed wind effect into the point.
|
||||
outPos.xyz += wind.xyz * texCoord.w;
|
||||
|
||||
// Do a simple spherical clamp to keep the foliage
|
||||
// from stretching too much by wind effect.
|
||||
outPos.xyz = normalize( outPos.xyz ) * len;
|
||||
|
||||
// Move the point into world space.
|
||||
position += outPos;
|
||||
|
||||
// Grab the uv set and setup the texture coord.
|
||||
vec4 uvSet = gc_typeRects[type];
|
||||
texCoord.x = uvSet.x + ( uvSet.z * sUVCornerExtent[corner].x );
|
||||
texCoord.y = uvSet.y + ( uvSet.w * sUVCornerExtent[corner].y );
|
||||
|
||||
// Animate the normal to get lighting changes
|
||||
// across the the wind swept foliage.
|
||||
//
|
||||
// TODO: Expose the 10x as a factor to control
|
||||
// how much the wind effects the lighting on the grass.
|
||||
//
|
||||
normal.xy += wind.xy * ( 10.0 * texCoord.w );
|
||||
normal = normalize( normal );
|
||||
|
||||
// Get the alpha fade value.
|
||||
|
||||
float fadeStart = gc_fadeParams.x;
|
||||
float fadeEnd = gc_fadeParams.y;
|
||||
float fadeRange = fadeEnd - fadeStart;
|
||||
|
||||
float dist = distance( eyePos, position.xyz ) - fadeStart;
|
||||
diffuse.a = 1.0 - clamp( dist / fadeRange, 0.0, 1.0 );
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Data
|
||||
//-----------------------------------------------------------------------------
|
||||
uniform sampler2D diffuseMap, alphaMap;
|
||||
uniform vec4 groundAlpha;
|
||||
|
||||
in vec4 color, groundAlphaCoeff;
|
||||
in vec2 outTexCoord, alphaLookup;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
void main()
|
||||
{
|
||||
vec4 alpha = texture(alphaMap, alphaLookup);
|
||||
OUT_col = color * texture(diffuseMap, outTexCoord);
|
||||
OUT_col.a = OUT_col.a * min(alpha, groundAlpha + groundAlphaCoeff.x).x;
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Data
|
||||
//-----------------------------------------------------------------------------
|
||||
in vec4 vPosition;
|
||||
in vec3 vNormal;
|
||||
in vec4 vColor;
|
||||
in vec2 vTexCoord0;
|
||||
in vec2 vTexCoord1;
|
||||
in vec2 vTexCoord2;
|
||||
|
||||
uniform mat4 projection, world;
|
||||
uniform vec3 CameraPos;
|
||||
uniform float GlobalSwayPhase, SwayMagnitudeSide, SwayMagnitudeFront,
|
||||
GlobalLightPhase, LuminanceMagnitude, LuminanceMidpoint, DistanceRange;
|
||||
|
||||
out vec4 color, groundAlphaCoeff;
|
||||
out vec2 outTexCoord, alphaLookup;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
void main()
|
||||
{
|
||||
// Init a transform matrix to be used in the following steps
|
||||
mat4 trans = mat4(0.0);
|
||||
trans[0][0] = 1.0;
|
||||
trans[1][1] = 1.0;
|
||||
trans[2][2] = 1.0;
|
||||
trans[3][3] = 1.0;
|
||||
trans[3][0] = vPosition.x;
|
||||
trans[3][1] = vPosition.y;
|
||||
trans[3][2] = vPosition.z;
|
||||
|
||||
// Billboard transform * world matrix
|
||||
mat4 o = world;
|
||||
o = o * trans;
|
||||
|
||||
// Keep only the up axis result and position transform.
|
||||
// This gives us "cheating" cylindrical billboarding.
|
||||
o[0][0] = 1.0;
|
||||
o[0][1] = 0.0;
|
||||
o[0][2] = 0.0;
|
||||
o[0][3] = 0.0;
|
||||
o[1][0] = 0.0;
|
||||
o[1][1] = 1.0;
|
||||
o[1][2] = 0.0;
|
||||
o[1][3] = 0.0;
|
||||
|
||||
// Handle sway. Sway is stored in a texture coord. The x coordinate is the sway phase multiplier,
|
||||
// the y coordinate determines if this vertex actually sways or not.
|
||||
float xSway, ySway;
|
||||
float wavePhase = GlobalSwayPhase * vTexCoord1.x;
|
||||
ySway = sin(wavePhase);
|
||||
xSway = cos(wavePhase);
|
||||
xSway = xSway * vTexCoord1.y * SwayMagnitudeSide;
|
||||
ySway = ySway * vTexCoord1.y * SwayMagnitudeFront;
|
||||
vec4 p;
|
||||
p = o * vec4(vNormal.x + xSway, ySway, vNormal.z, 1.0);
|
||||
|
||||
// Project the point
|
||||
gl_Position = projection * p;
|
||||
|
||||
// Lighting
|
||||
float Luminance = LuminanceMidpoint + LuminanceMagnitude * cos(GlobalLightPhase + vNormal.y);
|
||||
|
||||
// Alpha
|
||||
vec3 worldPos = vec3(vPosition.x, vPosition.y, vPosition.z);
|
||||
float alpha = abs(distance(worldPos, CameraPos)) / DistanceRange;
|
||||
alpha = clamp(alpha, 0.0, 1.0); //pass it through
|
||||
|
||||
alphaLookup = vec2(alpha, 0.0);
|
||||
bool alphaCoeff = bool(vNormal.z);
|
||||
groundAlphaCoeff = vec4(float(alphaCoeff));
|
||||
outTexCoord = vTexCoord0.st;
|
||||
color = vec4(Luminance, Luminance, Luminance, 1.0);
|
||||
gl_Position.y *= -1;
|
||||
}
|
||||
39
Templates/BaseGame/game/core/shaders/gl/guiMaterialV.glsl
Normal file
39
Templates/BaseGame/game/core/shaders/gl/guiMaterialV.glsl
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
in vec4 vPosition;
|
||||
in vec2 vTexCoord0;
|
||||
|
||||
uniform mat4x4 modelview;
|
||||
|
||||
out vec4 hpos;
|
||||
out vec2 uv0;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
hpos = vec4( modelview * vPosition );
|
||||
gl_Position = hpos;
|
||||
|
||||
uv0 = vTexCoord0.st;
|
||||
gl_Position.y *= -1;
|
||||
}
|
||||
103
Templates/BaseGame/game/core/shaders/gl/hlslCompat.glsl
Normal file
103
Templates/BaseGame/game/core/shaders/gl/hlslCompat.glsl
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// These are some simple wrappers for simple
|
||||
// HLSL compatibility.
|
||||
|
||||
#define float4 vec4
|
||||
#define float3 vec3
|
||||
#define float2 vec2
|
||||
|
||||
#define half float
|
||||
#define half2 vec2
|
||||
#define half3 vec3
|
||||
#define half4 vec4
|
||||
|
||||
#define float4x4 mat4
|
||||
#define float3x3 mat3
|
||||
#define float2x2 mat2
|
||||
|
||||
#define texCUBE texture
|
||||
#define tex2D texture
|
||||
#define tex1D texture
|
||||
#define tex2Dproj textureProj
|
||||
#define tex2Dlod( sampler, texCoord ) textureLod(sampler, texCoord.xy, texCoord.w)
|
||||
|
||||
#define samplerCUBE samplerCube
|
||||
|
||||
#define frac fract
|
||||
|
||||
#define lerp mix
|
||||
|
||||
void tSetMatrixRow(inout float3x3 m, int row, float3 value)
|
||||
{
|
||||
m[0][row] = value.x;
|
||||
m[1][row] = value.y;
|
||||
m[2][row] = value.z;
|
||||
}
|
||||
|
||||
void tSetMatrixRow(inout float4x4 m, int row, float4 value)
|
||||
{
|
||||
m[0][row] = value.x;
|
||||
m[1][row] = value.y;
|
||||
m[2][row] = value.z;
|
||||
m[3][row] = value.w;
|
||||
}
|
||||
|
||||
#define tGetMatrix3Row(matrix, row) float3(matrix[0][row], matrix[1][row], matrix[2][row])
|
||||
#define tGetMatrix4Row(matrix, row) float4(matrix[0][row], matrix[1][row], matrix[2][row], matrix[3][row])
|
||||
|
||||
float3x3 float4x4to3x3(float4x4 m)
|
||||
{
|
||||
return float3x3( vec3(m[0]).xyz, m[1].xyz, m[2].xyz);
|
||||
}
|
||||
|
||||
float3x3 float4x4to3x3_(float4x4 m)
|
||||
{
|
||||
return float3x3( vec3(m[0]), m[1].xyz, m[2].xyz);
|
||||
}
|
||||
|
||||
mat4 mat4FromRow( float r0c0, float r0c1, float r0c2, float r0c3,
|
||||
float r1c0, float r1c1, float r1c2, float r1c3,
|
||||
float r2c0, float r2c1, float r2c2, float r2c3,
|
||||
float r3c0, float r3c1, float r3c2, float r3c3 )
|
||||
{
|
||||
return mat4( r0c0, r1c0, r2c0, r3c0,
|
||||
r0c1, r1c1, r2c1, r3c1,
|
||||
r0c2, r1c2, r2c2, r3c2,
|
||||
r0c3, r1c3, r2c3, r3c3 );
|
||||
}
|
||||
|
||||
|
||||
#define saturate( val ) clamp( val, 0.0, 1.0 )
|
||||
|
||||
#define round( n ) (sign( n ) * floor( abs( n ) + 0.5 ))
|
||||
|
||||
#define tMul(a, b) (a*b)
|
||||
|
||||
#define inversesqrt( n ) inversesqrt( n )
|
||||
|
||||
#define correctSSP(vec) vec.y *= -1
|
||||
|
||||
#ifdef TORQUE_PIXEL_SHADER
|
||||
void clip(float a) { if(a < 0) discard;}
|
||||
#endif
|
||||
161
Templates/BaseGame/game/core/shaders/gl/imposter.glsl
Normal file
161
Templates/BaseGame/game/core/shaders/gl/imposter.glsl
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "torque.glsl"
|
||||
|
||||
|
||||
#define IMPOSTER_MAX_UVS 64
|
||||
|
||||
|
||||
void imposter_v(
|
||||
// These parameters usually come from the vertex.
|
||||
vec3 center,
|
||||
int corner,
|
||||
float halfSize,
|
||||
vec3 imposterUp,
|
||||
vec3 imposterRight,
|
||||
|
||||
// These are from the imposter shader constant.
|
||||
int numEquatorSteps,
|
||||
int numPolarSteps,
|
||||
float polarAngle,
|
||||
bool includePoles,
|
||||
|
||||
// Other shader constants.
|
||||
vec3 camPos,
|
||||
vec4 uvs[IMPOSTER_MAX_UVS],
|
||||
|
||||
// The outputs of this function.
|
||||
out vec3 outWsPosition,
|
||||
out vec2 outTexCoord,
|
||||
out mat3 outWorldToTangent
|
||||
)
|
||||
{
|
||||
|
||||
float M_HALFPI_F = 1.57079632679489661923;
|
||||
float M_PI_F = 3.14159265358979323846;
|
||||
float M_2PI_F = 6.28318530717958647692;
|
||||
|
||||
|
||||
float sCornerRight[4];// = float[]( -1.0, 1.0, 1.0, -1.0 );
|
||||
sCornerRight[0] = -1.0;
|
||||
sCornerRight[1] = 1.0;
|
||||
sCornerRight[2] = 1.0;
|
||||
sCornerRight[3] = -1.0;
|
||||
float sCornerUp[4];// = float[]( -1.0, -1.0, 1.0, 1.0 );
|
||||
sCornerUp[0] = -1.0;
|
||||
sCornerUp[1] = -1.0;
|
||||
sCornerUp[2] = 1.0;
|
||||
sCornerUp[3] = 1.0;
|
||||
vec2 sUVCornerExtent[4];// = vec2[](vec2( 0.0, 1.0 ), vec2( 1.0, 1.0 ), vec2( 1.0, 0.0 ), vec2( 0.0, 0.0 ));
|
||||
sUVCornerExtent[0] = vec2( 0.0, 1.0 );
|
||||
sUVCornerExtent[1] = vec2( 1.0, 1.0 );
|
||||
sUVCornerExtent[2] = vec2( 1.0, 0.0 );
|
||||
sUVCornerExtent[3] = vec2( 0.0, 0.0 );
|
||||
|
||||
// TODO: This could all be calculated on the CPU.
|
||||
float equatorStepSize = M_2PI_F / float( numEquatorSteps );
|
||||
float equatorHalfStep = ( equatorStepSize / 2.0 ) - 0.0001;
|
||||
float polarStepSize = M_PI_F / float( numPolarSteps );
|
||||
float polarHalfStep = ( polarStepSize / 2.0 ) - 0.0001;
|
||||
|
||||
// The vector between the camera and the billboard.
|
||||
vec3 lookVec = normalize( camPos - center );
|
||||
|
||||
// Generate the camera up and right vectors from
|
||||
// the object transform and camera forward.
|
||||
vec3 camUp = imposterUp;
|
||||
vec3 camRight = cross( -lookVec, camUp );
|
||||
|
||||
// The billboarding is based on the camera directions.
|
||||
vec3 rightVec = camRight * sCornerRight[corner];
|
||||
vec3 upVec = camUp * sCornerUp[corner];
|
||||
|
||||
float lookPitch = acos( dot( imposterUp, lookVec ) );
|
||||
|
||||
// First check to see if we need to render the top billboard.
|
||||
int index;
|
||||
/*
|
||||
if ( includePoles && ( lookPitch < polarAngle || lookPitch > sPi - polarAngle ) )
|
||||
{
|
||||
index = numEquatorSteps * 3;
|
||||
|
||||
// When we render the top/bottom billboard we always use
|
||||
// a fixed vector that matches the rotation of the object.
|
||||
rightVec = vec3( 1, 0, 0 ) * sCornerRight[corner];
|
||||
upVec = vec3( 0, 1, 0 ) * sCornerUp[corner];
|
||||
|
||||
if ( lookPitch > sPi - polarAngle )
|
||||
{
|
||||
upVec = -upVec;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
// Calculate the rotation around the z axis then add the
|
||||
// equator half step. This gets the images to switch a
|
||||
// half step before the captured angle is met.
|
||||
float lookAzimuth = atan( lookVec.y, lookVec.x );
|
||||
float azimuth = atan( imposterRight.y, imposterRight.x );
|
||||
float rotZ = ( lookAzimuth - azimuth ) + equatorHalfStep;
|
||||
|
||||
// The y rotation is calculated from the look vector and
|
||||
// the object up vector.
|
||||
float rotY = lookPitch - polarHalfStep;
|
||||
|
||||
// TODO: How can we do this without conditionals?
|
||||
// Normalize the result to 0 to 2PI.
|
||||
if ( rotZ < 0.0 )
|
||||
rotZ += M_2PI_F;
|
||||
if ( rotZ > M_2PI_F )
|
||||
rotZ -= M_2PI_F;
|
||||
if ( rotY < 0.0 )
|
||||
rotY += M_2PI_F;
|
||||
if ( rotY > M_PI_F ) // Not M_2PI_F?
|
||||
rotY -= M_2PI_F;
|
||||
|
||||
float polarIdx = round( abs( rotY ) / polarStepSize );
|
||||
|
||||
// Get the index to the start of the right polar
|
||||
// images for this viewing angle.
|
||||
int numPolarOffset = int( float( numEquatorSteps ) * polarIdx );
|
||||
|
||||
// Calculate the final image index for lookup
|
||||
// of the texture coords.
|
||||
index = int( rotZ / equatorStepSize ) + numPolarOffset;
|
||||
}
|
||||
|
||||
// Generate the final world space position.
|
||||
outWsPosition = center + ( upVec * halfSize ) + ( rightVec * halfSize );
|
||||
|
||||
// Grab the uv set and setup the texture coord.
|
||||
vec4 uvSet = uvs[index];
|
||||
outTexCoord.x = uvSet.x + ( uvSet.z * sUVCornerExtent[corner].x );
|
||||
outTexCoord.y = uvSet.y + ( uvSet.w * sUVCornerExtent[corner].y );
|
||||
|
||||
// Needed for normal mapping and lighting.
|
||||
outWorldToTangent[0] = vec3( 1, 0, 0 );
|
||||
outWorldToTangent[1] = vec3( 0, 1, 0 );
|
||||
outWorldToTangent[2] = vec3( 0, 0, -1 );
|
||||
}
|
||||
249
Templates/BaseGame/game/core/shaders/gl/lighting.glsl
Normal file
249
Templates/BaseGame/game/core/shaders/gl/lighting.glsl
Normal file
|
|
@ -0,0 +1,249 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "./torque.glsl"
|
||||
|
||||
#ifndef TORQUE_SHADERGEN
|
||||
|
||||
// These are the uniforms used by most lighting shaders.
|
||||
|
||||
uniform vec4 inLightPos[3];
|
||||
uniform vec4 inLightInvRadiusSq;
|
||||
uniform vec4 inLightColor[4];
|
||||
|
||||
#ifndef TORQUE_BL_NOSPOTLIGHT
|
||||
uniform vec4 inLightSpotDir[3];
|
||||
uniform vec4 inLightSpotAngle;
|
||||
uniform vec4 inLightSpotFalloff;
|
||||
#endif
|
||||
|
||||
uniform vec4 ambient;
|
||||
#define ambientCameraFactor 0.3
|
||||
uniform float specularPower;
|
||||
uniform vec4 specularColor;
|
||||
|
||||
#endif // !TORQUE_SHADERGEN
|
||||
|
||||
|
||||
void compute4Lights( vec3 wsView,
|
||||
vec3 wsPosition,
|
||||
vec3 wsNormal,
|
||||
vec4 shadowMask,
|
||||
|
||||
#ifdef TORQUE_SHADERGEN
|
||||
|
||||
vec4 inLightPos[3],
|
||||
vec4 inLightInvRadiusSq,
|
||||
vec4 inLightColor[4],
|
||||
vec4 inLightSpotDir[3],
|
||||
vec4 inLightSpotAngle,
|
||||
vec4 inLightSpotFalloff,
|
||||
float specularPower,
|
||||
vec4 specularColor,
|
||||
|
||||
#endif // TORQUE_SHADERGEN
|
||||
|
||||
out vec4 outDiffuse,
|
||||
out vec4 outSpecular )
|
||||
{
|
||||
// NOTE: The light positions and spotlight directions
|
||||
// are stored in SoA order, so inLightPos[0] is the
|
||||
// x coord for all 4 lights... inLightPos[1] is y... etc.
|
||||
//
|
||||
// This is the key to fully utilizing the vector units and
|
||||
// saving a huge amount of instructions.
|
||||
//
|
||||
// For example this change saved more than 10 instructions
|
||||
// over a simple for loop for each light.
|
||||
|
||||
int i;
|
||||
|
||||
vec4 lightVectors[3];
|
||||
for ( i = 0; i < 3; i++ )
|
||||
lightVectors[i] = wsPosition[i] - inLightPos[i];
|
||||
|
||||
vec4 squareDists = vec4(0);
|
||||
for ( i = 0; i < 3; i++ )
|
||||
squareDists += lightVectors[i] * lightVectors[i];
|
||||
|
||||
// Accumulate the dot product between the light
|
||||
// vector and the normal.
|
||||
//
|
||||
// The normal is negated because it faces away from
|
||||
// the surface and the light faces towards the
|
||||
// surface... this keeps us from needing to flip
|
||||
// the light vector direction which complicates
|
||||
// the spot light calculations.
|
||||
//
|
||||
// We normalize the result a little later.
|
||||
//
|
||||
vec4 nDotL = vec4(0);
|
||||
for ( i = 0; i < 3; i++ )
|
||||
nDotL += lightVectors[i] * -wsNormal[i];
|
||||
|
||||
vec4 rDotL = vec4(0);
|
||||
#ifndef TORQUE_BL_NOSPECULAR
|
||||
|
||||
// We're using the Phong specular reflection model
|
||||
// here where traditionally Torque has used Blinn-Phong
|
||||
// which has proven to be more accurate to real materials.
|
||||
//
|
||||
// We do so because its cheaper as do not need to
|
||||
// calculate the half angle for all 4 lights.
|
||||
//
|
||||
// Advanced Lighting still uses Blinn-Phong, but the
|
||||
// specular reconstruction it does looks fairly similar
|
||||
// to this.
|
||||
//
|
||||
vec3 R = reflect( wsView, -wsNormal );
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
rDotL += lightVectors[i] * R[i];
|
||||
|
||||
#endif
|
||||
|
||||
// Normalize the dots.
|
||||
//
|
||||
// Notice we're using the half type here to get a
|
||||
// much faster sqrt via the rsq_pp instruction at
|
||||
// the loss of some precision.
|
||||
//
|
||||
// Unless we have some extremely large point lights
|
||||
// i don't believe the precision loss will matter.
|
||||
//
|
||||
half4 correction = half4(inversesqrt( squareDists ));
|
||||
nDotL = saturate( nDotL * correction );
|
||||
rDotL = clamp( rDotL * correction, 0.00001, 1.0 );
|
||||
|
||||
// First calculate a simple point light linear
|
||||
// attenuation factor.
|
||||
//
|
||||
// If this is a directional light the inverse
|
||||
// radius should be greater than the distance
|
||||
// causing the attenuation to have no affect.
|
||||
//
|
||||
vec4 atten = saturate( 1.0 - ( squareDists * inLightInvRadiusSq ) );
|
||||
|
||||
#ifndef TORQUE_BL_NOSPOTLIGHT
|
||||
|
||||
// The spotlight attenuation factor. This is really
|
||||
// fast for what it does... 6 instructions for 4 spots.
|
||||
|
||||
vec4 spotAtten = vec4(0);
|
||||
for ( i = 0; i < 3; i++ )
|
||||
spotAtten += lightVectors[i] * inLightSpotDir[i];
|
||||
|
||||
vec4 cosAngle = ( spotAtten * correction ) - inLightSpotAngle;
|
||||
atten *= saturate( cosAngle * inLightSpotFalloff );
|
||||
|
||||
#endif
|
||||
|
||||
// Finally apply the shadow masking on the attenuation.
|
||||
atten *= shadowMask;
|
||||
|
||||
// Get the final light intensity.
|
||||
vec4 intensity = nDotL * atten;
|
||||
|
||||
// Combine the light colors for output.
|
||||
outDiffuse = vec4(0);
|
||||
for ( i = 0; i < 4; i++ )
|
||||
outDiffuse += intensity[i] * inLightColor[i];
|
||||
|
||||
// Output the specular power.
|
||||
vec4 specularIntensity = pow( rDotL, vec4(specularPower) ) * atten;
|
||||
|
||||
// Apply the per-light specular attenuation.
|
||||
vec4 specular = vec4(0,0,0,1);
|
||||
for ( i = 0; i < 4; i++ )
|
||||
specular += vec4( inLightColor[i].rgb * inLightColor[i].a * specularIntensity[i], 1 );
|
||||
|
||||
// Add the final specular intensity values together
|
||||
// using a single dot product operation then get the
|
||||
// final specular lighting color.
|
||||
outSpecular = specularColor * specular;
|
||||
}
|
||||
|
||||
|
||||
// This value is used in AL as a constant power to raise specular values
|
||||
// to, before storing them into the light info buffer. The per-material
|
||||
// specular value is then computer by using the integer identity of
|
||||
// exponentiation:
|
||||
//
|
||||
// (a^m)^n = a^(m*n)
|
||||
//
|
||||
// or
|
||||
//
|
||||
// (specular^constSpecular)^(matSpecular/constSpecular) = specular^(matSpecular*constSpecular)
|
||||
//
|
||||
#define AL_ConstantSpecularPower 12.0f
|
||||
|
||||
/// The specular calculation used in Advanced 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.
|
||||
///
|
||||
float AL_CalcSpecular( vec3 toLight, vec3 normal, vec3 toEye )
|
||||
{
|
||||
// (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);
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "torque.glsl"
|
||||
#include "hlslCompat.glsl"
|
||||
|
||||
in vec4 offscreenPos;
|
||||
in vec4 backbufferPos;
|
||||
|
||||
#define IN_offscreenPos offscreenPos
|
||||
#define IN_backbufferPos backbufferPos
|
||||
|
||||
uniform sampler2D colorSource;
|
||||
uniform vec4 offscreenTargetParams;
|
||||
|
||||
#ifdef TORQUE_LINEAR_DEPTH
|
||||
#define REJECT_EDGES
|
||||
uniform sampler2D edgeSource;
|
||||
uniform vec4 edgeTargetParams;
|
||||
#endif
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Off-screen particle source screenspace position in XY
|
||||
// Back-buffer screenspace position in ZW
|
||||
vec4 ssPos = vec4(offscreenPos.xy / offscreenPos.w, backbufferPos.xy / backbufferPos.w);
|
||||
|
||||
vec4 uvScene = ( ssPos + 1.0 ) / 2.0;
|
||||
uvScene.yw = 1.0 - uvScene.yw;
|
||||
uvScene.xy = viewportCoordToRenderTarget(uvScene.xy, offscreenTargetParams);
|
||||
|
||||
#ifdef REJECT_EDGES
|
||||
// Cut out particles along the edges, this will create the stencil mask
|
||||
uvScene.zw = viewportCoordToRenderTarget(uvScene.zw, edgeTargetParams);
|
||||
float edge = texture( edgeSource, uvScene.zw ).r;
|
||||
clip( -edge );
|
||||
#endif
|
||||
|
||||
// Sample offscreen target and return
|
||||
OUT_col = texture( colorSource, uvScene.xy );
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "hlslCompat.glsl"
|
||||
|
||||
in vec2 vTexCoord0;
|
||||
#define uvCoord vTexCoord0
|
||||
|
||||
out vec4 offscreenPos;
|
||||
out vec4 backbufferPos;
|
||||
|
||||
#define OUT_hpos gl_Position
|
||||
#define OUT_offscreenPos offscreenPos
|
||||
#define OUT_backbufferPos backbufferPos
|
||||
|
||||
uniform vec4 screenRect; // point, extent
|
||||
|
||||
void main()
|
||||
{
|
||||
OUT_hpos = vec4(uvCoord.xy, 1.0, 1.0);
|
||||
OUT_hpos.xy *= screenRect.zw;
|
||||
OUT_hpos.xy += screenRect.xy;
|
||||
|
||||
OUT_backbufferPos = OUT_hpos;
|
||||
OUT_offscreenPos = OUT_hpos;
|
||||
|
||||
correctSSP(gl_Position);
|
||||
}
|
||||
|
||||
113
Templates/BaseGame/game/core/shaders/gl/particlesP.glsl
Normal file
113
Templates/BaseGame/game/core/shaders/gl/particlesP.glsl
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "torque.glsl"
|
||||
#include "hlslCompat.glsl"
|
||||
|
||||
// With advanced lighting we get soft particles.
|
||||
#ifdef TORQUE_LINEAR_DEPTH
|
||||
#define SOFTPARTICLES
|
||||
#endif
|
||||
|
||||
#ifdef SOFTPARTICLES
|
||||
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
uniform float oneOverSoftness;
|
||||
uniform float oneOverFar;
|
||||
uniform sampler2D prepassTex;
|
||||
//uniform vec3 vEye;
|
||||
uniform vec4 prePassTargetParams;
|
||||
#endif
|
||||
|
||||
#define CLIP_Z // TODO: Make this a proper macro
|
||||
|
||||
in vec4 color;
|
||||
in vec2 uv0;
|
||||
in vec4 pos;
|
||||
|
||||
#define IN_color color
|
||||
#define IN_uv0 uv0
|
||||
#define IN_pos pos
|
||||
|
||||
uniform sampler2D diffuseMap;
|
||||
|
||||
uniform sampler2D paraboloidLightMap;
|
||||
|
||||
vec4 lmSample( vec3 nrm )
|
||||
{
|
||||
bool calcBack = (nrm.z < 0.0);
|
||||
if ( calcBack )
|
||||
nrm.z = nrm.z * -1.0;
|
||||
|
||||
vec2 lmCoord;
|
||||
lmCoord.x = (nrm.x / (2*(1 + nrm.z))) + 0.5;
|
||||
lmCoord.y = 1-((nrm.y / (2*(1 + nrm.z))) + 0.5);
|
||||
|
||||
|
||||
// If this is the back, offset in the atlas
|
||||
if ( calcBack )
|
||||
lmCoord.x += 1.0;
|
||||
|
||||
// Atlasing front and back maps, so scale
|
||||
lmCoord.x *= 0.5;
|
||||
|
||||
return texture(paraboloidLightMap, lmCoord);
|
||||
}
|
||||
|
||||
|
||||
uniform float alphaFactor;
|
||||
uniform float alphaScale;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
float softBlend = 1;
|
||||
|
||||
#ifdef SOFTPARTICLES
|
||||
vec2 tc = IN_pos.xy * vec2(1.0, -1.0) / IN_pos.w;
|
||||
tc = viewportCoordToRenderTarget(saturate( ( tc + 1.0 ) * 0.5 ), prePassTargetParams);
|
||||
|
||||
float sceneDepth = prepassUncondition( prepassTex, tc ).w;
|
||||
float depth = IN_pos.w * oneOverFar;
|
||||
float diff = sceneDepth - depth;
|
||||
#ifdef CLIP_Z
|
||||
// If drawing offscreen, this acts as the depth test, since we don't line up with the z-buffer
|
||||
// When drawing high-res, though, we want to be able to take advantage of hi-z
|
||||
// so this is #ifdef'd out
|
||||
//clip(diff);
|
||||
#endif
|
||||
softBlend = saturate( diff * oneOverSoftness );
|
||||
#endif
|
||||
|
||||
vec4 diffuse = texture( diffuseMap, IN_uv0 );
|
||||
|
||||
//OUT_col = vec4( lmSample(vec3(0, 0, -1)).rgb, IN_color.a * diffuse.a * softBlend * alphaScale);
|
||||
|
||||
// Scale output color by the alpha factor (turn LerpAlpha into pre-multiplied alpha)
|
||||
vec3 colorScale = ( alphaFactor < 0.0 ? IN_color.rgb * diffuse.rgb : vec3( alphaFactor > 0.0 ? IN_color.a * diffuse.a * alphaFactor * softBlend : softBlend ) );
|
||||
|
||||
OUT_col = hdrEncode( vec4( IN_color.rgb * diffuse.rgb * colorScale,
|
||||
IN_color.a * diffuse.a * softBlend * alphaScale ) );
|
||||
}
|
||||
|
||||
54
Templates/BaseGame/game/core/shaders/gl/particlesV.glsl
Normal file
54
Templates/BaseGame/game/core/shaders/gl/particlesV.glsl
Normal 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 "hlslCompat.glsl"
|
||||
|
||||
in vec4 vPosition;
|
||||
in vec4 vColor;
|
||||
in vec2 vTexCoord0;
|
||||
|
||||
#define In_pos vPosition
|
||||
#define In_color vColor
|
||||
#define In_uv0 vTexCoord0
|
||||
|
||||
out vec4 color;
|
||||
out vec2 uv0;
|
||||
out vec4 pos;
|
||||
|
||||
#define OUT_hpos gl_Position
|
||||
#define OUT_color color
|
||||
#define OUT_uv0 uv0
|
||||
#define OUT_pos pos
|
||||
|
||||
uniform mat4 modelViewProj;
|
||||
uniform mat4 fsModelViewProj;
|
||||
|
||||
void main()
|
||||
{
|
||||
OUT_hpos = tMul( modelViewProj, In_pos );
|
||||
OUT_pos = tMul( fsModelViewProj, In_pos );
|
||||
OUT_color = In_color;
|
||||
OUT_uv0 = In_uv0;
|
||||
|
||||
correctSSP(gl_Position);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Data
|
||||
//-----------------------------------------------------------------------------
|
||||
uniform sampler2D diffuseMap, refractMap, bumpMap;
|
||||
uniform vec4 shadeColor;
|
||||
|
||||
in vec2 TEX0;
|
||||
in vec4 TEX1;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Fade edges of axis for texcoord passed in
|
||||
//-----------------------------------------------------------------------------
|
||||
float fadeAxis( float val )
|
||||
{
|
||||
// Fades from 1.0 to 0.0 when less than 0.1
|
||||
float fadeLow = clamp( val * 10.0, 0.0, 1.0 );
|
||||
|
||||
// Fades from 1.0 to 0.0 when greater than 0.9
|
||||
float fadeHigh = 1.0 - clamp( (val - 0.9) * 10.0, 0.0, 1.0 );
|
||||
|
||||
return fadeLow * fadeHigh;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
void main()
|
||||
{
|
||||
vec3 bumpNorm = texture( bumpMap, TEX0 ).rgb * 2.0 - 1.0;
|
||||
vec2 offset = vec2( bumpNorm.x, bumpNorm.y );
|
||||
vec4 texIndex = TEX1;
|
||||
|
||||
// The fadeVal is used to "fade" the distortion at the edges of the screen.
|
||||
// This is done so it won't sample the reflection texture out-of-bounds and create artifacts
|
||||
// Note - this can be done more efficiently with a texture lookup
|
||||
float fadeVal = fadeAxis( texIndex.x / texIndex.w ) * fadeAxis( texIndex.y / texIndex.w );
|
||||
|
||||
const float distortion = 0.2;
|
||||
texIndex.xy += offset * distortion * fadeVal;
|
||||
|
||||
vec4 diffuseColor = texture( diffuseMap, TEX0 );
|
||||
vec4 reflectColor = textureProj( refractMap, texIndex );
|
||||
|
||||
OUT_col = diffuseColor + reflectColor * diffuseColor.a;
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Data
|
||||
//-----------------------------------------------------------------------------
|
||||
in vec4 vPosition;
|
||||
in vec2 vTexCoord0;
|
||||
|
||||
uniform mat4 modelview;
|
||||
|
||||
out vec2 TEX0;
|
||||
out vec4 TEX1;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
void main()
|
||||
{
|
||||
mat4 texGenTest = mat4(0.5, 0.0, 0.0, 0.0,
|
||||
0.0, -0.5, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.5, 0.5, 0.0, 1.0);
|
||||
|
||||
gl_Position = modelview * vPosition;
|
||||
|
||||
TEX0 = vTexCoord0.st;
|
||||
|
||||
TEX1 = texGenTest * gl_Position;
|
||||
TEX1.y = -TEX1.y;
|
||||
gl_Position.y *= -1;
|
||||
}
|
||||
43
Templates/BaseGame/game/core/shaders/gl/planarReflectP.glsl
Normal file
43
Templates/BaseGame/game/core/shaders/gl/planarReflectP.glsl
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Data
|
||||
//-----------------------------------------------------------------------------
|
||||
uniform sampler2D diffuseMap, refractMap;
|
||||
uniform vec4 shadeColor;
|
||||
|
||||
in vec2 TEX0;
|
||||
in vec4 TEX1;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
void main()
|
||||
{
|
||||
vec4 diffuseColor = texture( diffuseMap, TEX0 );
|
||||
vec4 reflectColor = textureProj( refractMap, TEX1 );
|
||||
|
||||
OUT_col = diffuseColor + reflectColor * diffuseColor.a;
|
||||
}
|
||||
51
Templates/BaseGame/game/core/shaders/gl/planarReflectV.glsl
Normal file
51
Templates/BaseGame/game/core/shaders/gl/planarReflectV.glsl
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Data
|
||||
//-----------------------------------------------------------------------------
|
||||
in vec4 vPosition;
|
||||
in vec2 vTexCoord0;
|
||||
|
||||
uniform mat4 modelview;
|
||||
|
||||
out vec2 TEX0;
|
||||
out vec4 TEX1;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
void main()
|
||||
{
|
||||
mat4 texGenTest = mat4(0.5, 0.0, 0.0, 0.0,
|
||||
0.0, -0.5, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.5, 0.5, 0.0, 1.0);
|
||||
|
||||
gl_Position = modelview * vPosition;
|
||||
|
||||
TEX0 = vTexCoord0;
|
||||
|
||||
TEX1 = texGenTest * gl_Position;
|
||||
TEX1.y = -TEX1.y;
|
||||
|
||||
}
|
||||
39
Templates/BaseGame/game/core/shaders/gl/precipP.glsl
Normal file
39
Templates/BaseGame/game/core/shaders/gl/precipP.glsl
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Data
|
||||
//-----------------------------------------------------------------------------
|
||||
uniform sampler2D diffuseMap;
|
||||
|
||||
in vec4 color;
|
||||
in vec2 texCoord;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
void main()
|
||||
{
|
||||
OUT_col = texture(diffuseMap, texCoord) * color;
|
||||
}
|
||||
54
Templates/BaseGame/game/core/shaders/gl/precipV.glsl
Normal file
54
Templates/BaseGame/game/core/shaders/gl/precipV.glsl
Normal 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Data
|
||||
//-----------------------------------------------------------------------------
|
||||
in vec4 vPosition;
|
||||
in vec2 vTexCoord0;
|
||||
|
||||
uniform mat4 modelview;
|
||||
uniform vec3 cameraPos, ambient;
|
||||
uniform vec2 fadeStartEnd;
|
||||
|
||||
out vec4 color;
|
||||
out vec2 texCoord;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
void main()
|
||||
{
|
||||
gl_Position = modelview * vPosition;
|
||||
texCoord = vTexCoord0.st;
|
||||
color = vec4( ambient.r, ambient.g, ambient.b, 1.0 );
|
||||
|
||||
// Do we need to do a distance fade?
|
||||
if ( fadeStartEnd.x < fadeStartEnd.y )
|
||||
{
|
||||
|
||||
float distance = length( cameraPos - vPosition.xyz );
|
||||
color.a = abs( clamp( ( distance - fadeStartEnd.x ) / ( fadeStartEnd.y - fadeStartEnd.x ), 0.0, 1.0 ) - 1.0 );
|
||||
}
|
||||
gl_Position.y *= -1;
|
||||
}
|
||||
|
||||
|
|
@ -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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
in vec2 texCoord;
|
||||
in vec4 color;
|
||||
in float fade;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
uniform sampler2D inputTex;
|
||||
uniform vec4 ambient;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
float shadow = texture( inputTex, texCoord ).a * color.a;
|
||||
OUT_col = ( ambient * shadow ) + ( 1 - shadow );
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue