/*********************************************************************NVMH3**** File: $Id: Scene_bloom.fx 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. Comments: Create a scratched-movie-film look using noise ******************************************************************************/ #include #define NOISE2D_SCALE 1 //#define NOISE2D_FORMAT "A16B16G16R16F" #include float4 ClearColor < string UIWidget = "none"; > = { 0.0f, 0.0f, 0.0f, 1.0f}; float ClearDepth = 1.0f; float Script : STANDARDSGLOBAL < string UIWidget = "none"; string ScriptClass = "scene"; string ScriptOrder = "postprocess"; string ScriptOutput = "color"; // We just call a script in the main technique. string Script = "Technique=Scratch;"; > = 0.8; float Timer : TIME ; /////////////////////////////////////////////////////////// /////////////////////////////////////// Tweakables //////// /////////////////////////////////////////////////////////// float Speed < string UIName = "Speed (Slower=Longer Scratches)"; string UIWidget = "slider"; float UIMin = 0.0f; float UIMax = 0.2f; float UIStep = 0.0001f; > = 0.03f; float Speed2 < string UIName = "Side Scroll Speed"; string UIWidget = "slider"; float UIMin = 0.0f; float UIMax = 0.01f; float UIStep = 0.0001f; > = 0.01f; float ScratchIntensity < string UIName = "Scratch Cutoff"; string UIWidget = "slider"; float UIMin = 0.0f; float UIMax = 1.0f; float UIStep = 0.0001f; > = 0.65f; float IS < string UIName = "Scratch Width"; string UIWidget = "slider"; float UIMin = 0.0f; float UIMax = 0.1f; float UIStep = 0.0001f; > = 0.01f; //static float IS = (1.0 - ScratchIntensity); /////////////////////////////////////////////////////////// ///////////////////////////// Render-to-Texture Data ////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////// texture SceneMap : RENDERCOLORTARGET < float2 ViewportRatio = { 1.0, 1.0 }; int MIPLEVELS = 1; string format = "X8R8G8B8"; string UIWidget = "none"; >; texture DepthMap : RENDERDEPTHSTENCILTARGET < float2 ViewportRatio = { 1.0, 1.0 }; string format = "D24S8"; string UIWidget = "none"; >; sampler SceneSampler = sampler_state { texture = ; AddressU = CLAMP; AddressV = CLAMP; AddressW = CLAMP; MIPFILTER = NONE; MINFILTER = LINEAR; MAGFILTER = LINEAR; }; ////////////////////////////////////////////////////// ////////////////////////////////// pixel shaders ///// ////////////////////////////////////////////////////// static float ScanLine = (Timer*Speed); static float Side = (Timer*Speed2); float4 scratchPS(QuadVertexOutput IN) : COLOR { float4 img = tex2D(SceneSampler,IN.UV); float2 s = float2(IN.UV.x+Side,ScanLine); float scratch = tex2D(Noise2DSamp,s).x; scratch = 2.0f*(scratch - ScratchIntensity)/IS; scratch = 1.0-abs(1.0f-scratch); //scratch = scratch * 100.0f; scratch = max(0,scratch); //scratch = min(scratch,1.0f); return img + float4(scratch.xxx,0); } //////////////////////////////////////////////////////////// /////////////////////////////////////// techniques ///////// //////////////////////////////////////////////////////////// technique Scratch < string Script = "ClearSetDepth=ClearDepth;" "RenderColorTarget=SceneMap;" "RenderDepthStencilTarget=DepthMap;" "ClearSetColor=ClearColor;" "ClearSetDepth=ClearDepth;" "Clear=Color;" "Clear=Depth;" "ScriptSignature=color;" "ScriptExternal=;" "Pass=p0;"; > { pass p0 < string Script ="RenderColorTarget0=;" "Draw=Buffer;"; > { VertexShader = compile vs_2_0 ScreenQuadVS(); ZEnable = false; ZWriteEnable = false; CullMode = None; PixelShader = compile ps_2_b scratchPS(); } } // eof