Jump to content
  • Advertisement
Sign in to follow this  
dbh

Render Order Basics

This topic is 4849 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!