Merge remote-tracking branch 'GG-Github/development' into fix_opengl_new_terrain_blend

This commit is contained in:
LuisAntonRebollo 2014-11-30 04:47:38 +01:00
commit ff83e8c209
1455 changed files with 98353 additions and 15020 deletions

View file

@ -0,0 +1,48 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// This material should work fine for uniformly colored ribbons.
//Basic ribbon shader/////////////////////////////////////////////
new ShaderData( BasicRibbonShader )
{
DXVertexShaderFile = "shaders/common/ribbons/basicRibbonShaderV.hlsl";
DXPixelShaderFile = "shaders/common/ribbons/basicRibbonShaderP.hlsl";
pixVersion = 2.0;
};
singleton CustomMaterial( BasicRibbonMat )
{
shader = BasicRibbonShader;
version = 2.0;
emissive[0] = true;
doubleSided = true;
translucent = true;
BlendOp = AddAlpha;
translucentBlendOp = AddAlpha;
preload = true;
};

View file

@ -0,0 +1,23 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
exec("./ribbons.cs");

View file

@ -0,0 +1,44 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
datablock RibbonNodeData(DefaultRibbonNodeData)
{
timeMultiple = 1.0;
};
//ribbon data////////////////////////////////////////
datablock RibbonData(BasicRibbon)
{
size[0] = 0.5;
color[0] = "1.0 0.0 0.0 1.0";
position[0] = 0.0;
size[1] = 0.0;
color[1] = "1.0 0.0 0.0 0.0";
position[1] = 1.0;
RibbonLength = 40;
fadeAwayStep = 0.1;
UseFadeOut = true;
RibbonMaterial = BasicRibbonMat;
};

View file

@ -68,8 +68,8 @@ function onStart()
if ($platform $= "macos")
$pref::Video::displayDevice = "OpenGL";
else
$pref::Video::displayDevice = "D3D9";
//else
//$pref::Video::displayDevice = "D3D9";
// Initialise stuff.
exec("./scripts/client/core.cs");

View file

@ -32,6 +32,8 @@ singleton ShaderData( CloudLayerShader )
OGLVertexShaderFile = "shaders/common/gl/cloudLayerV.glsl";
OGLPixelShaderFile = "shaders/common/gl/cloudLayerP.glsl";
samplerNames[0] = "$normalHeightMap";
pixVersion = 2.0;
};
@ -44,8 +46,10 @@ singleton ShaderData( BasicCloudsShader )
DXVertexShaderFile = "shaders/common/basicCloudsV.hlsl";
DXPixelShaderFile = "shaders/common/basicCloudsP.hlsl";
//OGLVertexShaderFile = "shaders/common/gl/basicCloudsV.glsl";
//OGLPixelShaderFile = "shaders/common/gl/basicCloudsP.glsl";
OGLVertexShaderFile = "shaders/common/gl/basicCloudsV.glsl";
OGLPixelShaderFile = "shaders/common/gl/basicCloudsP.glsl";
samplerNames[0] = "$diffuseMap";
pixVersion = 2.0;
};

View file

@ -53,7 +53,7 @@ new ShaderData( AL_DepthVisualizeShader )
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/lighting/advanced/dbgDepthVisualizeP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/postFxV.glsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgDepthVisualizeP.glsl";
samplerNames[0] = "prepassBuffer";
@ -90,10 +90,10 @@ new ShaderData( AL_NormalsVisualizeShader )
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/lighting/advanced/dbgNormalVisualizeP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/postFxV.glsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgNormalVisualizeP.glsl";
samplerNames[0] = "prepassTex";
samplerNames[0] = "prepassBuffer";
pixVersion = 2.0;
};
@ -126,8 +126,8 @@ new ShaderData( AL_LightColorVisualizeShader )
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/lighting/advanced/dbgLightColorVisualizeP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/dl/dbgLightColorVisualizeP.glsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgLightColorVisualizeP.glsl";
samplerNames[0] = "lightInfoBuffer";
@ -161,8 +161,8 @@ new ShaderData( AL_LightSpecularVisualizeShader )
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/lighting/advanced/dbgLightSpecularVisualizeP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/dl/dbgLightSpecularVisualizeP.glsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgLightSpecularVisualizeP.glsl";
samplerNames[0] = "lightInfoBuffer";

View file

@ -61,6 +61,11 @@ new ShaderData( AL_VectorLightShader )
OGLVertexShaderFile = "shaders/common/lighting/advanced/gl/farFrustumQuadV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/vectorLightP.glsl";
samplerNames[0] = "$prePassBuffer";
samplerNames[1] = "$ShadowMap";
samplerNames[2] = "$ssaoMask";
samplerNames[3] = "$gTapRotationTex";
pixVersion = 3.0;
};
@ -121,6 +126,11 @@ new ShaderData( AL_PointLightShader )
OGLVertexShaderFile = "shaders/common/lighting/advanced/gl/convexGeometryV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/pointLightP.glsl";
samplerNames[0] = "$prePassBuffer";
samplerNames[1] = "$shadowMap";
samplerNames[2] = "$cookieMap";
samplerNames[3] = "$gTapRotationTex";
pixVersion = 3.0;
};
@ -131,7 +141,7 @@ new CustomMaterial( AL_PointLightMaterial )
sampler["prePassBuffer"] = "#prepass";
sampler["shadowMap"] = "$dynamiclight";
sampler["cookieTex"] = "$dynamiclightmask";
sampler["cookieMap"] = "$dynamiclightmask";
target = "lightinfo";
@ -147,6 +157,11 @@ new ShaderData( AL_SpotLightShader )
OGLVertexShaderFile = "shaders/common/lighting/advanced/gl/convexGeometryV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/spotLightP.glsl";
samplerNames[0] = "$prePassBuffer";
samplerNames[1] = "$shadowMap";
samplerNames[2] = "$cookieMap";
samplerNames[3] = "$gTapRotationTex";
pixVersion = 3.0;
};
@ -157,7 +172,7 @@ new CustomMaterial( AL_SpotLightMaterial )
sampler["prePassBuffer"] = "#prepass";
sampler["shadowMap"] = "$dynamiclight";
sampler["cookieTex"] = "$dynamiclightmask";
sampler["cookieMap"] = "$dynamiclightmask";
target = "lightinfo";
@ -210,6 +225,8 @@ new ShaderData( AL_ParticlePointLightShader )
OGLVertexShaderFile = "shaders/common/lighting/advanced/gl/convexGeometryV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/pointLightP.glsl";
samplerNames[0] = "$prePassBuffer";
pixVersion = 3.0;
};

View file

@ -28,6 +28,9 @@ new ShaderData( AL_ShadowVisualizeShader )
OGLVertexShaderFile = "shaders/common/gl/guiMaterialV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgShadowVisualizeP.glsl";
samplerNames[0] = "$shadowMap";
samplerNames[1] = "$depthViz";
pixVersion = 2.0;
};

View file

@ -46,6 +46,8 @@ singleton ShaderData( BL_ProjectedShadowShaderData )
OGLVertexShaderFile = "shaders/common/gl/projectedShadowV.glsl";
OGLPixelShaderFile = "shaders/common/gl/projectedShadowP.glsl";
samplerNames[0] = "inputTex";
pixVersion = 2.0;
};

View file

@ -26,8 +26,8 @@ singleton ShaderData( BL_ShadowFilterShaderV )
DXVertexShaderFile = "shaders/common/lighting/basic/shadowFilterV.hlsl";
DXPixelShaderFile = "shaders/common/lighting/basic/shadowFilterP.hlsl";
OGLVertexShaderFile = "shaders/common/lighting/basic/gl/shadowFilterV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/basic/gl/shadowFilterP.glsl";
OGLVertexShaderFile = "shaders/common/lighting/basic/gl/shadowFilterV.glsl";
OGLPixelShaderFile = "shaders/common/lighting/basic/gl/shadowFilterP.glsl";
samplerNames[0] = "$diffuseMap";

View file

@ -36,8 +36,8 @@ singleton ShaderData( PFX_PassthruShader )
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/passthruP.hlsl";
// OGLVertexShaderFile = "shaders/common/postFx/gl//postFxV.glsl";
// OGLPixelShaderFile = "shaders/common/postFx/gl/passthruP.glsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/gl/passthruP.glsl";
samplerNames[0] = "$inputTex";

View file

@ -25,6 +25,12 @@ singleton ShaderData( GammaShader )
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/gammaP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/gl/gammaP.glsl";
samplerNames[0] = "$backBuffer";
samplerNames[1] = "$colorCorrectionTex";
pixVersion = 2.0;
};

View file

@ -47,7 +47,11 @@ singleton ShaderData( MLAA_EdgeDetectionShader )
DXVertexShaderFile = "shaders/common/postFx/mlaa/offsetV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/mlaa/edgeDetectionP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/mlaa/gl/offsetV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/mlaa/gl/edgeDetectionP.glsl";
samplerNames[0] = "$colorMapG";
samplerNames[1] = "$prepassMap";
pixVersion = 3.0;
};
@ -72,6 +76,9 @@ singleton ShaderData( MLAA_BlendWeightCalculationShader )
DXVertexShaderFile = "shaders/common/postFx/mlaa/passthruV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/mlaa/blendWeightCalculationP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/mlaa/gl/passthruV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/mlaa/gl/blendWeightCalculationP.glsl";
samplerNames[0] = "$edgesMap";
samplerNames[1] = "$edgesMapL";
samplerNames[2] = "$areaMap";
@ -98,6 +105,9 @@ singleton ShaderData( MLAA_NeighborhoodBlendingShader )
{
DXVertexShaderFile = "shaders/common/postFx/mlaa/offsetV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/mlaa/neighborhoodBlendingP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/mlaa/gl/offsetV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/mlaa/gl/neighborhoodBlendingP.glsl";
samplerNames[0] = "$blendMap";
samplerNames[1] = "$colorMapL";

View file

@ -25,6 +25,12 @@ singleton ShaderData( PFX_MotionBlurShader )
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl"; //we use the bare-bones postFxV.hlsl
DXPixelShaderFile = "shaders/common/postFx/motionBlurP.hlsl"; //new pixel shader
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/gl/motionBlurP.glsl";
samplerNames[0] = "$backBuffer";
samplerNames[1] = "$prepassTex";
pixVersion = 3.0;
};

View file

@ -38,9 +38,13 @@ singleton ShaderData( PFX_CausticsShader )
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/caustics/causticsP.hlsl";
//OGLVertexShaderFile = "shaders/common/postFx/gl//postFxV.glsl";
//OGLPixelShaderFile = "shaders/common/postFx/gl/passthruP.glsl";
OGLVertexShaderFile = "shaders/common/postFx/gl//postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/caustics/gl/causticsP.glsl";
samplerNames[0] = "$prepassTex";
samplerNames[1] = "$causticsTex0";
samplerNames[2] = "$causticsTex1";
pixVersion = 3.0;
};

View file

@ -47,6 +47,12 @@ singleton ShaderData( PFX_ChromaticLensShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/chromaticLens.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/gl/chromaticLens.glsl";
samplerNames[0] = "$backBuffer";
pixVersion = 3.0;
};

View file

@ -320,6 +320,13 @@ singleton ShaderData( PFX_DOFDownSampleShader )
{
DXVertexShaderFile = "shaders/common/postFx/dof/DOF_DownSample_V.hlsl";
DXPixelShaderFile = "shaders/common/postFx/dof/DOF_DownSample_P.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/dof/gl/DOF_DownSample_V.glsl";
OGLPixelShaderFile = "shaders/common/postFx/dof/gl/DOF_DownSample_P.glsl";
samplerNames[0] = "$colorSampler";
samplerNames[1] = "$depthSampler";
pixVersion = 3.0;
};
@ -327,6 +334,12 @@ singleton ShaderData( PFX_DOFBlurYShader )
{
DXVertexShaderFile = "shaders/common/postFx/dof/DOF_Gausian_V.hlsl";
DXPixelShaderFile = "shaders/common/postFx/dof/DOF_Gausian_P.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/dof/gl/DOF_Gausian_V.glsl";
OGLPixelShaderFile = "shaders/common/postFx/dof/gl/DOF_Gausian_P.glsl";
samplerNames[0] = "$diffuseMap";
pixVersion = 2.0;
defines = "BLUR_DIR=float2(0.0,1.0)";
};
@ -340,6 +353,13 @@ singleton ShaderData( PFX_DOFCalcCoCShader )
{
DXVertexShaderFile = "shaders/common/postFx/dof/DOF_CalcCoC_V.hlsl";
DXPixelShaderFile = "shaders/common/postFx/dof/DOF_CalcCoC_P.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/dof/gl/DOF_CalcCoC_V.glsl";
OGLPixelShaderFile = "shaders/common/postFx/dof/gl/DOF_CalcCoC_P.glsl";
samplerNames[0] = "$shrunkSampler";
samplerNames[1] = "$blurredSampler";
pixVersion = 3.0;
};
@ -347,6 +367,12 @@ singleton ShaderData( PFX_DOFSmallBlurShader )
{
DXVertexShaderFile = "shaders/common/postFx/dof/DOF_SmallBlur_V.hlsl";
DXPixelShaderFile = "shaders/common/postFx/dof/DOF_SmallBlur_P.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/dof/gl/DOF_SmallBlur_V.glsl";
OGLPixelShaderFile = "shaders/common/postFx/dof/gl/DOF_SmallBlur_P.glsl";
samplerNames[0] = "$colorSampler";
pixVersion = 3.0;
};
@ -354,6 +380,15 @@ singleton ShaderData( PFX_DOFFinalShader )
{
DXVertexShaderFile = "shaders/common/postFx/dof/DOF_Final_V.hlsl";
DXPixelShaderFile = "shaders/common/postFx/dof/DOF_Final_P.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/dof/gl/DOF_Final_V.glsl";
OGLPixelShaderFile = "shaders/common/postFx/dof/gl/DOF_Final_P.glsl";
samplerNames[0] = "$colorSampler";
samplerNames[1] = "$smallBlurSampler";
samplerNames[2] = "$largeBlurSampler";
samplerNames[3] = "$depthSampler";
pixVersion = 3.0;
};

View file

@ -37,10 +37,10 @@ singleton ShaderData( PFX_EdgeAADetectShader )
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/edgeaa/edgeDetectP.hlsl";
//OGLVertexShaderFile = "shaders/common/postFx/gl//postFxV.glsl";
//OGLPixelShaderFile = "shaders/common/postFx/gl/passthruP.glsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/edgeaa/gl/edgeDetectP.glsl";
samplerNames[0] = "$inputTex";
samplerNames[0] = "$prepassBuffer";
pixVersion = 3.0;
};
@ -50,10 +50,11 @@ singleton ShaderData( PFX_EdgeAAShader )
DXVertexShaderFile = "shaders/common/postFx/edgeaa/edgeAAV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/edgeaa/edgeAAP.hlsl";
//OGLVertexShaderFile = "shaders/common/postFx/gl//postFxV.glsl";
//OGLPixelShaderFile = "shaders/common/postFx/gl/passthruP.glsl";
OGLVertexShaderFile = "shaders/common/postFx/edgeaa/gl/edgeAAV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/edgeaa/gl/edgeAAP.glsl";
samplerNames[0] = "$inputTex";
samplerNames[0] = "$edgeBuffer";
samplerNames[1] = "$backBuffer";
pixVersion = 3.0;
};
@ -63,10 +64,10 @@ singleton ShaderData( PFX_EdgeAADebugShader )
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/edgeaa/dbgEdgeDisplayP.hlsl";
//OGLVertexShaderFile = "shaders/common/postFx/gl//postFxV.glsl";
//OGLPixelShaderFile = "shaders/common/postFx/gl/passthruP.glsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/edgeaa/gl/dbgEdgeDisplayP.glsl";
samplerNames[0] = "$inputTex";
samplerNames[0] = "$edgeBuffer";
pixVersion = 3.0;
};
@ -83,7 +84,7 @@ singleton PostEffect( EdgeDetectPostEffect )
texture[0] = "#prepass";
target = "#edge";
isEnabled = false;
isEnabled = true;
};
singleton PostEffect( EdgeAAPostEffect )

View file

@ -24,6 +24,11 @@ singleton ShaderData( PFX_FlashShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/flashP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/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)";

View file

@ -29,8 +29,8 @@ singleton ShaderData( FogPassShader )
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/fogP.hlsl";
// OGLVertexShaderFile = "shaders/common/postFx/gl//postFxV.glsl";
// OGLPixelShaderFile = "shaders/common/postFx/gl/fogP.glsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/gl/fogP.glsl";
samplerNames[0] = "$prepassTex";
@ -75,10 +75,12 @@ singleton ShaderData( UnderwaterFogPassShader )
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/underwaterFogP.hlsl";
// OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
// OGLPixelShaderFile = "shaders/common/postFx/gl/fogP.glsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/gl/underwaterFogP.glsl";
samplerNames[0] = "$prepassTex";
samplerNames[1] = "$backbuffer";
samplerNames[2] = "$waterDepthGradMap";
pixVersion = 2.0;
};

View file

@ -39,6 +39,9 @@ singleton ShaderData( FXAA_ShaderData )
DXVertexShaderFile = "shaders/common/postFx/fxaa/fxaaV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/fxaa/fxaaP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/fxaa/gl/fxaaV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/fxaa/gl/fxaaP.glsl";
samplerNames[0] = "$colorTex";
pixVersion = 3.0;

View file

@ -26,8 +26,8 @@ singleton ShaderData( PFX_GlowBlurVertShader )
DXVertexShaderFile = "shaders/common/postFx/glowBlurV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/glowBlurP.hlsl";
// OGLVertexShaderFile = "shaders/common/postFx/glowBlurV.glsl";
// OGLPixelShaderFile = "shaders/common/postFx/glowBlurP.glsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/glowBlurV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/gl/glowBlurP.glsl";
defines = "BLUR_DIR=float2(0.0,1.0)";

View file

@ -77,7 +77,13 @@ $HDRPostFX::colorCorrectionRamp = "core/scripts/client/postFx/null_color_ramp.pn
singleton ShaderData( HDR_BrightPassShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/hdr/brightPassFilterP.hlsl";
DXPixelShaderFile = "shaders/common/postFx/hdr/brightPassFilterP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/hdr/gl/brightPassFilterP.glsl";
samplerNames[0] = "$inputTex";
samplerNames[1] = "$luminanceTex";
pixVersion = 3.0;
};
@ -85,6 +91,11 @@ singleton ShaderData( HDR_DownScale4x4Shader )
{
DXVertexShaderFile = "shaders/common/postFx/hdr/downScale4x4V.hlsl";
DXPixelShaderFile = "shaders/common/postFx/hdr/downScale4x4P.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/hdr/gl/downScale4x4V.glsl";
OGLPixelShaderFile = "shaders/common/postFx/hdr/gl/downScale4x4P.glsl";
samplerNames[0] = "$inputTex";
pixVersion = 2.0;
};
@ -92,6 +103,11 @@ singleton ShaderData( HDR_BloomGaussBlurHShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/hdr/bloomGaussBlurHP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/hdr/gl/bloomGaussBlurHP.glsl";
samplerNames[0] = "$inputTex";
pixVersion = 3.0;
};
@ -99,6 +115,11 @@ singleton ShaderData( HDR_BloomGaussBlurVShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/hdr/bloomGaussBlurVP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/hdr/gl/bloomGaussBlurVP.glsl";
samplerNames[0] = "$inputTex";
pixVersion = 3.0;
};
@ -106,6 +127,11 @@ singleton ShaderData( HDR_SampleLumShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/hdr/sampleLumInitialP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/hdr/gl/sampleLumInitialP.glsl";
samplerNames[0] = "$inputTex";
pixVersion = 3.0;
};
@ -113,6 +139,11 @@ singleton ShaderData( HDR_DownSampleLumShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/hdr/sampleLumIterativeP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/hdr/gl/sampleLumIterativeP.glsl";
samplerNames[0] = "$inputTex";
pixVersion = 3.0;
};
@ -120,6 +151,12 @@ singleton ShaderData( HDR_CalcAdaptedLumShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/hdr/calculateAdaptedLumP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/hdr/gl/calculateAdaptedLumP.glsl";
samplerNames[0] = "$currLum";
samplerNames[1] = "$lastAdaptedLum";
pixVersion = 3.0;
};
@ -127,6 +164,14 @@ singleton ShaderData( HDR_CombineShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/hdr/finalPassCombineP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/hdr/gl/finalPassCombineP.glsl";
samplerNames[0] = "$sceneTex";
samplerNames[1] = "$luminanceTex";
samplerNames[2] = "$bloomTex";
samplerNames[3] = "$colorCorrectionTex";
pixVersion = 3.0;
};
@ -421,6 +466,11 @@ singleton ShaderData( LuminanceVisShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/hdr/luminanceVisP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/hdr/gl/luminanceVisP.glsl";
samplerNames[0] = "$inputTex";
pixVersion = 3.0;
};

View file

@ -34,6 +34,12 @@ singleton ShaderData( LightRayOccludeShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/lightRay/lightRayOccludeP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/lightRay/gl/lightRayOccludeP.glsl";
samplerNames[0] = "$backBuffer";
samplerNames[1] = "$prepassTex";
pixVersion = 3.0;
};
@ -42,6 +48,12 @@ singleton ShaderData( LightRayShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/lightRay/lightRayP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/lightRay/gl/lightRayP.glsl";
samplerNames[0] = "$frameSampler";
samplerNames[1] = "$backBuffer";
pixVersion = 3.0;
};

View file

@ -32,6 +32,11 @@ singleton ShaderData( OVRMonoToStereoShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/oculusvr/monoToStereoP.hlsl";
//OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.hlsl";
//OGLPixelShaderFile = "shaders/common/postFx/oculusvr/gl/monoToStereoP.glsl";
samplerNames[0] = "$backBuffer";
pixVersion = 2.0;
};
@ -40,6 +45,11 @@ singleton ShaderData( OVRBarrelDistortionShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/oculusvr/barrelDistortionP.hlsl";
//OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
//OGLPixelShaderFile = "shaders/common/postFx/oculusvr/gl/barrelDistortionP.glsl";
samplerNames[0] = "$backBuffer";
pixVersion = 2.0;
};

View file

@ -78,7 +78,7 @@
new GuiTabBookCtrl(ppOptionsTabBook) {
tabPosition = "Top";
tabMargin = "7";
minTabWidth = "64";
minTabWidth = "32";
tabHeight = "20";
allowReorder = "0";
defaultPage = "-1";
@ -2199,6 +2199,55 @@
canSaveDynamicFields = "0";
};
};
new GuiTabPageCtrl(ppOptionsVignetteTab) {
fitBook = "0";
text = "Vignette";
maxLength = "1024";
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "1";
anchorLeft = "1";
anchorRight = "1";
position = "0 40";
extent = "394 193";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiTabPageProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
tooltip = "Options for the Vignette postFX";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
Enabled = "1";
new GuiCheckBoxCtrl(ppOptionsEnableVignette) {
text = "Enable";
groupNum = "-1";
buttonType = "ToggleButton";
useMouseEvents = "0";
position = "329 7";
extent = "53 20";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiCheckBoxProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
tooltip = "Enable/Disable the vignette postFX";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
Enabled = "1";
};
};
new GuiTabPageCtrl() {
fitBook = "0";
text = "Color Correction";

View file

@ -94,7 +94,13 @@ 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
@ -379,6 +385,24 @@ function ppOptionsEnableHDRDebug::onAction(%this)
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 (*.*)|*.*|";

View file

@ -50,6 +50,11 @@ function PostFXManager::settingsSetEnabled(%this, %bEnablePostFX)
DOFPostEffect.enable();
else
DOFPostEffect.disable();
if ( $PostFXManager::PostFX::EnableVignette )
VignettePostEffect.enable();
else
VignettePostEffect.disable();
postVerbose("% - PostFX Manager - PostFX enabled");
}
@ -61,6 +66,7 @@ function PostFXManager::settingsSetEnabled(%this, %bEnablePostFX)
HDRPostFX.disable();
LightRayPostFX.disable();
DOFPostEffect.disable();
VignettePostEffect.disable();
postVerbose("% - PostFX Manager - PostFX disabled");
}
@ -95,6 +101,12 @@ function PostFXManager::settingsEffectSetEnabled(%this, %sName, %bEnable)
$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 )
@ -196,6 +208,13 @@ function PostFXManager::settingsRefreshDOF(%this)
}
function PostFXManager::settingsRefreshVignette(%this)
{
//Apply the enabled flag
ppOptionsEnableVignette.setValue($PostFXManager::PostFX::EnableVignette);
}
function PostFXManager::settingsRefreshAll(%this)
{
$PostFXManager::PostFX::Enabled = $pref::enablePostEffects;
@ -203,6 +222,7 @@ function PostFXManager::settingsRefreshAll(%this)
$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.
@ -211,6 +231,7 @@ function PostFXManager::settingsRefreshAll(%this)
%this.settingsRefreshHDR();
%this.settingsRefreshLightrays();
%this.settingsRefreshDOF();
%this.settingsRefreshVignette();
ppOptionsEnable.setValue($PostFXManager::PostFX::Enabled);
@ -272,6 +293,7 @@ function PostFXManager::settingsApplyFromPreset(%this)
{
$PostFXManager::PostFX::Enabled = $PostFXManager::Settings::EnablePostFX;
$PostFXManager::PostFX::EnableDOF = $PostFXManager::Settings::EnableDOF;
$PostFXManager::PostFX::EnableVignette = $PostFXManager::Settings::EnableVignette;
$PostFXManager::PostFX::EnableLightRays = $PostFXManager::Settings::EnableLightRays;
$PostFXManager::PostFX::EnableHDR = $PostFXManager::Settings::EnableHDR;
$PostFXManager::PostFX::EnableSSAO = $PostFXManager::Settings::EnabledSSAO;
@ -353,11 +375,18 @@ function PostFXManager::settingsApplyDOF(%this)
}
function PostFXManager::settingsApplyVignette(%this)
{
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::EnabledSSAO = $PostFXManager::PostFX::EnableSSAO;
@ -373,6 +402,8 @@ function PostFXManager::settingsApplyAll(%this, %sFrom)
%this.settingsApplyLightRays();
// DOF
%this.settingsApplyDOF();
// Vignette
%this.settingsApplyVignette();
postVerbose("% - PostFX Manager - All Settings applied to $PostFXManager::Settings");
}

View file

@ -152,6 +152,14 @@ singleton ShaderData( SSAOShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/ssao/SSAO_P.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/ssao/gl/SSAO_P.glsl";
samplerNames[0] = "$prepassMap";
samplerNames[1] = "$randNormalTex";
samplerNames[2] = "$powTable";
pixVersion = 3.0;
};
@ -159,6 +167,13 @@ singleton ShaderData( SSAOBlurYShader )
{
DXVertexShaderFile = "shaders/common/postFx/ssao/SSAO_Blur_V.hlsl";
DXPixelShaderFile = "shaders/common/postFx/ssao/SSAO_Blur_P.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/ssao/gl/SSAO_Blur_V.glsl";
OGLPixelShaderFile = "shaders/common/postFx/ssao/gl/SSAO_Blur_P.glsl";
samplerNames[0] = "$occludeMap";
samplerNames[1] = "$prepassMap";
pixVersion = 3.0;
defines = "BLUR_DIR=float2(0.0,1.0)";
@ -266,6 +281,10 @@ singleton ShaderData( SSAOPowTableShader )
{
DXVertexShaderFile = "shaders/common/postFx/ssao/SSAO_PowerTable_V.hlsl";
DXPixelShaderFile = "shaders/common/postFx/ssao/SSAO_PowerTable_P.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/ssao/gl/SSAO_PowerTable_V.glsl";
OGLPixelShaderFile = "shaders/common/postFx/ssao/gl/SSAO_PowerTable_P.glsl";
pixVersion = 2.0;
};

View file

@ -35,6 +35,10 @@ singleton ShaderData( PFX_TurbulenceShader )
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/turbulenceP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
OGLPixelShaderFile = "shaders/common/postFx/gl/turbulenceP.glsl";
samplerNames[0] = "$inputTex";
pixVersion = 3.0;
};

View file

@ -0,0 +1,49 @@
//-----------------------------------------------------------------------------
// 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::RadiusX = 0.6;
$VignettePostEffect::RadiusY = 0.2;
singleton ShaderData( VignetteShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXPixelShaderFile = "shaders/common/postFx/vignette/VignetteP.hlsl";
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("$radiusX", $VignettePostEffect::RadiusX);
%this.setShaderConst("$radiusY", $VignettePostEffect::RadiusY);
}

View file

@ -44,5 +44,7 @@ singleton ShaderData( ScatterSkyShaderData )
OGLVertexShaderFile = "shaders/common/gl/scatterSkyV.glsl";
OGLPixelShaderFile = "shaders/common/gl/scatterSkyP.glsl";
samplerNames[0] = "$nightSky";
pixVersion = 2.0;
};

View file

@ -33,6 +33,10 @@ singleton ShaderData( ParticlesShaderData )
OGLVertexShaderFile = "shaders/common/gl/particlesV.glsl";
OGLPixelShaderFile = "shaders/common/gl/particlesP.glsl";
samplerNames[0] = "$diffuseMap";
samplerNames[1] = "$prepassTex";
samplerNames[2] = "$paraboloidLightMap";
pixVersion = 2.0;
};
@ -44,6 +48,9 @@ singleton ShaderData( OffscreenParticleCompositeShaderData )
OGLVertexShaderFile = "shaders/common/gl/particleCompositeV.glsl";
OGLPixelShaderFile = "shaders/common/gl/particleCompositeP.glsl";
samplerNames[0] = "$colorSource";
samplerNames[1] = "$edgeSource";
pixVersion = 2.0;
};
@ -55,8 +62,8 @@ new ShaderData( ReflectBump )
DXVertexShaderFile = "shaders/common/planarReflectBumpV.hlsl";
DXPixelShaderFile = "shaders/common/planarReflectBumpP.hlsl";
OGLVertexShaderFile = "shaders/common/gl/planarReflectBumpV.glsl";
OGLPixelShaderFile = "shaders/common/gl/planarReflectBumpP.glsl";
OGLVertexShaderFile = "shaders/common/gl/planarReflectBumpV.glsl";
OGLPixelShaderFile = "shaders/common/gl/planarReflectBumpP.glsl";
samplerNames[0] = "$diffuseMap";
samplerNames[1] = "$refractMap";
@ -70,8 +77,8 @@ new ShaderData( Reflect )
DXVertexShaderFile = "shaders/common/planarReflectV.hlsl";
DXPixelShaderFile = "shaders/common/planarReflectP.hlsl";
OGLVertexShaderFile = "shaders/common/gl/planarReflectV.glsl";
OGLPixelShaderFile = "shaders/common/gl/planarReflectP.glsl";
OGLVertexShaderFile = "shaders/common/gl/planarReflectV.glsl";
OGLPixelShaderFile = "shaders/common/gl/planarReflectP.glsl";
samplerNames[0] = "$diffuseMap";
samplerNames[1] = "$refractMap";

View file

@ -29,5 +29,8 @@ singleton ShaderData( TerrainBlendShader )
OGLVertexShaderFile = "shaders/common/terrain/gl/blendV.glsl";
OGLPixelShaderFile = "shaders/common/terrain/gl/blendP.glsl";
samplerNames[0] = "layerTex";
samplerNames[1] = "textureMap";
pixVersion = 2.0;
};

View file

@ -34,6 +34,14 @@ singleton ShaderData( WaterShader )
OGLVertexShaderFile = "shaders/common/water/gl/waterV.glsl";
OGLPixelShaderFile = "shaders/common/water/gl/waterP.glsl";
samplerNames[0] = "$bumpMap"; // noise
samplerNames[1] = "$prepassTex"; // #prepass
samplerNames[2] = "$reflectMap"; // $reflectbuff
samplerNames[3] = "$refractBuff"; // $backbuff
samplerNames[4] = "$skyMap"; // $cubemap
samplerNames[5] = "$foamMap"; // foam
samplerNames[6] = "$depthGradMap"; // depthMap ( color gradient )
pixVersion = 3.0;
};
@ -73,6 +81,14 @@ singleton CustomMaterial( WaterMat )
sampler["prepassTex"] = "#prepass";
sampler["reflectMap"] = "$reflectbuff";
sampler["refractBuff"] = "$backbuff";
// These samplers are set in code not here.
// This is to allow different WaterObject instances
// to use this same material but override these textures
// per instance.
//sampler["bumpMap"] = "";
//sampler["skyMap"] = "";
//sampler["foamMap"] = "";
//sampler["depthGradMap"] = "";
shader = WaterShader;
stateBlock = WaterStateBlock;
@ -85,16 +101,9 @@ singleton CustomMaterial( WaterMat )
// Underwater
//-----------------------------------------------------------------------------
singleton ShaderData( UnderWaterShader )
{
DXVertexShaderFile = "shaders/common/water/waterV.hlsl";
DXPixelShaderFile = "shaders/common/water/waterP.hlsl";
OGLVertexShaderFile = "shaders/common/water/gl/waterV.glsl";
OGLPixelShaderFile = "shaders/common/water/gl/waterP.glsl";
singleton ShaderData( UnderWaterShader : WaterShader )
{
defines = "UNDERWATER";
pixVersion = 3.0;
};
singleton CustomMaterial( UnderwaterMat )
@ -125,8 +134,14 @@ singleton ShaderData( WaterBasicShader )
DXVertexShaderFile = "shaders/common/water/waterBasicV.hlsl";
DXPixelShaderFile = "shaders/common/water/waterBasicP.hlsl";
OGLVertexShaderFile = "shaders/common/water/gl/waterBasicV.glsl";
OGLPixelShaderFile = "shaders/common/water/gl/waterBasicP.glsl";
OGLVertexShaderFile = "shaders/common/water/gl/waterBasicV.glsl";
OGLPixelShaderFile = "shaders/common/water/gl/waterBasicP.glsl";
samplerNames[0] = "$bumpMap";
samplerNames[2] = "$reflectMap";
samplerNames[3] = "$refractBuff";
samplerNames[4] = "$skyMap";
samplerNames[5] = "$depthGradMap";
pixVersion = 2.0;
};
@ -170,16 +185,9 @@ singleton CustomMaterial( WaterBasicMat )
// Basic UnderWater
//-----------------------------------------------------------------------------
singleton ShaderData( UnderWaterBasicShader )
singleton ShaderData( UnderWaterBasicShader : WaterBasicShader)
{
DXVertexShaderFile = "shaders/common/water/waterBasicV.hlsl";
DXPixelShaderFile = "shaders/common/water/waterBasicP.hlsl";
OGLVertexShaderFile = "shaders/common/water/gl/waterBasicV.glsl";
OGLPixelShaderFile = "shaders/common/water/gl/waterBasicP.glsl";
defines = "UNDERWATER";
pixVersion = 2.0;
defines = "UNDERWATER";
};
singleton CustomMaterial( UnderwaterBasicMat )

View file

@ -34,6 +34,7 @@ function onServerCreated()
// Load up any objects or datablocks saved to the editor managed scripts
%datablockFiles = new ArrayObject();
%datablockFiles.add( "art/ribbons/ribbonExec.cs" );
%datablockFiles.add( "art/particles/managedParticleData.cs" );
%datablockFiles.add( "art/particles/managedParticleEmitterData.cs" );
%datablockFiles.add( "art/decals/managedDecalData.cs" );

View file

@ -144,6 +144,7 @@ function onServerCreated()
// Load up any objects or datablocks saved to the editor managed scripts
%datablockFiles = new ArrayObject();
%datablockFiles.add( "art/ribbons/ribbonExec.cs" );
%datablockFiles.add( "art/particles/managedParticleData.cs" );
%datablockFiles.add( "art/particles/managedParticleEmitterData.cs" );
%datablockFiles.add( "art/decals/managedDecalData.cs" );

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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.
//-----------------------------------------------------------------------------
#include "hlslCompat.glsl"
//CloudVert
in vec4 vPosition;
in vec2 vTexCoord0;
#define IN_pos vPosition
#define IN_uv0 vTexCoord0
uniform mat4 modelview;
uniform float accumTime;
uniform float texScale;
uniform vec2 texDirection;
uniform vec2 texOffset;
out vec2 texCoord;
#define OUT_texCoord texCoord
void main()
{
gl_Position = tMul(modelview, IN_pos);
vec2 uv = IN_uv0;
uv += texOffset;
uv *= texScale;
uv += accumTime * texDirection;
OUT_texCoord = uv;
correctSSP(gl_Position);
}

View file

@ -48,14 +48,14 @@
#define lerp mix
void tSetMatrixRow(out float3x3 m, int row, float3 value)
void tSetMatrixRow(inout float3x3 m, int row, float3 value)
{
m[0][row] = value.x;
m[1][row] = value.y;
m[2][row] = value.z;
}
void tSetMatrixRow(out float4x4 m, int row, float4 value)
void tSetMatrixRow(inout float4x4 m, int row, float4 value)
{
m[0][row] = value.x;
m[1][row] = value.y;

View file

@ -0,0 +1,85 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "../../gl/postFX.glsl"
#include "shadergen:/autogenConditioners.h"
uniform vec3 eyePosWorld;
uniform vec4 rtParams0;
uniform vec4 waterFogPlane;
uniform float accumTime;
uniform sampler2D prepassTex;
uniform sampler2D causticsTex0;
uniform sampler2D causticsTex1;
uniform vec2 targetSize;
float distanceToPlane(vec4 plane, vec3 pos)
{
return (plane.x * pos.x + plane.y * pos.y + plane.z * pos.z) + plane.w;
}
void main()
{
//Sample the pre-pass
vec4 prePass = prepassUncondition( prepassTex, IN_uv0 );
//Get depth
float depth = prePass.w;
if(depth > 0.9999)
{
OUT_FragColor0 = vec4(0,0,0,0);
return;
}
//Get world position
vec3 pos = eyePosWorld + IN_wsEyeRay * depth;
// Check the water depth
float waterDepth = -distanceToPlane(waterFogPlane, pos);
if(waterDepth < 0)
{
OUT_FragColor0 = vec4(0,0,0,0);
return;
}
waterDepth = saturate(waterDepth);
//Use world position X and Y to calculate caustics UV
vec2 causticsUV0 = mod(abs(pos.xy * 0.25), vec2(1, 1));
vec2 causticsUV1 = mod(abs(pos.xy * 0.2), vec2(1, 1));
//Animate uvs
float timeSin = sin(accumTime);
causticsUV0.xy += vec2(accumTime*0.1, timeSin*0.2);
causticsUV1.xy -= vec2(accumTime*0.15, timeSin*0.15);
//Sample caustics texture
vec4 caustics = texture(causticsTex0, causticsUV0);
caustics *= texture(causticsTex1, causticsUV1);
//Use normal Z to modulate caustics
//float waterDepth = 1 - saturate(pos.z + waterFogPlane.w + 1);
caustics *= saturate(prePass.z) * pow(1-depth, 64) * waterDepth;
OUT_FragColor0 = caustics;
}

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.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "../../gl/postFX.glsl"
// These are set by the game engine.
uniform sampler2D shrunkSampler; // Output of DofDownsample()
uniform sampler2D blurredSampler; // Blurred version of the shrunk sampler
// This is the pixel shader function that calculates the actual
// value used for the near circle of confusion.
// "texCoords" are 0 at the bottom left pixel and 1 at the top right.
void main()
{
vec3 color;
float coc;
half4 blurred;
half4 shrunk;
shrunk = texture( shrunkSampler, IN_uv0 );
blurred = texture( blurredSampler, IN_uv1 );
color = shrunk.rgb;
//coc = shrunk.a;
//coc = blurred.a;
//coc = max( blurred.a, shrunk.a );
coc = 2 * max( blurred.a, shrunk.a ) - shrunk.a;
//OUT_FragColor0 = vec4( coc.rrr, 1.0 );
//OUT_FragColor0 = vec4( color, 1.0 );
OUT_FragColor0 = vec4( color, coc );
//OUT_FragColor0 = vec4( 1.0, 0.0, 1.0, 1.0 );
}

View file

@ -0,0 +1,69 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "../../../gl/torque.glsl"
#include "../../gl/postFX.glsl"
uniform vec4 rtParams0;
uniform vec4 rtParams1;
uniform vec4 rtParams2;
uniform vec4 rtParams3;
void main()
{
/*
OUT_hpos = IN.pos;
OUT_uv0 = IN_uv;
OUT_uv1 = IN_uv;
OUT_uv2 = IN_uv;
OUT_uv3 = IN_uv;
*/
/*
OUT_hpos = IN_pos;
OUT_uv0 = IN_uv + rtParams0.xy;
OUT_uv1 = IN_uv + rtParams1.xy;
OUT_uv2 = IN_uv + rtParams2.xy;
OUT_uv3 = IN_uv + rtParams3.xy;
*/
/*
OUT_hpos = IN_pos;
OUT_uv0 = IN_uv * rtParams0.zw;
OUT_uv1 = IN_uv * rtParams1.zw;
OUT_uv2 = IN_uv * rtParams2.zw;
OUT_uv3 = IN_uv * rtParams3.zw;
*/
OUT_hpos = IN_pos;
OUT_uv0 = viewportCoordToRenderTarget( IN_uv, rtParams0 );
OUT_uv1 = viewportCoordToRenderTarget( IN_uv, rtParams1 );
OUT_uv2 = viewportCoordToRenderTarget( IN_uv, rtParams2 );
OUT_uv3 = viewportCoordToRenderTarget( IN_uv, rtParams3 );
OUT_wsEyeRay = IN_wsEyeRay;
correctSSP(gl_Position);;
}

View file

@ -0,0 +1,138 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h"
// These are set by the game engine.
// The render target size is one-quarter the scene rendering size.
uniform sampler2D colorSampler;
uniform sampler2D depthSampler;
uniform vec2 dofEqWorld;
uniform float depthOffset;
uniform vec2 targetSize;
uniform float maxWorldCoC;
//uniform vec2 dofEqWeapon;
//uniform vec2 dofRowDelta; // vec2( 0, 0.25 / renderTargetHeight )
in vec2 tcColor0;
#define IN_tcColor0 tcColor0
in vec2 tcColor1;
#define IN_tcColor1 tcColor1
in vec2 tcDepth0;
#define IN_tcDepth0 tcDepth0
in vec2 tcDepth1;
#define IN_tcDepth1 tcDepth1
in vec2 tcDepth2;
#define IN_tcDepth2 tcDepth2
in vec2 tcDepth3;
#define IN_tcDepth3 tcDepth3
void main()
{
//return vec4( 1.0, 0.0, 1.0, 1.0 );
vec2 dofRowDelta = vec2( 0, 0.25 / targetSize.y );
//vec2 dofEqWorld = vec2( -60, 1.0 );
half3 color;
half maxCoc;
vec4 depth;
half4 viewCoc;
half4 sceneCoc;
half4 curCoc;
half4 coc;
vec2 rowOfs[4];
// "rowOfs" reduces how many moves PS2.0 uses to emulate swizzling.
rowOfs[0] = vec2(0);
rowOfs[1] = dofRowDelta.xy;
rowOfs[2] = dofRowDelta.xy * 2;
rowOfs[3] = dofRowDelta.xy * 3;
// Use bilinear filtering to average 4 color samples for free.
color = half3(0);
color += texture( colorSampler, IN_tcColor0.xy + rowOfs[0] ).rgb;
color += texture( colorSampler, IN_tcColor1.xy + rowOfs[0] ).rgb;
color += texture( colorSampler, IN_tcColor0.xy + rowOfs[2] ).rgb;
color += texture( colorSampler, IN_tcColor1.xy + rowOfs[2] ).rgb;
color /= 4;
// Process 4 samples at a time to use vector hardware efficiently.
// The CoC will be 1 if the depth is negative, so use "min" to pick
// between "sceneCoc" and "viewCoc".
for ( int i = 0; i < 4; i++ )
{
depth[0] = prepassUncondition( depthSampler, ( IN_tcDepth0.xy + rowOfs[i] ) ).w;
depth[1] = prepassUncondition( depthSampler, ( IN_tcDepth1.xy + rowOfs[i] ) ).w;
depth[2] = prepassUncondition( depthSampler, ( IN_tcDepth2.xy + rowOfs[i] ) ).w;
depth[3] = prepassUncondition( depthSampler, ( IN_tcDepth3.xy + rowOfs[i] ) ).w;
coc[i] = clamp( dofEqWorld.x * depth + dofEqWorld.y, 0.0, maxWorldCoC );
}
/*
depth[0] = texture( depthSampler, pixel.tcDepth0.xy + rowOfs[0] ).r;
depth[1] = texture( depthSampler, pixel.tcDepth1.xy + rowOfs[0] ).r;
depth[2] = texture( depthSampler, pixel.tcDepth2.xy + rowOfs[0] ).r;
depth[3] = texture( depthSampler, pixel.tcDepth3.xy + rowOfs[0] ).r;
viewCoc = saturate( dofEqWeapon.x * -depth + dofEqWeapon.y );
sceneCoc = saturate( dofEqWorld.x * depth + dofEqWorld.y );
curCoc = min( viewCoc, sceneCoc );
coc = curCoc;
depth[0] = texture( depthSampler, pixel.tcDepth0.xy + rowOfs[1] ).r;
depth[1] = texture( depthSampler, pixel.tcDepth1.xy + rowOfs[1] ).r;
depth[2] = texture( depthSampler, pixel.tcDepth2.xy + rowOfs[1] ).r;
depth[3] = texture( depthSampler, pixel.tcDepth3.xy + rowOfs[1] ).r;
viewCoc = saturate( dofEqWeapon.x * -depth + dofEqWeapon.y );
sceneCoc = saturate( dofEqWorld.x * depth + dofEqWorld.y );
curCoc = min( viewCoc, sceneCoc );
coc = max( coc, curCoc );
depth[0] = texture( depthSampler, pixel.tcDepth0.xy + rowOfs[2] ).r;
depth[1] = texture( depthSampler, pixel.tcDepth1.xy + rowOfs[2] ).r;
depth[2] = texture( depthSampler, pixel.tcDepth2.xy + rowOfs[2] ).r;
depth[3] = texture( depthSampler, pixel.tcDepth3.xy + rowOfs[2] ).r;
viewCoc = saturate( dofEqWeapon.x * -depth + dofEqWeapon.y );
sceneCoc = saturate( dofEqWorld.x * depth + dofEqWorld.y );
curCoc = min( viewCoc, sceneCoc );
coc = max( coc, curCoc );
depth[0] = texture( depthSampler, pixel.tcDepth0.xy + rowOfs[3] ).r;
depth[1] = texture( depthSampler, pixel.tcDepth1.xy + rowOfs[3] ).r;
depth[2] = texture( depthSampler, pixel.tcDepth2.xy + rowOfs[3] ).r;
depth[3] = texture( depthSampler, pixel.tcDepth3.xy + rowOfs[3] ).r;
viewCoc = saturate( dofEqWeapon.x * -depth + dofEqWeapon.y );
sceneCoc = saturate( dofEqWorld.x * depth + dofEqWorld.y );
curCoc = min( viewCoc, sceneCoc );
coc = max( coc, curCoc );
*/
maxCoc = max( max( coc[0], coc[1] ), max( coc[2], coc[3] ) );
//OUT_FragColor0 = half4( 1.0, 0.0, 1.0, 1.0 );
OUT_FragColor0 = half4( color, maxCoc );
//OUT_FragColor0 = half4( color, 1.0f );
//OUT_FragColor0 = half4( maxCoc.rrr, 1.0 );
}

View file

@ -0,0 +1,67 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "../../../gl/torque.glsl"
in vec4 vPosition;
in vec2 vTexCoord0;
in vec3 vTexCoord1;
#define IN_pos vPosition
#define IN_tc vTexCoord0
#define IN_wsEyeRay vTexCoord1
#define OUT_position gl_Position
out vec2 tcColor0;
#define OUT_tcColor0 tcColor0
out vec2 tcColor1;
#define OUT_tcColor1 tcColor1
out vec2 tcDepth0;
#define OUT_tcDepth0 tcDepth0
out vec2 tcDepth1;
#define OUT_tcDepth1 tcDepth1
out vec2 tcDepth2;
#define OUT_tcDepth2 tcDepth2
out vec2 tcDepth3;
#define OUT_tcDepth3 tcDepth3
uniform vec4 rtParams0;
uniform vec2 oneOverTargetSize;
void main()
{
OUT_position = IN_pos;
vec2 uv = viewportCoordToRenderTarget( IN_tc, rtParams0 );
//OUT_position = tMul( IN_pos, modelView );
OUT_tcColor1 = uv + vec2( +1.0, -0.0 ) * oneOverTargetSize;
OUT_tcColor0 = uv + vec2( -1.0, -0.0 ) * oneOverTargetSize;
OUT_tcDepth0 = uv + vec2( -0.5, -0.0 ) * oneOverTargetSize;
OUT_tcDepth1 = uv + vec2( -1.5, -0.0 ) * oneOverTargetSize;
OUT_tcDepth2 = uv + vec2( +1.5, -0.0 ) * oneOverTargetSize;
OUT_tcDepth3 = uv + vec2( +2.5, -0.0 ) * oneOverTargetSize;
correctSSP(gl_Position);
}

View file

@ -0,0 +1,145 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h"
#include "../../gl/postFX.glsl"
uniform sampler2D colorSampler; // Original source image
uniform sampler2D smallBlurSampler; // Output of SmallBlurPS()
uniform sampler2D largeBlurSampler; // Blurred output of DofDownsample()
uniform sampler2D depthSampler; //
uniform vec2 oneOverTargetSize;
uniform vec4 dofLerpScale;
uniform vec4 dofLerpBias;
uniform vec3 dofEqFar;
uniform float maxFarCoC;
//static float d0 = 0.1;
//static float d1 = 0.1;
//static float d2 = 0.8;
//static vec4 dofLerpScale = vec4( -1.0 / d0, -1.0 / d1, -1.0 / d2, 1.0 / d2 );
//static vec4 dofLerpBias = vec4( 1.0, (1.0 - d2) / d1, 1.0 / d2, (d2 - 1.0) / d2 );
//static vec3 dofEqFar = vec3( 2.0, 0.0, 1.0 );
vec4 tex2Doffset( sampler2D s, vec2 tc, vec2 offset )
{
return texture( s, tc + offset * oneOverTargetSize );
}
half3 GetSmallBlurSample( vec2 tc )
{
half3 sum;
const half weight = 4.0 / 17;
sum = half3(0); // Unblurred sample done by alpha blending
//sum += weight * tex2Doffset( colorSampler, tc, vec2( 0, 0 ) ).rgb;
sum += weight * tex2Doffset( colorSampler, tc, vec2( +0.5, -1.5 ) ).rgb;
sum += weight * tex2Doffset( colorSampler, tc, vec2( -1.5, -0.5 ) ).rgb;
sum += weight * tex2Doffset( colorSampler, tc, vec2( -0.5, +1.5 ) ).rgb;
sum += weight * tex2Doffset( colorSampler, tc, vec2( +1.5, +0.5 ) ).rgb;
return sum;
}
half4 InterpolateDof( half3 small, half3 med, half3 large, half t )
{
//t = 2;
half4 weights;
half3 color;
half alpha;
// Efficiently calculate the cross-blend weights for each sample.
// Let the unblurred sample to small blur fade happen over distance
// d0, the small to medium blur over distance d1, and the medium to
// large blur over distance d2, where d0 + d1 + d2 = 1.
//vec4 dofLerpScale = vec4( -1 / d0, -1 / d1, -1 / d2, 1 / d2 );
//vec4 dofLerpBias = vec4( 1, (1 d2) / d1, 1 / d2, (d2 1) / d2 );
weights = saturate( t * dofLerpScale + dofLerpBias );
weights.yz = min( weights.yz, 1 - weights.xy );
// Unblurred sample with weight "weights.x" done by alpha blending
color = weights.y * small + weights.z * med + weights.w * large;
//color = med;
alpha = dot( weights.yzw, half3( 16.0 / 17, 1.0, 1.0 ) );
//alpha = 0.0;
return half4( color, alpha );
}
void main()
{
//return half4( 1,0,1,1 );
//return half4( texture( colorSampler, IN_uv0 ).rgb, 1.0 );
//return half4( texture( colorSampler, texCoords ).rgb, 0 );
half3 small;
half4 med;
half3 large;
half depth;
half nearCoc;
half farCoc;
half coc;
small = GetSmallBlurSample( IN_uv0 );
//small = half3( 1,0,0 );
//return half4( small, 1.0 );
med = texture( smallBlurSampler, IN_uv1 );
//med.rgb = half3( 0,1,0 );
//return half4(med.rgb, 0.0);
large = texture( largeBlurSampler, IN_uv2 ).rgb;
//large = half3( 0,0,1 );
//return large;
//return half4(large.rgb,1.0);
nearCoc = med.a;
// Since the med blur texture is screwed up currently
// replace it with the large, but this needs to be fixed.
//med.rgb = large;
//nearCoc = 0;
depth = prepassUncondition( depthSampler, IN_uv3 ).w;
//return half4(depth.rrr,1);
//return half4(nearCoc.rrr,1.0);
if (depth > 0.999 )
{
coc = nearCoc; // We don't want to blur the sky.
//coc = 0;
}
else
{
// dofEqFar.x and dofEqFar.y specify the linear ramp to convert
// to depth for the distant out-of-focus region.
// dofEqFar.z is the ratio of the far to the near blur radius.
farCoc = clamp( dofEqFar.x * depth + dofEqFar.y, 0.0, maxFarCoC );
coc = max( nearCoc, farCoc * dofEqFar.z );
//coc = nearCoc;
}
//coc = nearCoc;
//coc = farCoc;
//return half4(coc.rrr,0.5);
//return half4(farCoc.rrr,1);
//return half4(nearCoc.rrr,1);
//return half4( 1,0,1,0 );
OUT_FragColor0 = InterpolateDof( small, med.rgb, large, coc );
}

View file

@ -0,0 +1,71 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "../../../gl/torque.glsl"
#include "../../gl/postFX.glsl"
uniform vec4 rtParams0;
uniform vec4 rtParams1;
uniform vec4 rtParams2;
uniform vec4 rtParams3;
uniform vec2 oneOverTargetSize;
void main()
{
/*
OUT.hpos = IN_pos;
OUT_uv0 = IN_uv;
OUT_uv1 = IN_uv;
OUT_uv2 = IN_uv;
OUT_uv3 = IN_uv;
*/
/*
OUT_hpos = IN_pos;
OUT_uv0 = IN_uv + rtParams0.xy;
OUT_uv1 = IN_uv + rtParams1.xy;
OUT_uv2 = IN_uv + rtParams2.xy;
OUT_uv3 = IN_uv + rtParams3.xy;
*/
/*
OUT_hpos = IN_pos;
OUT_uv0 = IN_uv * rtParams0.zw;
OUT_uv1 = IN_uv * rtParams1.zw;
OUT_uv2 = IN_uv * rtParams2.zw;
OUT_uv3 = IN_uv * rtParams3.zw;
*/
OUT_hpos = IN_pos;
OUT_uv0 = viewportCoordToRenderTarget( IN_uv, rtParams0 );
OUT_uv1 = viewportCoordToRenderTarget( IN_uv, rtParams1 ); // + vec2( -5, 1 ) * oneOverTargetSize;
OUT_uv2 = viewportCoordToRenderTarget( IN_uv, rtParams2 );
OUT_uv3 = viewportCoordToRenderTarget( IN_uv, rtParams3 );
OUT_wsEyeRay = IN_wsEyeRay;
correctSSP(gl_Position);
}

View file

@ -0,0 +1,68 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h"
in vec3 wsEyeRay;
#define IN_wsEyeRay wsEyeRay
in vec2 uv0;
#define IN_uv0 uv0
in vec2 uv1;
#define IN_uv1 uv1
in vec2 uv2;
#define IN_uv2 uv2
in vec2 uv3;
#define IN_uv3 uv3
in vec2 uv4;
#define IN_uv4 uv4
in vec2 uv5;
#define IN_uv5 uv5
in vec2 uv6;
#define IN_uv6 uv6
in vec2 uv7;
#define IN_uv7 uv7
#define OUT OUT_FragColor0
uniform sampler2D diffuseMap;
void main()
{
vec4 kernel = vec4( 0.175, 0.275, 0.375, 0.475 ) * 0.5 / 1.3; //25f;
OUT = vec4(0);
OUT += texture( diffuseMap, IN_uv0 ) * kernel.x;
OUT += texture( diffuseMap, IN_uv1 ) * kernel.y;
OUT += texture( diffuseMap, IN_uv2 ) * kernel.z;
OUT += texture( diffuseMap, IN_uv3 ) * kernel.w;
OUT += texture( diffuseMap, IN_uv4 ) * kernel.x;
OUT += texture( diffuseMap, IN_uv5 ) * kernel.y;
OUT += texture( diffuseMap, IN_uv6 ) * kernel.z;
OUT += texture( diffuseMap, IN_uv7 ) * kernel.w;
// Calculate a lumenance value in the alpha so we
// can use alpha test to save fillrate.
//vec3 rgb2lum = vec3( 0.30, 0.59, 0.11 );
//OUT.a = dot( OUT.rgb, rgb2lum );
}

View file

@ -0,0 +1,91 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "../../../gl/torque.glsl"
in vec4 vPosition;
in vec2 vTexCoord0;
in vec3 vTexCoord1;
#define IN_pos vPosition
#define _IN_uv vTexCoord0
#define IN_wsEyeRay vTexCoord1
#define OUT_hpos gl_Position
out vec3 wsEyeRay;
#define OUT_wsEyeRay wsEyeRay
out vec2 uv0;
#define OUT_uv0 uv0
out vec2 uv1;
#define OUT_uv1 uv1
out vec2 uv2;
#define OUT_uv2 uv2
out vec2 uv3;
#define OUT_uv3 uv3
out vec2 uv4;
#define OUT_uv4 uv4
out vec2 uv5;
#define OUT_uv5 uv5
out vec2 uv6;
#define OUT_uv6 uv6
out vec2 uv7;
#define OUT_uv7 uv7
uniform vec2 texSize0;
uniform vec4 rtParams0;
uniform vec2 oneOverTargetSize;
void main()
{
OUT_hpos = IN_pos;
vec2 IN_uv = viewportCoordToRenderTarget( _IN_uv, rtParams0 );
// I don't know why this offset is necessary, but it is.
//IN_uv = IN_uv * oneOverTargetSize;
OUT_uv0 = IN_uv + ( ( BLUR_DIR * 3.5f ) / texSize0 );
OUT_uv1 = IN_uv + ( ( BLUR_DIR * 2.5f ) / texSize0 );
OUT_uv2 = IN_uv + ( ( BLUR_DIR * 1.5f ) / texSize0 );
OUT_uv3 = IN_uv + ( ( BLUR_DIR * 0.5f ) / texSize0 );
OUT_uv4 = IN_uv - ( ( BLUR_DIR * 3.5f ) / texSize0 );
OUT_uv5 = IN_uv - ( ( BLUR_DIR * 2.5f ) / texSize0 );
OUT_uv6 = IN_uv - ( ( BLUR_DIR * 1.5f ) / texSize0 );
OUT_uv7 = IN_uv - ( ( BLUR_DIR * 0.5f ) / texSize0 );
/*
OUT_uv0 = viewportCoordToRenderTarget( OUT_uv0, rtParams0 );
OUT_uv1 = viewportCoordToRenderTarget( OUT_uv1, rtParams0 );
OUT_uv2 = viewportCoordToRenderTarget( OUT_uv2, rtParams0 );
OUT_uv3 = viewportCoordToRenderTarget( OUT_uv3, rtParams0 );
OUT_uv4 = viewportCoordToRenderTarget( OUT_uv4, rtParams0 );
OUT_uv5 = viewportCoordToRenderTarget( OUT_uv5, rtParams0 );
OUT_uv6 = viewportCoordToRenderTarget( OUT_uv6, rtParams0 );
OUT_uv7 = viewportCoordToRenderTarget( OUT_uv7, rtParams0 );
*/
correctSSP(gl_Position);
}

View file

@ -0,0 +1,69 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "../../../gl/torque.glsl"
#include "../../gl/postFX.glsl"
uniform vec4 rtParams0;
uniform vec4 rtParams1;
uniform vec4 rtParams2;
uniform vec4 rtParams3;
void main()
{
/*
OUT.hpos = IN_pos;
OUT_uv0 = IN_uv;
OUT_uv1 = IN_uv;
OUT_uv2 = IN_uv;
OUT_uv3 = IN_uv;
*/
/*
OUT_hpos = IN_pos;
OUT_uv0 = IN_uv + rtParams0.xy;
OUT_uv1 = IN_uv + rtParams1.xy;
OUT_uv2 = IN_uv + rtParams2.xy;
OUT_uv3 = IN_uv + rtParams3.xy;
*/
/*
OUT_hpos = IN_pos;
OUT_uv0 = IN_uv * rtParams0.zw;
OUT_uv1 = IN_uv * rtParams1.zw;
OUT_uv2 = IN_uv * rtParams2.zw;
OUT_uv3 = IN_uv * rtParams3.zw;
*/
OUT_hpos = IN_pos;
OUT_uv0 = viewportCoordToRenderTarget( IN_uv, rtParams0 );
OUT_uv1 = viewportCoordToRenderTarget( IN_uv, rtParams1 );
OUT_uv2 = viewportCoordToRenderTarget( IN_uv, rtParams2 );
OUT_uv3 = viewportCoordToRenderTarget( IN_uv, rtParams3 );
OUT_wsEyeRay = IN_wsEyeRay;
correctSSP(gl_Position);
}

View file

@ -0,0 +1,44 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// This vertex and pixel shader applies a 3 x 3 blur to the image in
// colorMapSampler, which is the same size as the render target.
// The sample weights are 1/16 in the corners, 2/16 on the edges,
// and 4/16 in the center.
#include "../../../gl/hlslCompat.glsl"
uniform sampler2D colorSampler; // Output of DofNearCoc()
in vec4 texCoords;
#define IN_texCoords texCoords
void main()
{
vec4 color;
color = vec4(0.0);
color += texture( colorSampler, IN_texCoords.xz );
color += texture( colorSampler, IN_texCoords.yz );
color += texture( colorSampler, IN_texCoords.xw );
color += texture( colorSampler, IN_texCoords.yw );
OUT_FragColor0 = color / 4.0;
}

View file

@ -0,0 +1,54 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// This vertex and pixel shader applies a 3 x 3 blur to the image in
// colorMapSampler, which is the same size as the render target.
// The sample weights are 1/16 in the corners, 2/16 on the edges,
// and 4/16 in the center.
#include "../../../gl/hlslCompat.glsl"
#include "../../../gl/torque.glsl"
in vec4 vPosition;
in vec2 vTexCoord0;
#define IN_position vPosition
#define IN_texCoords vTexCoord0
#define OUT_position gl_Position
out vec4 texCoords;
#define OUT_texCoords texCoords
uniform vec2 oneOverTargetSize;
uniform vec4 rtParams0;
void main()
{
const vec4 halfPixel = vec4( -0.5, 0.5, -0.5, 0.5 );
OUT_position = IN_position; //Transform_ObjectToClip( IN_position );
//vec2 uv = IN_texCoords + rtParams0.xy;
vec2 uv = viewportCoordToRenderTarget( IN_texCoords, rtParams0 );
OUT_texCoords = uv.xxyy + halfPixel * oneOverTargetSize.xxyy;
correctSSP(gl_Position);
}

View file

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

View file

@ -0,0 +1,68 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h"
#include "../../gl/postFX.glsl"
uniform sampler2D edgeBuffer;
uniform sampler2D backBuffer;
uniform vec2 targetSize;
void main()
{
vec2 pixelSize = 1.0 / targetSize;
// Sample edge buffer, bail if not on an edge
float edgeSample = texture(edgeBuffer, IN_uv0).r;
clip(edgeSample - 1e-6);
// Ok we're on an edge, so multi-tap sample, average, and return
vec2 offsets[9] = vec2[](
vec2( 0.0, 0.0),
vec2(-1.0, -1.0),
vec2( 0.0, -1.0),
vec2( 1.0, -1.0),
vec2( 1.0, 0.0),
vec2( 1.0, 1.0),
vec2( 0.0, 1.0),
vec2(-1.0, 1.0),
vec2(-1.0, 0.0)
);
vec4 accumColor = vec4(0.0);
for(int i = 0; i < 9; i++)
{
// Multiply the intensity of the edge, by the UV, so that things which maybe
// aren't quite full edges get sub-pixel sampling to reduce artifacts
// Scaling offsets by 0.5 to reduce the range bluriness from extending to
// far outward from the edge.
vec2 offsetUV = IN_uv1 + edgeSample * ( offsets[i] * 0.5 ) * pixelSize;//rtWidthHeightInvWidthNegHeight.zw;
//offsetUV *= 0.999;
accumColor+= texture(backBuffer, offsetUV);
}
accumColor /= 9.0;
OUT_FragColor0 = accumColor;
}

View file

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

View file

@ -0,0 +1,94 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h"
// GPU Gems 3, pg 443-444
float GetEdgeWeight(vec2 uv0, in sampler2D prepassBuffer, in vec2 targetSize)
{
vec2 offsets[9] = vec2[](
vec2( 0.0, 0.0),
vec2(-1.0, -1.0),
vec2( 0.0, -1.0),
vec2( 1.0, -1.0),
vec2( 1.0, 0.0),
vec2( 1.0, 1.0),
vec2( 0.0, 1.0),
vec2(-1.0, 1.0),
vec2(-1.0, 0.0)
);
vec2 PixelSize = 1.0 / targetSize;
float Depth[9];
vec3 Normal[9];
for(int i = 0; i < 9; i++)
{
vec2 uv = uv0 + offsets[i] * PixelSize;
vec4 gbSample = prepassUncondition( prepassBuffer, uv );
Depth[i] = gbSample.a;
Normal[i] = gbSample.rgb;
}
vec4 Deltas1 = vec4(Depth[1], Depth[2], Depth[3], Depth[4]);
vec4 Deltas2 = vec4(Depth[5], Depth[6], Depth[7], Depth[8]);
Deltas1 = abs(Deltas1 - Depth[0]);
Deltas2 = abs(Depth[0] - Deltas2);
vec4 maxDeltas = max(Deltas1, Deltas2);
vec4 minDeltas = max(min(Deltas1, Deltas2), 0.00001);
vec4 depthResults = step(minDeltas * 25.0, maxDeltas);
Deltas1.x = dot(Normal[1], Normal[0]);
Deltas1.y = dot(Normal[2], Normal[0]);
Deltas1.z = dot(Normal[3], Normal[0]);
Deltas1.w = dot(Normal[4], Normal[0]);
Deltas2.x = dot(Normal[5], Normal[0]);
Deltas2.y = dot(Normal[6], Normal[0]);
Deltas2.z = dot(Normal[7], Normal[0]);
Deltas2.w = dot(Normal[8], Normal[0]);
Deltas1 = abs(Deltas1 - Deltas2);
vec4 normalResults = step(0.4, Deltas1);
normalResults = max(normalResults, depthResults);
return dot(normalResults, vec4(1.0, 1.0, 1.0, 1.0)) * 0.25;
}
in vec2 uv0;
#define IN_uv0 uv0
uniform sampler2D prepassBuffer;
uniform vec2 targetSize;
void main()
{
OUT_FragColor0 = vec4( GetEdgeWeight(IN_uv0, prepassBuffer, targetSize ) );//rtWidthHeightInvWidthNegHeight.zw);
}

View file

@ -44,7 +44,7 @@ Etc.
(2.)
Then include this file,
#include "Fxaa3_11.h"
include "Fxaa3_11.h"
(3.)
Then call the FXAA pixel shader from within your desired shader.

View file

@ -0,0 +1,123 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
#define FXAA_PC 1
#define FXAA_GLSL_130 1
#define FXAA_QUALITY__PRESET 12
#define FXAA_GREEN_AS_LUMA 1
#include "../Fxaa3_11.h"
#include "../../../gl/hlslCompat.glsl"
uniform sampler2D colorTex ;
uniform vec2 oneOverTargetSize;
in vec4 hpos;
in vec2 uv0;
void main()
{
OUT_FragColor0 = FxaaPixelShader(
uv0, // vertex position
vec4(0), // Unused... console stuff
colorTex, // The color back buffer
colorTex, // Used for 360 optimization
colorTex, // Used for 360 optimization
oneOverTargetSize,
vec4(0), // Unused... console stuff
vec4(0), // Unused... console stuff
vec4(0), // Unused... console stuff
//
// Only used on FXAA Quality.
// This used to be the FXAA_QUALITY__SUBPIX define.
// It is here now to allow easier tuning.
// Choose the amount of sub-pixel aliasing removal.
// This can effect sharpness.
// 1.00 - upper limit (softer)
// 0.75 - default amount of filtering
// 0.50 - lower limit (sharper, less sub-pixel aliasing removal)
// 0.25 - almost off
// 0.00 - completely off
0.75,
//
// Only used on FXAA Quality.
// This used to be the FXAA_QUALITY__EDGE_THRESHOLD define.
// It is here now to allow easier tuning.
// The minimum amount of local contrast required to apply algorithm.
// 0.333 - too little (faster)
// 0.250 - low quality
// 0.166 - default
// 0.125 - high quality
// 0.063 - overkill (slower)
0.166,
//
// Only used on FXAA Quality.
// This used to be the FXAA_QUALITY__EDGE_THRESHOLD_MIN define.
// It is here now to allow easier tuning.
// Trims the algorithm from processing darks.
// 0.0833 - upper limit (default, the start of visible unfiltered edges)
// 0.0625 - high quality (faster)
// 0.0312 - visible limit (slower)
// Special notes when using FXAA_GREEN_AS_LUMA,
// Likely want to set this to zero.
// As colors that are mostly not-green
// will appear very dark in the green channel!
// Tune by looking at mostly non-green content,
// then start at zero and increase until aliasing is a problem.
0,
//
// Only used on FXAA Console.
// This used to be the FXAA_CONSOLE__EDGE_SHARPNESS define.
// It is here now to allow easier tuning.
// This does not effect PS3, as this needs to be compiled in.
// Use FXAA_CONSOLE__PS3_EDGE_SHARPNESS for PS3.
// Due to the PS3 being ALU bound,
// there are only three safe values here: 2 and 4 and 8.
// These options use the shaders ability to a free *|/ by 2|4|8.
// For all other platforms can be a non-power of two.
// 8.0 is sharper (default!!!)
// 4.0 is softer
// 2.0 is really soft (good only for vector graphics inputs)
8,
0, // Unused... console stuff
0, // Unused... console stuff
vec4(0) // Unused... console stuff
);
}

View file

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

View file

@ -0,0 +1,60 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// Based on 'Cubic Lens Distortion HLSL Shader' by François Tarlier
// www.francois-tarlier.com/blog/index.php/2009/11/cubic-lens-distortion-shader
#include "./postFx.glsl"
#include "../../gl/torque.glsl"
#include "../../gl/hlslCompat.glsl"
uniform sampler2D backBuffer;
uniform float distCoeff;
uniform float cubeDistort;
uniform vec3 colorDistort;
void main()
{
vec2 tex = IN_uv0;
float f = 0;
float r2 = (tex.x - 0.5) * (tex.x - 0.5) + (tex.y - 0.5) * (tex.y - 0.5);
// Only compute the cubic distortion if necessary.
if ( cubeDistort == 0.0 )
f = 1 + r2 * distCoeff;
else
f = 1 + r2 * (distCoeff + cubeDistort * sqrt(r2));
// Distort each color channel seperately to get a chromatic distortion effect.
vec3 outColor;
vec3 distort = vec3(f) + colorDistort;
for ( int i=0; i < 3; i++ )
{
float x = distort[i] * ( tex.x - 0.5 ) + 0.5;
float y = distort[i] * ( tex.y - 0.5 ) + 0.5;
outColor[i] = tex2Dlod( backBuffer, vec4(x,y,0,0) )[i];
}
OUT_FragColor0 = vec4( outColor.rgb, 1 );
}

View file

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

View file

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

View file

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

View file

@ -0,0 +1,58 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../gl/hlslCompat.glsl"
uniform sampler2D diffuseMap ;
in vec4 hpos; //POSITION;
in vec2 uv0; //TEXCOORD0;
in vec2 uv1; //TEXCOORD1;
in vec2 uv2; //TEXCOORD2;
in vec2 uv3; //TEXCOORD3;
in vec2 uv4; //TEXCOORD4;
in vec2 uv5; //TEXCOORD5;
in vec2 uv6; //TEXCOORD6;
in vec2 uv7; //TEXCOORD7;
void main()
{
vec4 kernel = vec4( 0.175, 0.275, 0.375, 0.475 ) * 0.5f;
vec4 OUT = vec4(0);
OUT += texture( diffuseMap, uv0 ) * kernel.x;
OUT += texture( diffuseMap, uv1 ) * kernel.y;
OUT += texture( diffuseMap, uv2 ) * kernel.z;
OUT += texture( diffuseMap, uv3 ) * kernel.w;
OUT += texture( diffuseMap, uv4 ) * kernel.x;
OUT += texture( diffuseMap, uv5 ) * kernel.y;
OUT += texture( diffuseMap, uv6 ) * kernel.z;
OUT += texture( diffuseMap, uv7 ) * kernel.w;
// Calculate a lumenance value in the alpha so we
// can use alpha test to save fillrate.
vec3 rgb2lum = vec3( 0.30, 0.59, 0.11 );
OUT.a = dot( OUT.rgb, rgb2lum );
OUT_FragColor0 = OUT;
}

View file

@ -0,0 +1,59 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../gl/hlslCompat.glsl"
#include "../../gl/torque.glsl"
in vec4 vPosition;
in vec2 vTexCoord0;
uniform vec2 texSize0;
out vec4 hpos; //POSITION;
out vec2 uv0; //TEXCOORD0;
out vec2 uv1; //TEXCOORD1;
out vec2 uv2; //TEXCOORD2;
out vec2 uv3; //TEXCOORD3;
out vec2 uv4; //TEXCOORD4;
out vec2 uv5; //TEXCOORD5;
out vec2 uv6; //TEXCOORD6;
out vec2 uv7; //TEXCOORD7;
void main()
{
gl_Position = vPosition;
hpos = gl_Position;
vec2 uv = vTexCoord0 + (0.5f / texSize0);
uv0 = uv + ( ( BLUR_DIR * 3.5f ) / texSize0 );
uv1 = uv + ( ( BLUR_DIR * 2.5f ) / texSize0 );
uv2 = uv + ( ( BLUR_DIR * 1.5f ) / texSize0 );
uv3 = uv + ( ( BLUR_DIR * 0.5f ) / texSize0 );
uv4 = uv - ( ( BLUR_DIR * 3.5f ) / texSize0 );
uv5 = uv - ( ( BLUR_DIR * 2.5f ) / texSize0 );
uv6 = uv - ( ( BLUR_DIR * 1.5f ) / texSize0 );
uv7 = uv - ( ( BLUR_DIR * 0.5f ) / texSize0 );
correctSSP(gl_Position);
}

View file

@ -0,0 +1,76 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../gl/hlslCompat.glsl"
#include "../../gl/torque.glsl"
#include "shadergen:/autogenConditioners.h"
#include "postFX.glsl"
#undef IN_uv0
#define _IN_uv0 uv0
uniform mat4 matPrevScreenToWorld;
uniform mat4 matWorldToScreen;
// Passed in from setShaderConsts()
uniform float velocityMultiplier;
uniform sampler2D backBuffer;
uniform sampler2D prepassTex;
void main()
{
vec2 IN_uv0 = _IN_uv0;
float samples = 5;
// First get the prepass texture for uv channel 0
vec4 prepass = prepassUncondition( prepassTex, IN_uv0 );
// Next extract the depth
float depth = prepass.a;
// Create the screen position
vec4 screenPos = vec4(IN_uv0.x*2-1, IN_uv0.y*2-1, depth*2-1, 1);
// Calculate the world position
vec4 D = tMul(screenPos, matWorldToScreen);
vec4 worldPos = D / D.w;
// Now calculate the previous screen position
vec4 previousPos = tMul( worldPos, matPrevScreenToWorld );
previousPos /= previousPos.w;
// Calculate the XY velocity
vec2 velocity = ((screenPos - previousPos) / velocityMultiplier).xy;
// Generate the motion blur
vec4 color = texture(backBuffer, IN_uv0);
IN_uv0 += velocity;
for(int i = 1; i<samples; ++i, IN_uv0 += velocity)
{
vec4 currentColor = texture(backBuffer, IN_uv0);
color += currentColor;
}
OUT_FragColor0 = color / samples;
}

View file

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

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.
//-----------------------------------------------------------------------------
#ifdef TORQUE_VERTEX_SHADER
in vec4 vPosition;
in vec2 vTexCoord0;
in vec3 vTexCoord1;
#define IN_pos vPosition
#define IN_uv vTexCoord0.st
#define IN_wsEyeRay vTexCoord1.xyz
out vec2 uv0;
out vec2 uv1;
out vec2 uv2;
out vec2 uv3;
out vec3 wsEyeRay;
#define OUT_uv0 uv0
#define OUT_uv1 uv1
#define OUT_uv2 uv2
#define OUT_uv3 uv3
#define OUT_wsEyeRay wsEyeRay
#define OUT_hpos gl_Position
#endif //TORQUE_VERTEX_SHADER
#ifdef TORQUE_PIXEL_SHADER
in vec2 uv0;
in vec2 uv1;
in vec2 uv2;
in vec2 uv3;
in vec3 wsEyeRay;
#define IN_uv0 uv0
#define IN_uv1 uv1
#define IN_uv2 uv2
#define IN_uv3 uv3
#define IN_wsEyeRay wsEyeRay
#endif//TORQUE_PIXEL_SHADER

View file

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

View file

@ -0,0 +1,50 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../gl/hlslCompat.glsl"
#include "../../gl/torque.glsl"
#include "shadergen:/autogenConditioners.h"
uniform float accumTime;
uniform vec2 projectionOffset;
uniform vec4 targetViewport;
uniform sampler2D inputTex;
in vec2 uv0;
#define IN_uv0 uv0
void main()
{
float speed = 2.0;
float distortion = 6.0;
float y = IN_uv0.y + (cos((IN_uv0.y+projectionOffset.y) * distortion + accumTime * speed) * 0.01);
float x = IN_uv0.x + (sin((IN_uv0.x+projectionOffset.x) * distortion + accumTime * speed) * 0.01);
// Clamp the calculated uv values to be within the target's viewport
y = clamp(y, targetViewport.y, targetViewport.w);
x = clamp(x, targetViewport.x, targetViewport.z);
OUT_FragColor0 = texture (inputTex, vec2(x, y));
}

View file

@ -0,0 +1,138 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../gl/hlslCompat.glsl"
#include "../../gl/torque.glsl"
#include "postFX.glsl"
#include "shadergen:/autogenConditioners.h"
//-----------------------------------------------------------------------------
// Defines
//-----------------------------------------------------------------------------
// oceanFogData
#define FOG_DENSITY waterFogData[0]
#define FOG_DENSITY_OFFSET waterFogData[1]
#define WET_DEPTH waterFogData[2]
#define WET_DARKENING waterFogData[3]
//-----------------------------------------------------------------------------
// Uniforms
//-----------------------------------------------------------------------------
uniform sampler2D prepassTex ;
uniform sampler2D backbuffer ;
uniform sampler1D waterDepthGradMap;
uniform vec3 eyePosWorld;
uniform vec3 ambientColor;
uniform vec4 waterColor;
uniform vec4 waterFogData;
uniform vec4 waterFogPlane;
uniform vec2 nearFar;
uniform vec4 rtParams0;
uniform float waterDepthGradMax;
void main()
{
//vec2 prepassCoord = IN_uv0;
//IN_uv0 = ( IN_uv0.xy * rtParams0.zw ) + rtParams0.xy;
float depth = prepassUncondition( prepassTex, IN_uv0 ).w;
//return vec4( depth.rrr, 1 );
// Skip fogging the extreme far plane so that
// the canvas clear color always appears.
//clip( 0.9 - depth );
// We assume that the eye position is below water because
// otherwise this shader/posteffect should not be active.
depth *= nearFar.y;
vec3 eyeRay = normalize( IN_wsEyeRay );
vec3 rayStart = eyePosWorld;
vec3 rayEnd = eyePosWorld + ( eyeRay * depth );
//return vec4( rayEnd, 1 );
vec4 plane = waterFogPlane; //vec4( 0, 0, 1, -waterHeight );
//plane.w -= 0.15;
float startSide = dot( plane.xyz, rayStart ) + plane.w;
if ( startSide > 0 )
{
rayStart.z -= ( startSide );
//return vec4( 1, 0, 0, 1 );
}
vec3 hitPos;
vec3 ray = rayEnd - rayStart;
float rayLen = length( ray );
vec3 rayDir = normalize( ray );
float endSide = dot( plane.xyz, rayEnd ) + plane.w;
float planeDist;
if ( endSide < -0.005 )
{
//return vec4( 0, 0, 1, 1 );
hitPos = rayEnd;
planeDist = endSide;
}
else
{
//return vec4( 0, 0, 0, 0 );
float den = dot( ray, plane.xyz );
// Parallal to the plane, return the endPnt.
//if ( den == 0.0f )
// return endPnt;
float dist = -( dot( plane.xyz, rayStart ) + plane.w ) / den;
if ( dist < 0.0 )
dist = 0.0;
//return vec4( 1, 0, 0, 1 );
//return vec4( ( dist ).rrr, 1 );
hitPos = mix( rayStart, rayEnd, dist );
planeDist = dist;
}
float delta = length( hitPos - rayStart );
float fogAmt = 1.0 - saturate( exp( -FOG_DENSITY * ( delta - FOG_DENSITY_OFFSET ) ) );
//return vec4( fogAmt.rrr, 1 );
// Calculate the water "base" color based on depth.
vec4 fogColor = waterColor * texture( waterDepthGradMap, saturate( delta / waterDepthGradMax ) );
// Modulate baseColor by the ambientColor.
fogColor *= vec4( ambientColor.rgb, 1 );
vec3 inColor = hdrDecode( texture( backbuffer, IN_uv0 ).rgb );
inColor.rgb *= 1.0 - saturate( abs( planeDist ) / WET_DEPTH ) * WET_DARKENING;
//return vec4( inColor, 1 );
vec3 outColor = mix( inColor, fogColor.rgb, fogAmt );
OUT_FragColor0 = vec4( hdrEncode( outColor ), 1 );
}

View file

@ -0,0 +1,70 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h"
#include "../../gl/postFX.glsl"
uniform sampler2D inputTex ;
uniform vec2 oneOverTargetSize;
uniform float gaussMultiplier;
uniform float gaussMean;
uniform float gaussStdDev;
#define PI 3.141592654
float computeGaussianValue( float x, float mean, float std_deviation )
{
// The gaussian equation is defined as such:
/*
-(x - mean)^2
-------------
1.0 2*std_dev^2
f(x,mean,std_dev) = -------------------- * e^
sqrt(2*pi*std_dev^2)
*/
float tmp = ( 1.0f / sqrt( 2.0f * PI * std_deviation * std_deviation ) );
float tmp2 = exp( ( -( ( x - mean ) * ( x - mean ) ) ) / ( 2.0f * std_deviation * std_deviation ) );
return tmp * tmp2;
}
void main()
{
vec4 color = vec4( 0.0f, 0.0f, 0.0f, 0.0f );
float offset = 0;
float weight = 0;
float x = 0;
float fI = 0;
for( int i = 0; i < 9; i++ )
{
fI = float(i);
offset = (i - 4.0) * oneOverTargetSize.x;
x = (i - 4.0) / 4.0;
weight = gaussMultiplier * computeGaussianValue( x, gaussMean, gaussStdDev );
color += (texture( inputTex, IN_uv0 + vec2( offset, 0.0f ) ) * weight );
}
OUT_FragColor0 = vec4( color.rgb, 1.0f );
}

View file

@ -0,0 +1,69 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h"
#include "../../gl/postFX.glsl"
uniform sampler2D inputTex ;
uniform vec2 oneOverTargetSize;
uniform float gaussMultiplier;
uniform float gaussMean;
uniform float gaussStdDev;
#define D3DX_PI 3.141592654
float computeGaussianValue( float x, float mean, float std_deviation )
{
// The gaussian equation is defined as such:
/*
-(x - mean)^2
-------------
1.0 2*std_dev^2
f(x,mean,std_dev) = -------------------- * e^
sqrt(2*pi*std_dev^2)
*/
float tmp = ( 1.0f / sqrt( 2.0f * D3DX_PI * std_deviation * std_deviation ) );
float tmp2 = exp( ( -( ( x - mean ) * ( x - mean ) ) ) / ( 2.0f * std_deviation * std_deviation ) );
return tmp * tmp2;
}
void main()
{
vec4 color = vec4( 0.0f, 0.0f, 0.0f, 0.0f );
float offset = 0;
float weight = 0;
float x = 0;
float fI = 0;
for( int i = 0; i < 9; i++ )
{
fI = float(i);
offset = (fI - 4.0) * oneOverTargetSize.y;
x = (fI - 4.0) / 4.0;
weight = gaussMultiplier * computeGaussianValue( x, gaussMean, gaussStdDev );
color += (texture( inputTex, IN_uv0 + vec2( 0.0f, offset ) ) * weight );
}
OUT_FragColor0 = vec4( color.rgb, 1.0f );
}

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.
//-----------------------------------------------------------------------------
#include "../../../gl/torque.glsl"
#include "../../../gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h"
#include "../../gl/postFX.glsl"
uniform sampler2D inputTex ;
uniform sampler2D luminanceTex ;
uniform vec2 oneOverTargetSize;
uniform float brightPassThreshold;
uniform float g_fMiddleGray;
const vec3 LUMINANCE_VECTOR = vec3(0.3125f, 0.6154f, 0.0721f);
const vec2 gTapOffsets[4] = vec2[]
(
vec2( -0.5, 0.5 ), vec2( 0.5, -0.5 ),
vec2( -0.5, -0.5 ), vec2( 0.5, 0.5 )
);
void main()
{
vec4 average = vec4( 0.0f, 0.0f, 0.0f, 0.0f );
// Combine and average 4 samples from the source HDR texture.
for( int i = 0; i < 4; i++ )
average += hdrDecode( texture( inputTex, IN_uv0 + ( gTapOffsets[i] * oneOverTargetSize ) ) );
average *= 0.25f;
// Determine the brightness of this particular pixel.
float adaptedLum = texture( luminanceTex, vec2( 0.5f, 0.5f ) ).r;
float lum = (g_fMiddleGray / (adaptedLum + 0.0001)) * hdrLuminance( average.rgb );
//float lum = hdrLuminance( average.rgb );
// Determine whether this pixel passes the test...
if ( lum < brightPassThreshold )
average = vec4( 0.0f, 0.0f, 0.0f, 1.0f );
// Write the colour to the bright-pass render target
OUT_FragColor0 = hdrEncode( average );
}

View file

@ -0,0 +1,46 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h"
#include "../../gl/postFX.glsl"
uniform sampler2D currLum;
uniform sampler2D lastAdaptedLum;
uniform float adaptRate;
uniform float deltaTime;
void main()
{
float fAdaptedLum = texture( lastAdaptedLum, vec2(0.5f, 0.5f) ).r;
float fCurrentLum = texture( currLum, vec2(0.5f, 0.5f) ).r;
// The user's adapted luminance level is simulated by closing the gap between
// adapted luminance and current luminance by 2% every frame, based on a
// 30 fps rate. This is not an accurate model of human adaptation, which can
// take longer than half an hour.
float diff = fCurrentLum - fAdaptedLum;
float fNewAdaptation = fAdaptedLum + ( diff * ( 1.0 - exp( -deltaTime * adaptRate ) ) );
OUT_FragColor0 = vec4( fNewAdaptation, 0.0, 0.0, 1.0f );
}

View file

@ -0,0 +1,48 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#define IN_GLSL
#include "../../../shdrConsts.h"
#include "../../../gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h"
in vec4 texCoords[8];
#define IN_texCoords texCoords
uniform sampler2D inputTex;
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
void main()
{
// We calculate the texture coords
// in the vertex shader as an optimization.
vec4 _sample = vec4(0.0f);
for ( int i = 0; i < 8; i++ )
{
_sample += texture( inputTex, IN_texCoords[i].xy );
_sample += texture( inputTex, IN_texCoords[i].zw );
}
OUT_FragColor0 = _sample / 16;
}

View file

@ -0,0 +1,141 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
#define IN_GLSL
#include "../../../shdrConsts.h"
#include "../../../gl/hlslCompat.glsl"
in vec4 vPosition;
in vec2 vTexCoord0;
#define In_pos vPosition
#define In_uv vTexCoord0
//-----------------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------------
out vec4 texCoords[8];
#define Out_texCoords texCoords
#define Out_hpos gl_Position
uniform vec2 targetSize;
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
void main()
{
Out_hpos = In_pos;
// Sample from the 16 surrounding points. Since the center point will be in
// the exact center of 16 texels, a 0.5f offset is needed to specify a texel
// center.
vec2 texSize = vec2( 1.0 / (targetSize.x - 1.0), 1.0 / (targetSize.y - 1.0) );
vec4 uv;
uv.xy = In_uv.xy;
uv.zw = In_uv.xy;
Out_texCoords[0] = uv;
Out_texCoords[0].x += texSize.x;
Out_texCoords[0].y += texSize.y;
Out_texCoords[0].z += texSize.x;
Out_texCoords[0].w += texSize.y;
Out_texCoords[0].x += ( 0 - 1.5 ) * texSize.x;
Out_texCoords[0].y += ( 0 - 1.5 ) * texSize.y;
Out_texCoords[0].z += ( 1 - 1.5 ) * texSize.x;
Out_texCoords[0].w += ( 0 - 1.5 ) * texSize.y;
Out_texCoords[1] = uv;
Out_texCoords[1].x += texSize.x;
Out_texCoords[1].y += texSize.y;
Out_texCoords[1].z += texSize.x;
Out_texCoords[1].w += texSize.y;
Out_texCoords[1].x += ( 2 - 1.5 ) * texSize.x;
Out_texCoords[1].y += ( 0 - 1.5 ) * texSize.y;
Out_texCoords[1].z += ( 3 - 1.5 ) * texSize.x;
Out_texCoords[1].w += ( 0 - 1.5 ) * texSize.y;
Out_texCoords[2] = uv;
Out_texCoords[2].x += texSize.x;
Out_texCoords[2].y += texSize.y;
Out_texCoords[2].z += texSize.x;
Out_texCoords[2].w += texSize.y;
Out_texCoords[2].x += ( 0 - 1.5 ) * texSize.x;
Out_texCoords[2].y += ( 1 - 1.5 ) * texSize.y;
Out_texCoords[2].z += ( 1 - 1.5 ) * texSize.x;
Out_texCoords[2].w += ( 1 - 1.5 ) * texSize.y;
Out_texCoords[3] = uv;
Out_texCoords[3].x += texSize.x;
Out_texCoords[3].y += texSize.y;
Out_texCoords[3].z += texSize.x;
Out_texCoords[3].w += texSize.y;
Out_texCoords[3].x += ( 2 - 1.5 ) * texSize.x;
Out_texCoords[3].y += ( 1 - 1.5 ) * texSize.y;
Out_texCoords[3].z += ( 3 - 1.5 ) * texSize.x;
Out_texCoords[3].w += ( 1 - 1.5 ) * texSize.y;
Out_texCoords[4] = uv;
Out_texCoords[4].x += texSize.x;
Out_texCoords[4].y += texSize.y;
Out_texCoords[4].z += texSize.x;
Out_texCoords[4].w += texSize.y;
Out_texCoords[4].x += ( 0 - 1.5 ) * texSize.x;
Out_texCoords[4].y += ( 2 - 1.5 ) * texSize.y;
Out_texCoords[4].z += ( 1 - 1.5 ) * texSize.x;
Out_texCoords[4].w += ( 2 - 1.5 ) * texSize.y;
Out_texCoords[5] = uv;
Out_texCoords[5].x += texSize.x;
Out_texCoords[5].y += texSize.y;
Out_texCoords[5].z += texSize.x;
Out_texCoords[5].w += texSize.y;
Out_texCoords[5].x += ( 2 - 1.5 ) * texSize.x;
Out_texCoords[5].y += ( 2 - 1.5 ) * texSize.y;
Out_texCoords[5].z += ( 3 - 1.5 ) * texSize.x;
Out_texCoords[5].w += ( 2 - 1.5 ) * texSize.y;
Out_texCoords[6] = uv;
Out_texCoords[6].x += texSize.x;
Out_texCoords[6].y += texSize.y;
Out_texCoords[6].z += texSize.x;
Out_texCoords[6].w += texSize.y;
Out_texCoords[6].x += ( 0 - 1.5 ) * texSize.x;
Out_texCoords[6].y += ( 3 - 1.5 ) * texSize.y;
Out_texCoords[6].z += ( 1 - 1.5 ) * texSize.x;
Out_texCoords[6].w += ( 3 - 1.5 ) * texSize.y;
Out_texCoords[7] = uv;
Out_texCoords[7].x += texSize.x;
Out_texCoords[7].y += texSize.y;
Out_texCoords[7].z += texSize.x;
Out_texCoords[7].w += texSize.y;
Out_texCoords[7].x += ( 2 - 1.5 ) * texSize.x;
Out_texCoords[7].y += ( 3 - 1.5 ) * texSize.y;
Out_texCoords[7].z += ( 3 - 1.5 ) * texSize.x;
Out_texCoords[7].w += ( 3 - 1.5 ) * texSize.y;
correctSSP(gl_Position);
}

View file

@ -0,0 +1,96 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/torque.glsl"
#include "../../../gl/hlslCompat.glsl"
#include "../../gl/postFX.glsl"
uniform sampler2D sceneTex;
uniform sampler2D luminanceTex;
uniform sampler2D bloomTex;
uniform sampler1D colorCorrectionTex;
uniform vec2 texSize0;
uniform vec2 texSize2;
uniform float g_fEnableToneMapping;
uniform float g_fMiddleGray;
uniform float g_fWhiteCutoff;
uniform float g_fEnableBlueShift;
uniform vec3 g_fBlueShiftColor;
uniform float g_fBloomScale;
uniform float g_fOneOverGamma;
void main()
{
vec4 _sample = hdrDecode( texture( sceneTex, IN_uv0 ) );
float adaptedLum = texture( luminanceTex, vec2( 0.5f, 0.5f ) ).r;
vec4 bloom = texture( bloomTex, IN_uv0 );
// For very low light conditions, the rods will dominate the perception
// of light, and therefore color will be desaturated and shifted
// towards blue.
if ( g_fEnableBlueShift > 0.0f )
{
const vec3 LUMINANCE_VECTOR = vec3(0.2125f, 0.7154f, 0.0721f);
// Define a linear blending from -1.5 to 2.6 (log scale) which
// determines the mix amount for blue shift
float coef = 1.0f - ( adaptedLum + 1.5 ) / 4.1;
coef = saturate( coef * g_fEnableBlueShift );
// Lerp between current color and blue, desaturated copy
vec3 rodColor = dot( _sample.rgb, LUMINANCE_VECTOR ) * g_fBlueShiftColor;
_sample.rgb = mix( _sample.rgb, rodColor, coef );
rodColor = dot( bloom.rgb, LUMINANCE_VECTOR ) * g_fBlueShiftColor;
bloom.rgb = mix( bloom.rgb, rodColor, coef );
}
// Map the high range of color values into a range appropriate for
// display, taking into account the user's adaptation level,
// white point, and selected value for for middle gray.
if ( g_fEnableToneMapping > 0.0f )
{
float Lp = (g_fMiddleGray / (adaptedLum + 0.0001)) * hdrLuminance( _sample.rgb );
//float toneScalar = ( Lp * ( 1.0 + ( Lp / ( g_fWhiteCutoff ) ) ) ) / ( 1.0 + Lp );
float toneScalar = Lp;
_sample.rgb = mix( _sample.rgb, _sample.rgb * toneScalar, g_fEnableToneMapping );
}
// Add the bloom effect.
_sample += g_fBloomScale * bloom;
// Apply the color correction.
_sample.r = texture( colorCorrectionTex, _sample.r ).r;
_sample.g = texture( colorCorrectionTex, _sample.g ).g;
_sample.b = texture( colorCorrectionTex, _sample.b ).b;
// Apply gamma correction
_sample.rgb = pow( abs(_sample.rgb), vec3(g_fOneOverGamma) );
OUT_FragColor0 = _sample;
}

View file

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

View file

@ -0,0 +1,60 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/torque.glsl"
#include "../../../gl/hlslCompat.glsl"
#include "../../gl/postFX.glsl"
uniform sampler2D inputTex;
uniform vec2 texSize0;
uniform float g_fMinLuminace;
const vec2 gTapOffsets[9] = vec2[]
(
vec2( -1.0, -1.0 ), vec2( 0.0, -1.0 ), vec2( 1.0, -1.0 ),
vec2( -1.0, 0.0 ), vec2( 0.0, 0.0 ), vec2( 1.0, 0.0 ),
vec2( -1.0, 1.0 ), vec2( 0.0, 1.0 ), vec2( 1.0, 1.0 )
);
void main()
{
vec2 tsize = 1.0 / texSize0;
vec3 _sample;
float average = 0.0;
for ( int i = 0; i < 9; i++ )
{
// Decode the hdr value.
_sample = hdrDecode( texture( inputTex, IN_uv0 + ( gTapOffsets[i] * tsize ) ).rgb );
// Get the luminance and add it to the average.
float lum = max( hdrLuminance( _sample ), g_fMinLuminace );
average += log( lum );
}
average = exp( average / 9.0 );
OUT_FragColor0 = vec4( average, 0.0, 0.0, 1.0 );
}

View file

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

View file

@ -0,0 +1,54 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h"
#include "../../gl/postFx.glsl"
uniform sampler2D backBuffer; // The original backbuffer.
uniform sampler2D prepassTex; // The pre-pass depth and normals.
uniform float brightScalar;
const vec3 LUMINANCE_VECTOR = vec3(0.3125f, 0.6154f, 0.0721f);
void main()
{
vec4 col = vec4( 0, 0, 0, 1 );
// Get the depth at this pixel.
float depth = prepassUncondition( prepassTex, IN_uv0 ).w;
// If the depth is equal to 1.0, read from the backbuffer
// and perform the exposure calculation on the result.
if ( depth >= 0.999 )
{
col = texture( backBuffer, IN_uv0 );
//col = 1 - exp(-120000 * col);
col += dot( vec3(col), LUMINANCE_VECTOR ) + 0.0001f;
col *= brightScalar;
}
OUT_FragColor0 = col;
}

View file

@ -0,0 +1,92 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../../gl/hlslCompat.glsl"
#include "../../gl/postFx.glsl"
uniform sampler2D frameSampler;
uniform sampler2D backBuffer;
uniform vec3 camForward;
uniform vec3 lightDirection;
uniform vec2 screenSunPos;
uniform vec2 oneOverTargetSize;
uniform int numSamples;
uniform float density;
uniform float weight;
uniform float decay;
uniform float exposure;
void main()
{
vec4 texCoord = vec4( IN_uv0.xy, 0, 0 );
// Store initial sample.
half3 color = half3(texture( frameSampler, texCoord.xy ).rgb);
// Store original bb color.
vec4 bbCol = texture( backBuffer, IN_uv1 );
// Set up illumination decay factor.
half illuminationDecay = 1.0;
float amount = saturate( dot( -lightDirection, camForward ) );
int samples = int(numSamples * amount);
if ( samples <= 0 )
{
OUT_FragColor0 = bbCol;
return;
}
// Calculate vector from pixel to light source in screen space.
half2 deltaTexCoord = half2( texCoord.xy - screenSunPos );
// Divide by number of samples and scale by control factor.
deltaTexCoord *= 1.0 / half(samples * density);
// Evaluate summation from Equation 3 NUM_SAMPLES iterations.
for ( int i = 0; i < samples; i++ )
{
// Step sample location along ray.
texCoord.xy -= deltaTexCoord;
// Retrieve sample at new location.
half3 sample_ = half3(tex2Dlod( frameSampler, texCoord ));
// Apply sample attenuation scale/decay factors.
sample_ *= illuminationDecay * weight;
// Accumulate combined color.
color += sample_;
// Update exponential decay factor.
illuminationDecay *= decay;
}
//return saturate( amount ) * color * Exposure;
//return bbCol * decay;
// Output final color with a further scale control factor.
OUT_FragColor0 = saturate( amount ) * vec4( color * exposure, 1 ) + bbCol;
}

View file

@ -0,0 +1,81 @@
//-----------------------------------------------------------------------------
// 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/
#include "../../../gl/hlslCompat.glsl"
in vec2 texcoord;
uniform sampler2D edgesMap;
uniform sampler2D edgesMapL;
uniform sampler2D areaMap;
#include "./functions.glsl"
void main()
{
vec4 areas = vec4(0.0);
vec2 e = texture(edgesMap, texcoord).rg;
//[branch]
if (bool(e.g)) // Edge at north
{
// Search distances to the left and to the right:
vec2 d = vec2(SearchXLeft(texcoord), SearchXRight(texcoord));
// Now fetch the crossing edges. Instead of sampling between edgels, we
// sample at -0.25, to be able to discern what value has each edgel:
vec4 coords = mad(vec4(d.x, -0.25, d.y + 1.0, -0.25),
PIXEL_SIZE.xyxy, texcoord.xyxy);
float e1 = tex2Dlevel0(edgesMapL, coords.xy).r;
float e2 = tex2Dlevel0(edgesMapL, coords.zw).r;
// Ok, we know how this pattern looks like, now it is time for getting
// the actual area:
areas.rg = Area(abs(d), e1, e2);
}
//[branch]
if (bool(e.r)) // Edge at west
{
// Search distances to the top and to the bottom:
vec2 d = vec2(SearchYUp(texcoord), SearchYDown(texcoord));
// Now fetch the crossing edges (yet again):
vec4 coords = mad(vec4(-0.25, d.x, -0.25, d.y + 1.0),
PIXEL_SIZE.xyxy, texcoord.xyxy);
float e1 = tex2Dlevel0(edgesMapL, coords.xy).g;
float e2 = tex2Dlevel0(edgesMapL, coords.zw).g;
// Get the area for this direction:
areas.ba = Area(abs(d), e1, e2);
}
OUT_FragColor0 = areas;
}

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.
//-----------------------------------------------------------------------------
// 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/
#include "../../../gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h"
uniform sampler2D colorMapG;
uniform sampler2D prepassMap;
uniform vec3 lumaCoefficients;
uniform float threshold;
uniform float depthThreshold;
in vec2 texcoord;
in vec4 offset[2];
void main()
{
// Luma calculation requires gamma-corrected colors (texture 'colorMapG').
//
// Note that there is a lot of overlapped luma calculations; performance
// can be improved if this luma calculation is performed in the main pass,
// which may give you an edge if used in conjunction with a z prepass.
float L = dot(texture(colorMapG, texcoord).rgb, lumaCoefficients);
float Lleft = dot(texture(colorMapG, offset[0].xy).rgb, lumaCoefficients);
float Ltop = dot(texture(colorMapG, offset[0].zw).rgb, lumaCoefficients);
float Lright = dot(texture(colorMapG, offset[1].xy).rgb, lumaCoefficients);
float Lbottom = dot(texture(colorMapG, offset[1].zw).rgb, lumaCoefficients);
vec4 delta = abs(vec4(L) - vec4(Lleft, Ltop, Lright, Lbottom));
vec4 edges = step(threshold, delta);
// Add depth edges to color edges
float D = prepassUncondition(prepassMap, texcoord).w;
float Dleft = prepassUncondition(prepassMap, offset[0].xy).w;
float Dtop = prepassUncondition(prepassMap, offset[0].zw).w;
float Dright = prepassUncondition(prepassMap, offset[1].xy).w;
float Dbottom = prepassUncondition(prepassMap, offset[1].zw).w;
delta = abs(vec4(D) - vec4(Dleft, Dtop, Dright, Dbottom));
edges += step(depthThreshold, delta);
if (dot(edges, vec4(1.0)) == 0.0)
discard;
OUT_FragColor0 = edges;
}

View file

@ -0,0 +1,145 @@
//-----------------------------------------------------------------------------
// 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/
uniform vec2 texSize0;
#if !defined(PIXEL_SIZE)
#define PIXEL_SIZE (1.0 / texSize0)
#define MAX_SEARCH_STEPS 8
#define MAX_DISTANCE 33
#endif
// Typical Multiply-Add operation to ease translation to assembly code.
vec4 mad(vec4 m, vec4 a, vec4 b)
{
#if defined(XBOX)
vec4 result;
asm {
mad result, m, a, b
};
return result;
#else
return m * a + b;
#endif
}
// This one just returns the first level of a mip map chain, which allow us to
// avoid the nasty ddx/ddy warnings, even improving the performance a little
// bit.
vec4 tex2Dlevel0(sampler2D map, vec2 texcoord)
{
return tex2Dlod(map, vec4(texcoord, 0.0, 0.0));
}
// Same as above, this eases translation to assembly code;
vec4 tex2Doffset(sampler2D map, vec2 texcoord, vec2 offset)
{
#if defined(XBOX) && MAX_SEARCH_STEPS < 6
vec4 result;
float x = offset.x;
float y = offset.y;
asm {
tfetch2D result, texcoord, map, OffsetX = x, OffsetY = y
};
return result;
#else
return tex2Dlevel0(map, texcoord + PIXEL_SIZE * offset);
#endif
}
// Ok, we have the distance and both crossing edges, can you please return
// the vec2 blending weights?
vec2 Area(vec2 distance, float e1, float e2)
{
// * By dividing by areaSize - 1.0 below we are implicitely offsetting to
// always fall inside of a pixel
// * Rounding prevents bilinear access precision problems
float areaSize = MAX_DISTANCE * 5.0;
vec2 pixcoord = MAX_DISTANCE * round(4.0 * vec2(e1, e2)) + distance;
vec2 texcoord = pixcoord / (areaSize - 1.0);
return tex2Dlevel0(areaMap, texcoord).rg;
}
// Search functions for the 2nd pass.
float SearchXLeft(vec2 texcoord)
{
// We compare with 0.9 to prevent bilinear access precision problems.
float i;
float e = 0.0;
for (i = -1.5; i > -2.0 * MAX_SEARCH_STEPS; i -= 2.0)
{
e = tex2Doffset(edgesMapL, texcoord, vec2(i, 0.0)).g;
/*[flatten]*/ if (e < 0.9) break;
}
return max(i + 1.5 - 2.0 * e, -2.0 * MAX_SEARCH_STEPS);
}
// Search functions for the 2nd pass.
float SearchXRight(vec2 texcoord)
{
float i;
float e = 0.0;
for (i = 1.5; i < 2.0 * MAX_SEARCH_STEPS; i += 2.0)
{
e = tex2Doffset(edgesMapL, texcoord, vec2(i, 0.0)).g;
/*[flatten]*/ if (e < 0.9) break;
}
return min(i - 1.5 + 2.0 * e, 2.0 * MAX_SEARCH_STEPS);
}
// Search functions for the 2nd pass.
float SearchYUp(vec2 texcoord)
{
float i;
float e = 0.0;
for (i = -1.5; i > -2.0 * MAX_SEARCH_STEPS; i -= 2.0)
{
e = tex2Doffset(edgesMapL, texcoord, vec2(i, 0.0).yx).r;
/*[flatten]*/ if (e < 0.9) break;
}
return max(i + 1.5 - 2.0 * e, -2.0 * MAX_SEARCH_STEPS);
}
// Search functions for the 2nd pass.
float SearchYDown(vec2 texcoord)
{
float i;
float e = 0.0;
for (i = 1.5; i < 2.0 * MAX_SEARCH_STEPS; i += 2.0)
{
e = tex2Doffset(edgesMapL, texcoord, vec2(i, 0.0).yx).r;
/*[flatten]*/ if (e < 0.9) break;
}
return min(i - 1.5 + 2.0 * e, 2.0 * MAX_SEARCH_STEPS);
}

View file

@ -0,0 +1,87 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// 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/
#include "../../../gl/hlslCompat.glsl"
in vec2 texcoord;
in vec4 offset[2];
uniform sampler2D blendMap;
uniform sampler2D colorMapL;
uniform sampler2D colorMap;
// Dummy sampers to please include.
uniform sampler2D areaMap;
uniform sampler2D edgesMapL;
#include "./functions.glsl"
void main()
{
// Fetch the blending weights for current pixel:
vec4 topLeft = texture(blendMap, texcoord);
float bottom = texture(blendMap, offset[1].zw).g;
float right = texture(blendMap, offset[1].xy).a;
vec4 a = vec4(topLeft.r, bottom, topLeft.b, right);
// Up to 4 lines can be crossing a pixel (one in each edge). So, we perform
// a weighted average, where the weight of each line is 'a' cubed, which
// favors blending and works well in practice.
vec4 w = a * a * a;
// There is some blending weight with a value greater than 0.0?
float sum = dot(w, vec4(1.0));
if (sum < 1e-5)
discard;
vec4 color = vec4(0.0);
// Add the contributions of the possible 4 lines that can cross this pixel:
#ifdef BILINEAR_FILTER_TRICK
vec4 coords = mad(vec4( 0.0, -a.r, 0.0, a.g), PIXEL_SIZE.yyyy, texcoord.xyxy);
color = mad(texture(colorMapL, coords.xy), vec4(w.r), color);
color = mad(texture(colorMapL, coords.zw), vec4(w.g), color);
coords = mad(vec4(-a.b, 0.0, a.a, 0.0), PIXEL_SIZE.xxxx, texcoord.xyxy);
color = mad(texture(colorMapL, coords.xy), vec4(w.b), color);
color = mad(texture(colorMapL, coords.zw), vec4(w.a), color);
#else
vec4 C = texture(colorMap, texcoord);
vec4 Cleft = texture(colorMap, offset[0].xy);
vec4 Ctop = texture(colorMap, offset[0].zw);
vec4 Cright = texture(colorMap, offset[1].xy);
vec4 Cbottom = texture(colorMap, offset[1].zw);
color = mad(mix(C, Ctop, a.r), vec4(w.r), color);
color = mad(mix(C, Cbottom, a.g), vec4(w.g), color);
color = mad(mix(C, Cleft, a.b), vec4(w.b), color);
color = mad(mix(C, Cright, a.a), vec4(w.a), color);
#endif
// Normalize the resulting color and we are finished!
OUT_FragColor0 = color / sum;
}

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.
//-----------------------------------------------------------------------------
// 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/
#include "../../../gl/hlslCompat.glsl"
in vec4 vPosition;
in vec2 vTexCoord0;
#define IN_position vPosition
#define IN_texcoord vTexCoord0
#define OUT_position gl_Position
out vec2 texcoord;
#define OUT_texcoord texcoord
out vec4 offset[2];
#define OUT_offset offset
uniform vec2 texSize0;
void main()
{
OUT_position = IN_position;
vec2 PIXEL_SIZE = 1.0 / texSize0;
OUT_texcoord = IN_texcoord;
OUT_texcoord.xy += PIXEL_SIZE * 0.5;
OUT_offset[0] = OUT_texcoord.xyxy + PIXEL_SIZE.xyxy * vec4(-1.0, 0.0, 0.0, -1.0);
OUT_offset[1] = OUT_texcoord.xyxy + PIXEL_SIZE.xyxy * vec4( 1.0, 0.0, 0.0, 1.0);
correctSSP(gl_Position);
}

View file

@ -0,0 +1,52 @@
//-----------------------------------------------------------------------------
// 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/
#include "../../../gl/hlslCompat.glsl"
in vec4 vPosition;
in vec2 vTexCoord0;
#define IN_position vPosition
#define IN_texcoord vTexCoord0
#define OUT_position gl_Position
out vec2 texcoord;
#define OUT_texcoord texcoord
uniform vec2 texSize0;
void main()
{
OUT_position = IN_position;
vec2 PIXEL_SIZE = 1.0 / texSize0;
OUT_texcoord = IN_texcoord;
texcoord.xy += PIXEL_SIZE * 0.5;
correctSSP(gl_Position);
}

View file

@ -0,0 +1,95 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../postFx.hlsl"
#include "../../torque.hlsl"
uniform sampler2D backBuffer : register(S0);
uniform vec3 LensCenter; // x=Left X, y=Right X, z=Y
uniform vec2 ScreenCenter;
uniform vec2 Scale;
uniform vec2 ScaleIn;
uniform vec4 HmdWarpParam;
uniform vec4 HmdChromaAbParam; // Chromatic aberration correction
vec4 main( PFXVertToPix IN ) : COLOR0
{
vec2 texCoord;
float xOffset;
vec2 lensCenter;
lensCenter.y = LensCenter.z;
if(IN.uv0.x < 0.5)
{
texCoord.x = IN.uv0.x;
texCoord.y = IN.uv0.y;
xOffset = 0.0;
lensCenter.x = LensCenter.x;
}
else
{
texCoord.x = IN.uv0.x - 0.5;
texCoord.y = IN.uv0.y;
xOffset = 0.5;
lensCenter.x = LensCenter.y;
}
// Scales input texture coordinates for distortion.
// ScaleIn maps texture coordinates to Scales to ([-1, 1]), although top/bottom will be
// larger due to aspect ratio.
vec2 theta = (texCoord - lensCenter) * ScaleIn; // Scales to [-1, 1]
float rSq = theta.x * theta.x + theta.y * theta.y;
vec2 theta1 = theta * (HmdWarpParam.x + HmdWarpParam.y * rSq + HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);
// Detect whether blue texture coordinates are out of range
// since these will scaled out the furthest.
vec2 thetaBlue = theta1 * (HmdChromaAbParam.z + HmdChromaAbParam.w * rSq);
vec2 tcBlue = lensCenter + Scale * thetaBlue;
vec4 color;
if (any(clamp(tcBlue, ScreenCenter-vec2(0.25,0.5), ScreenCenter+vec2(0.25, 0.5)) - tcBlue))
{
color = vec4(0,0,0,0);
}
else
{
// Now do blue texture lookup.
tcBlue.x += xOffset;
float blue = texture(backBuffer, tcBlue).b;
// Do green lookup (no scaling).
vec2 tcGreen = lensCenter + Scale * theta1;
tcGreen.x += xOffset;
float green = texture(backBuffer, tcGreen).g;
// Do red scale and lookup.
vec2 thetaRed = theta1 * (HmdChromaAbParam.x + HmdChromaAbParam.y * rSq);
vec2 tcRed = lensCenter + Scale * thetaRed;
tcRed.x += xOffset;
float red = texture(backBuffer, tcRed).r;
color = vec4(red, green, blue, 1);
}
return color;
}

Some files were not shown because too many files have changed in this diff Show more