mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +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
4 changed files with 38 additions and 38 deletions
|
|
@ -20,6 +20,16 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
singleton GFXStateBlockData( PFX_TurbulenceStateBlock : PFX_DefaultStateBlock)
|
||||||
|
{
|
||||||
|
zDefined = false;
|
||||||
|
zEnable = false;
|
||||||
|
zWriteEnable = false;
|
||||||
|
|
||||||
|
samplersDefined = true;
|
||||||
|
samplerStates[0] = SamplerClampLinear;
|
||||||
|
};
|
||||||
|
|
||||||
singleton ShaderData( PFX_TurbulenceShader )
|
singleton ShaderData( PFX_TurbulenceShader )
|
||||||
{
|
{
|
||||||
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
|
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
|
||||||
|
|
@ -39,7 +49,7 @@ singleton PostEffect( TurbulenceFx )
|
||||||
renderBin = "ObjTranslucentBin";
|
renderBin = "ObjTranslucentBin";
|
||||||
|
|
||||||
shader = PFX_TurbulenceShader;
|
shader = PFX_TurbulenceShader;
|
||||||
stateBlock = PFX_myShaderStateBlock;
|
stateBlock=PFX_TurbulenceStateBlock;
|
||||||
texture[0] = "$backBuffer";
|
texture[0] = "$backBuffer";
|
||||||
|
|
||||||
renderPriority = 0.1;
|
renderPriority = 0.1;
|
||||||
|
|
|
||||||
|
|
@ -26,20 +26,10 @@ uniform float accumTime;
|
||||||
|
|
||||||
float4 main( PFXVertToPix IN, uniform sampler2D inputTex : register(S0) ) : COLOR
|
float4 main( PFXVertToPix IN, uniform sampler2D inputTex : register(S0) ) : COLOR
|
||||||
{
|
{
|
||||||
float reduction = 128;
|
float speed = 2.0;
|
||||||
float power = 1.0;
|
float distortion = 6.0;
|
||||||
float speed = 3.0;
|
|
||||||
float frequency=8;
|
|
||||||
|
|
||||||
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,6 +20,16 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
singleton GFXStateBlockData( PFX_TurbulenceStateBlock : PFX_DefaultStateBlock)
|
||||||
|
{
|
||||||
|
zDefined = false;
|
||||||
|
zEnable = false;
|
||||||
|
zWriteEnable = false;
|
||||||
|
|
||||||
|
samplersDefined = true;
|
||||||
|
samplerStates[0] = SamplerClampLinear;
|
||||||
|
};
|
||||||
|
|
||||||
singleton ShaderData( PFX_TurbulenceShader )
|
singleton ShaderData( PFX_TurbulenceShader )
|
||||||
{
|
{
|
||||||
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
|
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
|
||||||
|
|
@ -39,7 +49,7 @@ singleton PostEffect( TurbulenceFx )
|
||||||
renderBin = "ObjTranslucentBin";
|
renderBin = "ObjTranslucentBin";
|
||||||
|
|
||||||
shader = PFX_TurbulenceShader;
|
shader = PFX_TurbulenceShader;
|
||||||
stateBlock = PFX_myShaderStateBlock;
|
stateBlock=PFX_TurbulenceStateBlock;
|
||||||
texture[0] = "$backBuffer";
|
texture[0] = "$backBuffer";
|
||||||
|
|
||||||
renderPriority = 0.1;
|
renderPriority = 0.1;
|
||||||
|
|
|
||||||
|
|
@ -26,20 +26,10 @@ uniform float accumTime;
|
||||||
|
|
||||||
float4 main( PFXVertToPix IN, uniform sampler2D inputTex : register(S0) ) : COLOR
|
float4 main( PFXVertToPix IN, uniform sampler2D inputTex : register(S0) ) : COLOR
|
||||||
{
|
{
|
||||||
float reduction = 128;
|
float speed = 2.0;
|
||||||
float power = 1.0;
|
float distortion = 6.0;
|
||||||
float speed = 3.0;
|
|
||||||
float frequency=8;
|
|
||||||
|
|
||||||
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…
Add table
Add a link
Reference in a new issue