Jump to content
  • Advertisement
Sign in to follow this  

Postprocessing problem

This topic is 2826 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

It's probably not his fault, the thread existed before the site change, and as I have read there are issues with the transformation, especially with source code. This helped, well, a bit at least. Hope this is the way it was:

I have a problem in mechanical/CPU side of post processing.

What I am trying to do is, before rendering my regular scene , setting
render target as my custom DX surface associated with my texture

Then I try to render that captured texture on a pre-created quad mesh...

But I have problems with it :

1) Originial scene dwarf2.jpg

2) not-working postprocessing dwarf1r.jpg

The code I tried is below :

IDirect3DDevice9* m_graphicsDevice ;
EngineEffect m_effect ;
IDirect3DSurface9* m_surface;
IDirect3DSurface9* m_tempBackBuffer;
ID3DXMesh* PPQuadMesh;
m_graphicsDevice->CreateTexture(width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_texture, NULL);
m_texture->GetSurfaceLevel(0, &m_surface);
m_graphicsDevice->GetRenderTarget(0, &m_tempBackBuffer);
m_graphicsDevice->SetRenderTarget(0, m_surface);
sceneObject.Render(); // mesh with many sub parts with material and textures...
m_graphicsDevice->SetRenderTarget(0, m_tempBackBuffer);
m_effect.SetTechnique("None"); // that technique really does nothing at the moment
unsigned int nPass ;
for(int i = 0 ;i<nPass;i++)


////// scene object rendering

void EngineMesh::Render()
DWORD dwNumMaterials = materials.size();

for( DWORD i = 0; i < dwNumMaterials; i++ )

if( pCustomTexture)

m_mesh->DrawSubset( i );

/////////// create quad code

void EnginePostProcess::CreateQuad(float nQuadZ,float nQuadWidth,float nQuadHeight)
D3DXCreateMeshFVF(2, 4, D3DXMESH_MANAGED, VERTEXPOSTPROCESS_FVF, m_graphicsDevice, &PPQuadMesh);
float fStartX = -1.0f;
float fStartY = -1.0f;

VertexPostProcess* v = 0;
PPQuadMesh->LockVertexBuffer(0, (void**)&v);

v[0] = VertexPostProcess( fStartX, fStartY, nQuadZ, 0.0f, 1.0f);
v[1] = VertexPostProcess( fStartX, fStartY+nQuadHeight, nQuadZ, 0.0f, 0.0f);
v[2] = VertexPostProcess( fStartX+nQuadWidth, fStartY+nQuadHeight, nQuadZ, 1.0f, 0.0f);
v[3] = VertexPostProcess( fStartX+nQuadWidth, fStartY, nQuadZ, 1.0f, 1.0f);


WORD* i = 0;
PPQuadMesh->LockIndexBuffer(0, (void**)&i);

i[0] = 0; i[1] = 1; i[2] = 2;
i[3] = 0; i[4] = 2; i[5] = 3;


std::vector<DWORD> adjacencyBuffer(PPQuadMesh->GetNumFaces() * 3);
PPQuadMesh->GenerateAdjacency(0, &adjacencyBuffer[0]);

Share this post

Link to post
Share on other sites
Unbird thanks a lot ! How did you find the original version before the site change ? I was preparing to re write it...

btw , any help is really appreciated , if you look at code I believe I am making a simple mistake

Share this post

Link to post
Share on other sites
How did you find the original version before the site change ?[/quote]
I didn't.

About the problem: Did not look at the code closely, but the second picture looks like you are rendering to one of the dwarf's material textures, and/or using said texture as your post-process texture. So I think you've a mixup with the textures/render-targets. If you can't spot it in the source, I'd have a look at PIX.

Share this post

Link to post
Share on other sites
The only thing I could find was the broken texture scene on the screen is the very first texture of the all textures of the mesh file.

As I am looking to samples I am unable to spot the error in the code above.

How can I mixup with textures and render targets ?

And how can I debug this with PIX ?

Share this post

Link to post
Share on other sites
After digging everything I found out that there was an extra SetTexture call which was messing things up

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!