Scene Scale and Z-fighting

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Scene Scale and Z-fighting

Post by Ion Dune »

I'm thinking of using a 1 unit = 1 meter scale in my scene because I've noticed that irrlicht starts to have problems with really huge scenes, and I want to have a pretty big one. I want to know what problems I might have with this, as it seems kind of small. According to this topic, the main problem seems to be z-fighting. Can I control this entirely my changing the near plane, or are there other factors? Are there any other problems that might arise from a really tiny scene?

Thanks for your time.
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

Can I control this entirely my changing the near plane, or are there other factors?
It is possible that disabling the stencil buffer when creating the Irrlicht device will leave more precision for the zbuffer, but that also means you can't use stencil shadows.

When that is not enough, you can, in theory, render your scene in two passes like this:

Code: Select all

driver->beginScene(...);

// Draw distant objects
camera->setNearValue(50000.0f);
camera->setFarValue(100000.0f);
manager->drawAll();

// Draw near objects
driver->clearZBuffer();
camera->setNearValue(0.01f);
camera->setFarValue(50000.0f);
// TODO: Set skybox invisible here
manager->drawAll();

driver->endScene();
Now, when I said in theory, this is because Irrlicht is not very pleasant towards multipass rendering. In fact, calling drawAll() will get your scene nodes animated twice, causing both desync between the two render passes, and also a performance hit. I think it will require some tweaking to get it right.
Mirror
Posts: 218
Joined: Sat Dec 01, 2007 4:09 pm

Post by Mirror »

we should lobby nvidia and amd to increase the zbuffer to 64bit/pixel ! that's the only true solution! :D
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Can I control this entirely my changing the near plane, or are there other factors?
Yes: far plane. In fact It is influenced by those two in relation to each other. So by changing just near plane you may accomplish nothing. You may need to manipulate both.
Post Reply