/*********************************************************************NVMH3**** File: $Id: //sw/devtools/SDK/9.5/SDK/MEDIA/HLSL/post_titleOverlay.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. Comments: Typical set of blend modes -- overlay a file texture. By setting the appropriate #define values and recompiling, these shaders also support "Advanced" blend modes like those found in the layers of Adobe Photoshop (TM). Advanced "blend" ranges are based on VM-generated textures. For best results,use a card capable of FP-pixel texture support. See "scene_blendModes" for a similar example. ******************************************************************************/ #include // Turn this on to get the "dissolve" technique -- a bit slow just now // #define DISSOLVE float Script : STANDARDSGLOBAL < string UIWidget = "none"; string ScriptClass = "scene"; string ScriptOrder = "postprocess"; string ScriptOutput = "color"; string Script = "Technique=Teknik?title:withOpacity"; > = 0.8; float4 ClearColor : DIFFUSE < string UIName = "Background"; > = {0.3,0.3,0.3,1.0}; float ClearDepth < string UIWidget = "none"; > = 1.0; /////////////////////////////////////////////////////////// ///////////////////////////// Render-to-Texture Data ////// /////////////////////////////////////////////////////////// //DECLARE_QUAD_TEX(SceneTexture,SceneSampler,"A8R8G8B8") //DECLARE_QUAD_DEPTH_BUFFER(DepthBuffer, "D24S8") ///////////////////////////////////////////////////// //// Textures for Input Images ////////////////////// ///////////////////////////////////////////////////// FILE_TEXTURE_2D_MODAL(TitleCard,BlendImgSampler,"Blended.dds",BORDER) ///////////////////////////////////////////////////// //// Tweakables ///////////////////////////////////// ///////////////////////////////////////////////////// float Opacity < string UIWidget = "slider"; float uimin = 0.0; float uimax = 1.0; float uistep = 0.01; string UIName = "Title Opacity"; > = 1.0; float XScale < string UIName = "Width"; string UIWidget = "slider"; float UIMin = 0.1; float UIMax = 10.0; float UIStep = 0.01; > = 1.0f; float YScale < string UIName = "Height"; string UIWidget = "slider"; float UIMin = 0.1; float UIMax = 10.0; float UIStep = 0.01; > = 1.0f; float XPos < string UIName = "X"; string UIWidget = "slider"; float UIMin = -2.0; float UIMax = 4.0; float UIStep = 0.001; > = 0.0f; float YPos < string UIName = "Y"; string UIWidget = "slider"; float UIMin = -2.0; float UIMax = 4.0; float UIStep = 0.001; > = 0.0f; #define CTR QUAD_REAL2(0.5,0.5) static float2 Scale = 1.0/float2(XScale,YScale); static float2 Pos = float2(-XPos,YPos) + CTR; static QUAD_REAL2 pixelOffset = QUAD_REAL2(QuadTexOffset/(QuadScreenSize.x),QuadTexOffset/(QuadScreenSize.y)); /**************************************************************/ /********* utility pixel-shader functions and macros **********/ /**************************************************************/ QuadVertexOutput TitleQuadVS( QUAD_REAL3 Position : POSITION, QUAD_REAL3 TexCoord : TEXCOORD0 ) { QuadVertexOutput OUT; OUT.Position = QUAD_REAL4(Position, 1); QUAD_REAL2 nuv = Pos + (TexCoord.xy-CTR) * Scale; #ifdef NO_TEXEL_OFFSET OUT.UV = uv; #else /* NO_TEXEL_OFFSET */ OUT.UV = QUAD_REAL2(nuv+pixelOffset); #endif /* NO_TEXEL_OFFSET */ return OUT; } QUAD_REAL4 TexQuadOPS(QuadVertexOutput IN,uniform sampler2D InputSampler) : COLOR { QUAD_REAL4 texCol = tex2D(InputSampler, IN.UV); return texCol*QUAD_REAL4(1,1,1,Opacity); } /*******************************************************************/ /************* TECHNIQUES ******************************************/ /*******************************************************************/ // simplest techniques work in ps_1_1 technique title < string Script = // "RenderColorTarget0=SceneTexture;" // "RenderDepthStencilTarget=DepthBuffer;" "ClearSetColor=ClearColor;" "ClearSetDepth=ClearDepth;" "Clear=Color;" "Clear=Depth;" "ScriptExternal=color;" "Pass=p0;"; > { pass p0 < string Script="Draw=Buffer;"; > { VertexShader = compile vs_1_1 TitleQuadVS(); ZEnable = false; ZWriteEnable = false; CullMode = None; AlphaBlendEnable = true; SrcBlend = SrcAlpha; DestBlend = InvSrcAlpha; PixelShader = compile ps_1_1 TexQuadPS(BlendImgSampler); } } // simplest techniques work in ps_1_1 technique withOpacity < string Script = // "RenderColorTarget0=SceneTexture;" // "RenderDepthStencilTarget=DepthBuffer;" "ClearSetColor=ClearColor;" "ClearSetDepth=ClearDepth;" "Clear=Color;" "Clear=Depth;" "ScriptExternal=color;" "Pass=p0;"; > { pass p0 < string Script="Draw=Buffer;"; > { VertexShader = compile vs_1_1 TitleQuadVS(); ZEnable = false; ZWriteEnable = false; CullMode = None; AlphaBlendEnable = true; SrcBlend = SrcAlpha; DestBlend = InvSrcAlpha; PixelShader = compile ps_1_1 TexQuadOPS(BlendImgSampler); } } /***************************** eof ***/