Jump to content
  • Advertisement
Sign in to follow this  
MTclip

Pixel shaders in Post production

This topic is 4886 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

Facewound Pixel shaders tutorial. In that tutorial he tells about how to write the fx shader for post production. I was just wondering a) if you would call the shader affect right before presenting ( since it is just a pixel shader that affects the final image ... if not how would you utilize this... B) does that shader automatically grab the screen or do you have to some how send it to the shader... (im reading up on shaders.. but if anyone knows ;) ) C) if it is even possible to use pixel shaders on _xyzrhw (pre transformmed coords) .. i know you cannot use vertex shaders........ anyways ....;P

Share this post


Link to post
Share on other sites
Advertisement
hi there.

You can do this in two steps, but it seems he's using some fancy no vertex shader technique in his particular app. I've never seen that before, anyways, here is one method on how to do something similar in your own game...

1) Create a render target when the application begins. This is a texture and created with the render target flag so that DX can draw to it, rather than the backbuffer, but told to do so with SetRenderTarget(). It's an expensive operation. It's safe to assume in this case that the texture has the same dimensions as the backbuffer (example 800x600). Draw the scene to this texture (don't need shaders for this). It is drawn with the fixed function pipeline and therefore requires an FVF as you said, xyzrhw, as a fullscreen quad.

2) Change the render target to the back buffer to begin drawing the final image. Be sure to clear the zbuffer / disable it, because changing the render target does not change to a separate z/stencil buffer. This therefore requires a shader and does not need an FVF. This means that you can and must pass an arbitrary vertex declaration and setting it with SetVertexDeclaration(). Since his vertex shader is NULL, this is done differently in his case. The vertex shader must take this data in and eventually return a required float4 with the POSITION semantic (z and w should be 1.0f), but also a few other things to the pixel shader if needed. For a 2D textured quad, a float2 is passed in as the position and casted as a float4 in the vertex shader. Its x and z values should therefore range from 0 to the backbuffer's width and height whereas (0,0) is the top left of the screen. Texture coordinates are also necessary, in order to look up into original scene which was passed in as a texture constant to the shader, which is what the sampler is.

You can now begin to go nuts in the pixel shader!!

Share this post


Link to post
Share on other sites
Never done that before, but my guess is:
since the tutorial uses vertices with pre-transformed coordinates XYZRHW, the vertex shader would be ignored anyways, so it is set to null.
Correct me if I´m wrong, but the pixel shader should use the XYZRHW coordinates directly from the vertex buffer, since they´re already in screen space?

Share this post


Link to post
Share on other sites
Gosh, makes sense, I never even thought about that. If it is correct, then (c) is yes. Well, nevertheless, the sampler of the original scene is still needed one way or another.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!