I have two render targets:

  1. a fake backbuffer; a special render target where I do all my rendering.

  2. a light render target; where I render my light fx.

I'm sure I'm rendering correctly on both.

The problem arises when I overlay the light render target onto the fake backbuffer by drawing a quad covering it:

DxEngine.DrawSprite(0.0f, 0.0f, 0.0f,
    (float)DxEngine.GetWidth(), (float)DxEngine.GetHeight(),
    0xFFFFFFFF, LightSurface->GetTexture());

Regardless of what's in the light target, nothing is rendered onto the other target. I tried clearing the light target with full-white or full-black, but still get nothing.

Fake backbuffer created with

Direct3dDev->CreateTexture(Width, Height, 1, D3DUSAGE_RENDERTARGET,
    D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &Texture, nullptr);

Light render target created with

Direct3dDev->CreateTexture(Width, Height, 1, D3DUSAGE_RENDERTARGET,
    D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &Texture, nullptr);

I also tried to create both with D3DFMT_A8R8G8B8, again without difference. Both targets have the same width and height.

Only the fixed pipeline is used

DirectX setup for rendering :

Direct3dDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
Direct3dDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
Direct3dDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE );
Direct3dDev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP );
Direct3dDev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP );
Direct3dDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
Direct3dDev->SetRenderState(D3DRS_LIGHTING, false);
Direct3dDev->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);

Direct3dDev->SetRenderState(D3DRS_ALPHABLENDENABLE,  true );
Direct3dDev->SetRenderState(D3DRS_ALPHAREF, 0x00000000ul);
Direct3dDev->SetRenderState(D3DRS_ALPHATESTENABLE, true);
Direct3dDev->SetRenderState(D3DRS_SRCBLEND,  D3DBLEND_SRCALPHA );

Direct3dDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
Direct3dDev->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
Direct3dDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
Direct3dDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
Direct3dDev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
Direct3dDev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);

Direct3dDev->SetTextureStageState(0, D3DTSS_RESULTARG, D3DTA_CURRENT);

Direct3dDev->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU);

//ensure the first stage is not used for now
Direct3dDev->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);

How can I do this right?

  • \$\begingroup\$ Should i add some more details to attract an answer?? \$\endgroup\$ Aug 17, 2014 at 16:53
  • \$\begingroup\$ Yes, specifically how you set up your render targets, and how you set them to be rendered to. Are you trying to create a deferred renderer and want to write to multiple render targets at the same time MRT (msdn.microsoft.com/en-us/library/windows/desktop/… ) \$\endgroup\$
    – Roy T.
    Aug 19, 2014 at 18:19
  • \$\begingroup\$ Ok, i'll add that, and no i don't think we could call what i'm doing deferred rendering, i just want to write to a single target at a time, btw i'm only rendering quads, no real 3d here. \$\endgroup\$ Aug 19, 2014 at 19:32
  • \$\begingroup\$ What's this: DxEngine.DrawSprite? \$\endgroup\$ Aug 21, 2014 at 12:50
  • \$\begingroup\$ You have the depth tests enabled so it might be that all your pixels are discarded by that. Or maybe a problem with alpha. This is the kind of issue that can be easily solved using PIX / Visual Studio Graphics Debugger. Learn how to use it, you won't regret it. \$\endgroup\$ Aug 21, 2014 at 12:59

1 Answer 1


Finally found the culprit, it was a really stupid typo error in my code, the light surface was not the same size as the backbuffer (width and height reversed)....

By the way i was able to pinpoint the problem really fast with PIX, if that can help someone.

  • \$\begingroup\$ Can you then mark your answer as correct answer? \$\endgroup\$
    – alariq
    Jan 29, 2015 at 19:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .