renderProgram guiBlur { program vertex cg { <% struct VsInputs { float3 pos : $positionAttrib; float2 tex : $texCoordAttrib; float4 col : $colorAttrib; }; struct VsOutputs { float2 texCoord0 : TEXCOORD0; float4 col : COLOR0; }; float2 screenSize : $currentRenderTexelSize; VsOutputs vertex( VsInputs indata ) { VsOutputs outdata; $if r_32ByteVtx indata.tex *= 1.0f / 4096.0f; $endif float2 coord = indata.tex.xy; coord.y = 1.0f - coord.y; outdata.texCoord0 = coord * screenSize; outdata.col = indata.col; return outdata; } %> } program fragment cg { <% struct VsOutputs { float2 texCoord0 : TEXCOORD0; float4 col : COLOR0; }; samplerRECT framebuffer : $currentRender; samplerRECT blured : $map; #define OFFSET_START -2 #define GRID_SIZE 4 float4 fragment( VsOutputs indata ) : COLOR { // this is the number of pixels between grid squares, increase to expand blur grid area float2 offset = float2( 2.2f, 2.2f ); float4 clean = texRECT( framebuffer, indata.texCoord0 ); float4 blur = 0.0f; float2 currentOffset = offset * OFFSET_START; for ( int y = 0; y < GRID_SIZE; y++ ) { for ( int x = 0; x < GRID_SIZE; x++ ) { blur += texRECT( blured, (indata.texCoord0 + currentOffset)/4 ); currentOffset.x += offset.x; } currentOffset.x = offset.x * OFFSET_START; currentOffset.y += offset.y; } blur /= ( GRID_SIZE * GRID_SIZE ); return lerp( clean, blur, indata.col.a ); } %> } } renderProgram guiBlur_4x4 { program vertex cg { <% struct VsInputs { float3 pos : $positionAttrib; float2 tex : $texCoordAttrib; float4 col : $colorAttrib; }; struct VsOutputs { float2 texCoord0 : TEXCOORD0; float4 col : COLOR0; }; float2 screenSize : $currentRenderTexelSize; VsOutputs vertex( VsInputs indata ) { VsOutputs outdata; $if r_32ByteVtx indata.tex *= 1.0f / 4096.0f; $endif float2 coord = indata.tex.xy; coord.y = 1.0f - coord.y; outdata.texCoord0 = coord * screenSize; outdata.col = indata.col; return outdata; } %> } program fragment cg { <% struct VsOutputs { float2 texCoord0 : TEXCOORD0; float4 col : COLOR0; }; samplerRECT framebuffer : $currentRender; #define OFFSET_START -2 #define GRID_SIZE 4 float4 fragment( VsOutputs indata ) : COLOR { // this is the number of pixels between grid squares, increase to expand blur grid area float2 offset = float2( 2.2f, 2.2f ); float4 blur = 0.0f; float2 currentOffset = offset * OFFSET_START; for ( int y = 0; y < GRID_SIZE; y++ ) { for ( int x = 0; x < GRID_SIZE; x++ ) { blur += texRECT( framebuffer, indata.texCoord0 + currentOffset ); currentOffset.x += offset.x; } currentOffset.x = offset.x * OFFSET_START; currentOffset.y += offset.y; } blur /= ( GRID_SIZE * GRID_SIZE ); return blur; } %> } }