Question on 3d perspective proyection
category: general [glöplog]
From Wikipedia:
Well, suppose I'm doing wireframe. Suppose a triangle vertex is not in front of the eye, but in the back of the eye, but I want to paint it too. So, is this correct?
Bx=Ax*(abs(Bz)/abs(Az));
Note that what I want is a boundary to do the rasterization with triangle-raytracing, and I don't want to cut the triangle with the screen
Well, suppose I'm doing wireframe. Suppose a triangle vertex is not in front of the eye, but in the back of the eye, but I want to paint it too. So, is this correct?
Bx=Ax*(abs(Bz)/abs(Az));
Note that what I want is a boundary to do the rasterization with triangle-raytracing, and I don't want to cut the triangle with the screen
I'm thinking and I should use a near plane cut...
Yep.
If you are using a planar projection, then there is no sensible 2D interpretation of vertex positions which are "behind" the eye. You need to clip your primitives in 3D against your viewing frustum before going to 2D. Or, at the very least, clip the primitives against the near-plane.
So: set up a near plane very close to the eye, and clip your lines against the near plane. After clipping, the resulting vertex positions can be projected 3D->2D safely.
If you are using a planar projection, then there is no sensible 2D interpretation of vertex positions which are "behind" the eye. You need to clip your primitives in 3D against your viewing frustum before going to 2D. Or, at the very least, clip the primitives against the near-plane.
So: set up a near plane very close to the eye, and clip your lines against the near plane. After clipping, the resulting vertex positions can be projected 3D->2D safely.
I'm not sure I understand. If you're doing raytracing, what's the perspective projection for?
Oh right, a boundary. Silly me. :) Then you need to cut the triangle with a near plane, or ignore any triangle that has one or more points behind the near plane. There's no sensible way to project lines across z = 0.
if you're raytracing, you just spawn your rays on the near plane instead of using the eye point as origin. if you're doing rasterization, you need to clip triangles. i'm not sure which you're using from the description.
To "see" triangles behind your head, you can use a fisheye, easy with raytracing.
Well, I explain:
I'm doing a mixed rasterization/raytracing. Why? Because I want a clean/easy solution for perspective corrected textures, and I've already done it with RT. It is only for the first pass. So, What I'm doing is using a z-buffer for the raytracer and raytracing only 1 triangle at a time. Then, If I do it only for the boundaries of the triangles, it is faster.
With the boundaries I mean the square in the screen where I'm sure the triangle will fit.
This is why I'm proyecting the triangle edges.
The problem is when I have very very big triangles that are in part behind and in part in front of the eye. In a concrete case, a very big ground created with 2 very big triangles.
So, what to do in that case?
I'm doing a mixed rasterization/raytracing. Why? Because I want a clean/easy solution for perspective corrected textures, and I've already done it with RT. It is only for the first pass. So, What I'm doing is using a z-buffer for the raytracer and raytracing only 1 triangle at a time. Then, If I do it only for the boundaries of the triangles, it is faster.
With the boundaries I mean the square in the screen where I'm sure the triangle will fit.
This is why I'm proyecting the triangle edges.
The problem is when I have very very big triangles that are in part behind and in part in front of the eye. In a concrete case, a very big ground created with 2 very big triangles.
So, what to do in that case?
Uhm. Clipping?!
So, ok, I will clip the triangles.
I have to learn how to do it :)
Thanks :)
I have to learn how to do it :)
Thanks :)
You don't need to clip the triangle to generate some conservative screen-space bounds. Just assume that the edges that goes through the z=0 plane extends to infinity in negative z-case. Or even easier - if a triangle intersects the z-plane, just make the bounding rectangle the entire screen. In general, triangles intersecting the z-plane are quite big, but there's only a few of them.