mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Merge pull request #875 from GoldenThumbs/development_gld
New Bloom Post Processing Effect
This commit is contained in:
commit
f4a6a0f7ae
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -184,3 +184,5 @@ Project Manager.exe
|
|||
projects.xml
|
||||
Qt*.dll
|
||||
.vs
|
||||
Engine/lib/assimp/include/assimp/config.h
|
||||
Engine/lib/assimp/revision.h
|
||||
|
|
|
|||
BIN
Templates/BaseGame/game/core/postFX/images/lensDirt.png
Normal file
BIN
Templates/BaseGame/game/core/postFX/images/lensDirt.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 MiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="lensDirt_image"
|
||||
imageFile="@assetFile=lensDirt.png"/>
|
||||
|
|
@ -56,31 +56,33 @@ $PostFX::HDRPostFX::minLuminace = 0.001;
|
|||
/// average scene luminance.
|
||||
$PostFX::HDRPostFX::adaptRate = 0.85;
|
||||
|
||||
/// Blends between the scene and the bloomed scene.
|
||||
$PostFX::HDRPostFX::enableBloom = 1.0;
|
||||
// Inspired by bloom described in paper listed here:
|
||||
// http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare
|
||||
|
||||
/// The threshold luminace value for pixels which are
|
||||
/// considered "bright" and need to be bloomed.
|
||||
$PostFX::HDRPostFX::brightPassThreshold = 0.08;
|
||||
$PostFX::HDRPostFX::enableBloom = true;
|
||||
$PostFX::HDRPostFX::threshold = 1.25;
|
||||
$PostFX::HDRPostFX::intensity = 0.25;
|
||||
$PostFX::HDRPostFX::radius = 4.0;
|
||||
|
||||
/// These are used in the gaussian blur of the
|
||||
/// bright pass for the bloom effect.
|
||||
$PostFX::HDRPostFX::gaussMultiplier = 0.4;
|
||||
$PostFX::HDRPostFX::gaussMean = 0;
|
||||
$PostFX::HDRPostFX::gaussStdDev = 0.5;
|
||||
$PostFX::HDRPostFX::enableDirt = true;
|
||||
$PostFX::HDRPostFX::dirtScale = 2048.0;
|
||||
$PostFX::HDRPostFX::dirtIntensity = 2.0;
|
||||
$PostFX::HDRPostFX::dirtEdgeMinDist = 0.125;
|
||||
$PostFX::HDRPostFX::dirtEdgeMaxDist = 0.75;
|
||||
$PostFX::HDRPostFX::dirtEdgeMinVal = 0.05;
|
||||
$PostFX::HDRPostFX::dirtImage = "core/postFX/images/lensDirt.png";
|
||||
|
||||
// The tonemapping algo to use
|
||||
$PostFX::HDRPostFX::tonemapMode = "ACES";
|
||||
|
||||
$PostFX::HDRPostFX::enableAutoExposure = true;
|
||||
|
||||
|
||||
singleton ShaderData( HDR_BrightPassShader )
|
||||
singleton ShaderData( HDR_BloomInitShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = "./HDR_utils/brightPassFilterP.hlsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "./HDR_utils/brightPassFilterP.glsl";
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = "./HDR_Bloom/bloomInitSample.hlsl";
|
||||
OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "./HDR_Bloom/bloomInitSample.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
samplerNames[1] = "$luminanceTex";
|
||||
|
|
@ -88,42 +90,56 @@ singleton ShaderData( HDR_BrightPassShader )
|
|||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( HDR_DownScale4x4Shader )
|
||||
singleton ShaderData( HDR_BloomThresholdShader )
|
||||
{
|
||||
DXVertexShaderFile = "./HDR_Bloom/downScale4x4V.hlsl";
|
||||
DXPixelShaderFile = "./HDR_Bloom/downScale4x4P.hlsl";
|
||||
OGLVertexShaderFile = "./HDR_Bloom/downScale4x4V.glsl";
|
||||
OGLPixelShaderFile = "./HDR_Bloom/downScale4x4P.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( HDR_BloomGaussBlurHShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = "./HDR_Bloom/bloomGaussBlurHP.hlsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "./HDR_Bloom/bloomGaussBlurHP.glsl";
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = "./HDR_Bloom/bloomThresholdP.hlsl";
|
||||
OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "./HDR_Bloom/bloomThresholdP.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( HDR_BloomGaussBlurVShader )
|
||||
singleton ShaderData( HDR_BloomDownSampleShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = "./HDR_Bloom/bloomGaussBlurVP.hlsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "./HDR_Bloom/bloomGaussBlurVP.glsl";
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = "./HDR_Bloom/downSampleP.hlsl";
|
||||
OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "./HDR_Bloom/downSampleP.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( HDR_BloomUpSampleShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = "./HDR_Bloom/upSampleP.hlsl";
|
||||
OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "./HDR_Bloom/upSampleP.glsl";
|
||||
|
||||
samplerNames[0] = "$nxtTex";
|
||||
samplerNames[1] = "$mipTex";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( HDR_BloomDirtShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = "./HDR_Bloom/bloomStrengthP.hlsl";
|
||||
OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "./HDR_Bloom/bloomStrengthP.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
samplerNames[1] = "$dirtTex";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( HDR_SampleLumShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
|
|
@ -191,6 +207,13 @@ singleton GFXStateBlockData( HDR_DownSampleStateBlock : PFX_DefaultStateBlock )
|
|||
samplerStates[1] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( HDR_LensDirtStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
samplerStates[1] = SamplerWrapLinear;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( HDR_CombineStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
|
|
@ -223,23 +246,7 @@ singleton GFXStateBlockData( HDRStateBlock )
|
|||
|
||||
function HDRPostFX::setShaderConsts( %this )
|
||||
{
|
||||
%this.setShaderConst( "$brightPassThreshold", $PostFX::HDRPostFX::brightPassThreshold );
|
||||
%this.setShaderConst( "$g_fMiddleGray", $PostFX::HDRPostFX::keyValue );
|
||||
%this.setShaderConst( "$exposureValue", $PostFX::HDRPostFX::exposureValue );
|
||||
%this.setShaderConst( "$whitePoint", $PostFX::HDRPostFX::whitePoint );
|
||||
%this.setShaderConst( "$logContrast", $PostFX::HDRPostFX::logContrast );
|
||||
%this.setShaderConst( "$saturationValue", $PostFX::HDRPostFX::saturationValue );
|
||||
|
||||
|
||||
%bloomH = %this-->bloomH;
|
||||
%bloomH.setShaderConst( "$gaussMultiplier", $PostFX::HDRPostFX::gaussMultiplier );
|
||||
%bloomH.setShaderConst( "$gaussMean", $PostFX::HDRPostFX::gaussMean );
|
||||
%bloomH.setShaderConst( "$gaussStdDev", $PostFX::HDRPostFX::gaussStdDev );
|
||||
|
||||
%bloomV = %this-->bloomV;
|
||||
%bloomV.setShaderConst( "$gaussMultiplier", $PostFX::HDRPostFX::gaussMultiplier );
|
||||
%bloomV.setShaderConst( "$gaussMean", $PostFX::HDRPostFX::gaussMean );
|
||||
%bloomV.setShaderConst( "$gaussStdDev", $PostFX::HDRPostFX::gaussStdDev );
|
||||
%this.setShaderConst( "$g_fMiddleGray", $PostFX::HDRPostFX::keyValue );
|
||||
|
||||
%minLuminace = $PostFX::HDRPostFX::minLuminace;
|
||||
if ( %minLuminace <= 0.0 )
|
||||
|
|
@ -262,8 +269,7 @@ function HDRPostFX::setShaderConsts( %this )
|
|||
%combinePass.setShaderConst( "$colorFilter", $PostFX::HDRPostFX::colorFilter );
|
||||
%combinePass.setShaderConst( "$saturationValue", $PostFX::HDRPostFX::saturationValue );
|
||||
%combinePass.setShaderConst( "$logContrast", $PostFX::HDRPostFX::logContrast );
|
||||
|
||||
%combinePass.setShaderConst( "$g_fBloomScale", $PostFX::HDRPostFX::enableBloom );
|
||||
|
||||
%combinePass.setShaderConst( "$g_fEnableAutoExposure", $PostFX::HDRPostFX::enableAutoExposure );
|
||||
|
||||
%tonemapMode = 1;
|
||||
|
|
@ -285,7 +291,35 @@ function HDRPostFX::setShaderConsts( %this )
|
|||
%combinePass.setShaderConst( "$g_fOneOverGamma", 1 / %clampedGamma );
|
||||
%combinePass.setShaderConst( "$Brightness", $pref::Video::Brightness );
|
||||
%combinePass.setShaderConst( "$Contrast", $pref::Video::Contrast );
|
||||
|
||||
|
||||
// /----- BLOOM CONSTS -----/
|
||||
%bloom = %this->hdrbloom;
|
||||
%bloom.skip = !$PostFX::HDRPostFX::enableBloom;
|
||||
|
||||
%bloom.setShaderConst("$threshold", $PostFX::HDRPostFX::threshold);
|
||||
|
||||
for (%idx = 0; %idx < %this.mipsCount; %idx++)
|
||||
{
|
||||
%mip = %bloom.getObject(%this.mipsCount + %idx);
|
||||
%mip.setShaderConst("$filterRadius", $PostFX::HDRPostFX::radius);
|
||||
}
|
||||
|
||||
%strength = $PostFX::HDRPostFX::intensity;
|
||||
if (!$PostFX::HDRPostFX::enableBloom)
|
||||
%strength = 0.0;
|
||||
|
||||
%bloomFinal = %this->hdrbloom_end;
|
||||
%bloomFinal.setShaderConst("$strength", %strength);
|
||||
|
||||
%dirtScale = $PostFX::HDRPostFX::dirtScale;
|
||||
%dirtIntensity = $PostFX::HDRPostFX::dirtIntensity;
|
||||
%bloomFinal.setShaderConst("$dirtParams", %dirtScale SPC %dirtScale SPC %dirtIntensity);
|
||||
|
||||
%edgeMin = $PostFX::HDRPostFX::dirtEdgeMinDist;
|
||||
%edgeMax = $PostFX::HDRPostFX::dirtEdgeMaxDist;
|
||||
%edgeVal = $PostFX::HDRPostFX::dirtEdgeMinVal;
|
||||
%bloomFinal.setShaderConst("$edgeParams", %edgeMin SPC %edgeMax SPC %edgeVal);
|
||||
// \----- BLOOM CONSTS -----\
|
||||
}
|
||||
|
||||
function HDRPostFX::preProcess( %this )
|
||||
|
|
@ -293,7 +327,31 @@ function HDRPostFX::preProcess( %this )
|
|||
%combinePass = %this-->combinePass;
|
||||
|
||||
if ( %combinePass.texture[3] !$= $PostFX::HDRPostFX::colorCorrectionRamp )
|
||||
%combinePass.setTexture( 3, $PostFX::HDRPostFX::colorCorrectionRamp );
|
||||
%combinePass.setTexture( 3, $PostFX::HDRPostFX::colorCorrectionRamp );
|
||||
|
||||
// /----- BLOOM CONSTS -----/
|
||||
%bloomFinal = %this->hdrbloom_end;
|
||||
|
||||
if (%this.enableDirt != $PostFX::HDRPostFX::enableDirt)
|
||||
{
|
||||
%this.enableDirt = $PostFX::HDRPostFX::enableDirt;
|
||||
|
||||
if (%this.enableDirt)
|
||||
{
|
||||
%bloomFinal.setShaderMacro("USE_DIRT");
|
||||
} else {
|
||||
%bloomFinal.removeShaderMacro("USE_DIRT");
|
||||
}
|
||||
}
|
||||
|
||||
if(%bloomFinal.texture[1] !$= $PostFX::HDRPostFX::dirtImage)
|
||||
{
|
||||
if ($PostFX::HDRPostFX::dirtImage $= "")
|
||||
$PostFX::HDRPostFX::dirtImage = "core/postFX/images/lensDirt.png";
|
||||
|
||||
%bloomFinal.setTexture(1, $PostFX::HDRPostFX::dirtImage);
|
||||
}
|
||||
// \----- BLOOM CONSTS -----\
|
||||
}
|
||||
|
||||
function HDRPostFX::onEnabled( %this )
|
||||
|
|
@ -355,6 +413,8 @@ function HDRPostFX::onDisabled( %this )
|
|||
|
||||
function HDRPostFX::onAdd( %this )
|
||||
{
|
||||
%this.SetupBloomFX();
|
||||
|
||||
PostFXManager.registerPostEffect(%this);
|
||||
|
||||
$PostFX::HDRPostFX::enableToneMapping = 1;
|
||||
|
|
@ -382,11 +442,24 @@ function HDRPostFX::populatePostFXSettings(%this)
|
|||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::colorFilter", "Color Tint", "colorF", "", $PostFX::HDRPostFX::colorFilter, "0 0 0");
|
||||
PostEffectEditorInspector.endGroup();
|
||||
|
||||
PostEffectEditorInspector.startGroup("HDR - HDR Bloom");
|
||||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::enableBloom", "Enable HDR Bloom", "bool", "", $PostFX::HDRPostFX::enableBloom, "");
|
||||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::gaussMultiplier", "Bloom Multiplier", "range", "", $PostFX::HDRPostFX::gaussMultiplier, "0.0 1.0 2.0");
|
||||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::brightPassThreshold", "Bright Pass Threshold", "float", "", $PostFX::HDRPostFX::brightPassThreshold, "");
|
||||
PostEffectEditorInspector.endGroup();
|
||||
// /----- BLOOM SETTINGS -----/
|
||||
PostEffectEditorInspector.startGroup("HDR - Bloom");
|
||||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::enableBloom", "Enable Bloom", "bool", "", $PostFX::HDRPostFX::enableBloom, "");
|
||||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::threshold", "Threshold", "range", "", $PostFX::HDRPostFX::threshold, "0 2 10");
|
||||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::intensity", "Intensity", "range", "", $PostFX::HDRPostFX::intensity, "0 10 10");
|
||||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::radius", "Radius", "float", "", $PostFX::HDRPostFX::radius, "");
|
||||
PostEffectEditorInspector.endGroup();
|
||||
|
||||
PostEffectEditorInspector.startGroup("HDR - Lens Dirt");
|
||||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::enableDirt", "Enable Dirt", "bool", "", $PostFX::HDRPostFX::enableDirt, "");
|
||||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::dirtScale", "Scale", "float", "", $PostFX::HDRPostFX::dirtScale, "");
|
||||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::dirtIntensity", "Intensity", "float", "", $PostFX::HDRPostFX::dirtIntensity, "");
|
||||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::dirtEdgeMinDist", "Min Dist", "range", "", $PostFX::HDRPostFX::dirtEdgeMinDist, "0 1 10");
|
||||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::dirtEdgeMaxDist", "Max Dist", "range", "", $PostFX::HDRPostFX::dirtEdgeMaxDist, "0 1 10");
|
||||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::dirtEdgeMinVal", "Min Value", "range", "", $PostFX::HDRPostFX::dirtEdgeMinVal, "0 1 10");
|
||||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::dirtImage", "Dirt Image", "image", "", $PostFX::HDRPostFX::dirtImage, "");
|
||||
PostEffectEditorInspector.endGroup();
|
||||
// \----- BLOOM SETTINGS -----\
|
||||
|
||||
PostEffectEditorInspector.startGroup("HDR - Adaptation");
|
||||
PostEffectEditorInspector.addField("$PostFX::HDRPostFX::enableAutoExposure", "Enable Auto Exposure", "bool", "", $PostFX::HDRPostFX::enableAutoExposure, "");
|
||||
|
|
@ -426,11 +499,93 @@ function HDRPostFX::savePresetSettings(%this)
|
|||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::whiteCutoff");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::adaptRate");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::tonemapMode");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::enableBloom");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::brightPassThreshold");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::gaussMultiplier");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::enableAutoExposure");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::keyValue");
|
||||
|
||||
// /----- BLOOM SETTINGS -----/
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::enableBloom");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::threshold");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::intensity");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::radius");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::enableDirt");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::dirtScale");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::dirtIntensity");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::dirtImage");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::dirtEdgeMinDist");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::dirtEdgeMaxDist");
|
||||
PostFXManager::savePresetSetting("$PostFX::HDRPostFX::dirtEdgeMinVal");
|
||||
// \----- BLOOM SETTINGS -----\
|
||||
}
|
||||
|
||||
// This function sets up s sort of "mip-chain" for the bloom effect
|
||||
// Not really "optimal" but it works well enough
|
||||
function HDRPostFX::SetupBloomFX( %this )
|
||||
{
|
||||
%bloomFX = new PostEffect()
|
||||
{
|
||||
internalName = "hdrbloom";
|
||||
allowReflectPass = false;
|
||||
shader = HDR_BloomThresholdShader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = "#hdrInitBloom";
|
||||
target = "#hdrbloom_0";
|
||||
targetFormat = %this.mipTexFormat;
|
||||
};
|
||||
|
||||
%textureName = "#hdrbloom_0";
|
||||
for (%idx = 0; %idx < %this.mipsCount; %idx++)
|
||||
{
|
||||
%mipName = "hdrbloom_" @ (%idx + 1);
|
||||
%mipFX = new PostEffect()
|
||||
{
|
||||
internalName = %mipName;
|
||||
allowReflectPass = false;
|
||||
shader = HDR_BloomDownSampleShader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = %textureName;
|
||||
target = "#" @ %mipName;
|
||||
targetScale = "0.5 0.5";
|
||||
targetFormat = %this.mipTexFormat;
|
||||
};
|
||||
|
||||
%bloomFX.add(%mipFX);
|
||||
%textureName = "#" @ %mipName;
|
||||
}
|
||||
|
||||
for (%idx = %this.mipsCount; %idx > 0; %idx--)
|
||||
{
|
||||
%nxt = "#hdrbloom_" @ (%idx - 1);
|
||||
%mipName = "hdrbloom_up_" @ (%idx - 1);
|
||||
|
||||
%mipFX = new PostEffect()
|
||||
{
|
||||
internalName = %mipName;
|
||||
allowReflectPass = false;
|
||||
shader = HDR_BloomUpSampleShader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = %nxt;
|
||||
texture[1] = %textureName;
|
||||
target = "#" @ %mipName;
|
||||
targetFormat = %this.mipTexFormat;
|
||||
};
|
||||
|
||||
%bloomFX.add(%mipFX);
|
||||
%textureName = "#" @ %mipName;
|
||||
}
|
||||
|
||||
%finalFX = new PostEffect()
|
||||
{
|
||||
internalName = "hdrbloom_end";
|
||||
allowReflectPass = false;
|
||||
shader = HDR_BloomDirtShader;
|
||||
stateBlock = HDR_LensDirtStateBlock;
|
||||
texture[0] = "#hdrbloom_up_0";
|
||||
target = "#hdrbloom_end";
|
||||
targetFormat = %this.mipTexFormat;
|
||||
};
|
||||
|
||||
%this.add(%bloomFX);
|
||||
%this.add(%finalFX);
|
||||
}
|
||||
|
||||
singleton PostEffect( HDRPostFX )
|
||||
|
|
@ -443,6 +598,12 @@ singleton PostEffect( HDRPostFX )
|
|||
renderTime = "PFXBeforeBin";
|
||||
renderBin = "EditorBin";
|
||||
renderPriority = 9999;
|
||||
|
||||
// Hardcoded bloom settings.
|
||||
// -- Amount of mip targets the bloom uses.
|
||||
mipsCount = 5;
|
||||
// -- Texture format for mip targets.
|
||||
mipTexFormat = "GFXFormatR16G16B16A16F";
|
||||
|
||||
// The bright pass generates a bloomed version of
|
||||
// the scene for pixels which are brighter than a
|
||||
|
|
@ -452,48 +613,15 @@ singleton PostEffect( HDRPostFX )
|
|||
// at the end of this post effect chain.
|
||||
//
|
||||
|
||||
shader = HDR_BrightPassShader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
texture[1] = "#adaptedLum";
|
||||
target = "$outTex";
|
||||
targetFormat = "GFXFormatR16G16B16A16F";
|
||||
targetScale = "0.5 0.5";
|
||||
|
||||
new PostEffect()
|
||||
{
|
||||
allowReflectPass = false;
|
||||
shader = HDR_DownScale4x4Shader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "$outTex";
|
||||
targetFormat = "GFXFormatR16G16B16A16F";
|
||||
targetScale = "0.25 0.25";
|
||||
};
|
||||
|
||||
new PostEffect()
|
||||
{
|
||||
allowReflectPass = false;
|
||||
internalName = "bloomH";
|
||||
|
||||
shader = HDR_BloomGaussBlurHShader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "$outTex";
|
||||
targetFormat = "GFXFormatR16G16B16A16F";
|
||||
};
|
||||
shader = HDR_BloomInitShader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
texture[1] = "#adaptedLum";
|
||||
target = "#hdrInitBloom";
|
||||
targetFormat = "GFXFormatR16G16B16A16F";
|
||||
targetScale = "0.5 0.5";
|
||||
|
||||
new PostEffect()
|
||||
{
|
||||
allowReflectPass = false;
|
||||
internalName = "bloomV";
|
||||
|
||||
shader = HDR_BloomGaussBlurVShader;
|
||||
stateBlock = HDR_DownSampleStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "#bloomFinal";
|
||||
targetFormat = "GFXFormatR16G16B16A16F";
|
||||
};
|
||||
// Bloom should get inserted about here.
|
||||
|
||||
// BrightPass End
|
||||
|
||||
|
|
@ -572,7 +700,7 @@ singleton PostEffect( HDRPostFX )
|
|||
stateBlock = HDR_CombineStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
texture[1] = "#adaptedLum";
|
||||
texture[2] = "#bloomFinal";
|
||||
texture[2] = "#hdrbloom_end";
|
||||
texture[3] = $PostFX::HDRPostFX::colorCorrectionRamp;
|
||||
target = "$backBuffer";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,111 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "core/rendering/shaders/postFX/postFx.hlsl"
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
|
||||
uniform float2 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;
|
||||
}
|
||||
|
||||
float SCurve (float x)
|
||||
{
|
||||
x = x * 2.0 - 1.0;
|
||||
return -x * abs(x) * 0.5 + x + 0.5;
|
||||
}
|
||||
|
||||
float4 BlurH (TORQUE_SAMPLER2D(source), float2 size, float2 uv, float radius)
|
||||
{
|
||||
if (radius >= 1.0)
|
||||
{
|
||||
float4 A = float4(0.0,0.0,0.0,0.0);
|
||||
float4 C = float4(0.0,0.0,0.0,0.0);
|
||||
|
||||
float width = 1.0 / size.x;
|
||||
|
||||
float divisor = 0.0;
|
||||
float weight = 0.0;
|
||||
|
||||
float radiusMultiplier = 1.0 / radius;
|
||||
|
||||
// Hardcoded for radius 20 (normally we input the radius
|
||||
// in there), needs to be literal here
|
||||
|
||||
for (float x = -20.0; x <= 20.0; x++)
|
||||
{
|
||||
A = TORQUE_TEX2D(source, uv + float2(x * width, 0.0));
|
||||
|
||||
weight = SCurve(1.0 - (abs(x) * radiusMultiplier));
|
||||
|
||||
C += A * weight;
|
||||
|
||||
divisor += weight;
|
||||
}
|
||||
|
||||
return float4(C.r / divisor, C.g / divisor, C.b / divisor, 1.0);
|
||||
}
|
||||
|
||||
return TORQUE_TEX2D(source, uv);
|
||||
}
|
||||
|
||||
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
||||
{
|
||||
float4 color = { 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 += (TORQUE_TEX2D( inputTex, IN.uv0 + float2( offset, 0.0f ) ) * weight );
|
||||
}
|
||||
|
||||
//float2 targetSize = 1/oneOverTargetSize;
|
||||
//float4 color = BlurH(TORQUE_SAMPLER2D_MAKEARG(inputTex), targetSize, IN.uv0, 20.0);
|
||||
|
||||
return float4( color.rgb, 1.0f );
|
||||
}
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "core/rendering/shaders/postFX/postFx.hlsl"
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
|
||||
uniform float2 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;
|
||||
}
|
||||
|
||||
float SCurve (float x)
|
||||
{
|
||||
x = x * 2.0 - 1.0;
|
||||
return -x * abs(x) * 0.5 + x + 0.5;
|
||||
}
|
||||
|
||||
float4 BlurV (TORQUE_SAMPLER2D(source), float2 size, float2 uv, float radius)
|
||||
{
|
||||
if (radius >= 1.0)
|
||||
{
|
||||
float4 A = float4(0.0,0.0,0.0,0.0);
|
||||
float4 C = float4(0.0,0.0,0.0,0.0);
|
||||
|
||||
float height = 1.0 / size.y;
|
||||
|
||||
float divisor = 0.0;
|
||||
float weight = 0.0;
|
||||
|
||||
float radiusMultiplier = 1.0 / radius;
|
||||
|
||||
for (float y = -20.0; y <= 20.0; y++)
|
||||
{
|
||||
A = TORQUE_TEX2D(source, uv + float2(0.0, y * height));
|
||||
|
||||
weight = SCurve(1.0 - (abs(y) * radiusMultiplier));
|
||||
|
||||
C += A * weight;
|
||||
|
||||
divisor += weight;
|
||||
}
|
||||
|
||||
return float4(C.r / divisor, C.g / divisor, C.b / divisor, 1.0);
|
||||
}
|
||||
|
||||
return TORQUE_TEX2D(source, uv);
|
||||
}
|
||||
|
||||
|
||||
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
||||
{
|
||||
float4 color = { 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 += (TORQUE_TEX2D( inputTex, IN.uv0 + float2( 0.0f, offset ) ) * weight );
|
||||
}
|
||||
|
||||
//float2 targetSize = 1/oneOverTargetSize;
|
||||
//float4 color = BlurV(TORQUE_SAMPLER2D_MAKEARG(inputTex), targetSize, IN.uv0, 20.0);
|
||||
|
||||
return float4( color.rgb, 1.0f );
|
||||
}
|
||||
|
|
@ -21,52 +21,39 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "core/rendering/shaders/gl/hlslCompat.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "core/rendering/shaders/postFX/gl/postFx.glsl"
|
||||
#include "core/rendering/shaders/gl/torque.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
uniform sampler2D inputTex ;
|
||||
#define KERNEL_SAMPLES 4
|
||||
const vec2 KERNEL[9] = vec2[](
|
||||
vec2( 0.5, 0.5),
|
||||
vec2( 0.5,-0.5),
|
||||
vec2(-0.5,-0.5),
|
||||
vec2(-0.5, 0.5)
|
||||
);
|
||||
|
||||
uniform sampler2D inputTex;
|
||||
uniform sampler2D luminanceTex;
|
||||
uniform float g_fMiddleGray;
|
||||
uniform vec2 oneOverTargetSize;
|
||||
uniform float gaussMultiplier;
|
||||
uniform float gaussMean;
|
||||
uniform float gaussStdDev;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
#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 );
|
||||
}
|
||||
const float weight = 1.0 / KERNEL_SAMPLES;
|
||||
vec4 downSample = vec4(0, 0, 0, 0);
|
||||
|
||||
OUT_col = vec4( color.rgb, 1.0f );
|
||||
}
|
||||
for (int i=0; i<KERNEL_SAMPLES; i++)
|
||||
{
|
||||
vec2 offset = KERNEL[i] * oneOverTargetSize;
|
||||
vec4 sampleCol = hdrDecode( texture(inputTex, IN_uv0 + offset) );
|
||||
downSample += sampleCol;
|
||||
}
|
||||
|
||||
float adaptedLum = texture( luminanceTex, vec2( 0.5, 0.5 ) ).r;
|
||||
float lum = (g_fMiddleGray / (adaptedLum + 0.0001));
|
||||
|
||||
return downSample * weight * lum;
|
||||
}
|
||||
|
|
@ -20,34 +20,37 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define IN_HLSL
|
||||
#include "core/rendering/shaders/shdrConsts.h"
|
||||
#include "core/rendering/shaders/postFX/postFx.hlsl"
|
||||
#include "core/rendering/shaders/torque.hlsl"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Data
|
||||
//-----------------------------------------------------------------------------
|
||||
struct VertIn
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
float4 texCoords[8] : TEXCOORD0;
|
||||
#define KERNEL_SAMPLES 4
|
||||
static const float2 KERNEL[4] = {
|
||||
float2( 0.5f, 0.5f),
|
||||
float2( 0.5f,-0.5f),
|
||||
float2(-0.5f,-0.5f),
|
||||
float2(-0.5f, 0.5f)
|
||||
};
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
|
||||
TORQUE_UNIFORM_SAMPLER2D(luminanceTex, 1);
|
||||
uniform float g_fMiddleGray;
|
||||
uniform float2 oneOverTargetSize;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
float4 main( VertIn IN) : TORQUE_TARGET0
|
||||
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
||||
{
|
||||
// We calculate the texture coords
|
||||
// in the vertex shader as an optimization.
|
||||
float4 sample = 0.0f;
|
||||
for ( int i = 0; i < 8; i++ )
|
||||
{
|
||||
sample += TORQUE_TEX2D( inputTex, IN.texCoords[i].xy );
|
||||
sample += TORQUE_TEX2D( inputTex, IN.texCoords[i].zw );
|
||||
}
|
||||
const float weight = 1.0f / KERNEL_SAMPLES;
|
||||
float4 downSample = float4(0, 0, 0, 0);
|
||||
|
||||
return sample / 16;
|
||||
}
|
||||
[unroll]
|
||||
for (int i=0; i<KERNEL_SAMPLES; i++)
|
||||
{
|
||||
float2 offset = KERNEL[i] * oneOverTargetSize;
|
||||
float4 sampleCol = hdrDecode( TORQUE_TEX2D(inputTex, IN.uv0 + offset) );
|
||||
downSample += sampleCol;
|
||||
}
|
||||
|
||||
float adaptedLum = TORQUE_TEX2D( luminanceTex, float2( 0.5f, 0.5f ) ).r;
|
||||
float lum = (g_fMiddleGray / (adaptedLum + 0.0001f));
|
||||
|
||||
return downSample * weight * lum;
|
||||
}
|
||||
|
|
@ -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 "core/rendering/shaders/gl/hlslCompat.glsl"
|
||||
#include "core/rendering/shaders/postFX/gl/postFx.glsl"
|
||||
#include "core/rendering/shaders/gl/torque.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
#line 28
|
||||
|
||||
uniform sampler2D inputTex;
|
||||
uniform sampler2D dirtTex;
|
||||
uniform float strength;
|
||||
// XY: Dirt Texture Size/Scale
|
||||
// Z: Dirt Effect Strength
|
||||
uniform vec3 dirtParams;
|
||||
// XY: Edge Min & Max Distance
|
||||
// Z: Edge Min Value
|
||||
uniform vec3 edgeParams;
|
||||
uniform vec2 oneOverTargetSize;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
#ifdef USE_DIRT
|
||||
float edge = distance(IN_uv0, vec2(0.5, 0.5));
|
||||
edge = max(smoothstep(edgeParams.x, edgeParams.y, edge), edgeParams.z);
|
||||
vec3 dirt = texture(dirtTex, IN_uv0 / (dirtParams.xy * oneOverTargetSize)).rgb * dirtParams.z * edge;
|
||||
#endif
|
||||
|
||||
vec4 upSample = texture(inputTex, IN_uv0) * strength;
|
||||
|
||||
#ifdef USE_DIRT
|
||||
upSample.rgb += upSample.rgb * dirt;
|
||||
#endif
|
||||
|
||||
OUT_col = max(upSample, 0.0);
|
||||
}
|
||||
|
|
@ -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 "core/rendering/shaders/postFX/postFx.hlsl"
|
||||
#include "core/rendering/shaders/torque.hlsl"
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
|
||||
TORQUE_UNIFORM_SAMPLER2D(dirtTex, 1);
|
||||
uniform float strength;
|
||||
// XY: Dirt Texture Size/Scale
|
||||
// Z: Dirt Effect Strength
|
||||
uniform float3 dirtParams;
|
||||
// XY: Edge Min & Max Distance
|
||||
// Z: Edge Min Value
|
||||
uniform float3 edgeParams;
|
||||
uniform float2 oneOverTargetSize;
|
||||
|
||||
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
||||
{
|
||||
#ifdef USE_DIRT
|
||||
float edge = distance(IN.uv0, float2(0.5f, 0.5f));
|
||||
edge = max(smoothstep(edgeParams.x, edgeParams.y, edge), edgeParams.z);
|
||||
float3 dirt = TORQUE_TEX2D(dirtTex, IN.uv0 / (dirtParams.xy * oneOverTargetSize)).rgb * dirtParams.z * edge;
|
||||
#endif
|
||||
|
||||
float4 upSample = TORQUE_TEX2D(inputTex, IN.uv0) * strength;
|
||||
|
||||
#ifdef USE_DIRT
|
||||
upSample.rgb += upSample.rgb * dirt;
|
||||
#endif
|
||||
|
||||
return max(upSample, 0.0f);
|
||||
}
|
||||
|
|
@ -20,31 +20,24 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define IN_GLSL
|
||||
#include "core/rendering/shaders/shdrConsts.h"
|
||||
#include "core/rendering/shaders/gl/hlslCompat.glsl"
|
||||
#include "core/rendering/shaders/postFX/gl/postFx.glsl"
|
||||
#include "core/rendering/shaders/gl/torque.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
in vec4 texCoords[8];
|
||||
#define IN_texCoords texCoords
|
||||
#line 28
|
||||
|
||||
uniform sampler2D inputTex;
|
||||
uniform float threshold;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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_col = _sample / 16;
|
||||
}
|
||||
vec4 screenColor = texture(inputTex, IN_uv0);
|
||||
|
||||
float brightness = max(screenColor.r, max(screenColor.g, screenColor.b));
|
||||
float contribution = clamp(brightness - threshold, 0.0, 1.0) / max(brightness, 0.0001);
|
||||
|
||||
OUT_col = max(screenColor * contribution, 0.0001);
|
||||
}
|
||||
|
|
@ -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 "core/rendering/shaders/postFX/postFx.hlsl"
|
||||
#include "core/rendering/shaders/torque.hlsl"
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
|
||||
uniform float threshold;
|
||||
|
||||
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
||||
{
|
||||
float4 screenColor = TORQUE_TEX2D(inputTex, IN.uv0);
|
||||
|
||||
float brightness = max(screenColor.r, max(screenColor.g, screenColor.b));
|
||||
float contribution = saturate(brightness - threshold) / max(brightness, 0.0001f);
|
||||
|
||||
return max(screenColor * contribution, 0.0001f);
|
||||
}
|
||||
|
|
@ -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 "core/rendering/shaders/gl/hlslCompat.glsl"
|
||||
#include "core/rendering/shaders/postFX/gl/postFx.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
#line 27
|
||||
|
||||
#define KERNEL_SAMPLES 9
|
||||
const vec3 KERNEL[9] = vec3[](
|
||||
vec3( 0.0000, 0.0000, 0.2500),
|
||||
vec3( 1.0000, 0.0000, 0.1250),
|
||||
vec3( 0.0000, 1.0000, 0.1250),
|
||||
vec3(-1.0000, 0.0000, 0.1250),
|
||||
vec3( 0.0000,-1.0000, 0.1250),
|
||||
vec3( 1.0000, 1.0000, 0.0625),
|
||||
vec3( 1.0000,-1.0000, 0.0625),
|
||||
vec3(-1.0000,-1.0000, 0.0625),
|
||||
vec3(-1.0000, 1.0000, 0.0625)
|
||||
);
|
||||
|
||||
uniform sampler2D inputTex;
|
||||
uniform vec2 oneOverTargetSize;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 downSample = vec4(0, 0, 0, 0);
|
||||
|
||||
for (int i=0; i<KERNEL_SAMPLES; i++)
|
||||
{
|
||||
// XY: Sample Offset
|
||||
// Z: Sample Weight
|
||||
vec3 offsetWeight = KERNEL[i];
|
||||
vec2 offsetXY = offsetWeight.xy * oneOverTargetSize;
|
||||
float weight = offsetWeight.z;
|
||||
vec4 sampleCol = texture(inputTex, IN_uv0 + offsetXY);
|
||||
downSample += sampleCol * weight;
|
||||
}
|
||||
|
||||
OUT_col = downSample;
|
||||
}
|
||||
|
|
@ -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 "core/rendering/shaders/postFX/postFx.hlsl"
|
||||
|
||||
#define KERNEL_SAMPLES 9
|
||||
static const float3 KERNEL[9] = {
|
||||
float3( 0.0000f, 0.0000f, 0.2500f),
|
||||
float3( 1.0000f, 0.0000f, 0.1250f),
|
||||
float3( 0.0000f, 1.0000f, 0.1250f),
|
||||
float3(-1.0000f, 0.0000f, 0.1250f),
|
||||
float3( 0.0000f,-1.0000f, 0.1250f),
|
||||
float3( 1.0000f, 1.0000f, 0.0625f),
|
||||
float3( 1.0000f,-1.0000f, 0.0625f),
|
||||
float3(-1.0000f,-1.0000f, 0.0625f),
|
||||
float3(-1.0000f, 1.0000f, 0.0625f)
|
||||
};
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
|
||||
uniform float2 oneOverTargetSize;
|
||||
|
||||
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
||||
{
|
||||
float4 downSample = float4(0, 0, 0, 0);
|
||||
|
||||
[unroll]
|
||||
for (int i=0; i<KERNEL_SAMPLES; i++)
|
||||
{
|
||||
// XY: Sample Offset
|
||||
// Z: Sample Weight
|
||||
float3 offsetWeight = KERNEL[i];
|
||||
float2 offset = offsetWeight.xy * oneOverTargetSize;
|
||||
float weight = offsetWeight.z;
|
||||
float4 sampleCol = TORQUE_TEX2D(inputTex, IN.uv0 + offset);
|
||||
downSample += sampleCol * weight;
|
||||
}
|
||||
|
||||
return downSample;
|
||||
}
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define IN_GLSL
|
||||
#include "core/rendering/shaders/shdrConsts.h"
|
||||
#include "core/rendering/shaders/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);
|
||||
}
|
||||
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define IN_HLSL
|
||||
#include "core/rendering/shaders/shdrConsts.h"
|
||||
#include "core/rendering/shaders/postFX/postFx.hlsl"
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constants
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct Conn
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
float4 texCoords[8] : TEXCOORD0;
|
||||
};
|
||||
|
||||
uniform float2 targetSize;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
Conn main( PFXVert In )
|
||||
{
|
||||
Conn Out;
|
||||
|
||||
Out.hpos = float4(In.pos,1.0);
|
||||
|
||||
// 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.
|
||||
float2 texSize = float2( 1.0 / (targetSize.x - 1.0), 1.0 / (targetSize.y - 1.0) );
|
||||
|
||||
float4 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;
|
||||
|
||||
return Out;
|
||||
}
|
||||
|
||||
|
|
@ -21,51 +21,47 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "core/rendering/shaders/gl/hlslCompat.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "core/rendering/shaders/postFX/gl/postFx.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
uniform sampler2D inputTex ;
|
||||
#line 27
|
||||
|
||||
#define KERNEL_SAMPLES 9
|
||||
const vec3 KERNEL[9] = vec3[](
|
||||
vec3( 0.0000, 0.0000, 0.5000),
|
||||
vec3( 1.0000, 0.0000, 0.0625),
|
||||
vec3( 0.0000, 1.0000, 0.0625),
|
||||
vec3(-1.0000, 0.0000, 0.0625),
|
||||
vec3( 0.0000,-1.0000, 0.0625),
|
||||
vec3( 0.7070, 0.7070, 0.0625),
|
||||
vec3( 0.7070,-0.7070, 0.0625),
|
||||
vec3(-0.7070,-0.7070, 0.0625),
|
||||
vec3(-0.7070, 0.7070, 0.0625)
|
||||
);
|
||||
|
||||
uniform sampler2D nxtTex;
|
||||
uniform sampler2D mipTex;
|
||||
uniform float filterRadius;
|
||||
uniform vec2 oneOverTargetSize;
|
||||
uniform float gaussMultiplier;
|
||||
uniform float gaussMean;
|
||||
uniform float gaussStdDev;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
#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;
|
||||
vec4 upSample = vec4(0, 0, 0, 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_col = vec4( color.rgb, 1.0f );
|
||||
}
|
||||
for (int i=0; i<KERNEL_SAMPLES; i++)
|
||||
{
|
||||
// XY: Sample Offset
|
||||
// Z: Sample Weight
|
||||
vec3 offsetWeight = KERNEL[i];
|
||||
vec2 offsetXY = offsetWeight.xy * oneOverTargetSize * filterRadius;
|
||||
float weight = offsetWeight.z;
|
||||
vec4 sampleCol = texture(mipTex, IN_uv0 + offsetXY);
|
||||
upSample += sampleCol * weight;
|
||||
}
|
||||
|
||||
upSample = texture(nxtTex, IN_uv0) + upSample;
|
||||
|
||||
OUT_col = upSample;
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "core/rendering/shaders/postFX/postFx.hlsl"
|
||||
|
||||
#define KERNEL_SAMPLES 9
|
||||
static const float3 KERNEL[9] = {
|
||||
float3( 0.0000f, 0.0000f, 0.5000f),
|
||||
float3( 1.0000f, 0.0000f, 0.0625f),
|
||||
float3( 0.0000f, 1.0000f, 0.0625f),
|
||||
float3(-1.0000f, 0.0000f, 0.0625f),
|
||||
float3( 0.0000f,-1.0000f, 0.0625f),
|
||||
float3( 0.7070f, 0.7070f, 0.0625f),
|
||||
float3( 0.7070f,-0.7070f, 0.0625f),
|
||||
float3(-0.7070f,-0.7070f, 0.0625f),
|
||||
float3(-0.7070f, 0.7070f, 0.0625f)
|
||||
};
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(nxtTex, 0);
|
||||
TORQUE_UNIFORM_SAMPLER2D(mipTex, 1);
|
||||
uniform float filterRadius;
|
||||
uniform float2 oneOverTargetSize;
|
||||
|
||||
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
||||
{
|
||||
float4 upSample = float4(0, 0, 0, 0);
|
||||
|
||||
[unroll]
|
||||
for (int i=0; i<KERNEL_SAMPLES; i++)
|
||||
{
|
||||
// XY: Sample Offset
|
||||
// Z: Sample Weight
|
||||
float3 offsetWeight = KERNEL[i];
|
||||
float2 offset = offsetWeight.xy * oneOverTargetSize * filterRadius;
|
||||
float weight = offsetWeight.z;
|
||||
float4 sampleCol = TORQUE_TEX2D(mipTex, IN.uv0 + offset);
|
||||
upSample += sampleCol * weight;
|
||||
}
|
||||
|
||||
upSample = TORQUE_TEX2D(nxtTex, IN.uv0) + upSample;
|
||||
|
||||
return upSample;
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ uniform float g_fWhiteCutoff;
|
|||
uniform float g_fEnableAutoExposure;
|
||||
uniform float g_fTonemapMode;
|
||||
|
||||
uniform float g_fBloomScale;
|
||||
//uniform float g_fBloomScale;
|
||||
|
||||
uniform float g_fOneOverGamma;
|
||||
uniform float Brightness;
|
||||
|
|
@ -102,7 +102,7 @@ void main()
|
|||
|
||||
|
||||
// Add the bloom effect.
|
||||
_sample += (g_fBloomScale * bloom) / 10;
|
||||
_sample += bloom;
|
||||
|
||||
//Apply Exposure
|
||||
_sample.rgb *= TO_Exposure(_sample.rgb, exposureValue, colorFilter);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ uniform float g_fMiddleGray;
|
|||
uniform float g_fEnableAutoExposure;
|
||||
uniform float g_fTonemapMode;
|
||||
|
||||
uniform float g_fBloomScale;
|
||||
//uniform float g_fBloomScale;
|
||||
uniform float g_fOneOverGamma;
|
||||
uniform float Brightness;
|
||||
uniform float Contrast;
|
||||
|
|
@ -94,7 +94,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
|||
float4 bloom = TORQUE_TEX2D( bloomTex, IN.uv0 );
|
||||
|
||||
// Add the bloom effect.
|
||||
sample += (g_fBloomScale * bloom) / 10;
|
||||
sample += bloom;
|
||||
|
||||
//Apply Exposure
|
||||
sample.rgb *= TO_Exposure(sample.rgb, exposureValue, colorFilter);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,27 @@
|
|||
<<<<<<< HEAD
|
||||
$PostFX::BloomPostFX::Enabled = "1";
|
||||
$PostFX::BloomPostFX::threshold = "0.5";
|
||||
$PostFX::BloomPostFX::intensity = "0.5";
|
||||
$PostFX::BloomPostFX::radius = "4";
|
||||
$PostFX::BloomPostFX::dirtEnabled = "1";
|
||||
$PostFX::BloomPostFX::dirtScale = "2048";
|
||||
$PostFX::BloomPostFX::dirtIntensity = "40";
|
||||
$PostFX::BloomPostFX::dirtImage = "core/postFX/images/lensDirt.png";
|
||||
$PostFX::BloomPostFX::dirtEdgeMinDist = "0.115384616";
|
||||
$PostFX::BloomPostFX::dirtEdgeMaxDist = "0.951923072";
|
||||
$PostFX::BloomPostFX::dirtEdgeMinVal = "0.00961538497";
|
||||
$PostFX::HDRPostFX::Enabled = 1;
|
||||
$PostFX::HDRPostFX::exposureValue = "1.5";
|
||||
$PostFX::HDRPostFX::whitePoint = "2";
|
||||
$PostFX::HDRPostFX::logContrast = "1.25";
|
||||
$PostFX::HDRPostFX::saturationValue = "1";
|
||||
$PostFX::HDRPostFX::colorFilter = "1.0 1.0 1.0";
|
||||
$PostFX::HDRPostFX::minLuminace = "0.001";
|
||||
$PostFX::HDRPostFX::adaptRate = "0.85";
|
||||
$PostFX::HDRPostFX::tonemapMode = "ACES";
|
||||
$PostFX::HDRPostFX::enableBloom = "1";
|
||||
=======
|
||||
>>>>>>> development
|
||||
$PostFX::HDRPostFX::brightPassThreshold = "0.02";
|
||||
$PostFX::HDRPostFX::gaussMultiplier = "0.4";
|
||||
$PostFX::HDRPostFX::enableAutoExposure = "1";
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
float M_HALFPI_F = 1.57079632679489661923;
|
||||
float M_PI_F = 3.14159265358979323846;
|
||||
float M_2PI_F = 6.28318530717958647692;
|
||||
float M_1OVER_PI_F = 0.31830988618f;
|
||||
float M_1OVER_PI_F = 0.31830988618;
|
||||
|
||||
/// Calculate fog based on a start and end positions in worldSpace.
|
||||
float computeSceneFog( vec3 startPos,
|
||||
|
|
|
|||
|
|
@ -1,15 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone ="yes"?>
|
||||
<ProjectSettings>
|
||||
<Group name="UI">
|
||||
<Setting name="mainMenuName">MainMenuGUI</Setting>
|
||||
<Setting name="playGUIName">PlayGUI</Setting>
|
||||
</Group>
|
||||
<Group name="AssetManagement">
|
||||
<Group name="Modules">
|
||||
<Setting name="coreModulePath">core/</Setting>
|
||||
<Group
|
||||
name="AssetManagement">
|
||||
<Group
|
||||
name="Modules">
|
||||
<Setting
|
||||
name="coreModulePath">core/</Setting>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group name="General">
|
||||
<Setting name="LightingMode">Deferred</Setting>
|
||||
<Group
|
||||
name="General">
|
||||
<Setting
|
||||
name="LightingMode">Deferred</Setting>
|
||||
</Group>
|
||||
<Group
|
||||
name="Terrain">
|
||||
<Setting
|
||||
name="BlendDepth">0.560687482</Setting>
|
||||
<Setting
|
||||
name="DetailTextureFormat">12</Setting>
|
||||
<Setting
|
||||
name="LerpBlend">0</Setting>
|
||||
<Setting
|
||||
name="MacroTextureFormat">12</Setting>
|
||||
<Setting
|
||||
name="NormalTextureFormat">12</Setting>
|
||||
<Setting
|
||||
name="OrmTextureFormat">12</Setting>
|
||||
</Group>
|
||||
<Group
|
||||
name="UI">
|
||||
<Setting
|
||||
name="mainMenuName">MainMenuGUI</Setting>
|
||||
<Setting
|
||||
name="playGUIName">PlayGUI</Setting>
|
||||
</Group>
|
||||
</ProjectSettings>
|
||||
|
|
|
|||
Loading…
Reference in a new issue