Jump to content
  • Advertisement
Sign in to follow this  
A A

flickering when light is on

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

I have a mesh and a directional light turned on. When I move the mesh it flickers all over. Areas of color interchanges by black areas and those do not match faces. When I move the mesh closer the black areas fade away, when I move the mesh away and turn it they reappear. When lighting is off everything seems to look good. There might be something with the z-buffer because if there is noithin behind a face then it renders correctly. This is 'a good mesh', actually it is a text created by the D3DXCreateText function but I can reproduce it on different meshes. Sometimes, if indices are not correct, a mesh looks very strange when you transform it. Some faces reappear and disappear. In this case, however, everything seems to be OK. The mesh looks good when lighting is off and it looks good in the mesh viewer. It seems that the best way to describe this is to attach a picture but I do not know how I can do that on the forum. Has anybody any clue what it may be? Hardware, wrong SetRenderState, whatever?

Share this post


Link to post
Share on other sites
Advertisement
Hmmm some things to check
-Clearing the Z and stencil buffer
-Drawing Twice
-D3DXComputeNormals(pMesh,NULL) can recalulate your normals for you

If not try uploading a screen shot to www.photobucket.com
and post it here using the

<img src="location of your image" />

Share this post


Link to post
Share on other sites
Normals seem to be where they are supposed to be.
At least MView shows that. For texts, D3DXCreateText does
the job, for other meshes I use
D3DXComputeNormals(pMesh, (DWORD*)pAdjacencyBuffer->GetBufferPointer());

Regarding buffer clearing. Is this enough?
hr = mpD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, mrgbaBackground, 1.0f, 0 );

What I have found today is that if culling is on then everything looks good.
However sometimes I need both surfaces, so, it is not a solution.

Share this post


Link to post
Share on other sites
If everything looks okay with culling and flickers otherwise, then perhaps you are not using depth buffer correctly. Make sure it is created and D3DRS_ZENABLE state is set to D3DZB_TRUE.

Share this post


Link to post
Share on other sites
Learn to love PIX [wink]

If you have some D3D code (mesh viewer) that is displaying the image as intended, yet your code with the exact same data isn't then it's almost certainly going to be down to your pipeline configuration.

Run a single frame capture of both applications in PIX and examine the device state and compare. Hopefully there'll be a configuration that's obviously different between the working and non-working application - and that'll be the one you need to correct in your app...

hth
Jack

Share this post


Link to post
Share on other sites
It seems that I have solved it!
There was
D3DXMatrixPerspectiveFovLH(&mmatProjection, fov, fAspect, 1.0f/800.0f, 4000.0f);
When I made the fourth parameter 0.1f everything went fine.
Can anybody say more than "Z-value of the near view-plane" about it?
My favorite MView has m_pdeSelected->fRadius / 64 as the parameter,
so may be it worths to do similar thing: calculate the bounding sphere for the scene and ... Wow! That's exactly how it should be.
I wonder how 1/800 got there.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!