Jump to content

  • Log In with Google      Sign In   
  • Create Account

About downsampling & Upsampling


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 arijan   Members   -  Reputation: 104

Like
0Likes
Like

Posted 20 March 2011 - 11:00 PM

Hi all ,



1. Regarding the multiple render targets (surface+texture pairs ) in a post process sequence,

if I do create one of those textures as 1/4 of the screen , can this be considered as down sampling ?

or if I do create one of those textures 4 times greater then screen dimensions , can also this be considered as upsampling ?

I am asking since I saw this in some few samples. And when saying screen dimensions I am assuming it is for fullscreen.


2. I looked at DX SDK and other samples. I cant say I am able to fully understand logic of downsampling & upsampling.

Could you explain how it works ? Also a simplified HLSL code would be great.

Sponsor:

#2 Hodgman   Moderators   -  Reputation: 31799

Like
0Likes
Like

Posted 20 March 2011 - 11:36 PM

If you copy from a larger sized texture into a smaller sized texture, you are down-sampling. If you copy from a smaller texture into a larger texture, you are up-sampling. That's it.

To use the example of a post-processing operation, you'll often see something like:
1) Render scene to full-screen sized buffer.
2) Copy to 1/4 sized buffer (i.e. downsample it).
3) Do something cool, like blurring the 1/4 sized buffer.
4) Blend the 1/4 sized buffer back over the top of the full-screen one (i.e. upsample it).

#3 arijan   Members   -  Reputation: 104

Like
0Likes
Like

Posted 21 March 2011 - 12:24 AM

Thanks for your reply , but when I simply try to copy from a large texture to a smaller texture and then make some stuff like blur and

when I re copy the processed smaller texture to a larger texture , quality of final `so up sampled` texture becomes worse


Is there a way to keep the quality ?

#4 Hodgman   Moderators   -  Reputation: 31799

Like
0Likes
Like

Posted 21 March 2011 - 12:29 AM

What texture filtering mode are you using when you perform the down/up sampling?

#5 arijan   Members   -  Reputation: 104

Like
0Likes
Like

Posted 21 March 2011 - 12:39 AM

What texture filtering mode are you using when you perform the down/up sampling?


As below , what would you suggest ?

sampler ColorSampler = sampler_state

{

    Texture = <diffuseTexture>;

    MinFilter = LINEAR;

    MagFilter = LINEAR;

    MipFilter = LINEAR;

};



#6 mancubit   Members   -  Reputation: 518

Like
0Likes
Like

Posted 21 March 2011 - 06:06 AM

filtermodes look ok..

have you tried generating mips before upsampling?

#7 arijan   Members   -  Reputation: 104

Like
0Likes
Like

Posted 21 March 2011 - 10:08 AM

filtermodes look ok..

have you tried generating mips before upsampling?




not actually, how can I do that ?

#8 arijan   Members   -  Reputation: 104

Like
0Likes
Like

Posted 21 March 2011 - 12:37 PM

As I have checked mipmap stuff , I am creating textures with options : D3DUSAGE_RENDERTARGET|D3DUSAGE_AUTOGENMIPMAP



Then I am calling : m_texture->GenerateMipSubLevels();



But just after that when I call GetLevelCount it returns zero

Except that , can I code mipmmaping in pixel shader for my downsampler and also upsampler ?



#9 arijan   Members   -  Reputation: 104

Like
0Likes
Like

Posted 21 March 2011 - 03:54 PM

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[i].x, DownSampleOffsets[i].y) );
    }
        
    average *= ( 1.0f / 16.0f );

    return average;
}



What exactly does it do ?



#10 TiagoCosta   Crossbones+   -  Reputation: 2438

Like
0Likes
Like

Posted 21 March 2011 - 04:05 PM

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[i].x, DownSampleOffsets[i].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.

#11 Creator_Chen   Members   -  Reputation: 100

Like
0Likes
Like

Posted 13 July 2011 - 09:41 PM


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[i].x, DownSampleOffsets[i].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.



What's the difference if I just simply copy the original texture to a smaller one rather than downsample it manually?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS