/*********************************************************************NVMH3**** File: $Id: //sw/devtools/SDK/9.5/SDK/MEDIA/HLSL/post_drainBamage.fx#3 $ Copyright NVIDIA Corporation 2004 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. ******************************************************************************/ #include #define NOISE_SCALE 2 #include float Script : STANDARDSGLOBAL < string UIWidget = "none"; string ScriptClass = "scene"; string ScriptOrder = "postprocess"; string ScriptOutput = "color"; string Script = "Technique=frosted;"; > = 0.8; // version # float4 ClearColor < string UIWidget = "color"; string UIName = "background"; > = {0,0,0,0}; float ClearDepth = 1.0; DECLARE_QUAD_TEX(SceneMap,SceneSampler,"X8R8G8B8") DECLARE_QUAD_DEPTH_BUFFER(DepthBuffer,"D24S8") float Timer:TIME ; float Speed < string UIWidget = "slider"; float UIMin = 0.000001; float UIMax = 2; float UIStep = 0.000001; > = 0.2; static float Anim = (Timer*Speed); static float Anim2 = ((Timer+.5)*Speed); static float Mix = (0.5*(cos(Anim*4.0*3.141592653589)+1.0)); /************* TWEAKABLES **************/ float Distort < string UIName = "Overall Distortion"; string UIWidget = "slider"; float UIMin = 0; float UIMax = 0.2; float UIStep = 0.0001; > = 0.06f; ////////////// struct SolidVertexOutput { QUAD_REAL4 Position : POSITION; QUAD_REAL3 UV : TEXCOORD0; QUAD_REAL3 UV2 : TEXCOORD1; }; SolidVertexOutput ScreenSolidVS( QUAD_REAL3 Position : POSITION, QUAD_REAL3 TexCoord : TEXCOORD0 ) { SolidVertexOutput OUT; OUT.Position = QUAD_REAL4(Position, 1); #ifdef NO_TEXEL_OFFSET OUT.UV = TexCoord.xy; #else /* NO_TEXEL_OFFSET */ QUAD_REAL2 off = QUAD_REAL2(QuadTexOffset/(QuadScreenSize.x),QuadTexOffset/(QuadScreenSize.y)); OUT.UV = QUAD_REAL3((TexCoord.xy+off),Anim); OUT.UV2 = QUAD_REAL3((TexCoord.xy+off),Anim2); #endif /* NO_TEXEL_OFFSET */ return OUT; } QUAD_REAL4 distortPS(SolidVertexOutput IN) : COLOR { QUAD_REAL2 off1 = tex3D(NoiseSamp, IN.UV).xy; QUAD_REAL2 off2 = tex3D(NoiseSamp, IN.UV2).xy; // zw? QUAD_REAL2 result = lerp(off1,off2,Mix); QUAD_REAL2 d = Distort*(result-QUAD_REAL2(0.5,0.5)); QUAD_REAL2 nuv = (IN.UV.xy + d); return tex2D(SceneSampler,nuv); } /*************/ technique frosted < string Script = "RenderColorTarget0=SceneMap;" "RenderDepthStencilTarget=DepthBuffer;" "ClearSetColor=ClearColor;" "ClearSetDepth=ClearDepth;" "Clear=Color;" "Clear=Depth;" "ScriptExternal=color;" "Pass=p0;"; > { pass p0 < string Script ="RenderColorTarget0=;" "Draw=Buffer;"; > { VertexShader = compile vs_2_0 ScreenSolidVS(); ZEnable = false; ZWriteEnable = false; CullMode = None; PixelShader = compile ps_2_a distortPS(); } } /***************************** eof ***/