POV-Ray : Newsgroups : povray.off-topic : Viewing frustum question Server Time
4 Sep 2024 15:17:36 EDT (-0400)
  Viewing frustum question (Message 10 to 19 of 19)  
<<< Previous 9 Messages Goto Initial 10 Messages
From: Warp
Subject: Re: Viewing frustum question
Date: 13 Feb 2010 15:42:21
Message: <4b770ead@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Isn't such a transformation non-affine? So it wouldn't be possible to do 
> it with a simple 4x4 matrix multiplication.

  Multiplication with a 4x4 matrix can be used for perspective projection.
It's a 3x3 transformation matrix which is restricted to affine transformations.

  (Yes, I didn't know that either, many years ago.)

-- 
                                                          - Warp


Post a reply to this message

From: Kevin Wampler
Subject: Re: Viewing frustum question
Date: 13 Feb 2010 15:57:59
Message: <4b771257@news.povray.org>
Warp wrote:
> clipka <ano### [at] anonymousorg> wrote:
>> Isn't such a transformation non-affine? So it wouldn't be possible to do 
>> it with a simple 4x4 matrix multiplication.

The trick which allows this is to use "homogeneous coordinates". 
Basically the 4th (or 3rd in you're in 2D) index in the coordinate 
vector is treated differently and is used to divide the other 
coordinates.  For example, let's say that the camera matrix maps a point 
(x,y,z,1) in 3D homogeneous coordinates to the point (u,v,w) in camera 
viewing coordinates.  The actual position on the "screen" given by this 
is then (u/w, v/w), where we've divided by the last coordinate.  It's 
this division which allows non-affine transformations to be represented.

Wikipedia has a nice article on homogeneous coordinates if you're 
interested in more:

http://en.wikipedia.org/wiki/Homogeneous_coordinates
http://en.wikipedia.org/wiki/Camera_matrix


>   Multiplication with a 4x4 matrix can be used for perspective projection.
> It's a 3x3 transformation matrix which is restricted to affine transformations.

3x4 is restricted to affine transformations.  A 3x3 matrix is restricted 
to linear transformations (assuming Cartesian instead of homogeneous 
coordinates).


Post a reply to this message

From: Fredrik Eriksson
Subject: Re: Viewing frustum question
Date: 13 Feb 2010 16:09:16
Message: <op.u723plzb7bxctx@toad.bredbandsbolaget.se>
On Sat, 13 Feb 2010 21:05:06 +0100, Warp <war### [at] tagpovrayorg> wrote:
> Hence the near and far clipping planes could indeed be "encoded" into the
> transformation matrix by specifying the depth scaling (which, I suppose,
> would prove my original assertion in this thread wrong).
>
>   However, I don't remember if something else was involved for this to
> work properly.

The clipping itself becomes slightly more complicated in that it must be  
performed in homogenous coordinates.



-- 
FE


Post a reply to this message

From: Warp
Subject: Re: Viewing frustum question
Date: 13 Feb 2010 16:25:02
Message: <4b7718ae@news.povray.org>
Fredrik Eriksson <fe79}--at--{yahoo}--dot--{com> wrote:
> On Sat, 13 Feb 2010 21:05:06 +0100, Warp <war### [at] tagpovrayorg> wrote:
> > Hence the near and far clipping planes could indeed be "encoded" into the
> > transformation matrix by specifying the depth scaling (which, I suppose,
> > would prove my original assertion in this thread wrong).
> >
> >   However, I don't remember if something else was involved for this to
> > work properly.

> The clipping itself becomes slightly more complicated in that it must be  
> performed in homogenous coordinates.

  Ah, yes, homogenous coordinates. It starts ringing bells now. That's the
thing I was not remembering in all this. (Man, it has been a long time since
I knew all these things.)

-- 
                                                          - Warp


Post a reply to this message

From: Darren New
Subject: Re: Viewing frustum question
Date: 13 Feb 2010 17:08:46
Message: <4b7722ee$1@news.povray.org>
Warp wrote:
> point coordinates will overflow, screwing up the projected coordinates, which

I hadn't thought of that. Thanks for clearing it up.

>   Note that I don't have first-hand experience on this. 

Well, looking at the structure, I'm pretty sure it's not in the matrix, but 
again I wanted to make sure it wasn't something clever, as you said.

-- 
Darren New, San Diego CA, USA (PST)
   Forget "focus follows mouse." When do
   I get "focus follows gaze"?


Post a reply to this message

From: Darren New
Subject: Re: Viewing frustum question
Date: 13 Feb 2010 17:11:43
Message: <4b77239f$1@news.povray.org>
Fredrik Eriksson wrote:
> Typically, the perspective transform is defined such that the resulting 
> z-coordinates fall in a suitable range (e.g. [0,1]). Clipping can then 
> be performed without knowledge about the original clipping planes.

I see. So there's extra information, but it might be implicit. Interesting 
approach.

Now I'm curious enough to screw around with the matrixes and math again to 
see if I can figure out what it's doing.

(I'll also mention in passing that the XNA compiler is the first compiler 
I've run into that hoists constant expressions in loops not only out of the 
loop but onto an entirely different CPU altogether. :-)

-- 
Darren New, San Diego CA, USA (PST)
   Forget "focus follows mouse." When do
   I get "focus follows gaze"?


Post a reply to this message

From: somebody
Subject: Re: Viewing frustum question
Date: 15 Feb 2010 07:44:27
Message: <4b7941ab$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:4b770ead@news.povray.org...
> clipka <ano### [at] anonymousorg> wrote:

> > Isn't such a transformation non-affine? So it wouldn't be possible to do
> > it with a simple 4x4 matrix multiplication.

>   Multiplication with a 4x4 matrix can be used for perspective projection.
> It's a 3x3 transformation matrix which is restricted to affine
transformations.
>
>   (Yes, I didn't know that either, many years ago.)

That's not correct. 3x3 matrix multiplication only gives you linear
transformations (in 3D). You need a particularly designed 4x4 matrix for
affine transformations, which includes translation on top of linear
transformations of scaling, rotation and projective ("orthogonal")
transformations. Perspective projection is not strictly achieved with matrix
multiplication applied to standard coordinates, so you include a special
equivalency clause / homogenous coordinates (a division in disguise), and
with that in mind, you can use the remaining elements of the 4x4 matrix to
that end.


Post a reply to this message

From: Warp
Subject: Re: Viewing frustum question
Date: 15 Feb 2010 09:12:36
Message: <4b795653@news.povray.org>
somebody <x### [at] ycom> wrote:
> Perspective projection is not strictly achieved with matrix
> multiplication applied to standard coordinates, so you include a special
> equivalency clause / homogenous coordinates (a division in disguise), and
> with that in mind, you can use the remaining elements of the 4x4 matrix to
> that end.

  Yeah, perspective projection with a 4x4 transformation matrix is only
possible if the points are in homogeneous coordinates.

-- 
                                                          - Warp


Post a reply to this message

From: Darren New
Subject: Re: Viewing frustum question
Date: 16 Feb 2010 00:55:19
Message: <4b7a3347$1@news.povray.org>
Fredrik Eriksson wrote:
> Typically, the perspective transform is defined such that the resulting 
> z-coordinates fall in a suitable range (e.g. [0,1]). Clipping can then 
> be performed without knowledge about the original clipping planes.

Just peeking at some of the HLSL values that get passed around and some of 
the graphics card assembler instructions, it looks like this is quite 
likely. For example, there's a "free" modifier you can use to shift a result 
from [-1...1] to [0...1] on the graphics card without taking any more 
instruction cycles. Textures seem to get 0...1 while visible X,Y coordinates 
seem to go -1...1.  I'm not sure which range the Z coordinates fall into, 
but it certainly seems reasonable to believe that if the X and Y are scaled 
in such a way, the Z likely will be also.

-- 
Darren New, San Diego CA, USA (PST)
   Forget "focus follows mouse." When do
   I get "focus follows gaze"?


Post a reply to this message

From: scott
Subject: Re: Viewing frustum question
Date: 22 Feb 2010 06:17:09
Message: <4b8267b5@news.povray.org>
>> Typically, the perspective transform is defined such that the resulting 
>> z-coordinates fall in a suitable range (e.g. [0,1]). Clipping can then be 
>> performed without knowledge about the original clipping planes.
>
> I see. So there's extra information, but it might be implicit. Interesting 
> approach.

Yes, the 3D hardware is usually programmed to clip when Z is outside a 
certain range.  It is then up to you (the programmer) to decide how you map 
real world coordinates to this range, and yes you can do it with just a 4x4 
matrix.

DirectX has a helper function to create such a matrix for you:

http://tinyurl.com/yg5z9t7


Post a reply to this message

<<< Previous 9 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.