# Order of drawing

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

## Recommended Posts

Hey..
lets say I have a 3d model and I want to draw it on my screen
so I have to draw all of the polygons of my model

how do I determine what polygons to draw and in what order?

It's also good if you can point me to some guide or article that talks about this subject.

##### Share on other sites
Maybe you want to google for "culling", and in particular "backface culling" as a start.
backface culling simply cuts away every triangle that faces away from you, wich in the general case of an object on the screen in front of you should be roughly half of them.
Then there is lots of other culling techniques you can use to cut away even more of your geometry, mostly using some kind of spatial data structure to quickly figure out what triangles could be visible and should be considered.

Those are though more focused on things like levels, and not just a single object in front of you.

Order depends mostly on what materials they have.
For hardware acceleration, you want to draw solid triangles starting with the one closest to the camera and work your way back, so the card can do a quick discard of triangles that are behind.
Unless some of them are transparent, then you have to draw any triangles behind them first.

You also want to minimize big state changes, such as changing shaders, wich can have nasty side effects, so you might want to group them by material.

The basic techniques can be found in any book about computer graphics

##### Share on other sites
I tried to implement it but I am having some problems.
I calculate the normal vector and the vector the that points from the polygon to the camera
and then I calculate the dot-product between these two vectors and if the result is greater or equal to zero, I draw the polygon, just like the method says.

however, I get different results from different rotations.

I uploaded an image to show you the problem.
good drawing

what could be the problem?

##### Share on other sites

I tried to implement it but I am having some problems.
I calculate the normal vector and the vector the that points from the polygon to the camera
and then I calculate the dot-product between these two vectors and if the result is greater or equal to zero, I draw the polygon, just like the method says.

however, I get different results from different rotations.

I uploaded an image to show you the problem.
good drawing

what could be the problem?

Make sure that the normal and view vector are in the same space. If you calculate your view vector as eye - vertex, make sure that the vertex position used is in world space(which is most likely where your camera is). Also make sure that the normal vector has been transformed into the same space.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 21
• 21
• 11
• 25