Jump to content
  • Advertisement
Sign in to follow this  
Tispe

Setting shaders for Rendering to a Texture and then to backbuffer (HDR)

This topic is 2143 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi

 

Do I need a projection matrix in the shader if I just render a fullscreen quad with a HDR texture to the backbuffer?

 

I am rendering my scene to a 1920x1080 texture, and I want to draw it to the backbuffer(1920x1080) and present it. Is it enough to just have the UV coords in the quadVB, and have a simple passthrough vertex and pixel shader?

 

Can I use the same vertex declaration for the HDR chain? I guess I need to swap out the pixel shader for each step in the chain but the vertex shader can remain the same, a simple passthrough for quadVB?

 

To restore the backbuffer I need to first GetBackbuffer() and save it localy, will GetBackbuffer() AddRef() the surface?

 

FinalVersion_1.jpg

Share this post


Link to post
Share on other sites
Advertisement


Do I need a projection matrix in the shader if I just render a fullscreen quad with a HDR texture to the backbuffer?

 

No. You can eigther

 

- set the position-element in the declaration to POSITIONT (pretransformed) and set the quad corner coordiantes to (0,0) -> (1920, 1080) or

- set the position to POSITION and the quad corners to (-1, -1) -> (1, 1).


I am rendering my scene to a 1920x1080 texture, and I want to draw it to the backbuffer(1920x1080) and present it. Is it enough to just have the UV coords in the quadVB, and have a simple passthrough vertex and pixel shader?

 

Yes, you don't need anything special here.

 


Can I use the same vertex declaration for the HDR chain? I guess I need to swap out the pixel shader for each step in the chain but the vertex shader can remain the same, a simple passthrough for quadVB?

 

Are you talking about the vertex declaration or the vertex shader now? As long as the geometry doesn't change, you only need one declaration.

 


To restore the backbuffer I need to first GetBackbuffer() and save it localy, will GetBackbuffer() AddRef() the surface?

 

Dr. Google says:

 

 

Remarks

Calling this method will increase the internal reference count on the IDirect3DSurface9 interface. Failure to call IUnknown::Release when finished using this IDirect3DSurface9 interface results in a memory leak.

Share this post


Link to post
Share on other sites

You don't need any matrices for rendering a fullscreen quad or triangle. You just need to make sure your geo is pretransformed in screen space ( [ -1.f, 1.f] in x and y ) and you either also have correct UVs or derive the UVs in shader based on ss pos. 

example VS when passing in quad ( 2 triangles ) with vertex fmt being just one float4, xy component containing said positions and zw components containing uvs.
 

VsOutput main_vs(  VsInput input )
{
  VsOutput o = (VsOutput)0;
  
  o.pos = float4( input.PosUV.xy, 0.f, 1.f );
  o.uv = input.PosUV.zw;
  return o;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!