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!