POV-Ray : Newsgroups : povray.advanced-users : Spherical camera upside-down Server Time
22 Dec 2024 17:50:51 EST (-0500)
  Spherical camera upside-down (Message 1 to 10 of 19)  
Goto Latest 10 Messages Next 9 Messages >>>
From: Mike Horvath
Subject: Spherical camera upside-down
Date: 8 Sep 2016 08:44:35
Message: <57d15d33$1@news.povray.org>
I have the following spherical camera:

		#declare Camera_Up		= -y;
		#declare Camera_Right		= +z;
		#declare Camera_Location	= <0,0,0>;
		#declare Camera_Direction	= -x;
		#declare Camera_LookAt		= Camera_Location + Camera_Direction;
		#declare Camera_Transform = transform
		{
			matrix <0,0,-1,0,1,0,1,0,0,0,-88,-640>		// front entrance
		//	matrix <0,0,-1,0,1,0,1,0,0,0,-88,100>
		//	matrix <0,0,-1,0,1,0,1,0,0,0,-88,-180>
		//	matrix <0,0,-1,0,1,0,1,0,0,-280,-88,-180>
		//	matrix <0,0,-1,0,1,0,1,0,0,280,-312,140>
		//	matrix <0,0,-1,0,1,0,1,0,0,200,-312,-140>
		//	matrix <0,0,-1,0,1,0,1,0,0,-200,-312,-140>
		//	matrix <0,0,-1,0,1,0,1,0,0,-360,-312,140>
		}
		camera
		{
			spherical
			angle		360 180
			up		Camera_Up
			right		Camera_Right
			location	Camera_Location
			direction	Camera_Direction
			transform {Camera_Transform}
		}

It is a LDraw model, which has an inverted y axis or handedness. The 
problem is when I render the scene, it appears upside-down. Even though 
I already compensated by making the y axis negative. Anyone have an idea 
what is going on?

Mike


Post a reply to this message

From: Le Forgeron
Subject: Re: Spherical camera upside-down
Date: 8 Sep 2016 08:49:50
Message: <57d15e6e$1@news.povray.org>
Le 08/09/2016 à 14:44, Mike Horvath a écrit :
> I have the following spherical camera:
>
>         #declare Camera_Up        = -y;
>         #declare Camera_Right        = +z;
>         #declare Camera_Location    = <0,0,0>;
>         #declare Camera_Direction    = -x;
>         #declare Camera_LookAt        = Camera_Location + Camera_Direction;
>         #declare Camera_Transform = transform
>         {
>             matrix <0,0,-1,0,1,0,1,0,0,0,-88,-640>        // front entrance
>         //    matrix <0,0,-1,0,1,0,1,0,0,0,-88,100>
>         //    matrix <0,0,-1,0,1,0,1,0,0,0,-88,-180>
>         //    matrix <0,0,-1,0,1,0,1,0,0,-280,-88,-180>
>         //    matrix <0,0,-1,0,1,0,1,0,0,280,-312,140>
>         //    matrix <0,0,-1,0,1,0,1,0,0,200,-312,-140>
>         //    matrix <0,0,-1,0,1,0,1,0,0,-200,-312,-140>
>         //    matrix <0,0,-1,0,1,0,1,0,0,-360,-312,140>
>         }
>         camera
>         {
>             spherical
>             angle        360 180
>             up        Camera_Up
>             right        Camera_Right
>             location    Camera_Location
>             direction    Camera_Direction
>             transform {Camera_Transform}
>         }
>
> It is a LDraw model, which has an inverted y axis or handedness. The
> problem is when I render the scene, it appears upside-down. Even though
> I already compensated by making the y axis negative. Anyone have an idea
> what is going on?
>
> Mike

You might enjoy a "sky" in your camera. And I do not know what the 
matrix transform is doing, but there is also a -1 in it.

But classical "right hand" is z up, y forward, x right


Post a reply to this message

From: Mike Horvath
Subject: Re: Spherical camera upside-down
Date: 8 Sep 2016 14:14:47
Message: <57d1aa97$1@news.povray.org>
On 9/8/2016 8:49 AM, Le_Forgeron wrote:
> Le 08/09/2016 à 14:44, Mike Horvath a écrit :
>> I have the following spherical camera:
>>
>>         #declare Camera_Up        = -y;
>>         #declare Camera_Right        = +z;
>>         #declare Camera_Location    = <0,0,0>;
>>         #declare Camera_Direction    = -x;
>>         #declare Camera_LookAt        = Camera_Location +
>> Camera_Direction;
>>         #declare Camera_Transform = transform
>>         {
>>             matrix <0,0,-1,0,1,0,1,0,0,0,-88,-640>        // front
>> entrance
>>         //    matrix <0,0,-1,0,1,0,1,0,0,0,-88,100>
>>         //    matrix <0,0,-1,0,1,0,1,0,0,0,-88,-180>
>>         //    matrix <0,0,-1,0,1,0,1,0,0,-280,-88,-180>
>>         //    matrix <0,0,-1,0,1,0,1,0,0,280,-312,140>
>>         //    matrix <0,0,-1,0,1,0,1,0,0,200,-312,-140>
>>         //    matrix <0,0,-1,0,1,0,1,0,0,-200,-312,-140>
>>         //    matrix <0,0,-1,0,1,0,1,0,0,-360,-312,140>
>>         }
>>         camera
>>         {
>>             spherical
>>             angle        360 180
>>             up        Camera_Up
>>             right        Camera_Right
>>             location    Camera_Location
>>             direction    Camera_Direction
>>             transform {Camera_Transform}
>>         }
>>
>> It is a LDraw model, which has an inverted y axis or handedness. The
>> problem is when I render the scene, it appears upside-down. Even though
>> I already compensated by making the y axis negative. Anyone have an idea
>> what is going on?
>>
>> Mike
>
> You might enjoy a "sky" in your camera. And I do not know what the
> matrix transform is doing, but there is also a -1 in it.
>
> But classical "right hand" is z up, y forward, x right

The docs don't say anything about "sky", nor should I need one. Adding 
one doesn't help. Also, I removed the matrix transformation but the 
result is still upside-down.


Mike


Post a reply to this message

From: Bald Eagle
Subject: Re: Spherical camera upside-down
Date: 8 Sep 2016 15:15:01
Message: <web.57d1b861978968acb488d9aa0@news.povray.org>
Mike Horvath <mik### [at] gmailcom> wrote:

> The docs don't say anything about "sky", nor should I need one. Adding
> one doesn't help. Also, I removed the matrix transformation but the
> result is still upside-down.
>
> Mike

I do believe that Jerome meant that you might find adding a sky VECTOR to your
camera definition may be of some help.

I realize you must be frustrated, but he is very knowledgeable and provides
excellent advice, and I would suggest taking a step back, a breath, and a few
more minutes to search before responding.

This may help in addition to the docs which DO explain the use of a sky vector:

http://www.joshuarenglish.com/cyclopedia/sky.html


Post a reply to this message

From: clipka
Subject: Re: Spherical camera upside-down
Date: 8 Sep 2016 16:10:28
Message: <57d1c5b4$1@news.povray.org>
Am 08.09.2016 um 14:44 schrieb Mike Horvath:

> It is a LDraw model, which has an inverted y axis or handedness. The
> problem is when I render the scene, it appears upside-down. Even though
> I already compensated by making the y axis negative. Anyone have an idea
> what is going on?

To me it looks like you're trying to achieve via camera up, right and
direction what someone else has already cared for via the matrix
transform, so effectively the two cancel out.

My recommendation would be to try and start from scratch:

- The `sky` vector should be set to whatever is really "up" in the
scene; the default is `y`, but you most certainly want `-y`.

- The `up` vector should also be set to whatever is really "up" in the
scene, possibly multiplied by `image_height/image_width`(*).

- The `right` vector should be set to whatever is "right" according to
the orientation you find the scene easiest to visualize, possibly
multiplied by `image_width/image_height`(*). You might pick `+x`.

- The `direction` vector should be set to whatever is "forward"
according to your choice of "right", possibly multiplied by a zoom
factor. (Alternatively, you can keep the `direction` vector constant and
apply a factor to both `up` and `right` for zooming.

- The `location` should, for now, be a place from where, given the above
settings, you should be able to see something in the scene.

(*only one of `up` or `right` should be multiplied with the stated
factor; note that one is the inverse of the other)


Once you get something remotely useful out of this straightforward
camera setup, you can proceed to tweak the perspective to your liking in
one of the following manners:

(A) The Hard Way: Mess with the `up`, `right` and `direction` vectors
manually. It is up to you to make sure they stay orthogonal and at the
proper relative lengths, and since that can be quite a pain and prone to
errors I really wouldn't recommend this.

If you choose this approach, I think you should theoretically be able to
get away without a `sky` vector.

(B) Transformation: Simply add rotations and translations to the camera
statements. Be aware that rotations are always around the origin, so
unless your camera is at <0,0,0> rotations will not only change the
viewing direction, but also the location of the camera. (Theoretically
you can also use scaling and matrix transformations, but I would would
advise against this, as both may cause you to accidently flip the
coordinate system if you don't pay attention.)

If you choose this approach, I think you should also theoretically be
able to get away without a `sky` vector.

(C) Look At: Specify a `look_at` point; the camera will automatically be
re-oriented (but remain at the same place) to point at the specified
location. This is my preferred approach.

If you choose this approach, a `sky` vector is mandatory. POV-Ray will
re-orient the camera in such a manner that the effective `up` vector
will remain as close as possible to the `sky` vector


In all three variants, you can zoom by either messing with the length of
the direction vector in relation to that of the up/right vectors, or by
simply specifying an `angle` parameter.


Post a reply to this message

From: Mike Horvath
Subject: Re: Spherical camera upside-down
Date: 8 Sep 2016 17:41:42
Message: <57d1db16$1@news.povray.org>
On 9/8/2016 3:13 PM, Bald Eagle wrote:
> Mike Horvath <mik### [at] gmailcom> wrote:
> I do believe that Jerome meant that you might find adding a sky VECTOR to your
> camera definition may be of some help.
>
> I realize you must be frustrated, but he is very knowledgeable and provides
> excellent advice, and I would suggest taking a step back, a breath, and a few
> more minutes to search before responding.
>
> This may help in addition to the docs which DO explain the use of a sky vector:
>
> http://www.joshuarenglish.com/cyclopedia/sky.html
>
>
>

As I said, I did this and it did not help.


Mike


Post a reply to this message

From: Alain
Subject: Re: Spherical camera upside-down
Date: 8 Sep 2016 17:44:52
Message: <57d1dbd4$1@news.povray.org>
Le 16-09-08 à 08:44, Mike Horvath a écrit :
> I have the following spherical camera:
>
>         #declare Camera_Up        = -y;
>         #declare Camera_Right        = +z;
>         #declare Camera_Location    = <0,0,0>;
>         #declare Camera_Direction    = -x;
>         #declare Camera_LookAt        = Camera_Location + Camera_Direction;
>         #declare Camera_Transform = transform
>         {
>             matrix <0,0,-1,0,1,0,1,0,0,0,-88,-640>        // front entrance
>         //    matrix <0,0,-1,0,1,0,1,0,0,0,-88,100>
>         //    matrix <0,0,-1,0,1,0,1,0,0,0,-88,-180>
>         //    matrix <0,0,-1,0,1,0,1,0,0,-280,-88,-180>
>         //    matrix <0,0,-1,0,1,0,1,0,0,280,-312,140>
>         //    matrix <0,0,-1,0,1,0,1,0,0,200,-312,-140>
>         //    matrix <0,0,-1,0,1,0,1,0,0,-200,-312,-140>
>         //    matrix <0,0,-1,0,1,0,1,0,0,-360,-312,140>
>         }
>         camera
>         {
>             spherical
>             angle        360 180
>             up        Camera_Up
>             right        Camera_Right
>             location    Camera_Location
>             direction    Camera_Direction
>             transform {Camera_Transform}
>         }
>
> It is a LDraw model, which has an inverted y axis or handedness. The
> problem is when I render the scene, it appears upside-down. Even though
> I already compensated by making the y axis negative. Anyone have an idea
> what is going on?
>
> Mike

I'd start with a default like camera located at the origin and looking 
toward +z.
Next, I would translate it to the desired location then orient it using 
look_at.

camera{
  spherical
  location <0,0,0> // from here
  up y sky y
  right 4/3*x
  direction z // to here we replicate the default camera parameters
  translate Camera_Location
  look_at Interest_Point
  angle View_Angle
}

If the image is upside down, you can :
negate the up and sky vector. You may also need to negate the right 
vector in this case.
rotate the camera 180° around the z axis before translating it.



Alain


Post a reply to this message

From: Mike Horvath
Subject: Re: Spherical camera upside-down
Date: 8 Sep 2016 17:59:55
Message: <57d1df5b$1@news.povray.org>
On 9/8/2016 4:10 PM, clipka wrote:
> Am 08.09.2016 um 14:44 schrieb Mike Horvath:
>
>> It is a LDraw model, which has an inverted y axis or handedness. The
>> problem is when I render the scene, it appears upside-down. Even though
>> I already compensated by making the y axis negative. Anyone have an idea
>> what is going on?
>
> To me it looks like you're trying to achieve via camera up, right and
> direction what someone else has already cared for via the matrix
> transform, so effectively the two cancel out.
>

As I said, I tried totally removing the matrix transformation, and the 
result was the same upside-down orientation.



> My recommendation would be to try and start from scratch:
>
> - The `sky` vector should be set to whatever is really "up" in the
> scene; the default is `y`, but you most certainly want `-y`.
>
> - The `up` vector should also be set to whatever is really "up" in the
> scene, possibly multiplied by `image_height/image_width`(*).
>

I tried setting both the "sky" vector and the "up" vector to "-y", but 
the result was no different.


> - The `right` vector should be set to whatever is "right" according to
> the orientation you find the scene easiest to visualize, possibly
> multiplied by `image_width/image_height`(*). You might pick `+x`.
>

The camera is spherical. Do I really need to scale the "up" and "right" 
vectors to the image dimensions? I was under the impression that the 
spherical camera already automatically fills a 2:1 aspect ratio image.


> - The `direction` vector should be set to whatever is "forward"
> according to your choice of "right", possibly multiplied by a zoom
> factor. (Alternatively, you can keep the `direction` vector constant and
> apply a factor to both `up` and `right` for zooming.
>
> - The `location` should, for now, be a place from where, given the above
> settings, you should be able to see something in the scene.
>
> (*only one of `up` or `right` should be multiplied with the stated
> factor; note that one is the inverse of the other)
>
>
> Once you get something remotely useful out of this straightforward
> camera setup, you can proceed to tweak the perspective to your liking in
> one of the following manners:
>

Here's my non-spherical version of the camera, which works perfectly 
well and without problems. I am generating panoramic images, and this is 
the cube mapped version.

		#declare Camera_Up		= -y*2;
		#declare Camera_Right		= +z*2;
		#declare Camera_Location	= <0,0,0>;
		#declare Camera_Direction	= -x;
		#declare Camera_LookAt		= Camera_Location + Camera_Direction;		// does 
nothing right now
		#ifndef (view_direction)
			#declare view_direction = frame_number;
		#end
		#switch (view_direction)
			#case (0)
				#declare Camera_Rotate	= <0,000,0,>;
			#break
			#case (1)
				#declare Camera_Rotate	= <0,090,0,>;
			#break
			#case (2)
				#declare Camera_Rotate	= <0,180,0,>;
			#break
			#case (3)
				#declare Camera_Rotate	= <0,270,0,>;
			#break
			#case (4)
				#declare Camera_Rotate	= <0,0,090,>;
			#break
			#case (5)
				#declare Camera_Rotate	= <0,0,270,>;
			#break
		#end
		#declare Camera_Transform = transform
		{
			rotate		Camera_Rotate
		//	matrix <0,0,-1,0,1,0,1,0,0,0,-88,-640>		// front entrance
			matrix <0,0,-1,0,1,0,1,0,0,0,-88,100>		// courtyard
		//	matrix <0,0,-1,0,1,0,1,0,0,0,-88,-180>
		//	matrix <0,0,-1,0,1,0,1,0,0,-280,-88,-180>
		//	matrix <0,0,-1,0,1,0,1,0,0,280,-312,140>
		//	matrix <0,0,-1,0,1,0,1,0,0,200,-312,-140>
		//	matrix <0,0,-1,0,1,0,1,0,0,-200,-312,-140>
		//	matrix <0,0,-1,0,1,0,1,0,0,-360,-312,140>
		}
		camera
		{
			up		Camera_Up
			right		Camera_Right
			location	Camera_Location
			direction	Camera_Direction
			transform {Camera_Transform}
		}

I don't understand why with the spherical camera I need to "tweak the 
perspective" further. I know I can fix the scene by simply rotating it 
180 degrees in GIMP. But I can't shake the feeling that there's a bug in 
the spherical camera code.


Mike


Post a reply to this message

From: Mike Horvath
Subject: Re: Spherical camera upside-down
Date: 8 Sep 2016 18:30:22
Message: <57d1e67e$1@news.povray.org>
On 9/8/2016 5:45 PM, Alain wrote:
> Le 16-09-08 à 08:44, Mike Horvath a écrit :
>> I have the following spherical camera:
>>
>>         #declare Camera_Up        = -y;
>>         #declare Camera_Right        = +z;
>>         #declare Camera_Location    = <0,0,0>;
>>         #declare Camera_Direction    = -x;
>>         #declare Camera_LookAt        = Camera_Location +
>> Camera_Direction;
>>         #declare Camera_Transform = transform
>>         {
>>             matrix <0,0,-1,0,1,0,1,0,0,0,-88,-640>        // front
>> entrance
>>         //    matrix <0,0,-1,0,1,0,1,0,0,0,-88,100>
>>         //    matrix <0,0,-1,0,1,0,1,0,0,0,-88,-180>
>>         //    matrix <0,0,-1,0,1,0,1,0,0,-280,-88,-180>
>>         //    matrix <0,0,-1,0,1,0,1,0,0,280,-312,140>
>>         //    matrix <0,0,-1,0,1,0,1,0,0,200,-312,-140>
>>         //    matrix <0,0,-1,0,1,0,1,0,0,-200,-312,-140>
>>         //    matrix <0,0,-1,0,1,0,1,0,0,-360,-312,140>
>>         }
>>         camera
>>         {
>>             spherical
>>             angle        360 180
>>             up        Camera_Up
>>             right        Camera_Right
>>             location    Camera_Location
>>             direction    Camera_Direction
>>             transform {Camera_Transform}
>>         }
>>
>> It is a LDraw model, which has an inverted y axis or handedness. The
>> problem is when I render the scene, it appears upside-down. Even though
>> I already compensated by making the y axis negative. Anyone have an idea
>> what is going on?
>>
>> Mike
>
> I'd start with a default like camera located at the origin and looking
> toward +z.
> Next, I would translate it to the desired location then orient it using
> look_at.
>
> camera{
>   spherical
>   location <0,0,0> // from here
>   up y sky y
>   right 4/3*x
>   direction z // to here we replicate the default camera parameters
>   translate Camera_Location
>   look_at Interest_Point
>   angle View_Angle
> }
>
> If the image is upside down, you can :
> negate the up and sky vector. You may also need to negate the right
> vector in this case.
> rotate the camera 180° around the z axis before translating it.
>
>
>
> Alain

For a spherical camera this is totally wrong.


Mike


Post a reply to this message

From: clipka
Subject: Re: Spherical camera upside-down
Date: 8 Sep 2016 18:58:46
Message: <57d1ed26$1@news.povray.org>
Am 09.09.2016 um 00:00 schrieb Mike Horvath:

> The camera is spherical. Do I really need to scale the "up" and "right"
> vectors to the image dimensions? I was under the impression that the
> spherical camera already automatically fills a 2:1 aspect ratio image.

My bad, I didn't pay much attention to the camera type.

Having had a closer look at the source code, here's my updated
(counter-intuitive) advice:

- To mirror the image vertically, flip the _right_ vector.
- To mirror the image horizontally, flip the _up_ vector.
- To mirror the image vertically _and_ turn the camera 180 degrees, flip
the direction vector.

Entirely untested, but that's what I infer from the source code.


Post a reply to this message

Goto Latest 10 Messages Next 9 Messages >>>

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