Jump to content
  • Advertisement
Sign in to follow this  
george7378

Post-processing effect questions

This topic is 1409 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 everyone,

 

I've been using a sprite to do post-processing effects for a while now, but I'm having a few issues with it recently. Here is my code for drawing to the screen using post-processing:

bool draw_Processed_Texture(D3DXHANDLE technique, DrawableTex2D screen_texture)
{
if (FAILED(screenSprite->Begin(D3DXSPRITE_DO_NOT_ADDREF_TEXTURE | D3DXSPRITE_SORT_TEXTURE))){return false;}
 
globalEffect->SetValue("i_TextureWidth", &WIDTH, sizeof(unsigned));
globalEffect->SetValue("i_TextureHeight", &HEIGHT, sizeof(unsigned));
 
globalEffect->SetTexture("t_ScreenTexture", screen_texture.drawTexture);
 
globalEffect->SetTechnique(technique);
UINT numPasses = 0;
if (FAILED(globalEffect->Begin(&numPasses, 0))){return false;}
for (UINT i = 0; i < numPasses; i++)
{
if (FAILED(globalEffect->BeginPass(i))){return false;}
screenSprite->Draw(screen_texture.drawTexture, NULL, NULL, NULL, D3DCOLOR_ARGB(255, 255, 255, 255));
if (FAILED(screenSprite->End())){return false;}
if (FAILED(globalEffect->EndPass())){return false;}
}
if (FAILED(globalEffect->End())){return false;}
 
return true;
}
 
Is this the right way to go about doing it? Do I have my calls in the correct order? Also, in the screenSprite->Draw() function I have specified the texture (screen_texture.drawTexture) again. Since I've already sent it to the shader to be sampled, do I need to put it in the sprite draw call too?
 
Thanks!

Share this post


Link to post
Share on other sites
Advertisement
ID3DXSprite only issues a draw call when calling End() or Flush(). So the whole Begin(), Draw(), End() triple should be within that pass. I'm also not quite sure you actually can use it with custom shaders, at least call it with D3DXSPRITE_DONOTMODIFY_RENDERSTATE also.

If that fails, setup your own vertices and draw call. Make sure you don't forget the half-pixel offset needed for correct sampling.

Share this post


Link to post
Share on other sites

Thanks for the help. It's interesting because I've been using the above for things like gaussian blurs, greyscale rendering, etc... and as far as I can tell it actually works if all I do is apply a pixel shader, but the thing is, I can't remember exactly where I came across this method so I was beginning to question whether it's valid or not!

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!