mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Added Lens Dirt
This commit is contained in:
parent
cc1ef4d627
commit
99d8f28957
5 changed files with 84 additions and 4 deletions
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"/>
|
||||||
|
|
@ -24,6 +24,10 @@ $PostFX::BloomPostFX::threshold = 0.75;
|
||||||
$PostFX::BloomPostFX::intensity = 0.5;
|
$PostFX::BloomPostFX::intensity = 0.5;
|
||||||
$PostFX::BloomPostFX::radius = 8.0;
|
$PostFX::BloomPostFX::radius = 8.0;
|
||||||
|
|
||||||
|
$PostFX::BloomPostFX::dirtEnabled = true;
|
||||||
|
$PostFX::BloomPostFX::dirtScale = 2048.0;
|
||||||
|
$PostFX::BloomPostFX::dirtIntensity = 7.0;
|
||||||
|
|
||||||
$mipsCount = 4;
|
$mipsCount = 4;
|
||||||
|
|
||||||
singleton ShaderData( PFX_BloomThreshold_Shader )
|
singleton ShaderData( PFX_BloomThreshold_Shader )
|
||||||
|
|
@ -63,6 +67,7 @@ singleton ShaderData( PFX_BloomStrength_Shader )
|
||||||
DXPixelShaderFile = "./bloomStrengthP.hlsl";
|
DXPixelShaderFile = "./bloomStrengthP.hlsl";
|
||||||
|
|
||||||
samplerNames[0] = "$inputTex";
|
samplerNames[0] = "$inputTex";
|
||||||
|
samplerNames[1] = "$dirtTex";
|
||||||
|
|
||||||
pixVersion = 3.0;
|
pixVersion = 3.0;
|
||||||
};
|
};
|
||||||
|
|
@ -89,6 +94,7 @@ singleton GFXStateBlockData( BloomPostFX_Add_SampleStateBlock : PFX_DefaultState
|
||||||
|
|
||||||
samplersDefined = true;
|
samplersDefined = true;
|
||||||
samplerStates[0] = SamplerClampLinear;
|
samplerStates[0] = SamplerClampLinear;
|
||||||
|
samplerStates[1] = SamplerWrapLinear;
|
||||||
};
|
};
|
||||||
|
|
||||||
function BloomPostFX::setShaderConsts( %this )
|
function BloomPostFX::setShaderConsts( %this )
|
||||||
|
|
@ -104,10 +110,37 @@ function BloomPostFX::setShaderConsts( %this )
|
||||||
|
|
||||||
%final = %this->bloomFinal;
|
%final = %this->bloomFinal;
|
||||||
%final.setShaderConst("$strength", $PostFX::BloomPostFX::intensity);
|
%final.setShaderConst("$strength", $PostFX::BloomPostFX::intensity);
|
||||||
|
|
||||||
|
%dirtScale = $PostFX::BloomPostFX::dirtScale;
|
||||||
|
%dirtIntensity = $PostFX::BloomPostFX::dirtIntensity;
|
||||||
|
%final.setShaderConst("$dirtParams", %dirtScale SPC %dirtScale SPC %dirtIntensity);
|
||||||
}
|
}
|
||||||
|
|
||||||
function BloomPostFX::preProcess( %this )
|
function BloomPostFX::preProcess( %this )
|
||||||
{
|
{
|
||||||
|
if (%this.dirtEnabled != $PostFX::BloomPostFX::dirtEnabled)
|
||||||
|
{
|
||||||
|
%this.dirtEnabled = $PostFX::BloomPostFX::dirtEnabled;
|
||||||
|
|
||||||
|
%final = %this->bloomFinal;
|
||||||
|
if (%this.dirtEnabled)
|
||||||
|
{
|
||||||
|
%final.setShaderMacro("USE_DIRT");
|
||||||
|
} else {
|
||||||
|
%final.removeShaderMacro("USE_DIRT");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($PostFX::BloomPostFX::dirtImage $= "")
|
||||||
|
{
|
||||||
|
$PostFX::BloomPostFX::dirtImage = "core/postFX/images/lensDirt.png";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($PostFX::BloomPostFX::dirtImage !$= "")
|
||||||
|
{
|
||||||
|
%final = %this->bloomFinal;
|
||||||
|
%final.setTexture(1, $PostFX::BloomPostFX::dirtImage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function sets up s sort of "mip-chain" for the bloom effect
|
// This function sets up s sort of "mip-chain" for the bloom effect
|
||||||
|
|
@ -198,6 +231,13 @@ function BloomPostFX::populatePostFXSettings(%this)
|
||||||
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::intensity", "Intensity", "range", "", $PostFX::BloomPostFX::intensity, "0 2 10");
|
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::intensity", "Intensity", "range", "", $PostFX::BloomPostFX::intensity, "0 2 10");
|
||||||
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::radius", "Radius", "float", "", $PostFX::BloomPostFX::radius, "");
|
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::radius", "Radius", "float", "", $PostFX::BloomPostFX::radius, "");
|
||||||
PostEffectEditorInspector.endGroup();
|
PostEffectEditorInspector.endGroup();
|
||||||
|
|
||||||
|
PostEffectEditorInspector.startGroup("BloomPostFX - Dirt");
|
||||||
|
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtEnabled", "Enable Dirt", "bool", "", $PostFX::BloomPostFX::dirtEnabled, "");
|
||||||
|
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtScale", "Scale", "float", "", $PostFX::BloomPostFX::dirtScale, "");
|
||||||
|
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtIntensity", "Intensity", "float", "", $PostFX::BloomPostFX::dirtIntensity, "");
|
||||||
|
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtImage", "Dirt Image", "image", "", $PostFX::BloomPostFX::dirtImage, "");
|
||||||
|
PostEffectEditorInspector.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
//This is called back from our callbackField defined in populatePostFXSettings to
|
//This is called back from our callbackField defined in populatePostFXSettings to
|
||||||
|
|
@ -227,6 +267,11 @@ function BloomPostFX::savePresetSettings(%this)
|
||||||
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::threshold");
|
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::threshold");
|
||||||
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::intensity");
|
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::intensity");
|
||||||
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::radius");
|
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::radius");
|
||||||
|
|
||||||
|
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtEnabled");
|
||||||
|
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtScale");
|
||||||
|
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtIntensity");
|
||||||
|
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtImage");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Our actual postFX
|
//Our actual postFX
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,25 @@
|
||||||
#include "core/rendering/shaders/postFX/postFx.hlsl"
|
#include "core/rendering/shaders/postFX/postFx.hlsl"
|
||||||
|
|
||||||
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
|
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
|
||||||
|
TORQUE_UNIFORM_SAMPLER2D(dirtTex, 1);
|
||||||
uniform float strength;
|
uniform float strength;
|
||||||
|
// XY: Dirt Texture Size/Scale
|
||||||
|
// Z: Dirt Effect Strength
|
||||||
|
uniform float3 dirtParams;
|
||||||
|
uniform float2 oneOverTargetSize;
|
||||||
|
|
||||||
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
||||||
{
|
{
|
||||||
|
#if defined(USE_DIRT)
|
||||||
|
float3 dirt = TORQUE_TEX2D(dirtTex, IN.uv0 / (dirtParams.xy * oneOverTargetSize)).rgb * dirtParams.z;
|
||||||
|
#endif
|
||||||
|
|
||||||
float4 upSample = TORQUE_TEX2D(inputTex, IN.uv0);
|
float4 upSample = TORQUE_TEX2D(inputTex, IN.uv0);
|
||||||
|
|
||||||
|
#if defined(USE_DIRT)
|
||||||
|
upSample.rgb += upSample.rgb * dirt;
|
||||||
|
#endif
|
||||||
|
|
||||||
upSample.rgb *= strength;
|
upSample.rgb *= strength;
|
||||||
|
|
||||||
return upSample;
|
return upSample;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,23 @@
|
||||||
$PostFX::BloomPostFX::Enabled = "1";
|
$PostFX::BloomPostFX::Enabled = "1";
|
||||||
$PostFX::BloomPostFX::quality = "3";
|
$PostFX::BloomPostFX::threshold = "0.5";
|
||||||
$PostFX::BloomPostFX::threshold = "1";
|
$PostFX::BloomPostFX::intensity = "0.5";
|
||||||
$PostFX::BloomPostFX::intensity = "2";
|
$PostFX::BloomPostFX::radius = "8";
|
||||||
$PostFX::BloomPostFX::radius = "6";
|
$PostFX::BloomPostFX::dirtEnabled = "1";
|
||||||
|
$PostFX::BloomPostFX::dirtScale = "2048";
|
||||||
|
$PostFX::BloomPostFX::dirtIntensity = "2";
|
||||||
|
$PostFX::BloomPostFX::dirtImage = "core/postFX/images/lensDirt.png";
|
||||||
|
$PostFX::HDRPostFX::Enabled = 1;
|
||||||
|
$PostFX::HDRPostFX::exposureValue = 1;
|
||||||
|
$PostFX::HDRPostFX::minLuminace = 0.001;
|
||||||
|
$PostFX::HDRPostFX::whiteCutoff = 1;
|
||||||
|
$PostFX::HDRPostFX::adaptRate = "1";
|
||||||
|
$PostFX::HDRPostFX::tonemapMode = "ACES";
|
||||||
|
$PostFX::HDRPostFX::enableBloom = "0";
|
||||||
|
$PostFX::HDRPostFX::brightPassThreshold = 1;
|
||||||
|
$PostFX::HDRPostFX::gaussMultiplier = 0.3;
|
||||||
|
$PostFX::HDRPostFX::gaussMean = 0;
|
||||||
|
$PostFX::HDRPostFX::gaussStdDev = 0.8;
|
||||||
|
$PostFX::HDRPostFX::enableAutoExposure = "0";
|
||||||
|
$PostFX::HDRPostFX::keyValue = "1";
|
||||||
|
$PostFX::HDRPostFX::enableBlueShift = 0;
|
||||||
|
$PostFX::HDRPostFX::blueShiftColor = "1.05 0.97 1.27";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue