mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Convert Tabs to Space & Enable Glow Effect
This commit is contained in:
parent
606da2e8ba
commit
e9be30b932
10 changed files with 170 additions and 170 deletions
|
|
@ -39,8 +39,8 @@ singleton ShaderData( Bloom_ThresholdShader )
|
||||||
{
|
{
|
||||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||||
DXPixelShaderFile = "./bloomThresholdP.hlsl";
|
DXPixelShaderFile = "./bloomThresholdP.hlsl";
|
||||||
OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||||
OGLPixelShaderFile = "./gl/bloomThresholdP.glsl";
|
OGLPixelShaderFile = "./gl/bloomThresholdP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$inputTex";
|
samplerNames[0] = "$inputTex";
|
||||||
|
|
||||||
|
|
@ -51,8 +51,8 @@ singleton ShaderData( Bloom_DownSampleShader )
|
||||||
{
|
{
|
||||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||||
DXPixelShaderFile = "./downSampleP.hlsl";
|
DXPixelShaderFile = "./downSampleP.hlsl";
|
||||||
OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||||
OGLPixelShaderFile = "./gl/downSampleP.glsl";
|
OGLPixelShaderFile = "./gl/downSampleP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$inputTex";
|
samplerNames[0] = "$inputTex";
|
||||||
|
|
||||||
|
|
@ -63,8 +63,8 @@ singleton ShaderData( Bloom_UpSampleShader )
|
||||||
{
|
{
|
||||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||||
DXPixelShaderFile = "./upSampleP.hlsl";
|
DXPixelShaderFile = "./upSampleP.hlsl";
|
||||||
OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||||
OGLPixelShaderFile = "./gl/upSampleP.glsl";
|
OGLPixelShaderFile = "./gl/upSampleP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$nxtTex";
|
samplerNames[0] = "$nxtTex";
|
||||||
samplerNames[1] = "$mipTex";
|
samplerNames[1] = "$mipTex";
|
||||||
|
|
@ -76,8 +76,8 @@ singleton ShaderData( Bloom_StrengthShader )
|
||||||
{
|
{
|
||||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||||
DXPixelShaderFile = "./bloomStrengthP.hlsl";
|
DXPixelShaderFile = "./bloomStrengthP.hlsl";
|
||||||
OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||||
OGLPixelShaderFile = "./gl/bloomStrengthP.glsl";
|
OGLPixelShaderFile = "./gl/bloomStrengthP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$inputTex";
|
samplerNames[0] = "$inputTex";
|
||||||
samplerNames[1] = "$dirtTex";
|
samplerNames[1] = "$dirtTex";
|
||||||
|
|
@ -122,11 +122,11 @@ function BloomPostFX::setShaderConsts( %this )
|
||||||
%dirtScale = $PostFX::BloomPostFX::dirtScale;
|
%dirtScale = $PostFX::BloomPostFX::dirtScale;
|
||||||
%dirtIntensity = $PostFX::BloomPostFX::dirtIntensity;
|
%dirtIntensity = $PostFX::BloomPostFX::dirtIntensity;
|
||||||
%final.setShaderConst("$dirtParams", %dirtScale SPC %dirtScale SPC %dirtIntensity);
|
%final.setShaderConst("$dirtParams", %dirtScale SPC %dirtScale SPC %dirtIntensity);
|
||||||
|
|
||||||
%edgeMin = $PostFX::BloomPostFX::dirtEdgeMinDist;
|
%edgeMin = $PostFX::BloomPostFX::dirtEdgeMinDist;
|
||||||
%edgeMax = $PostFX::BloomPostFX::dirtEdgeMaxDist;
|
%edgeMax = $PostFX::BloomPostFX::dirtEdgeMaxDist;
|
||||||
%edgeVal = $PostFX::BloomPostFX::dirtEdgeMinVal;
|
%edgeVal = $PostFX::BloomPostFX::dirtEdgeMinVal;
|
||||||
%final.setShaderConst("$edgeParams", %edgeMin SPC %edgeMax SPC %edgeVal);
|
%final.setShaderConst("$edgeParams", %edgeMin SPC %edgeMax SPC %edgeVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
function BloomPostFX::preProcess( %this )
|
function BloomPostFX::preProcess( %this )
|
||||||
|
|
@ -146,11 +146,11 @@ function BloomPostFX::preProcess( %this )
|
||||||
|
|
||||||
if(%this.dirtImage !$= $PostFX::BloomPostFX::dirtImage)
|
if(%this.dirtImage !$= $PostFX::BloomPostFX::dirtImage)
|
||||||
{
|
{
|
||||||
if ($PostFX::BloomPostFX::dirtImage $= "")
|
if ($PostFX::BloomPostFX::dirtImage $= "")
|
||||||
$PostFX::BloomPostFX::dirtImage = "core/postFX/images/lensDirt.png";
|
$PostFX::BloomPostFX::dirtImage = "core/postFX/images/lensDirt.png";
|
||||||
|
|
||||||
%this.dirtImage = $PostFX::BloomPostFX::dirtImage;
|
%this.dirtImage = $PostFX::BloomPostFX::dirtImage;
|
||||||
|
|
||||||
%final = %this->bloomFinal;
|
%final = %this->bloomFinal;
|
||||||
%final.setTexture(1, %this.dirtImage);
|
%final.setTexture(1, %this.dirtImage);
|
||||||
}
|
}
|
||||||
|
|
@ -168,7 +168,7 @@ function BloomPostFX::SetupBlurFX( %this )
|
||||||
stateBlock = Bloom_SampleStateBlock;
|
stateBlock = Bloom_SampleStateBlock;
|
||||||
texture[0] = "#threshold";
|
texture[0] = "#threshold";
|
||||||
target = "#bloom_0";
|
target = "#bloom_0";
|
||||||
targetScale = "0.5 0.5";
|
targetScale = "0.5 0.5";
|
||||||
targetFormat = %this.mipTexFormat;
|
targetFormat = %this.mipTexFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -206,8 +206,8 @@ function BloomPostFX::SetupBlurFX( %this )
|
||||||
texture[0] = %nxt;
|
texture[0] = %nxt;
|
||||||
texture[1] = %textureName;
|
texture[1] = %textureName;
|
||||||
target = "#" @ %mipName;
|
target = "#" @ %mipName;
|
||||||
targetScale = "1.0 1.0";
|
targetScale = "1.0 1.0";
|
||||||
targetFormat = %this.mipTexFormat;
|
targetFormat = %this.mipTexFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
%blurFX.add(%mipFX);
|
%blurFX.add(%mipFX);
|
||||||
|
|
@ -250,9 +250,9 @@ function BloomPostFX::populatePostFXSettings(%this)
|
||||||
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtEnabled", "Enable Dirt", "bool", "", $PostFX::BloomPostFX::dirtEnabled, "");
|
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::dirtScale", "Scale", "float", "", $PostFX::BloomPostFX::dirtScale, "");
|
||||||
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtIntensity", "Intensity", "float", "", $PostFX::BloomPostFX::dirtIntensity, "");
|
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtIntensity", "Intensity", "float", "", $PostFX::BloomPostFX::dirtIntensity, "");
|
||||||
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtEdgeMinDist", "Min Dist", "range", "", $PostFX::BloomPostFX::dirtEdgeMinDist, "0 1 10");
|
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtEdgeMinDist", "Min Dist", "range", "", $PostFX::BloomPostFX::dirtEdgeMinDist, "0 1 10");
|
||||||
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtEdgeMaxDist", "Max Dist", "range", "", $PostFX::BloomPostFX::dirtEdgeMaxDist, "0 1 10");
|
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtEdgeMaxDist", "Max Dist", "range", "", $PostFX::BloomPostFX::dirtEdgeMaxDist, "0 1 10");
|
||||||
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtEdgeMinVal", "Min Value", "range", "", $PostFX::BloomPostFX::dirtEdgeMinVal, "0 1 10");
|
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtEdgeMinVal", "Min Value", "range", "", $PostFX::BloomPostFX::dirtEdgeMinVal, "0 1 10");
|
||||||
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtImage", "Dirt Image", "image", "", $PostFX::BloomPostFX::dirtImage, "");
|
PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtImage", "Dirt Image", "image", "", $PostFX::BloomPostFX::dirtImage, "");
|
||||||
PostEffectEditorInspector.endGroup();
|
PostEffectEditorInspector.endGroup();
|
||||||
}
|
}
|
||||||
|
|
@ -289,18 +289,18 @@ function BloomPostFX::savePresetSettings(%this)
|
||||||
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtScale");
|
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtScale");
|
||||||
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtIntensity");
|
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtIntensity");
|
||||||
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtImage");
|
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtImage");
|
||||||
|
|
||||||
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtEdgeMinDist");
|
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtEdgeMinDist");
|
||||||
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtEdgeMaxDist");
|
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtEdgeMaxDist");
|
||||||
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtEdgeMinVal");
|
PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtEdgeMinVal");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Our actual postFX
|
//Our actual postFX
|
||||||
singleton PostEffect( BloomPostFX )
|
singleton PostEffect( BloomPostFX )
|
||||||
{
|
{
|
||||||
mipsCount = 5;
|
mipsCount = 5;
|
||||||
mipTexFormat = "GFXFormatR16G16B16A16F";
|
mipTexFormat = "GFXFormatR16G16B16A16F";
|
||||||
|
|
||||||
enabled = false;
|
enabled = false;
|
||||||
allowReflectPass = false;
|
allowReflectPass = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,17 +36,17 @@ uniform float2 oneOverTargetSize;
|
||||||
|
|
||||||
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
||||||
{
|
{
|
||||||
#ifdef USE_DIRT
|
#ifdef USE_DIRT
|
||||||
float edge = distance(IN.uv0, float2(0.5f, 0.5f));
|
float edge = distance(IN.uv0, float2(0.5f, 0.5f));
|
||||||
edge = max(smoothstep(edgeParams.x, edgeParams.y, edge), edgeParams.z);
|
edge = max(smoothstep(edgeParams.x, edgeParams.y, edge), edgeParams.z);
|
||||||
float3 dirt = TORQUE_TEX2D(dirtTex, IN.uv0 / (dirtParams.xy * oneOverTargetSize)).rgb * dirtParams.z * edge;
|
float3 dirt = TORQUE_TEX2D(dirtTex, IN.uv0 / (dirtParams.xy * oneOverTargetSize)).rgb * dirtParams.z * edge;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float4 upSample = TORQUE_TEX2D(inputTex, IN.uv0) * strength;
|
float4 upSample = TORQUE_TEX2D(inputTex, IN.uv0) * strength;
|
||||||
|
|
||||||
#ifdef USE_DIRT
|
#ifdef USE_DIRT
|
||||||
upSample.rgb += upSample.rgb * dirt;
|
upSample.rgb += upSample.rgb * dirt;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return upSample * M_1OVER_PI_F;
|
return upSample * M_1OVER_PI_F;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,12 @@ uniform float threshold;
|
||||||
|
|
||||||
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
||||||
{
|
{
|
||||||
float4 screenColor = TORQUE_TEX2D(inputTex, IN.uv0);
|
float4 screenColor = TORQUE_TEX2D(inputTex, IN.uv0);
|
||||||
float lum = hdrLuminance(screenColor.rgb);
|
float lum = hdrLuminance(screenColor.rgb);
|
||||||
|
|
||||||
float brightness = max(screenColor.r, max(screenColor.g, screenColor.b));
|
float brightness = max(screenColor.r, max(screenColor.g, screenColor.b));
|
||||||
float contribution = saturate(brightness - threshold) / max(brightness, 0.0001f);
|
float contribution = saturate(brightness - threshold) / max(brightness, 0.0001f);
|
||||||
contribution = sqr(lum * contribution);
|
contribution = sqr(lum * contribution);
|
||||||
|
|
||||||
return max(screenColor * sqr(contribution), 0.0001f);
|
return max(screenColor * sqr(contribution), 0.0001f);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,15 +24,15 @@
|
||||||
|
|
||||||
#define KERNEL_SAMPLES 9
|
#define KERNEL_SAMPLES 9
|
||||||
static const float3 KERNEL[9] = {
|
static const float3 KERNEL[9] = {
|
||||||
float3( 0.0000f, 0.0000f, 0.2500f),
|
float3( 0.0000f, 0.0000f, 0.2500f),
|
||||||
float3( 1.0000f, 0.0000f, 0.1250f),
|
float3( 1.0000f, 0.0000f, 0.1250f),
|
||||||
float3( 0.0000f, 1.0000f, 0.1250f),
|
float3( 0.0000f, 1.0000f, 0.1250f),
|
||||||
float3(-1.0000f, 0.0000f, 0.1250f),
|
float3(-1.0000f, 0.0000f, 0.1250f),
|
||||||
float3( 0.0000f,-1.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),
|
||||||
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);
|
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
|
||||||
|
|
@ -40,19 +40,19 @@ uniform float2 oneOverTargetSize;
|
||||||
|
|
||||||
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
||||||
{
|
{
|
||||||
float4 downSample = float4(0, 0, 0, 0);
|
float4 downSample = float4(0, 0, 0, 0);
|
||||||
|
|
||||||
[unroll]
|
[unroll]
|
||||||
for (int i=0; i<KERNEL_SAMPLES; i++)
|
for (int i=0; i<KERNEL_SAMPLES; i++)
|
||||||
{
|
{
|
||||||
// XY: Sample Offset
|
// XY: Sample Offset
|
||||||
// Z: Sample Weight
|
// Z: Sample Weight
|
||||||
float3 offsetWeight = KERNEL[i];
|
float3 offsetWeight = KERNEL[i];
|
||||||
float2 offset = offsetWeight.xy * oneOverTargetSize;
|
float2 offset = offsetWeight.xy * oneOverTargetSize;
|
||||||
float weight = offsetWeight.z;
|
float weight = offsetWeight.z;
|
||||||
float4 sampleCol = TORQUE_TEX2D(inputTex, IN.uv0 + offset);
|
float4 sampleCol = TORQUE_TEX2D(inputTex, IN.uv0 + offset);
|
||||||
downSample += sampleCol * weight;
|
downSample += sampleCol * weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
return downSample;
|
return downSample;
|
||||||
}
|
}
|
||||||
|
|
@ -42,17 +42,17 @@ out vec4 OUT_col;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
#ifdef USE_DIRT
|
#ifdef USE_DIRT
|
||||||
float edge = distance(IN_uv0, vec2(0.5, 0.5));
|
float edge = distance(IN_uv0, vec2(0.5, 0.5));
|
||||||
edge = max(smoothstep(edgeParams.x, edgeParams.y, edge), edgeParams.z);
|
edge = max(smoothstep(edgeParams.x, edgeParams.y, edge), edgeParams.z);
|
||||||
vec3 dirt = texture(dirtTex, IN_uv0 / (dirtParams.xy * oneOverTargetSize)).rgb * dirtParams.z * edge;
|
vec3 dirt = texture(dirtTex, IN_uv0 / (dirtParams.xy * oneOverTargetSize)).rgb * dirtParams.z * edge;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vec4 upSample = texture(inputTex, IN_uv0) * strength;
|
vec4 upSample = texture(inputTex, IN_uv0) * strength;
|
||||||
|
|
||||||
#ifdef USE_DIRT
|
#ifdef USE_DIRT
|
||||||
upSample.rgb += upSample.rgb * dirt;
|
upSample.rgb += upSample.rgb * dirt;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OUT_col = upSample * M_1OVER_PI_F;
|
OUT_col = upSample * M_1OVER_PI_F;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,12 +34,12 @@ out vec4 OUT_col;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 screenColor = texture(inputTex, IN_uv0);
|
vec4 screenColor = texture(inputTex, IN_uv0);
|
||||||
float lum = hdrLuminance(screenColor.rgb);
|
float lum = hdrLuminance(screenColor.rgb);
|
||||||
|
|
||||||
float brightness = max(screenColor.r, max(screenColor.g, screenColor.b));
|
float brightness = max(screenColor.r, max(screenColor.g, screenColor.b));
|
||||||
float contribution = clamp(brightness - threshold, 0.0, 1.0) / max(brightness, 0.0001);
|
float contribution = clamp(brightness - threshold, 0.0, 1.0) / max(brightness, 0.0001);
|
||||||
contribution = sqr(lum * contribution);
|
contribution = sqr(lum * contribution);
|
||||||
|
|
||||||
OUT_col = max(screenColor * sqr(contribution), 0.0001);
|
OUT_col = max(screenColor * sqr(contribution), 0.0001);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,15 +28,15 @@
|
||||||
|
|
||||||
#define KERNEL_SAMPLES 9
|
#define KERNEL_SAMPLES 9
|
||||||
const vec3 KERNEL[9] = vec3[](
|
const vec3 KERNEL[9] = vec3[](
|
||||||
vec3( 0.0000, 0.0000, 0.2500),
|
vec3( 0.0000, 0.0000, 0.2500),
|
||||||
vec3( 1.0000, 0.0000, 0.1250),
|
vec3( 1.0000, 0.0000, 0.1250),
|
||||||
vec3( 0.0000, 1.0000, 0.1250),
|
vec3( 0.0000, 1.0000, 0.1250),
|
||||||
vec3(-1.0000, 0.0000, 0.1250),
|
vec3(-1.0000, 0.0000, 0.1250),
|
||||||
vec3( 0.0000,-1.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),
|
||||||
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 sampler2D inputTex;
|
||||||
|
|
@ -46,18 +46,18 @@ out vec4 OUT_col;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 downSample = vec4(0, 0, 0, 0);
|
vec4 downSample = vec4(0, 0, 0, 0);
|
||||||
|
|
||||||
for (int i=0; i<KERNEL_SAMPLES; i++)
|
for (int i=0; i<KERNEL_SAMPLES; i++)
|
||||||
{
|
{
|
||||||
// XY: Sample Offset
|
// XY: Sample Offset
|
||||||
// Z: Sample Weight
|
// Z: Sample Weight
|
||||||
vec3 offsetWeight = KERNEL[i];
|
vec3 offsetWeight = KERNEL[i];
|
||||||
vec2 offsetXY = offsetWeight.xy * oneOverTargetSize;
|
vec2 offsetXY = offsetWeight.xy * oneOverTargetSize;
|
||||||
float weight = offsetWeight.z;
|
float weight = offsetWeight.z;
|
||||||
vec4 sampleCol = texture(inputTex, IN_uv0 + offsetXY);
|
vec4 sampleCol = texture(inputTex, IN_uv0 + offsetXY);
|
||||||
downSample += sampleCol * weight;
|
downSample += sampleCol * weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
OUT_col = downSample;
|
OUT_col = downSample;
|
||||||
}
|
}
|
||||||
|
|
@ -28,15 +28,15 @@
|
||||||
|
|
||||||
#define KERNEL_SAMPLES 9
|
#define KERNEL_SAMPLES 9
|
||||||
const vec3 KERNEL[9] = vec3[](
|
const vec3 KERNEL[9] = vec3[](
|
||||||
vec3( 0.0000, 0.0000, 0.5000),
|
vec3( 0.0000, 0.0000, 0.5000),
|
||||||
vec3( 1.0000, 0.0000, 0.0625),
|
vec3( 1.0000, 0.0000, 0.0625),
|
||||||
vec3( 0.0000, 1.0000, 0.0625),
|
vec3( 0.0000, 1.0000, 0.0625),
|
||||||
vec3(-1.0000, 0.0000, 0.0625),
|
vec3(-1.0000, 0.0000, 0.0625),
|
||||||
vec3( 0.0000,-1.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),
|
||||||
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 nxtTex;
|
||||||
|
|
@ -48,20 +48,20 @@ out vec4 OUT_col;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 upSample = vec4(0, 0, 0, 0);
|
vec4 upSample = vec4(0, 0, 0, 0);
|
||||||
|
|
||||||
for (int i=0; i<KERNEL_SAMPLES; i++)
|
for (int i=0; i<KERNEL_SAMPLES; i++)
|
||||||
{
|
{
|
||||||
// XY: Sample Offset
|
// XY: Sample Offset
|
||||||
// Z: Sample Weight
|
// Z: Sample Weight
|
||||||
vec3 offsetWeight = KERNEL[i];
|
vec3 offsetWeight = KERNEL[i];
|
||||||
vec2 offsetXY = offsetWeight.xy * oneOverTargetSize * filterRadius;
|
vec2 offsetXY = offsetWeight.xy * oneOverTargetSize * filterRadius;
|
||||||
float weight = offsetWeight.z;
|
float weight = offsetWeight.z;
|
||||||
vec4 sampleCol = texture(mipTex, IN_uv0 + offsetXY);
|
vec4 sampleCol = texture(mipTex, IN_uv0 + offsetXY);
|
||||||
upSample += sampleCol * weight;
|
upSample += sampleCol * weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
upSample = texture(nxtTex, IN_uv0) + upSample;
|
upSample = texture(nxtTex, IN_uv0) + upSample;
|
||||||
|
|
||||||
OUT_col = upSample;
|
OUT_col = upSample;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,15 +24,15 @@
|
||||||
|
|
||||||
#define KERNEL_SAMPLES 9
|
#define KERNEL_SAMPLES 9
|
||||||
static const float3 KERNEL[9] = {
|
static const float3 KERNEL[9] = {
|
||||||
float3( 0.0000f, 0.0000f, 0.5000f),
|
float3( 0.0000f, 0.0000f, 0.5000f),
|
||||||
float3( 1.0000f, 0.0000f, 0.0625f),
|
float3( 1.0000f, 0.0000f, 0.0625f),
|
||||||
float3( 0.0000f, 1.0000f, 0.0625f),
|
float3( 0.0000f, 1.0000f, 0.0625f),
|
||||||
float3(-1.0000f, 0.0000f, 0.0625f),
|
float3(-1.0000f, 0.0000f, 0.0625f),
|
||||||
float3( 0.0000f,-1.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),
|
||||||
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(nxtTex, 0);
|
||||||
|
|
@ -42,21 +42,21 @@ uniform float2 oneOverTargetSize;
|
||||||
|
|
||||||
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
||||||
{
|
{
|
||||||
float4 upSample = float4(0, 0, 0, 0);
|
float4 upSample = float4(0, 0, 0, 0);
|
||||||
|
|
||||||
[unroll]
|
[unroll]
|
||||||
for (int i=0; i<KERNEL_SAMPLES; i++)
|
for (int i=0; i<KERNEL_SAMPLES; i++)
|
||||||
{
|
{
|
||||||
// XY: Sample Offset
|
// XY: Sample Offset
|
||||||
// Z: Sample Weight
|
// Z: Sample Weight
|
||||||
float3 offsetWeight = KERNEL[i];
|
float3 offsetWeight = KERNEL[i];
|
||||||
float2 offset = offsetWeight.xy * oneOverTargetSize * filterRadius;
|
float2 offset = offsetWeight.xy * oneOverTargetSize * filterRadius;
|
||||||
float weight = offsetWeight.z;
|
float weight = offsetWeight.z;
|
||||||
float4 sampleCol = TORQUE_TEX2D(mipTex, IN.uv0 + offset);
|
float4 sampleCol = TORQUE_TEX2D(mipTex, IN.uv0 + offset);
|
||||||
upSample += sampleCol * weight;
|
upSample += sampleCol * weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
upSample = TORQUE_TEX2D(nxtTex, IN.uv0) + upSample;
|
upSample = TORQUE_TEX2D(nxtTex, IN.uv0) + upSample;
|
||||||
|
|
||||||
return upSample;
|
return upSample;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ singleton PostEffect( GlowPostFX )
|
||||||
target = "$outTex";
|
target = "$outTex";
|
||||||
targetScale = "0.5 0.5";
|
targetScale = "0.5 0.5";
|
||||||
|
|
||||||
enabled = false;
|
enabled = true;
|
||||||
|
|
||||||
// Blur vertically
|
// Blur vertically
|
||||||
new PostEffect()
|
new PostEffect()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue