About downsampling & Upsampling

Started by
9 comments, last by Creator_Chen 12 years, 9 months ago
What's the difference if I just simply copy the original texture to a small one rather than downsample it manually?
Advertisement

[quote name='akhin' timestamp='1300744468' post='4788814']
One another thing is as I have looked at DX SDK HDRPipeline sample , it uses a pixel shader as below :



float4 DownSampleOffsets[16];


float4 PSDownsample(in V2P IN) : COLOR0
{
float4 average = { 0.0f, 0.0f, 0.0f, 0.0f };

for( int i = 0; i < 16; i++ )
{
average += tex2D( ColorSampler, IN.TexCoord + float2(DownSampleOffsets.x, DownSampleOffsets.y) );
}

average *= ( 1.0f / 16.0f );

return average;
}




What exactly does it do ?



Its samples 16 pixels around the current pixel being calculated, and calculates the average of the 16 pixels (it adds the value of each pixel sampled and divide the sum by the number of pixels sampled).

This is used to downsample a texture, so each texel of the texture created with that pixel shader contains the average of 16 texels of the original texture.
[/quote]


[color="#1C2837"]What's the difference if I just simply copy the original texture to a smaller one rather than downsample it manually?

This topic is closed to new replies.

Advertisement