mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Merge pull request #450 from smally/turbulence_postfx_update
Replacement of turbulence PostFX improves visual quality of underwater scenes
This commit is contained in:
commit
3909c0eba5
|
|
@ -20,12 +20,22 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton GFXStateBlockData( PFX_TurbulenceStateBlock : PFX_DefaultStateBlock)
|
||||
{
|
||||
zDefined = false;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
singleton ShaderData( PFX_TurbulenceShader )
|
||||
{
|
||||
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "shaders/common/postFx/turbulenceP.hlsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
samplerNames[0] = "$inputTex";
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
|
|
@ -39,8 +49,8 @@ singleton PostEffect( TurbulenceFx )
|
|||
renderBin = "ObjTranslucentBin";
|
||||
|
||||
shader = PFX_TurbulenceShader;
|
||||
stateBlock = PFX_myShaderStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
stateBlock=PFX_TurbulenceStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
|
||||
renderPriority = 0.1;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,20 +26,10 @@ uniform float accumTime;
|
|||
|
||||
float4 main( PFXVertToPix IN, uniform sampler2D inputTex : register(S0) ) : COLOR
|
||||
{
|
||||
float reduction = 128;
|
||||
float power = 1.0;
|
||||
float speed = 3.0;
|
||||
float frequency=8;
|
||||
float speed = 2.0;
|
||||
float distortion = 6.0;
|
||||
|
||||
float backbuffer_edge_coef=0.98;
|
||||
float2 screen_center = float2(0.5, 0.5);
|
||||
float2 cPos = (IN.uv0 - screen_center);
|
||||
|
||||
float len = 1.0 - length(cPos);
|
||||
float2 uv = clamp((cPos / len * cos(len * frequency - (accumTime * speed)) * (power / reduction)), 0, 1);
|
||||
return tex2D(inputTex, IN.uv0 * backbuffer_edge_coef + uv);
|
||||
|
||||
// float4 color = tex2D(inputTex, IN.uv0 * backbuffer_edge_coef+(sin*right));
|
||||
// return color;
|
||||
|
||||
}
|
||||
float y = IN.uv0.y + (cos(IN.uv0.y * distortion + accumTime * speed) * 0.01);
|
||||
float x = IN.uv0.x + (sin(IN.uv0.x * distortion + accumTime * speed) * 0.01);
|
||||
return tex2D (inputTex, float2(x, y));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,12 +20,22 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton GFXStateBlockData( PFX_TurbulenceStateBlock : PFX_DefaultStateBlock)
|
||||
{
|
||||
zDefined = false;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
singleton ShaderData( PFX_TurbulenceShader )
|
||||
{
|
||||
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "shaders/common/postFx/turbulenceP.hlsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
samplerNames[0] = "$inputTex";
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
|
|
@ -39,8 +49,8 @@ singleton PostEffect( TurbulenceFx )
|
|||
renderBin = "ObjTranslucentBin";
|
||||
|
||||
shader = PFX_TurbulenceShader;
|
||||
stateBlock = PFX_myShaderStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
stateBlock=PFX_TurbulenceStateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
|
||||
renderPriority = 0.1;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,20 +26,10 @@ uniform float accumTime;
|
|||
|
||||
float4 main( PFXVertToPix IN, uniform sampler2D inputTex : register(S0) ) : COLOR
|
||||
{
|
||||
float reduction = 128;
|
||||
float power = 1.0;
|
||||
float speed = 3.0;
|
||||
float frequency=8;
|
||||
float speed = 2.0;
|
||||
float distortion = 6.0;
|
||||
|
||||
float backbuffer_edge_coef=0.98;
|
||||
float2 screen_center = float2(0.5, 0.5);
|
||||
float2 cPos = (IN.uv0 - screen_center);
|
||||
|
||||
float len = 1.0 - length(cPos);
|
||||
float2 uv = clamp((cPos / len * cos(len * frequency - (accumTime * speed)) * (power / reduction)), 0, 1);
|
||||
return tex2D(inputTex, IN.uv0 * backbuffer_edge_coef + uv);
|
||||
|
||||
// float4 color = tex2D(inputTex, IN.uv0 * backbuffer_edge_coef+(sin*right));
|
||||
// return color;
|
||||
|
||||
}
|
||||
float y = IN.uv0.y + (cos(IN.uv0.y * distortion + accumTime * speed) * 0.01);
|
||||
float x = IN.uv0.x + (sin(IN.uv0.x * distortion + accumTime * speed) * 0.01);
|
||||
return tex2D (inputTex, float2(x, y));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue