PDA

View Full Version : is this a good way to...



jono_123
11-09-2002, 05:10 PM
hi
when i blend somthing, to make it be draw back to front i enable front culling,draw it, then enable back culling then draw it again. this is working fine for simple things like cubes etc but i was wondering would it be very practical on more complex objects? or will it be very slow and if it is how do i speed things up?
thanx in advance http://www.opengl.org/discussion_boards/ubb/smile.gif

Bob
11-09-2002, 06:22 PM
All triangles that are suppsed to be blended has to be sorted at the same time. Front or back facing, doesn't matter.

Your technique will work as long as your object is convex and you have one object only. As soon as you have a concave object and/or multiple object, it won't work anymore.

[This message has been edited by Bob (edited 11-09-2002).]

jono_123
11-09-2002, 06:29 PM
im not sure what you mean by concave and convex? and since im drawing the object twice will this slow things down if its a complex object?


Originally posted by Bob:
All triangles that are suppsed to be blended has to be sorted at the same time. Front or back facing, doesn't matter.

Your technique will work as long as your object is convex and you have one object only. As soon as you have a concave object and/or multiple object, it won't work anymore.

[This message has been edited by Bob (edited 11-09-2002).]

Bob
11-10-2002, 03:05 AM
I don't really know how to describe convex and concave. But let's take an example. Draw a circle on a paper. Now, take a ruler and try to draw a line that intersects the circle more than two times. You will see that it's impossible. Any line can intersect the circle either zero or two times. Never four times, or one time. Therefore a circle is convex.

A concave object, on the other hand, has a shape that lets the line intersect more than two times. Considet the shape of a C.



--------
| |
| -----
| |
| -----
| |
--------

Here you can draw a line that intersects the shape more than two times. Therefore this shape is considered a concave shape.

Examples of convex shapes are spheres, cubes, cones and pyramids. Concave objects are, well, most objects with a somewhat complex shape.


and since im drawing the object twice will this slow things down if its a complex object?

Not that slow, but it will be some kind of performance hit. But as I said above, a complex objetc is likely to be concave, so your trick with drawing first back and then front faces won't work. You have to sort them.

mm_freak
11-10-2002, 10:52 AM
Concave vs. convex test: Draw your polygon, then connect every point of it with each other. If one of the connection lines is outside of the polygon, it is concave.

http://freak32.dyndns.org/illustration2.jpg