= 0.8; /////////////////////////////////////////////////////////// /////////////////////////////////////// Tweakables //////// /////////////////////////////////////////////////////////// float SceneIntensity < string UIName = "Scene intensity"; string UIWidget = "slider"; float UIMin = 0.0f; float UIMax = 2.0f; float UIStep = 0.1f; > = 0.5f; float GlowIntensity < string UIName = "Glow intensity"; string UIWidget = "slider"; float UIMin = 0.0f; float UIMax = 2.0f; float UIStep = 0.1f; > = 0.5f; float HighlightThreshold < string UIName = "Highlight threshold"; string UIWidget = "slider"; float UIMin = 0.0f; float UIMax = 1.0f; float UIStep = 0.1f; > = 0.9f; float HighlightIntensity < string UIName = "Highlight intensity"; string UIWidget = "slider"; float UIMin = 0.0f; float UIMax = 10.0f; float UIStep = 0.1f; > = 0.5f; /////////////////////////////////////////////////////////// ///////////////////////////// Render-to-Texture Data ////// /////////////////////////////////////////////////////////// float2 WindowSize : VIEWPORTPIXELSIZE < string UIWidget = "none"; >; float downsampleScale = 0.25; float BlurWidth < string UIName = "Blur width"; string UIWidget = "slider"; float UIMin = 0.0f; float UIMax = 10.0f; float UIStep = 0.5f; > = 2.0f; texture SceneMap : RENDERCOLORTARGET < float2 ViewportRatio = { 1.0, 1.0 }; int MIPLEVELS = 1; string format = "X8R8G8B8"; >; texture DepthMap : RENDERDEPTHSTENCILTARGET < float2 ViewportRatio = { 1.0, 1.0 }; string format = "D24S8"; >; sampler SceneSampler = sampler_state { texture = ; AddressU = CLAMP; AddressV = CLAMP; AddressW = CLAMP; MIPFILTER = NONE; MINFILTER = LINEAR; MAGFILTER = LINEAR; }; texture DownsampleMap : RENDERCOLORTARGET < float2 ViewportRatio = { 0.25, 0.25 }; int MIPLEVELS = 1; string format = "A8R8G8B8"; >; sampler DownsampleSampler = sampler_state { texture = ; AddressU = CLAMP; AddressV = CLAMP; AddressW = CLAMP; MIPFILTER = NONE; MINFILTER = LINEAR; MAGFILTER = LINEAR; }; texture HBlurMap : RENDERCOLORTARGET < float2 ViewportRatio = { 0.25, 0.25 }; int MIPLEVELS = 1; string format = "A8R8G8B8"; >; sampler HBlurSampler = sampler_state { texture = ; AddressU = CLAMP; AddressV = CLAMP; AddressW = CLAMP; MIPFILTER = NONE; MINFILTER = LINEAR; MAGFILTER = LINEAR; }; texture FinalBlurMap : RENDERCOLORTARGET < float2 ViewportRatio = { 0.25, 0.25 }; int MIPLEVELS = 1; string format = "A8R8G8B8"; >; sampler FinalBlurSampler = sampler_state { texture = ; AddressU = CLAMP; AddressV = CLAMP; AddressW = CLAMP; MIPFILTER = NONE; MINFILTER = LINEAR; MAGFILTER = LINEAR; }; /////////////////////////////////////////////////////////// /////////////////////////////////// data structures /////// /////////////////////////////////////////////////////////// struct VS_OUTPUT_BLUR { float4 Position : POSITION; float2 TexCoord[8]: TEXCOORD0; }; struct VS_OUTPUT { float4 Position : POSITION; float2 TexCoord0 : TEXCOORD0; float2 TexCoord1 : TEXCOORD1; }; struct VS_OUTPUT_DOWNSAMPLE { float4 Position : POSITION; float2 TexCoord[4]: TEXCOORD0; }; //////////////////////////////////////////////////////////// ////////////////////////////////// vertex shaders ////////// //////////////////////////////////////////////////////////// // generate texture coordinates to sample 4 neighbours VS_OUTPUT_DOWNSAMPLE VS_Downsample(float4 Position : POSITION, float2 TexCoord : TEXCOORD0) { VS_OUTPUT_DOWNSAMPLE OUT; float2 texelSize = downsampleScale / WindowSize; float2 s = TexCoord; OUT.Position = Position; OUT.TexCoord[0] = s; OUT.TexCoord[1] = s + float2(2, 0)*texelSize; OUT.TexCoord[2] = s + float2(2, 2)*texelSize; OUT.TexCoord[3] = s + float2(0, 2)*texelSize; return OUT; } // generate texcoords for blur VS_OUTPUT_BLUR VS_Blur(float4 Position : POSITION, float2 TexCoord : TEXCOORD0, uniform int nsamples, uniform float2 direction ) { VS_OUTPUT_BLUR OUT = (VS_OUTPUT_BLUR)0; OUT.Position = Position; float2 texelSize = BlurWidth / WindowSize; float2 s = TexCoord - texelSize*(nsamples-1)*0.5*direction; for(int i=0; i { pass DownSample < string Script = "RenderColorTarget0=DownsampleMap;" "ClearSetColor=ClearColor;" "Clear=Color;" "Draw=Buffer;"; > { cullmode = none; ZEnable = false; ZWriteEnable = false; VertexShader = compile vs_2_0 VS_Downsample(); PixelShader = compile ps_2_0 PS_Downsample(SceneSampler); } pass GlowH < string Script = "RenderColorTarget0=HBlurMap;" "ClearSetColor=ClearColor;" "Clear=Color;" "Draw=Buffer;"; > { cullmode = none; ZEnable = false; ZWriteEnable = false; VertexShader = compile vs_2_0 VS_Blur(7, float2(1, 0)); // PixelShader = compile ps_2_0 PS_Blur7(SceneSampler, weights7); PixelShader = compile ps_2_0 PS_Blur7(DownsampleSampler, weights7); } pass GlowV < string Script = "RenderColorTarget0=FinalBlurMap;" "ClearSetColor=ClearColor;" "Clear=color;" "Draw=Buffer;"; > { cullmode = none; ZEnable = false; ZWriteEnable = false; VertexShader = compile vs_2_0 VS_Blur(7, float2(0, 1)); PixelShader = compile ps_2_0 PS_Blur7(HBlurSampler, weights7); } pass GlowH_Central < string Script = "RenderColorTarget0=HBlurMap;" "ClearSetColor=ClearColor;" "Clear=Color;" "Draw=Buffer;"; > { cullmode = none; ZEnable = false; ZWriteEnable = false; VertexShader = compile vs_2_0 VS_Blur(7, float2(1, 0)); PixelShader = compile ps_2_0 PS_Blur7(DownsampleSampler, weights7_Central); } pass GlowV_Central < string Script = "RenderColorTarget0=FinalBlurMap;" "ClearSetColor=ClearColor;" "Clear=Color;" "Draw=Buffer;"; > { cullmode = none; ZEnable = false; ZWriteEnable = false; VertexShader = compile vs_2_0 VS_Blur(7, float2(0, 1)); PixelShader = compile ps_2_0 PS_Blur7(HBlurSampler, weights7_Central); } pass FinalComp < string Script = "RenderColorTarget=;" "RenderDepthStencilTarget=;" "Draw=Buffer;"; > { cullmode = none; ZEnable = false; ZWriteEnable = false; VertexShader = compile vs_2_0 VS_Quad(); PixelShader = compile ps_2_0 PS_Comp(SceneSampler, FinalBlurSampler); } } ]]> // 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 = "p