From 8476242bdfa98882dc6b6bef12cad820535880b0 Mon Sep 17 00:00:00 2001 From: cpusci Date: Tue, 30 Jul 2013 07:17:53 -0500 Subject: [PATCH] Update to turbulence PostFX to improve the visual effect of being underwater. --- .../core/scripts/client/postFx/turbulence.cs | 16 +++++++++++--- .../shaders/common/postFx/turbulenceP.hlsl | 22 +++++-------------- .../core/scripts/client/postFx/turbulence.cs | 16 +++++++++++--- .../shaders/common/postFx/turbulenceP.hlsl | 22 +++++-------------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Templates/Empty/game/core/scripts/client/postFx/turbulence.cs b/Templates/Empty/game/core/scripts/client/postFx/turbulence.cs index af4d7dc7f..6e897621c 100644 --- a/Templates/Empty/game/core/scripts/client/postFx/turbulence.cs +++ b/Templates/Empty/game/core/scripts/client/postFx/turbulence.cs @@ -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; }; diff --git a/Templates/Empty/game/shaders/common/postFx/turbulenceP.hlsl b/Templates/Empty/game/shaders/common/postFx/turbulenceP.hlsl index a8f79cfee..631338814 100644 --- a/Templates/Empty/game/shaders/common/postFx/turbulenceP.hlsl +++ b/Templates/Empty/game/shaders/common/postFx/turbulenceP.hlsl @@ -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; - -} \ No newline at end of file + 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)); +} diff --git a/Templates/Full/game/core/scripts/client/postFx/turbulence.cs b/Templates/Full/game/core/scripts/client/postFx/turbulence.cs index af4d7dc7f..82f05f00e 100644 --- a/Templates/Full/game/core/scripts/client/postFx/turbulence.cs +++ b/Templates/Full/game/core/scripts/client/postFx/turbulence.cs @@ -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; }; diff --git a/Templates/Full/game/shaders/common/postFx/turbulenceP.hlsl b/Templates/Full/game/shaders/common/postFx/turbulenceP.hlsl index a8f79cfee..631338814 100644 --- a/Templates/Full/game/shaders/common/postFx/turbulenceP.hlsl +++ b/Templates/Full/game/shaders/common/postFx/turbulenceP.hlsl @@ -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; - -} \ No newline at end of file + 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)); +}