Custom rendering order with no need for a z buffer
Posted: Fri Jan 23, 2009 1:17 am
The application I'm working on is composed of layers going back into the screen. Imagine an old parallax scrolling game for example. Each layer can have little 2D tiles over it though, so at the moment I'm suffering from z-fighting. I could offset the tiles slightly above the layer they are on, but that won't completely solve the problem entirely and since I know the order I want to draw everything in, I'd like to call the render method of each scene node individually.
I tried a straight-forward approach and it just rendered the background color. Then I looked through the Irrlicht source and realized I hadn't added the camera to my custom rendering loop. So I copied that in (along with anything else that seemed relevant), but I still just get the background color.
So how would I go about specifying the render order of my objects? I'd really prefer not to use actual z-differences to get the effect, and it seems like a simple thing to ask. I know in straight OpenGL or DirectX it would be really straight-forward.
My original loop (ripped pretty much straight from the examples) was:
The current (non-working) version is:
I also notice in the source code that regular scene nodes are sorted according to material before rendering.
I tried a straight-forward approach and it just rendered the background color. Then I looked through the Irrlicht source and realized I hadn't added the camera to my custom rendering loop. So I copied that in (along with anything else that seemed relevant), but I still just get the background color.
So how would I go about specifying the render order of my objects? I'd really prefer not to use actual z-differences to get the effect, and it seems like a simple thing to ask. I know in straight OpenGL or DirectX it would be really straight-forward.
My original loop (ripped pretty much straight from the examples) was:
Code: Select all
driver->beginScene(true, true, video::SColor(255,128,0,0));
smgr->drawAll();
env->drawAll();
driver->endScene();Code: Select all
driver->beginScene(true, true, video::SColor(255,128,0,0));
if ( driver )
{
core::matrix4 identity;
driver->setTransform ( video::ETS_PROJECTION, identity );
driver->setTransform ( video::ETS_VIEW, identity );
driver->setTransform ( video::ETS_WORLD, identity );
driver->setTransform ( video::ETS_TEXTURE_0, identity );
driver->setTransform ( video::ETS_TEXTURE_1, identity );
driver->setTransform ( video::ETS_TEXTURE_2, identity );
driver->setTransform ( video::ETS_TEXTURE_3, identity );
}
smgr->getActiveCamera()->OnRegisterSceneNode();
smgr->getActiveCamera()->render();
controller->GetTarget()->GetSection()->Render();
env->drawAll();
driver->endScene();