Render Order Basics

Started by
3 comments, last by dbh 18 years, 11 months ago
Up until today I've been very excited about the progress I've been making on my 3D engine. Today I added a new section of the map (up until now it had just been 2D planes representing the first "layer" in the world). At any rate, upon adding a series of "wall" mesh objects (.x's exported from 3DSMax7) on the left side of the map, I noticed some strange drawing issues. From previous games I've worked on, I believe this is a render-order mishap. Now don't laugh... but at the moment, I'm not doing anything to sort/cull/etc. any of the game objects. Right now I just have all of the tiles I'm using (2D planes or 3D wall objects) in a <vector> object which is ordered according to the order they were in my map file on load. In other words, they are ordered like a 2D array... from left to right, top to bottom. The closest tile on the bottom-left corner is drawn first, the tile in the top-right is drawn last. I've done some research on optimizing techniques-- but I can't seem to find any resources on fixing this render issue-- nothing on sorting, culling, or anything else. Has anyone else had a problem similar to this when they were new to making a 3D engine? Anyone have any tips? Guides I should take a look at? I'm willing to do the work... no question there... I just don't know where to start :| Here is a screenshot of the problem: You can see the wall tile in the top left is being drawn properly as it was drawn last on its row. A closer angle of the problem. What the wall tile should look like, as seen in meshview. Any input would be greatly appreciated! -dbh
------------------------------------------------------------GDC/IGF 2006 Student Showcase Submission: Curator Defense
Advertisement
Draw back to front. This is because your tiles are overlapping, and as your draw front to back, the ground of the tile behind the current tile is drawing over the current tile...but you want the closest tiles to show, right? back to front.
Er, is there a reason why you can't just use a standard depth buffer? Just create your display with one and make sure your depth test is setup right.

If thats not an option then you'll have to draw back to front.
Quote:Original post by OrangyTang
Er, is there a reason why you can't just use a standard depth buffer? Just create your display with one and make sure your depth test is setup right.

If thats not an option then you'll have to draw back to front.


Right, this is definetly a Z-buffer issue. Make sure you check:

(1) EnableAutoDepthStencil is set to TRUE in your D3DPRESENT_PARAMETERS.

(2) AutoDepthStencilFormat is set to D3DFMT_D16 or D3DFMT_D32 in your D3DPRESENT_PARAMETERS. Creating a depth buffer with 32-bits of precision will help, but usually is not necessary. There are a bunch of other formats you can use to (that allocate bits for the stencil buffer, ect...) - they are all listed under "Buffer Formats" on the D3DFORMAT docs.

(3) D3DRS_ZENABLE render-state is set to TRUE.

(4) Check the values of the near and far plane in your projection matrix. The z-value of the near view-plane can't be too small, and the z-value of the far view-plane can't be too big. Remember, you only have 16 (or 32) bits of buffer to work with, so your range is limited. This is ususally the source of z-buffering problems.

Hope one of these fixes it [wink]
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
Great! The Z-Buffer tricks you mentioned, circlesoft, fixed the problem! I thought I had those set already, but the autodepthstencil was set to false and I hadn't set up its format either :(

Thank you all for your tips - it looks 10x better now!

... well, back to work ;)

-dbh
------------------------------------------------------------GDC/IGF 2006 Student Showcase Submission: Curator Defense

This topic is closed to new replies.

Advertisement