Original Post
I've some questions on post processing. I've looked over the sample application in the directX SDK, but I don't get it. I'm especially interested in the bloom effect, and I want to reproduce it in my application. I tried this code, but I'm not shure if this is correct or not. This code gets executed at the beginning of each frame, so that anything that gets rendered in the scene is written into the texture. After the Scene is completly rendered, I just want to paste the texture onto a Quad, so i can check if the scene was rendered to the texture. Therefore I restore the original Render Target and use the Scene Texture as a Texture for the effect. After that, the Scene is ended again and then presented. I can see the scene, but there are some ZBuffer issues, I think. This is a picture with this code, this is a picture of the application without post processing effects. I'm not shure what this is, but something goes wrong :) *edit* The blue thing you are seeing is water, it should be under the terrain and thus not visible in the picture, however it is :( Maybe it's worth noticing that I'm using D3DFMT_X8R8G8B8 and D3DFMT_A8R8G8B8 for the scene texture ( I've tried both of them with the same result as i stated above ). *edit2* It somehow seems that DirectX doesn't use the ZBuffer after all. I can chose wether the Water is rendered above the surface or under it, by changing the rendering chain, but when I disable the RenderTarget change, the ZBuffer is used again. *edit3* Hm, I think I've got it. I needed to create another Depthbuffer and then set this as the current Depthbuffer when rendering to the texture. I don't know why, but it works now ^^ [Edited by - SiS-Shadowman on January 1, 2007 5:28:20 PM]
Engine.pd3dDevice()->GetRenderTarget(0, &m_pOrigTarget); // Das alte Render Target wird gespeichert
IDirect3DSurface9 *pTexSurf = NULL; // Neuer Pointer zum Textur Surface
m_SceneTexture.pTexture->GetSurfaceLevel( 0, &pTexSurf ); // Surface der Textur abfragen
Engine.pd3dDevice()->SetRenderTarget( 0, pTexSurf ); // Surface als neues Render Target festlegen
SAFE_RELEASE(pTexSurf) // Surface freigeben
Engine.pd3dDevice()->EndScene();
Engine.pd3dDevice()->SetRenderTarget( 0, m_pOrigTarget); // widerherstellen des Originalen Rendertargets
SAFE_RELEASE( m_pOrigTarget );
Engine.pd3dDevice()->BeginScene();
m_Shader.m_Effect->SetTexture("Scene", m_SceneTexture.pTexture); // Textur Setzen ( Scene )
m_Shader.m_Effect->SetMatrix("matWorldViewProjection", &m_Transform);// Matrix ( Identitymatrix )
m_Shader.m_Effect->SetTechnique("PasteToScreen"); // Technik wählen
m_Shader.m_Effect->Begin(NULL, 0);
m_Shader.m_Effect->BeginPass(0);
m_ScreenQuad.Draw();
m_Shader.m_Effect->EndPass();
m_Shader.m_Effect->End();