#include "HDRBloom.cgfx" float blurMagnitude; //half nearLimit; //half farLimit; //half maxDensity; float3 inverseOffset; float3 inverseScale; float4 inverseParams; sampler2D screenTexture; sampler2D fullyBlurredImage; sampler2D depthTexture; #include "DepthOfField.cgfx" // Vertex Shader Output Structure struct vertexOutput { float4 position : POSITION; float2 texCoord : TEXCOORD0; }; // Vertex Shader // Simply passes the position and texture coords through vertexOutput postprocessBloomVP( float4 position : POSITION, half2 texCoord : TEXCOORD0 ) { vertexOutput OUT = (vertexOutput)0; OUT.position = position; OUT.texCoord = texCoord; return OUT; } // Pixel Shader // Uses the function 'ProcessBloom', and outputs the result half4 postprocessBloomFP( vertexOutput IN) : COLOR0 { half4 screenColour = tex2D(screenTexture, IN.texCoord); screenColour = screenColour/screenColour.a; const float3 depthFactor = float3(65536.0f/16777215.0f, 256.0f/16777215.0f, 1.0f/16777215.0f ); float4 RawDepth = tex2D(depthTexture, IN.texCoord); float Depth = dot(round( RawDepth.xyz * 255.0f.xxx ), depthFactor.xyz); float ScreenDepth = (Depth + inverseOffset.z) * inverseScale.z; half viewDepth = -inverseParams.w / (ScreenDepth + inverseParams.z); //// DEPTH OF FIELD //// screenColour = ProcessDOF( screenTexture, depthTexture, IN.texCoord, screenColour, viewDepth ); //// BLOOM ///// half4 BloomResult; BloomResult.rgb = ProcessBloom(IN.texCoord, screenColour.rgb, fullyBlurredImage); BloomResult.a = 1.h - blurMagnitude; BloomResult = saturate(BloomResult); return BloomResult; } // Technique for Bloom technique postprocessBloom { pass p0 { VertexProgram = compile vp30 postprocessBloomVP(); FragmentProgram = compile fp40 postprocessBloomFP(); DepthTestEnable = false; DepthMask = false; BlendEnable = true; } }