Sign in to follow this  

Post-processing effect questions

This topic is 1106 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
ID3DXSprite only issues a draw call when calling [tt]End()[/tt] or [tt]Flush()[/tt]. So the whole [tt]Begin(), Draw(), End()[/tt] 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 [tt]D3DXSPRITE_DONOTMODIFY_RENDERSTATE[/tt] 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

This topic is 1106 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.

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