POV-Ray : Newsgroups : povray.newusers : lens shift camera Server Time
12 Nov 2026 01:27:13 EST (-0500)
  lens shift camera (Message 1 to 17 of 17)  
From: tony
Subject: lens shift camera
Date: 9 Sep 2009 13:35:01
Message: <web.4aa7e7173006043315c9dce10@news.povray.org>
Has povray lens shift camera for architecture? How to do?

Thank you all.

Tony


Post a reply to this message

From: clipka
Subject: Re: lens shift camera
Date: 9 Sep 2009 13:56:38
Message: <4aa7ec56$1@news.povray.org>
tony schrieb:
> Has povray lens shift camera for architecture? How to do?

It /might/ be possible by choosing the "up" and/or "right" camera 
vectors to be nonperpendicular to the "direction" vector. Never tested 
it though.


Post a reply to this message

From: tony
Subject: Re: lens shift camera
Date: 9 Sep 2009 14:20:00
Message: <web.4aa7f115f237a03d15c9dce10@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> tony schrieb:
> > Has povray lens shift camera for architecture? How to do?
>
> It /might/ be possible by choosing the "up" and/or "right" camera
> vectors to be nonperpendicular to the "direction" vector. Never tested
> it though.

Thanks, clipka.

I am exporting from blender with Blend2Pov. These are the data from the camera
in my scene:

camera { perspective angle 83.125 location <-0.347254,2.04441,-1.44341> right
0.74813*x sky <0,1,1.21856e-007> look_at <-0.347254,2.04441,-0.44341>}

I put in blender a lens shift y: -0.19

Should reflect the data in "up" parameter?

Tony


Post a reply to this message

From: clipka
Subject: Re: lens shift camera
Date: 9 Sep 2009 14:23:46
Message: <4aa7f2b2$1@news.povray.org>
tony schrieb:
> I am exporting from blender with Blend2Pov. These are the data from the camera
> in my scene:
> 
> camera { perspective angle 83.125 location <-0.347254,2.04441,-1.44341> right
> 0.74813*x sky <0,1,1.21856e-007> look_at <-0.347254,2.04441,-0.44341>}
> 
> I put in blender a lens shift y: -0.19

I don't think lens shift is possible at all when using look_at to orient 
the camera, as it will automatically reassign the up, right and 
direction vectors.


Post a reply to this message

From: Stephen
Subject: Re: lens shift camera
Date: 9 Sep 2009 14:32:21
Message: <a4tfa5lfl8hfnptjqn72fbqeu9uk1dcj0q@4ax.com>
On Wed,  9 Sep 2009 13:34:15 EDT, "tony" <nomail@nomail> wrote:

>Has povray lens shift camera for architecture? How to do?
>
>Thank you all.
>

If you look in povray.binaries.scene-files, on 30 May 2008. Doctor John posted
something for someone who wanted a Tilt/Shift lens. The thread is called
"FieldCam for alex".

I hope that this helps.
-- 

Regards
     Stephen


Post a reply to this message

From: tony
Subject: Re: lens shift camera
Date: 9 Sep 2009 15:35:00
Message: <web.4aa80244f237a03d15c9dce10@news.povray.org>
Stephen <mcavoysAT@aolDOTcom> wrote:
> On Wed,  9 Sep 2009 13:34:15 EDT, "tony" <nomail@nomail> wrote:
>
> >Has povray lens shift camera for architecture? How to do?
> >
> >Thank you all.
> >
>
> If you look in povray.binaries.scene-files, on 30 May 2008. Doctor John posted
> something for someone who wanted a Tilt/Shift lens. The thread is called
> "FieldCam for alex".
>
> I hope that this helps.
> --
>
> Regards
>      Stephen


Scuse me Stephen:

I downloaded the fieldcam.zip archive. Uncompressed the "fieldcam" archive,
without extension. I open it with a text processor and it is illegible. I do
not know to do whith this.

I am on windows.

Tony


Post a reply to this message

From: Stephen
Subject: Re: lens shift camera
Date: 9 Sep 2009 16:10:00
Message: <ur2ga55r15el7icvbukm8qcj20433i041f@4ax.com>
On Wed,  9 Sep 2009 15:30:12 EDT, "tony" <nomail@nomail> wrote:

>Scuse me Stephen:
>
>I downloaded the fieldcam.zip archive. Uncompressed the "fieldcam" archive,
>without extension. I open it with a text processor and it is illegible. I do
>not know to do whith this.
>
>I am on windows.

Hi Tony,
	I've not used the file myself I just remember Doctor John talking about
it one night when we were having a drink.

 "FieldCam.zip" and can be opened with winzip. Inside the archive are three
folders one each for Mac, Unix and Windows. In the windows folder you will find
a file called "FieldCam3.inc". This is an include file that should be put in one
of your PovRay library paths.
In your scene you include the line:
#include FieldCam3.inc
This will allow PovRay to access the macro FieldCam()
You will need to read the include file for instructions on how to use it.
BTW just looking at the file, it looks to me that there is a line wrap problem
and some lines have had a cr/lf added. This means that you will need to go
through it and correct this problem before using it.
Doctor John does come by now and again so he might be able to help.
-- 

Regards
     Stephen


Post a reply to this message

From: Warp
Subject: Re: lens shift camera
Date: 9 Sep 2009 17:18:13
Message: <4aa81b95@news.povray.org>
You can apply any transform to the camera, including shearing.

-- 
                                                          - Warp


Post a reply to this message

From: Stephen
Subject: Re: lens shift camera
Date: 9 Sep 2009 17:20:49
Message: <h07ga51t68q9gblogqgmoir0kill50i0hb@4ax.com>
On 9 Sep 2009 17:18:13 -0400, Warp <war### [at] tagpovrayorg> wrote:

>  You can apply any transform to the camera, including shearing.

And how would a new user do that?

-- 

Regards
     Stephen


Post a reply to this message

From: tony
Subject: Re: lens shift camera
Date: 9 Sep 2009 17:50:00
Message: <web.4aa8220cf237a03d15c9dce10@news.povray.org>
Thanks Stephen:

When decompressing "FieldCam.zip" -> FieldCam, I put the zip extension and
returned to decompress. So are the three folders.

I put FieldCam3.inc in the "include" folder.

To obtain the parameters of lens shift, I exported to yafaray who has
implemented. These are the parameters yafaray:

<camera name="cam">
 <aperture fval="0"/>
 <bokeh_rotation fval="0"/>
 <bokeh_type sval="disk1"/>
 <dof_distance fval="0"/>
 <focal fval="1.09375"/>
 <from x="7.48113" y="-6.50764" z="5.34367"/>
 <resx ival="800"/>
 <resy ival="600"/>
 <to x="6.82627" y="-5.89697" z="4.89842"/>
 <type sval="perspective"/>
 <up x="7.16376" y="-6.19517" z="6.23901"/>
</camera>


On Povray:

#declare CamPos=<7.48113,5.34367,-6.50764>;
#declare CamLook=<6.82627,4.89842,-5.89697>;

camera {
        FieldCam ()
        perspective
        location CamPos
        angle 49.1343
        //right 1.33333*x   blender parametter
        //sky <-0.31737,0.895343,0.312469> blender parametter
        up y <7.16376,6.23901,-6.19517>
        transform {NoFall}
        look_at CamLook
        }


I'm trying to render and make error in "up y" (Parse Error: No matching) in
'camera, <found instead.

I'm approaching the process but I do not know what is bad.

Greetings.

Tony


Post a reply to this message

From: Reactor
Subject: Re: lens shift camera
Date: 9 Sep 2009 19:35:00
Message: <web.4aa83a7ff237a03d921da9530@news.povray.org>
"tony" <nomail@nomail> wrote:

> camera {
>         FieldCam ()
>         perspective
>         location CamPos
>         angle 49.1343
>         //right 1.33333*x   blender parametter
>         //sky <-0.31737,0.895343,0.312469> blender parametter
>         up y <7.16376,6.23901,-6.19517>
>         transform {NoFall}
>         look_at CamLook
>         }
>
>
> I'm trying to render and make error in "up y" (Parse Error: No matching) in
> 'camera, <found instead.
>
> I'm approaching the process but I do not know what is bad.
>


The line
>         up y <7.16376,6.23901,-6.19517>

POV-ray expects a single vector after up, and you have two:  the y vector, which
is <0,1,0>, and <7.16376,6.23901,-6.19517>.  You should only have one, probably
the second one, since up y is the default for perpendicular camera vectors.
Try removing the y after up but leaving the second vector.


-Reactor


Post a reply to this message

From: Doctor John
Subject: Re: lens shift camera
Date: 10 Sep 2009 06:56:14
Message: <4aa8db4e$1@news.povray.org>
tony wrote:
> Has povray lens shift camera for architecture? How to do?
> 
> Thank you all.
> 
> Tony
> 
> 
As has been mentioned by Stephen, I did a macro a few years back. If
you're having problems with line wrapping, here's the full text:

/**************************************************/
// Persistence of Vision SDL include file
// Description: A macro to simulate lens movements in architectural scenes
//		Helps prevent the "falling verticals syndrome"
// Author: John Guthkelch (Doctor John) <doc### [at] linuxmailorg>
// Version 3.0 Released May 2006
// History:
//  Version 3.0: 1. Removed necessity of passing parameters when calling
//                  macro. Less typing needed :-)
//               2. Added code so macro can be used when using
//                  right-handed coordinates (i.e. z-axis is up).
//  Version 2.0: 1. Improved warning so that camera automatically
//                  reverts to default type if insane values are given
//                  for CamPos and/or CamLook
//               2. Corrected silly mathematical error in vertical
//                  scaling.This is now correct so switch has been taken
//                  out.

/***********************************************************************
License & copyright:
(c) 2006 John Guthkelch
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version. This program is distributed in the hope that
it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
the GNU General Public License for more details.
(See http://www.gnu.org/licenses/gpl.txt for the full GPL text)

***********************************************************************/
#macro FieldCam()
   #local CD=CamLook-CamPos;
   #ifndef (Up_Z)
      #if (CD.x!=0 | CD.z!=0) // Note: That's a Boolean OR not an
                             // uppercase i or a lowercase L!
         #local HypoXZ=sqrt(pow(CD.x, 2)+pow(CD.z, 2));
         #local VCorr=pow(vlength(CD), 2)/pow(HypoXZ, 2);
         #local CosThetaX=CD.x/HypoXZ;
         #local CosThetaZ=CD.z/HypoXZ;
         #if (CD.x=0)
            #local ShearX=0;
         #else
            #local ShearX=(CD.y/CD.x)*pow(CosThetaX, 2);
         #end
         #if (CD.z=0)
            #local ShearZ=0;
         #else
            #local ShearZ=(CD.y/CD.z)*pow(CosThetaZ, 2);
         #end
         #declare NoFall=transform {
             matrix <1, 0, 0, ShearX, VCorr, ShearZ, 0, 0, 1, 0, 0, 0>
         }
      #else
         #warning "Viewing vector is perpendicular to XZ-plane.\n"
         #warning "Camera changed to default type.\n"
         #declare NoFall=transform {
            matrix <1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0>
         }
      #end
    #else
       #if (CD.x!=0 | CD.y!=0) // Note: That's a Boolean OR not an
                               //uppercase i or a lowercase L!
          #local HypoXY=sqrt(pow(CD.x, 2)+pow(CD.y, 2));
          #local VCorr=pow(vlength(CD), 2)/pow(HypoXY, 2);
          #local CosThetaX=CD.x/HypoXY;
          #local CosThetaY=CD.y/HypoXY;
          #if (CD.x=0)
          #local ShearX=0;
       #else
          #local ShearX=(CD.z/CD.x)*pow(CosThetaX, 2);
       #end
       #if (CD.y=0)
          #local ShearY=0;
       #else
          #local ShearY=(CD.z/CD.y)*pow(CosThetaY, 2);
       #end
       #declare NoFall=transform {
          matrix <1, 0, 0, 0, 1, 0, ShearX, ShearY, VCorr, 0, 0, 0>
       }
       #else
         #warning "Viewing vector is perpendicular to XY-plane.\n"
         #warning "Camera changed to default type.\n"
         #declare NoFall=transform {
            matrix <1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0>
         }
      #end
   #end
#end

/*****************USAGE1**********************

#declare CamPos=<Xc, Yc, Zc>;// Just replace <Xc,Yc,Zc> with location vector
#declare CamLook=<Xl, Yl, Zl>;  // -"-    -"-   <Xl,Yl,Zl> with look_at
vector
[#declare Up_Z=1;] // Only use this #declare when using right-handed
coordinates

camera {
        FieldCam ()
        perspective
        location CamPos
        [angle Whatever] // Not essential but can be used
        [right If_you_want] // Also not essential but can be used
        up y | up z //whichever you need
        transform {NoFall}
        look_at CamLook
}
*************USAGE 2**********************
Don't forget to switch vista buffer off by putting Vista_Buffer=0 in
your .ini file or using -uv on the command line.
******************************************************************/

I have never tested the macro on any scenes in which the viewing axes
are anything but either 'up y' or 'up z' so ymmv with your rotated camera.

John
-- 
"Eppur si muove" - Galileo Galilei


Post a reply to this message

From: Doctor John
Subject: Re: lens shift camera
Date: 10 Sep 2009 07:17:41
Message: <4aa8e055$1@news.povray.org>
Additional: When I get home this evening, I'll test with your unusual up
vector. If I hit problems then I'll have an excuse to rewrite the macro
to deal with it (in my copious free time)

John
-- 
"Eppur si muove" - Galileo Galilei


Post a reply to this message

From: Doctor John
Subject: Re: lens shift camera
Date: 11 Sep 2009 06:25:33
Message: <4aaa259d@news.povray.org>
tony wrote:
> Has povray lens shift camera for architecture? How to do?
> 
> Thank you all.
> 
> Tony
> 
> 

OK, Tony, i've now had a chance to play with your code.
Firstly, I don't quite understand why you're using such an unusual up
vector; you run into all sorts of problems with it. I suspect that this
is a product of the conversion process from Blender to Yafray but is
totally unnecessary in Povray. I suggest you read "3.3.1.1.5 Up and
Right Vectors" in the manual to understand why and how they're used.

Secondly, the FieldCam() macro was developed with an assumption that the
majority of people would be using either the standard left-hand system
or, at a pinch, the right-hand system, so you would use 'up y' or 'up z'
respectively. The macro looks at the camera position and the look-at
point and calculates the shearing values to ensure that the image plane
is always parallel to your chosen up vector. Unfortunately in its
present incarnation these vectors can only be <0,1,0> or <0,0,1> so the
camera is acting as if it had a limited shift function i.e it cannot
shift in y and x planes simultaneously. I am thinking about extending
its functionality but the macro would then need a total rewrite.

Lastly, try this in your scene:

#declare CamPos=<7.48113,5.34367,-6.50764>;
#declare CamLook=<6.82627,4.89842,-5.896970>;

camera {
        FieldCam ()
        perspective
        location CamPos
        angle 49.1343
        right (image_width/image_height)*x
        up y
        transform {NoFall}
        look_at CamLook
}
......and don't forget to switch off your vista buffers (-uv on the
command line)

John
-- 
"Eppur si muove" - Galileo Galilei


Post a reply to this message

From: tony
Subject: Re: lens shift camera
Date: 11 Sep 2009 10:40:00
Message: <web.4aaa60d6f237a03d15c9dce10@news.povray.org>
Doctor John:

After reading the documentation and perform various tests I think we are talking
about different things:

1. Camera parameters
2. Lens parameters.

I put several renders with different values of lens shift so you can understand
what I get, if possible with povray:


http://i750.photobucket.com/albums/xx142/tony_p2009/lensshift.jpg

Is it possible on povray?

Thanks.

Tony


Post a reply to this message

From: Doctor John
Subject: Re: lens shift camera
Date: 12 Sep 2009 07:47:17
Message: <4aab8a45@news.povray.org>
tony wrote:
> Doctor John:
> 
> After reading the documentation and perform various tests I think we are talking
> about different things:
> 
> 1. Camera parameters
> 2. Lens parameters.
> 
> I put several renders with different values of lens shift so you can understand
> what I get, if possible with povray:
> 

I don't think we are talking at cross-purposes, and I'll post a few
images to demonstrate what my macro does later ( I'll try to imitate
your test images as much as possible). It may be a couple of days though
as a death in the family has messed things up a bit and I need to
concentrate on that for the moment.

John
-- 
"Eppur si muove" - Galileo Galilei


Post a reply to this message

From: Doctor John
Subject: Re: lens shift camera
Date: 19 Sep 2009 06:58:37
Message: <4ab4b95d@news.povray.org>
Doctor John wrote:
> 
> I don't think we are talking at cross-purposes, and I'll post a few
> images to demonstrate what my macro does later ( I'll try to imitate
> your test images as much as possible). It may be a couple of days though
> as a death in the family has messed things up a bit and I need to
> concentrate on that for the moment.
> 
> John

Sorry for the delay, I've now got what you wanted. See p.b.i for the
first test images. The code for the camera is:
=============================================================

#declare CamPos=<0, 0, -10.5>;
#declare CamLook=<0, 0, 0>;
#declare Distance=vlength(CamLook-CamPos);
#declare ShiftX=0.0; //use whatever numbers you need here n<1
#declare ShiftY=0.0; //use whatever numbers you need here n<1
camera {
	perspective
	location CamPos
	look_at CamLook
	right x*image_width/image_height
	up <0, 1, 0>
	transform {
		matrix
		<1,0,0,
		0,1,0,
		ShiftX,ShiftY,1,
		ShiftX*Distance,ShiftY*Distance,0>
	}
}
==============================================================
I'm going to merge this with my FieldCam work to produce a (close to)
fully functioning studio camera

John
-- 
"Eppur si muove" - Galileo Galilei


Post a reply to this message

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