POV-Ray : Newsgroups : povray.binaries.animations : Playing with matrix transforms Server Time
23 Feb 2025 08:35:07 EST (-0500)
  Playing with matrix transforms (Message 21 to 25 of 25)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Kenneth
Subject: Re: Playing with matrix transforms
Date: 3 Feb 2025 16:45:00
Message: <web.67a138af28e99934e83955656e066e29@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
>
> {Illusion.inc] is basically a different
> way of applying an image_map to objects-- but from the camera's viewpoint, and
> with a rather magical matrix manipulation that alters the 'depth perspective'
> of the applied image.
>

It essentially applies the image_map as an 'orthographic' projection onto scene
objects, devoid of perspective... which is quite different from a typical
map_type 0 projection.


Post a reply to this message

From: Bald Eagle
Subject: Re: Playing with matrix transforms
Date: 3 Feb 2025 17:10:00
Message: <web.67a13e6b28e999341f9dae3025979125@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> It is basically a different
> way of applying an image_map to objects-- but from the camera's viewpoint, and
> with a rather magical matrix manipulation that alters the 'depth perspective' of
> the applied image.

Yes, I get that part.


> Rune's matrix transform is quite mysterious (to me) because it uses the
> *camera's* settings, along with some math manipulations that are presently way
> over my head.

So, as best I can tell, he's simply done the kind of thing that's done in the
"make this object/text always face the camera"... with the matrix.

but the image_map is converted to a function that incorporates x/z and y/z which
also corrects for the projection matrix so that everything lines up no matter
how near or far.

I just haven;t had the time to figure out how to start applying his include to a
scene, so that I can reverse-engineer it enough to provide a didactic diagram
and explanation.

So if you have working code....   ;)

- BW


Post a reply to this message

From: Bald Eagle
Subject: Re: Playing with matrix transforms
Date: 10 Feb 2025 07:00:00
Message: <web.67a9ea1428e999341f9dae3025979125@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> "Kenneth" <kdw### [at] gmailcom> wrote:
> >
> > {Illusion.inc] is basically a different
> > way of applying an image_map to objects-- but from the camera's viewpoint, and
> > with a rather magical matrix manipulation that alters the 'depth perspective'
> > of the applied image.
> >
>
> It essentially applies the image_map as an 'orthographic' projection onto scene
> objects, devoid of perspective... which is quite different from a typical
> map_type 0 projection.

So, I spent a bit of time working out how to do the "this object always faces
the camera" thing, and it's essentially what gets done in screen.inc, minus the
final translation.

Compare that to Rune's "rather magical matrix manipulation" and you'll see that
it's basically the same thing.

So it looks to me that what's going on is, the image gets oriented to be
perpendicular to the camera / parallel to the image plane, and the divisions by
z in the image function are there to provide the appropriate scaling of the
image depending upon where it gets mapped to.

- BW


Post a reply to this message


Attachments:
Download 'facecamera.pov.txt' (2 KB)

From: Bald Eagle
Subject: Re: Playing with matrix transforms
Date: 10 Feb 2025 09:20:00
Message: <web.67aa0ac428e9993425b4de9225979125@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> So, I spent a bit of time working out how to do the "this object always faces
> the camera" thing,

And here's a bit more commentary to better explain how that works, and provide a
useful bit of code for future reference.

#macro FaceCamera (Object, CL)
 #local Min = min_extent (Object);
 #local Max = max_extent (Object);
 #local OL = Min + (Max-Min)/2;

 #declare CamL = CameraLocation;   // wherever you're putting it
 #declare CamD = vnormalize (OL-CamL);  // direction of camera view
  // One can alternately look at this as -Caml, translated to the object's
  // location by adding OL.  -CamL+OL = (OL-CamL)
 #declare CamR = vnormalize (vcross(y,CamD)); // to the right
  // The vector cross product gives a vector that is perpendicular to the two
  // given vectors.  If we're at the vertex (camera location) and we cross the
  // direction of view and the y-axis, we get a vector pointing out to the right
  // CamD and y are likely not perpendicular, so the resulting vcross is some
  // size != 1, so we normalize the size.
 #declare CamU = vnormalize (vcross(CamD,CamR)); // camera up
  // So now we have a view direction and a right vector, which are perpendicular
  // So we do another vector cross product, and get the new "up" vector
  // Which completes our new "frame of reference".
  // The tangent, normal, and binormal unit vectors, often called T, N, and B,


  // So now when we take the old x, y, and z basis vectors or normal POV-space
  // and move them to align with the new TNB vectors, your object whose
  // orientation was based upon x, y, and z is now based upon the new
  // T, N, and B vectors.
  // Since default camera points at z, and default orientation of most objects
  // is in the xy plane, the object is now in the same relative orientation
  // to the camera in the new TNB frame, and so always faces the camera.
 #declare Object_Transform =
 transform {
  matrix <
  CamR.x, CamR.y, CamR.z,
  CamU.x, CamU.y, CamU.z,
  CamD.x, CamD.y, CamD.z,
      0,      0,      0
  >
 }

 object {
  Object
  transform {Object_Transform}
 }
#end // end macro FaceCamera


Post a reply to this message


Attachments:
Download 'always facing the camera.txt' (2 KB)

From: Bald Eagle
Subject: Re: Playing with matrix transforms
Date: 15 Feb 2025 21:40:00
Message: <web.67b14f9828e999341f9dae3025979125@news.povray.org>
OK, so I was diagramming this all out, and that got me to focus on the fact that
the text not only gets rotated, but MOVED.

That's because it's not rotating the text around the origin.
Just apply the following fix:


 object {
  Object
  translate -OL
  transform {Object_Transform}
  translate OL
 }
#end // end macro FaceCamera


Post a reply to this message


Attachments:
Download 'howfacethecameraworks.png' (26 KB)

Preview of image 'howfacethecameraworks.png'
howfacethecameraworks.png


 

<<< Previous 10 Messages Goto Initial 10 Messages

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