Taking perspective into account, testing if a poly is facing the screen
Posted 18 December 2005 - 09:46 PM
My code does the following: get the poly's normal, get the camera view direction, dot product, voila. < 0 and it's facing away; > 0 and it's facing the screen.
What's the problem? Well, it works fine around the center of the screen. But the more to the edges, the bigger the deviation, until the error is some extreme 45 degrees. My guess is that this is due to the perspective, I'm using "nicest" perspective calculations. The fellas over at GameDev were unable to help. How can I take the perspective into account?
Posted 18 December 2005 - 09:54 PM
Posted 20 December 2005 - 07:46 AM
Do you really cull quicker on the cpu, than the culled triangles can be transferred by the memory bus? If not, you are just un-optimizing...
Posted 21 December 2005 - 08:12 AM
As m4x0r said, you should use the vector going from the camera to the polygon instead.
Note that this can result quite tricky for huge polygons, since you have to compute the nearest point of the polygon. But I don't think it does matter for face culling, while for distance computing it does. ^_^;
Posted 30 December 2005 - 08:24 AM
Posted 30 December 2005 - 11:16 AM
Posted 30 December 2005 - 08:11 PM
I was thinking of projecting it into a parallel view space... kinda a project of it into a 3d screen space. Like if you wanted to project into a -1,1 view box with all prespective calculations done already to clip easy.
Posted 31 December 2005 - 12:16 AM
Currently working on: the 3D engine for Tomb Raider.
Posted 31 December 2005 - 05:32 AM
In most cases dotting the two (correct) vectors in world space is fastest, but as always that is implementation and hardware dependant. The projection might very well be "free" if you're doing it for some other reason in the pipeline (if this is the way you clip the view fulstrum, or some odd lighting hack, or ...?) that backface culling wouldn't eliminate. Besides I was only suggesting a different than the usual way of doing this hehe (not the best by any means).
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users