I try to render to a surface1 with a blur effect and then i r try to render surface1 to surface2 again with blurr effect but it doesn't work :Direct3D9: (WARN) :Can not render to a render target that is also used as a texture...
If i render to a surface whit a blur and then to backbuffer it works
Here is the code:
Device->GetRenderTarget(0,&pBackBuffer);
Device->SetRenderTarget(0,pScreenSurface);
Device->Clear(0,NULL,D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0),1.0f,0);
Device->BeginScene();
Device->SetFVF(CUSTOMFVF);
Obj->setPositionTo(50,50);
Obj2->setPositionTo(300,320);
ObjectManager->Draw();
Device->EndScene();
Device->SetRenderTarget(0,pBackBuffer);
Device->BeginScene();
if (SUCCEEDED(g_pEffect->SetTechnique("Blur")))
{
UINT numPasses;
g_pEffect->Begin(&numPasses,0);
g_pEffect->SetFloat("wave",wave);
g_pEffect->SetFloat("glow",glow);
g_pEffect->SetFloat("blur",blur);
g_pEffect->SetFloat("blurstrenght",blurstrenght);
g_pEffect->SetTexture("MarbleSplineSampler",pScreenTexture);
for (UINT i=0;i<numPasses;i++)
{
g_pEffect->BeginPass(i);
Screen->Draw(Device,NULL);
g_pEffect->EndPass();
}
g_pEffect->End();
}
Device->EndScene();
Device->Present(0,0,0,0);
If i try to rener the serface again to another surface it doesn't.
Device->GetRenderTarget(0,&pBackBuffer);
Device->SetRenderTarget(0,pScreenSurface);
Device->Clear(0,NULL,D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0),1.0f,0);
Device->BeginScene();
Device->SetFVF(CUSTOMFVF);
Obj->setPositionTo(50,50);
Obj2->setPositionTo(300,320);
ObjectManager->Draw();
Device->EndScene();
Device->SetRenderTarget(1,pScreenSurface1); // even if is 0 it doesn't work
Device->BeginScene();
if (SUCCEEDED(g_pEffect->SetTechnique("Blur")))
{
UINT numPasses;
g_pEffect->Begin(&numPasses,0);
g_pEffect->SetFloat("wave",wave);
g_pEffect->SetFloat("glow",glow);
g_pEffect->SetFloat("blur",blur);
g_pEffect->SetFloat("blurstrenght",blurstrenght);
g_pEffect->SetTexture("MarbleSplineSampler",pScreenTexture);
for (UINT i=0;i<numPasses;i++)
{
g_pEffect->BeginPass(i);
Screen->Draw(Device,NULL);
g_pEffect->EndPass();
}
g_pEffect->End();
}
Device->EndScene();
Device->SetRenderTarget(0,pBackBuffer);
Device->BeginScene();
if (SUCCEEDED(g_pEffect->SetTechnique("Blur")))
{
UINT numPasses;
g_pEffect->Begin(&numPasses,0);
g_pEffect->SetFloat("wave",wave);
g_pEffect->SetFloat("glow",glow);
g_pEffect->SetFloat("blur",blur);
g_pEffect->SetFloat("blurstrenght",blurstrenght);
g_pEffect->SetTexture("MarbleSplineSampler",pScreenTexture1);
for (UINT i=0;i<numPasses;i++)
{
g_pEffect->BeginPass(i);
Screen->Draw(Device,NULL);
g_pEffect->EndPass();
}
g_pEffect->End();
}
Device->EndScene();
Device->Present(0,0,0,0);
Any ideea why it doesn't work?