Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

softimage

how to save pixel shader result to another texture?

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

i can only see the texture addressing instructions to load a pixel from a texture. how can i save the result of one frame for comparing when processing the next frame?

Share this post


Link to post
Share on other sites
Advertisement
Create a texture with the D3DUSAGE_RENDERTARGET usage. Then, when you render your scene, call GetSurfaceLevel() on the texture to obtain a surface object, then call IDirect3DDevice9::SetRenderTarget() with the surface. After rendering, your pixel shader output will then be written to this texture. Don''t forget to restore the render target before you use this texture as a source texture in a later pass.

Share this post


Link to post
Share on other sites
quote:
Original post by jacklin
Create a texture with the D3DUSAGE_RENDERTARGET usage. Then, when you render your scene, call GetSurfaceLevel() on the texture to obtain a surface object, then call IDirect3DDevice9::SetRenderTarget() with the surface. After rendering, your pixel shader output will then be written to this texture. Don''t forget to restore the render target before you use this texture as a source texture in a later pass.




i SetRenderTarget, then after DrawScene,
i use StretchRect(renderTarget, NULL, renderResult, NULL, D3DTEXF_NONE);
but the renderResult appear to contain only the left top part of the result seen on the screen,
since i use NULL to specify full-size source, maybe the renderTarget itself contains only partial image?

Share this post


Link to post
Share on other sites
Are you trying to copy from renderResult to renderTarget? Check that you don''t have the order backward for StretchRect().

Do these two surfaces have the same size?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by jacklin
Are you trying to copy from renderResult to renderTarget? Check that you don''t have the order backward for StretchRect().

Do these two surfaces have the same size?



the sequence is right, copying rendertarget to renderresult.
the surface descriptions of this two including dimentions are the same.
and the StretchRect works fine when i change the source to another texture except renderTarget.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Did you setup new camera, projection and world matrixes before rendering to texture?

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Did you setup new camera, projection and world matrixes before rendering to texture?


yes, and it works well when i project another texture.
seems so strange.

Share this post


Link to post
Share on other sites
It may be because of the flags used when the textures were created. Are you running the Debug Runtime? Is there any output to the debug spew? Have you checked the HRESULT values? Many times, the debug spew will tell you if an error or even if something strange is happening.

neneboricua

Share this post


Link to post
Share on other sites

  • 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!