gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Flickering 3D rendering.

#130568 - blue_knight - Tue Jun 05, 2007 9:18 am

So I am using the 3D hardware to render 2D quads for a multi-level isometric map renderer. In an emulator everything renders correctly (Dualis, Ideas, NO$GBA). On the DS hardware I see flickering as I'm rendering. Oringally my loop looked kind of like this (pseudo code):
Code:

int main()
{
     //Setup video mode
     //Setup vbanks
     //Load Textures.
     //Load Texture palette
    while (1)
    {
         //Render quads
         //wait for vblank to actually render 3D geo.
         swiWaitForVBlank();
    };
}


I tried glFlush(0) as well, but no matter what I did even I rendered a certain number of pixels on a scanline I'd get flickering. Basically if I render a map and zoom out (so the map only takes a portion of the screen) then no flickering - it's not the number of quads rendered (I track that, I'm nowhere near the limit).

So I figured that it must be drawing at the wrong time, so I setup a vblank handler and do the scene setup (calculate quad positions/tcs, culling, etc. based on camera position) in the main loop - creating a renderlist of sorts -and then render that list in the vblank. Otherwise the loop is exactly the same. But I still get the same flickering - and it still renders correctly in all the emulators.

So my question: is there a way to get rid of the flickering without double buffering the 3D rendering? If not, can anyone give me any pointers on the best way to accomplish that.

#130585 - Lick - Tue Jun 05, 2007 4:04 pm

I think it's the depthbuffer is having a hardtime with rounding. Imagine two quads at the exact same positions both 'fighting' to be seen by the viewer, that causes flickering.

Maybe you could experiment with the near- and far-plane values.
_________________
http://licklick.wordpress.com

#130593 - blue_knight - Tue Jun 05, 2007 6:33 pm

All the vertices of each quad has the same z value and each quad has a different z value for sorting purposes. I know each value is different (being specified directly as an integer, not converted from floating point) and it uses a orthographic projection (with z buffering not w buffering). Additionally when I zoom out (by actually rendering the quads smaller but still arranged correctly to form the map), but use the same z values the flickering goes away. So I'm doubtful that it's "z-fighting", unless I'm missing something of course :) I do appreciate the reply though.

#130617 - Lick - Tue Jun 05, 2007 8:54 pm

Emphasis: near- and farplane values!
_________________
http://licklick.wordpress.com