More 3D Help
Author |
Message |
SNIPERDUDE
|
Posted: Mon Sep 08, 2008 9:48 pm Post subject: More 3D Help |
|
|
Ok, I have decided the method I want to use to sort out faces of a model,
but then I got stuck on another.
How do I determine the depth of a face (away from the camera)? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
DemonWasp
|
Posted: Tue Sep 09, 2008 11:16 am Post subject: RE:More 3D Help |
|
|
Depth is usually done on a per-pixel basis on your graphics card. That said, it may be too expensive to do in Turing.
I'd just calculate distance to the center of each polygon, then deal with the graphical glitches you'll get from that. Alternately, you could calculate the point on the polygon that each pixel is looking at and the distance to that point.
Remember, d = sqrt ( x^2 + y^2 + z^2 ) |
|
|
|
|
|
SNIPERDUDE
|
Posted: Tue Sep 09, 2008 11:55 am Post subject: RE:More 3D Help |
|
|
Ok, Thanks.
I'll post if I need any more help on this topic. |
|
|
|
|
|
DIIST
|
Posted: Thu Sep 11, 2008 7:30 am Post subject: Re: More 3D Help |
|
|
DemonWasp wrote:
Remember, d = sqrt ( x^2 + y^2 + z^2 )
You can also try doing an approximation. Instead of calculating a sqrt, 3 additions and 3 multiplications per point, you can just use the z values of each point in the triangle and round them. I find it doesn't make much of a difference, until you move away from a title safe area. Its speeds it up a bit. Also you might want to look into BSP tree. Its lets you place cyclic polygons and draw them properly with overlaps, painters algorithm doesn't do that. Also if you intend on using the painters algorithm just use quick sort to sort the distance of each polygon and draw the furthest one first. |
|
|
|
|
|
Zeroth
|
Posted: Thu Sep 11, 2008 9:47 am Post subject: Re: More 3D Help |
|
|
Take a look at Newton Approximation. A Newton Approximation with an appropriately chosen starting value will be many orders faster than a sqrt+3 multiplications. (Addition is a one-cycle effort on modern CPUs)
For example, Doom used a Newton Approximation to find Normal Vectors, which are calculated by taking the inverse of the square root of the tangent(iirc). This is a slow operation, so they used the approximation, and cut the calculation speed down to 1/10th of what it would cost. |
|
|
|
|
|
|
|