Hi...
I want to move the clipping-planes by a previous defined
number of pixel in horizontal
direction. And I want to insert the code into
'general_clip.h'. This is neccessary for my
two-viewport-rendering (stereoscopic viewing)
modifications.
I.e. for the 'y-'-clipping-plane is it no problem to
move the coordinates in horizontal
direction. I only have to add the desired value to
X(in).
Code with the modification:
/* * Clip against -Y */
#define PLANE (CLIP_BOTTOM_BIT)
#define INSIDE(K) (Y(K) >= -W(K))
#define COMPUTE_INTERSECTION( in, out, new )
\
dy = Y(out)-Y(in);
\
dw = W(out)-W(in);
\
t = -(Y(in)+W(in)) / (dw+dy);
\
neww = W(in) + t * dw;
\
X(new) = X(in) + t * (X(out) - X(in));
\
/* My modified lines */
if (!REleft) X(new) = X(in) - ( RE_PARA /
(REmaxX*0.5+RE_SEPA) )+ t * (X(out) - X(in)); \
else X(new) = X(in) + ( (RE_PARA - RE_SEPA*W(in)) /
(REmaxX*0.5+RE_SEPA) )+ t * (X(out) -
X(in)); \
/* originale Mesa3D */
Y(new) = -neww;
\
if (SIZE>=3) coord[new][2] = Z(in) + t * (Z(out)
- Z(in)); \
if (SIZE==4) coord[new][3] = neww;
Modifications for eye-depending stereoscopic viewing:
RE_PARA is the number of pixels moving the objects to
the left (for the right-eye-view).
RE_SEPA represents the viewport-expansion and the eye
depending viewing-frustum. The objects
for the right-eye-view will be moved to the right.
REmaxX*0.5 has the same value as 'sx' in 'clip_funcs.h'.
This is only a test-version. This works pretty and looks
well.
The problem:
The problem are the x-clipping planes. The primitives
are clipped at the right viewport
edge. But for the right-eye-view the viewport-edge have
to moved left by RE_SEPA pixels. I
thought it is enought to add the required numbers of
pixels to X(in). Isn't that right? The
value for pixels(n) is calculated by: value = (n *
W(in)) / sx -> I think that is right.
Further info:
I expand the frustum by RE_SEPA/2 pixels to the left and
RE_SEPA/2 pixels to the right. I.e.
horizontal-viewport-size 640 + 2 * 32 =704. 32 stands
for RE_SEPA/2. The vertices between 0
and 640 are related to the right viewport and vertex
values between 64 and 704 are related
to the left viewport. To receive the original
viewport-width I have to substract RE_SEPA
from the left viewport.
Now the problem is clear. The clipping functions clipps
all primitives at the last pixel
(704). Than I substract 64 from the 704 and receive the
regualar maximum about 640. But the
y-coordinate are calculated by the clipping point at
pixel number 704, so all primitives are
disoriented. This problem happens only at the right
viewport-edge (+X) from the
right-eye-viewport and the left viewport-edge (-X) from
the left-eye-viewport.
How can I move the clipping point to the left by 64
(RE_SEPA) pixels for a correct clipping?
Here the not working code:
/* * Clip against +X * * The if conditions are known at
compile time. */
#define PLANE (CLIP_RIGHT_BIT)
#define INSIDE(K) (X(K) <= W(K))
#define COMPUTE_INTERSECTION( in, out, new )
\
dx = X(out)-X(in);
\
dw = W(out)-W(in);
\
t = (X(in)-W(in)) / (dw-dx);
\
/* My inserted line*/
if (!REleft) t = (X(in) + ((RE_SEPA*W(in)-RE_PARA) /
(REmaxX*0.5+RE_SEPA)) - W(in)) /
(dw-dx);\
/* org. Mesa3D */
neww = W(in) + t * dw;
\
X(new) = neww;
\
Y(new) = Y(in) + t * (Y(out) - Y(in));
\
if (SIZE>=3) coord[new][2] = Z(in) + t * (Z(out)
- Z(in)); \
if (SIZE==4) coord[new][3] = new;
Still not confused enoght?
Here an overview about this project:
http://www.phrankphurt.com/VR-Worlds/tvr/tvr.html
Greatings
Robert
-----------------------------------------------------
This mail sent through IMP: http://web.horde.org/imp/
_______________________________________________
Mesa-dev maillist - [EMAIL PROTECTED]
http://lists.mesa3d.org/mailman/listinfo/mesa-dev