Page 1 of 1

(C++) Solution to Transparent Alpha Z-fighting/Render Order

Posted: Fri Apr 20, 2007 6:01 am
by imjinc2k
I just solved a zbuffer / render order issue I had with two EMT_TRANSPARENT_ALPHA_CHANNEL meshes. The parent node is a spherical planet while the child node is a slightly larger spherical atmosphere. At some angles there would be pixel zfighting, at other angles the inner planet would not render at all.

Others in the forum had the same problem but a search didn't turn up anything short of modifying Irrlicht source, writing my own scene node class etc... My simple nicotine-induced solution is to reposition the outer node slightly closer to the camera on every update, forcing it to be rendered last. This is a somewhat special case since they're both roughly the same shape, and in a parent-child relationship, but it works fine for this scenario.

Let me know if there's a more efficient way to do this as the getInverse makes me wonder about scalability.

Code: Select all


vector3df cameraModelVec = innerParentNode->getAbsolutePosition().operator -(camera->getAbsolutePosition());

irr::core::matrix4 modelSpace;
innerParentNode->getAbsoluteTransformation().getInverse(modelSpace);
cameraModelVec.normalize();
modelSpace.rotateVect(modelCameraVec);
cameraModelVec.operator *=(10.0f); // depending on your scale
outerChildNode->setPosition(-modelCameraVec);


-Black Matt