This seems to down size an image to 1/4 size of the input image by reading
every fourth texel across and down:
return tex2D(inputTex, Uv.xy * float2(4.0, 4.0));
However I want to down size AND down sample for HDR luminance, so I am trying
for an output of 1/4 size by writing every 4th texel while adding the colors of
the surrounding texels that get left out.
But I am getting a weird result instead! Here is what I am doing:
float4 DownsamplePS( float2 Tex : TEXCOORD0 ) : COLOR0
{
// start with an empty color
float4 color = float4(0.0f, 0.0f, 0.0f, 0.0f);
// accumulate value off all colors in 4x4 square
color += tex2D( orgRT, Tex + float2( 0.0 , 0.0 )); // get (0,0) color
color += tex2D( orgRT, Tex + float2( 1.0 , 0.0 )); // add (1,0)'s color to it
color += tex2D( orgRT, Tex + float2( 2.0 , 0.0 )); // add (2,0)'s color to it
color += tex2D( orgRT, Tex + float2( 3.0 , 0.0 )); // add (3,0)'s color to it
color += tex2D( orgRT, Tex + float2( 0.0 , 1.0 )); // add (0,1)'s color to it
color += tex2D( orgRT, Tex + float2( 1.0 , 1.0 )); // add (1,1)'s color to it
color += tex2D( orgRT, Tex + float2( 2.0 , 1.0 )); // add (2,1)'s color to it
color += tex2D( orgRT, Tex + float2( 3.0 , 1.0 )); // add (3,1)'s color to it
color += tex2D( orgRT, Tex + float2( 0.0 , 2.0 )); // add (0,2)'s color to it
color += tex2D( orgRT, Tex + float2( 3.0 , 2.0 )); // add (1,2)'s color to it
color += tex2D( orgRT, Tex + float2( 2.0 , 2.0 )); // add (2,2)'s color to it
color += tex2D( orgRT, Tex + float2( 3.0 , 2.0 )); // add (3,2)'s color to it
color += tex2D( orgRT, Tex + float2( 0.0 , 3.0 )); // add (0,3)'s color to it
color += tex2D( orgRT, Tex + float2( 1.0 , 3.0 )); // add (1,3)'s color to it
color += tex2D( orgRT, Tex + float2( 2.0 , 3.0 )); // add (2,3)'s color to it
color += tex2D( orgRT, Tex + float2( 3.0 , 3.0 )); // add (3,3)'s color to it
// Adjust the accumulated amount by lum factor
float lum = dot(color, luminance_factor);
// get average of the 16 samples
lum *= 0.0625;
return lum;
}
Any advice is appreciated, Thanks.
[Edited by - josiah7 on June 21, 2008 8:13:03 PM]