Initial implementation of the new Base Game Template and some starting modules.

This makes some tweaks to the engine to support this, specifically, it tweaks the hardcoded shaderpaths to defer to a pref variable, so none of the shader paths are hardcoded.

Also tweaks how post effects read in texture files, removing a bizzare filepath interpretation choice, where if the file path didn't start with "/" it forcefully appended the script's file path. This made it impossible to have images not in the same dir as the script file defining the post effect.

This was changed and the existing template's post effects tweaked for now to just add "./" to those few paths impacted, as well as the perf vars to support the non-hardcoded shader paths in the engine.
This commit is contained in:
Areloch 2017-02-24 02:40:56 -06:00
parent 5c8a82180b
commit d680dc9934
2321 changed files with 296541 additions and 85 deletions

View 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 );
}

View 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/postFx/mlaa/offsetV.hlsl";
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFx/postFx/mlaa/neighborhoodBlendingP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFx/postFx/mlaa/gl/offsetV.glsl";
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFx/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] = "data/postFX/art/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);
}

View 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 );
}

View 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] = "data/postFX/art/caustics_1";
texture[2] = "data/postFX/art/caustics_2";
target = "$backBuffer";
};

View 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 );
}

View 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 = "data/postFX/art/null_color_ramp.png";

View 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;
}
*/

View 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";
};

View 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 );
}
}

View 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;
}

View 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;
};

View 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 );
}

View 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 = "data/postFX/art/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;
}

View 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 );
}

View 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 );
}

View 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 = "data/postFX/art/null_color_ramp.png";
else
%filename = makeRelativePath( %filename, getMainDotCsDir() );
$HDRPostFX::colorCorrectionRamp = %filename;
PostFXManager-->ColorCorrectionFileName.Text = %filename;
}

View file

@ -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 = "data/postFX/scripts/client/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);
}

View file

@ -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);
}

View 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] = "data/postFX/art/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";
};

View 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";
};

View 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);
}

File diff suppressed because it is too large Load diff