Sign in to follow this  
Husbj

Downsampling texture size importance

Recommended Posts

I find myself in a situation where I need to downsample a bunch of textures (render targets from previous passes) in every frame.

Now my textures are 2048x2048 pixels in size and I wish to downsample these to 1024x1024. I also happen to have a "spare" 2048x2048 render target at this point in my loop. Is there any disadvantage to rendering my downsampled texture to this by simply drawing a screen quad from (-1, 1) .. (0, 0) (ie. the top left quadrant) onto here as opposed to setting up another render target that is of the desired downsampled size?

I noticed I got some borders drawn to the upsampled image again when I tried using this approach but maybe this can be worked around using backdrop clear colours and proper sampler states? (I'm writing this just before bed and haven't yet tried figuring out such states).

 

In the grand scheme of things it would probably be better to create a smaller render target to downsample to when it's just a half size thing like this, however I would like for my implementation to easily be able to work with other scale factors and then preferably without having to provide uniquely dimensioned render targets for each different downsampling.

 

Thanks for any pointers. 

Share this post


Link to post
Share on other sites

To render to part of a render target, what you usually want to do is to adjust the viewport. This allows you to render anything you want - it will handle the scaling and clipping for you.

 

The only downside is that when sampling from the render target, you can't clamp or wrap at the edge of the viewport, so it's easy to read outside of the viewport that you wrote to.

Share this post


Link to post
Share on other sites

Ah yes, I didn't think of using the viewport for this; that's useful!

The edge sampling is hopefully not an issue assuming my target images will be some power of 2 both before and after the "scaling", or am I wrong? (It will of course be upsampled back to the original resolution again before being used in any other process).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this