POV-Ray : Newsgroups : povray.general : perspective user defined camera? Server Time
21 Dec 2024 21:13:25 EST (-0500)
  perspective user defined camera? (Message 1 to 10 of 18)  
Goto Latest 10 Messages Next 8 Messages >>>
From: ingo
Subject: perspective user defined camera?
Date: 26 Jan 2019 10:07:05
Message: <XnsA9E3A3F647A49seed7@news.povray.org>
How do I get the proper functions for defining a perspective camera as a 
user_defined one? There's all kind of stuff I can calculate, but can't 
get it into functions. Been at it for a few days, must say that young 
blokes playing games a meter away doesn't help either.

I'd like to define location look at and angle, possibly roll. Below one 
of many approaches,

ingo

---%<------%<------%<---

#version 3.8;
global_settings {assumed_gamma 1}
// perspective camera as user_defined

#declare Loc   = <0,0.5,0>;
#declare Look  = <0,0,1>;
#declare Angle = 90;
#declare Up    = <0,1,0>;
//#declare Roll = <0,0,0>;

#declare AR = image_width/image_height;
#declare Right = <AR,0,0>;

#declare Distance = 0.5*vlength(Right)/tan((radians(Angle))/2);

#declare Direction = vnormalize(Look-Loc);  //W
#declare U = vnormalize(vcross(Up,Direction));  
#declare V = vcross(Direction,U);
// Roll, rotate cam around Direction 
// transforms.inc : Axis_Rotate_Trans(Axis, Angle)


camera {
  user_defined
  location {
    function{u*AR}
    function{v}
    function{Distance}
  }                             
  direction{
    function{u*AR}
    function{v}
    function{Distance}
  }
} 
//camera{location Loc look_at Look angle Angle}

background{rgb 1}
light_source {<100,100,-100> rgb 1}
light_source {<0,0,0> rgb .1}
sphere{< 0,0  , 2>,0.5 texture{pigment{checker rgb 1 rgb 0}}} //+Z
sphere{< 0,0.5, 2>,0.2 pigment{rgb 1}}
sphere{< 0,0  ,-2>,0.5 texture{pigment{checker rgb 1 rgb x}}} //-Z
sphere{< 0,0.5,-2>,0.2 pigment{rgb x}}
sphere{< 2,0  , 0>,0.5 texture{pigment{checker rgb 1 rgb y}}} //+X
sphere{< 2,0.5, 0>,0.2 pigment{rgb y}}
sphere{<-2,0  , 0>,0.5 texture{pigment{checker rgb 1 rgb z}}} //-X
sphere{<-2,0.5, 0>,0.2 pigment{rgb z}}


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: perspective user defined camera?
Date: 27 Jan 2019 02:45:00
Message: <web.5c4d601462f292196ac8a0470@news.povray.org>
ingo <ing### [at] tagpovrayorg> wrote:
> How do I get the proper functions for defining a perspective camera as a
> user_defined one? There's all kind of stuff I can calculate, but can't
> get it into functions. Been at it for a few days, must say that young
> blokes playing games a meter away doesn't help either.
>
> I'd like to define location look at and angle, possibly roll.
> ...

Hi Ingo

The code below shows how you can transform the direction-functions for a user
defined camera.

--
Tor Olav
http://subcube.com

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.8;

global_settings { assumed_gamma 1.0 }

#include "colors.inc"
#include "transforms.inc"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare pLocation = <0.0, 0.5, -6.0>;
#declare pLookAt = <0.0, 0.0, 1.0>;
#declare vDirection = pLookAt - pLocation;
#declare vRight = image_width/image_height*x;
#declare vUp = y;
#declare Angle = 90;

#declare vNewDirection = vDirection + 2.5*y;
#declare RotationAngle = 60;

#declare DirectionTransform =
    transform {
        Reorient_Trans(vDirection, vNewDirection)
        Axis_Rotate_Trans(vNewDirection, RotationAngle)
    }

#declare vT_X = vtransform(x, DirectionTransform);
#declare X_X = vT_X.x;
#declare X_Y = vT_X.y;
#declare X_Z = vT_X.z;

#declare vT_Y = vtransform(y, DirectionTransform);
#declare Y_X = vT_Y.x;
#declare Y_Y = vT_Y.y;
#declare Y_Z = vT_Y.z;

#declare vT_Z = vtransform(z, DirectionTransform);
#declare Z_X = vT_Z.x;
#declare Z_Y = vT_Z.y;
#declare Z_Z = vT_Z.z;

// To show where these components belong in a transformation matrix
//
// #declare vT_O = vtransform(<0, 0, 0>, DirectionTransform);
// #declare O_X = vT_O.x;
// #declare O_Y = vT_O.y;
// #declare O_Z = vT_O.z;
//
// #declare Transform =
//     transform {
//         matrix <
//             X_X, X_Y, X_Z,
//             Y_X, Y_Y, Y_Z,
//             Z_X, Z_Y, Z_Z,
//             O_X, O_Y, O_Z
//         >
//     }

#declare DX_Fn = function(u, v) { image_width*u };
#declare DY_Fn = function(u, v) { image_height*v };
#declare DZ_Fn = function(u, v) { image_width/2/tan(radians(Angle/2)) };

#declare NewDX_Fn =
    function(u, v) {
        0
        + X_X*DX_Fn(u, v)
        + Y_X*DY_Fn(u, v)
        + Z_X*DZ_Fn(u, v)
    }
#declare NewDY_Fn =
    function(u, v) {
        0
        + X_Y*DX_Fn(u, v)
        + Y_Y*DY_Fn(u, v)
        + Z_Y*DZ_Fn(u, v)
    }
#declare NewDZ_Fn =
    function(u, v) {
        0
        + X_Z*DX_Fn(u, v)
        + Y_Z*DY_Fn(u, v)
        + Z_Z*DZ_Fn(u, v)
}

#declare LocationX = pLocation.x;
#declare LocationY = pLocation.y;
#declare LocationZ = pLocation.z;

camera {
    user_defined
    location {
        function { LocationX }
        function { LocationY }
        function { LocationZ }
    }
    direction {
        function { NewDX_Fn(u, v) }
        function { NewDY_Fn(u, v) }
        function { NewDZ_Fn(u, v) }
    }
}

/*
camera {
    perspective
    location pLocation
    direction vtransform(vDirection, DirectionTransform)
    right vtransform(vRight, DirectionTransform)
    up vtransform(vUp, DirectionTransform)
    angle Angle
}
*/

/*
camera {
    user_defined
    location {
        function { LocationX }
        function { LocationY }
        function { LocationZ }
    }
    direction {
        function { DX_Fn(u, v) }
        function { DY_Fn(u, v) }
        function { DZ_Fn(u, v) }
    }
}
*/

/*
camera {
    perspective
    location pLocation
    direction vDirection
    right vRight
    up vUp
    angle Angle
}
*/

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare Radius = 0.1;

sphere { < 0,  0,  2>, Radius pigment { checker White Black } }
sphere { < 0,  0, -2>, Radius pigment { checker White Red   } }
sphere { < 2,  0,  0>, Radius pigment { checker White Green } }
sphere { <-2,  0,  0>, Radius pigment { checker White Blue  } }

union {
    sphere { < 0,  0,  2>, Radius pigment { White } }
    sphere { < 0,  0, -2>, Radius pigment { Red   } }
    sphere { < 2,  0,  0>, Radius pigment { Green } }
    sphere { <-2,  0,  0>, Radius pigment { Blue  } }
    translate 0.5*y
}

background { color Gray20 }

light_source { <1, 1, -1>*100 White }
light_source { <0, 0, 0> Gray10 }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: perspective user defined camera?
Date: 27 Jan 2019 03:45:00
Message: <web.5c4d6e4362f292196ac8a0470@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> ingo <ing### [at] tagpovrayorg> wrote:
> > How do I get the proper functions for defining a perspective camera as a
> > user_defined one? There's all kind of stuff I can calculate, but can't
> > get it into functions. Been at it for a few days, must say that young
> > blokes playing games a meter away doesn't help either.
> >
> > I'd like to define location look at and angle, possibly roll.
> > ...
>
> Hi Ingo
>
> The code below shows how you can transform the direction-functions for a user
> defined camera.
>...

I just noticed a problem with my code. The ordinary cameras doe not produce
exactly the same result as the user defined ones. That's because I'm not
calculating new vRight and vUp vectors after the direction vector has been
calculated. To get same results for the two camera types you can delete the
pLookAt point and set the vDirection vector "manually", e.g. like this:

#declare vDirection = 10*z;

Alternatively you can keep pLookAt and vDirection and then compose a "look at"
transformation and apply it to the vRight and vUp vectors.

--
Tor Olav
http://subcube.com


Post a reply to this message

From: ingo
Subject: Re: perspective user defined camera?
Date: 27 Jan 2019 04:03:59
Message: <XnsA9E466667FD4Dseed7@news.povray.org>
in news:web.5c4d6e4362f292196ac8a0470@news.povray.org Tor Olav
Kristensen wrote: 

> Alternatively you can keep pLookAt and vDirection and then compose a
> "look at" transformation and apply it to the vRight and vUp vectors.
> 
> 

Thank you Tor Olav!! Matrices are scary ;) I'll give it a go,

ingo


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: perspective user defined camera?
Date: 27 Jan 2019 18:50:01
Message: <web.5c4e437c62f29219264be49d0@news.povray.org>
ingo <ing### [at] tagpovrayorg> wrote:
> in news:web.5c4d6e4362f292196ac8a0470@news.povray.org Tor Olav
> Kristensen wrote:
>
> > Alternatively you can keep pLookAt and vDirection and then compose a
> > "look at" transformation and apply it to the vRight and vUp vectors.
> >
> >
>
> Thank you Tor Olav!! Matrices are scary ;) I'll give it a go,

No problem. It was an interesting problem to solve.

You don't have to deal much with matrices to do this. (I just showed the
relationship in case anyone is interested.)

Below is some more code for you.

--
Tor Olav
http://subcube.com

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.8;

global_settings { assumed_gamma 1.0 }

#include "colors.inc"
#include "transforms.inc"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Default directions for both camera types. (The default right vector
// can be considered to be +1*x for the user defined camera.)

#declare vDirection_0 = +1*z;
#declare vRight_0 = +image_width/image_height*x;
#declare vUp_0 = +1*y;

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare SphereRadius = 0.1;

#declare pLocation = <0.0, 0.5, -6.0>;
#declare Angle = 90;

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare PerspectiveCamera_0 =
    camera {
        perspective
        location pLocation
        direction vDirection_0
        right vRight_0
        up vUp_0
        angle Angle
    }

#declare LocationX = pLocation.x;
#declare LocationY = pLocation.y;
#declare LocationZ = pLocation.z;

#declare D0_X_Fn = function(u, v) { image_width*u };
#declare D0_Y_Fn = function(u, v) { image_height*v };
#declare D0_Z_Fn = function(u, v) { image_width/2/tan(radians(Angle/2)) };

#declare UserDefinedCamera_0 =
    camera {
        user_defined
        location {
            function { LocationX }
            function { LocationY }
            function { LocationZ }
        }
        direction {
            function { D0_X_Fn(u, v) }
            function { D0_Y_Fn(u, v) }
            function { D0_Z_Fn(u, v) }
        }
    }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare pLookAt = <+1.5, -1.0, 1.0>;

// This sphere should stay in center for these cameras
// sphere { pLookAt, SphereRadius pigment { Magenta } }

#declare vLookAt = pLookAt - pLocation;
#declare LookAtTransform = Reorient_Trans(z, vLookAt)

#declare vDirection_1 = vtransform(vDirection_0, LookAtTransform);
#declare vRight_1 = vtransform(vRight_0, LookAtTransform);
#declare vUp_1 = vtransform(vUp_0, LookAtTransform);

#declare PerspectiveCamera_1 =
    camera {
        perspective
        location pLocation
        direction vDirection_1
        right vRight_1
        up vUp_1
        angle Angle
    }

#declare vT1_X = vtransform(x, LookAtTransform);
#declare X1_X = vT1_X.x;
#declare X1_Y = vT1_X.y;
#declare X1_Z = vT1_X.z;

#declare vT1_Y = vtransform(y, LookAtTransform);
#declare Y1_X = vT1_Y.x;
#declare Y1_Y = vT1_Y.y;
#declare Y1_Z = vT1_Y.z;

#declare vT1_Z = vtransform(z, LookAtTransform);
#declare Z1_X = vT1_Z.x;
#declare Z1_Y = vT1_Z.y;
#declare Z1_Z = vT1_Z.z;

#declare D1_X_Fn =
    function(u, v) {
        0
        + X1_X*D0_X_Fn(u, v)
        + Y1_X*D0_Y_Fn(u, v)
        + Z1_X*D0_Z_Fn(u, v)
    }
;
#declare D1_Y_Fn =
    function(u, v) {
        0
        + X1_Y*D0_X_Fn(u, v)
        + Y1_Y*D0_Y_Fn(u, v)
        + Z1_Y*D0_Z_Fn(u, v)
    }
;
#declare D1_Z_Fn =
    function(u, v) {
        0
        + X1_Z*D0_X_Fn(u, v)
        + Y1_Z*D0_Y_Fn(u, v)
        + Z1_Z*D0_Z_Fn(u, v)
    }
;
#declare UserDefinedCamera_1 =
    camera {
        user_defined
        location {
            function { LocationX }
            function { LocationY }
            function { LocationZ }
        }
        direction {
            function { D1_X_Fn(u, v) }
            function { D1_Y_Fn(u, v) }
            function { D1_Z_Fn(u, v) }
        }
    }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare vNewDirection = <1.5, 1.0, 10>;
#declare RotationAngle = 55;

// This sphere should stay in center for these cameras while rotating
// them around the vNewDirection vector
// sphere { pLocation + vNewDirection, SphereRadius pigment { Cyan } }

#declare AnotherTransform =
    transform {
        Reorient_Trans(vDirection_1, vNewDirection)
        Axis_Rotate_Trans(vNewDirection, RotationAngle)
    }

#declare PerspectiveCamera_2a =
    camera {
        PerspectiveCamera_1
        transform {
            translate -pLocation
            AnotherTransform
            translate +pLocation
        }
    }

#declare vDirection_2 = vtransform(vDirection_1, AnotherTransform);
#declare vRight_2 = vtransform(vRight_1, AnotherTransform);
#declare vUp_2 = vtransform(vUp_1, AnotherTransform);

#declare PerspectiveCamera_2b =
    camera {
        perspective
        location pLocation
        direction vDirection_2
        right vRight_2
        up vUp_2
        angle Angle
    }

#declare vT2_X = vtransform(x, AnotherTransform);
#declare X2_X = vT2_X.x;
#declare X2_Y = vT2_X.y;
#declare X2_Z = vT2_X.z;

#declare vT2_Y = vtransform(y, AnotherTransform);
#declare Y2_X = vT2_Y.x;
#declare Y2_Y = vT2_Y.y;
#declare Y2_Z = vT2_Y.z;

#declare vT2_Z = vtransform(z, AnotherTransform);
#declare Z2_X = vT2_Z.x;
#declare Z2_Y = vT2_Z.y;
#declare Z2_Z = vT2_Z.z;

#declare D2_X_Fn =
    function(u, v) {
        0
        + X2_X*D1_X_Fn(u, v)
        + Y2_X*D1_Y_Fn(u, v)
        + Z2_X*D1_Z_Fn(u, v)
    }
;
#declare D2_Y_Fn =
    function(u, v) {
        0
        + X2_Y*D1_X_Fn(u, v)
        + Y2_Y*D1_Y_Fn(u, v)
        + Z2_Y*D1_Z_Fn(u, v)
    }
;
#declare D2_Z_Fn =
    function(u, v) {
        0
        + X2_Z*D1_X_Fn(u, v)
        + Y2_Z*D1_Y_Fn(u, v)
        + Z2_Z*D1_Z_Fn(u, v)
    }
;
#declare UserDefinedCamera_2 =
    camera {
        user_defined
        location {
            function { LocationX }
            function { LocationY }
            function { LocationZ }
        }
        direction {
            function { D2_X_Fn(u, v) }
            function { D2_Y_Fn(u, v) }
            function { D2_Z_Fn(u, v) }
        }
    }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

/*
camera { PerspectiveCamera_0 }
camera { UserDefinedCamera_0 }

camera { PerspectiveCamera_1 }
camera { UserDefinedCamera_1 }

camera { PerspectiveCamera_2a }
camera { PerspectiveCamera_2b }
camera { UserDefinedCamera_2 }
*/

camera { UserDefinedCamera_2 }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

sphere { < 0,  0,  2>, SphereRadius pigment { checker White Black } }
sphere { < 0,  0, -2>, SphereRadius pigment { checker White Red   } }
sphere { < 2,  0,  0>, SphereRadius pigment { checker White Green } }
sphere { <-2,  0,  0>, SphereRadius pigment { checker White Blue  } }

union {
    sphere { < 0,  0,  2>, SphereRadius pigment { White } }
    sphere { < 0,  0, -2>, SphereRadius pigment { Red   } }
    sphere { < 2,  0,  0>, SphereRadius pigment { Green } }
    sphere { <-2,  0,  0>, SphereRadius pigment { Blue  } }
    translate 0.5*y
}

background { color Gray20 }

light_source { <1, 1, -1>*100 White }
light_source { <0, 0, 0> Gray10 }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

From: Bald Eagle
Subject: Re: perspective user defined camera?
Date: 27 Jan 2019 21:25:01
Message: <web.5c4e678b62f29219765e06870@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:

> No problem. It was an interesting problem to solve.
>
> You don't have to deal much with matrices to do this. (I just showed the
> relationship in case anyone is interested.)

This is only tangentially related:

Would something related to this be the preferred way to set up a scene so that
an object would occupy a specific position on the screen - back calculating to
determine where the camera should be?

So, let's say there are 2 views (I think that might be necessary to get Z), each
showing the same cube (and maybe a reference point like the origin) from a
different vantage point.
I'm presuming that a matrix would be the best way to reverse-project back to
where the camera should be?

It's just something that struck me with the functions, and matrices, and
user-define camera...


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: perspective user defined camera?
Date: 27 Jan 2019 21:35:00
Message: <web.5c4e6a2962f2921970c5131a0@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
>...
> Below is some more code for you.
>...

BTW:
It would be nice if user defined cameras could be transformed directly like
other cameras. E.g. like this:

camera {
    user_defined
    location 0*z
    direction {
        function { image_width*u }
        function { image_height*v }
        function { image_width/2/tan(radians(Angle/2)) }
    }
    transform {
        LookAtTransform
        AnotherTransform
        translate pLocation
    }
}

- Then one would not have to transform the functions in order to transform the
camera.

The transformation block above does not seem to have any effect on the user
defined camera in the 3.8 version of POV-Ray that I'm using right now on my
Ubuntu PC; 3.8.0-x.freetype.unofficial (g++ 7 @ x86_64-pc-linux-gnu). I haven't
tested this on any 3.8 versions for Windows yet.

--
Tor Olav
http://subcube.com


Post a reply to this message

From: ingo
Subject: Re: perspective user defined camera?
Date: 28 Jan 2019 01:58:24
Message: <XnsA9E5511C8FD22seed7@news.povray.org>
in news:web.5c4e437c62f29219264be49d0@news.povray.org Tor Olav Kristensen 
wrote:

> Below is some more code for you

That will take some time to digest, thanks again Tor Olav,

Ingo


Post a reply to this message

From: ingo
Subject: Re: perspective user defined camera?
Date: 28 Jan 2019 12:27:28
Message: <XnsA9E5BBC3FC244seed7@news.povray.org>
in news:web.5c4e678b62f29219765e06870@news.povray.org Bald Eagle wrote:

> back calculating to
> determine where the camera should be?
> 

Kind of an inverse screen.inc?

ingo


Post a reply to this message

From: ingo
Subject: Re: perspective user defined camera?
Date: 28 Jan 2019 12:40:23
Message: <XnsA9E5BDF46A3E4seed7@news.povray.org>
in news:web.5c4e6a2962f2921970c5131a0@news.povray.org Tor Olav
Kristensen wrote: 

> BTW:
> It would be nice if user defined cameras could be transformed
> directly like other cameras. E.g. like this:
> 

Thats what I thought too, but,

This morning after seeing your new code I made a laarge pot of strong 
coffee and started tinkering. It thought me where I went wrong on several 
occasions. 
I consistenly threw away X1_Y and X1_Z components in simmilar constructs 
;(
  #local vT1_X = vtransform(x, LookAtTransform);
  #local X1_X = vT1_X.x;
  #local X1_Y = vT1_X.y;
  #local X1_Z = vT1_X.z;

After getting more grip on your code I turned it in a macro and that adds 
flexibility you won't have with direct transforms.

This way you can spend your attention to the screen --> scene transfer 
and then just call the macro. It should work for most camera types.
I can also see it useful for setting up stereo cams, parallel or toed in. 
Or for greating images with insets where a small region of the image is 
rendered as a detail for a bigger scene.
I added it to a tile rendering camera without problem.
So, a lot of options to investigate 

ingo

very unfinished:
---%<------%<------%<---
#version 3.8;

global_settings { assumed_gamma 1.0 }

#include "colors.inc"
#include "transforms.inc"

#macro ucdPerspective(pLocation,pLookAt,Angle)
  #local D0_X_Fn = function(u, v) {u*image_width };
  #local D0_Y_Fn = function(u, v) {v*image_height};
  #local D0_Z_Fn = function(u, v) {image_width/2/tan(radians(Angle/2))};
  #local LocationX = pLocation.x;
  #local LocationY = pLocation.y;
  #local LocationZ = pLocation.z;
  #local(D1_X_Fn, D1_Y_Fn, D1_Z_Fn) = ucdLookAtTransform(
    D0_X_Fn,D0_Y_Fn,D0_Z_Fn,pLocation,pLookAt,Angle
  );
  camera {
    user_defined
    location {
      function { LocationX }
      function { LocationY }
      function { LocationZ }
    }
    direction {
    function { D1_X_Fn(u, v) }
    function { D1_Y_Fn(u, v) }
    function { D1_Z_Fn(u, v) }
    }
  }
#end

#macro ucdLookAtTransform(
  D0_X_Fn,D0_Y_Fn,D0_Z_Fn,pLocation,pLookAt,Angle
)
  #local vDirection_0 = +1*z;
  #local vRight_0 = +image_width/image_height*x;
  #local vUp_0 = +1*y;
//the three above should probably move to the cam definition
  #local vLookAt = pLookAt - pLocation;
  #local LookAtTransform = Reorient_Trans(z, vLookAt)
  #local vDirection_1 = vtransform(vDirection_0, LookAtTransform);
  #local vRight_1 = vtransform(vRight_0, LookAtTransform);
  #local vUp_1 = vtransform(vUp_0, LookAtTransform);
  #local vT1_X = vtransform(x, LookAtTransform);
  #local X1_X = vT1_X.x;
  #local X1_Y = vT1_X.y;
  #local X1_Z = vT1_X.z;
  #local vT1_Y = vtransform(y, LookAtTransform);
  #local Y1_X = vT1_Y.x;
  #local Y1_Y = vT1_Y.y;
  #local Y1_Z = vT1_Y.z;
  #local vT1_Z = vtransform(z, LookAtTransform);
  #local Z1_X = vT1_Z.x;
  #local Z1_Y = vT1_Z.y;
  #local Z1_Z = vT1_Z.z;
  #local D1_X_Fn =
      function(u, v) {
          0
          + X1_X*D0_X_Fn(u, v)
          + Y1_X*D0_Y_Fn(u, v)
          + Z1_X*D0_Z_Fn(u, v)
      }
  ;
  #local D1_Y_Fn =
      function(u, v) {
          0
          + X1_Y*D0_X_Fn(u, v)
          + Y1_Y*D0_Y_Fn(u, v)
          + Z1_Y*D0_Z_Fn(u, v)
      }
  ;
  #local D1_Z_Fn =
      function(u, v) {
          0
          + X1_Z*D0_X_Fn(u, v)
          + Y1_Z*D0_Y_Fn(u, v)
          + Z1_Z*D0_Z_Fn(u, v)
      }
  ;
  (D1_X_Fn, D1_Y_Fn, D1_Z_Fn)
#end

#declare pLocation = <0.0, 0.5, -0.0>;
#declare pLookAt = <0.0, 0.0, 1.0>;
#declare Angle = 90;

ucdPerspective(pLocation,pLookAt,Angle)

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#declare SphereRadius = 0.3;

sphere { < 0,  0,  2>, SphereRadius pigment { checker White Black } }
sphere { < 0,  0, -2>, SphereRadius pigment { checker White Red   } }
sphere { < 2,  0,  0>, SphereRadius pigment { checker White Green } }
sphere { <-2,  0,  0>, SphereRadius pigment { checker White Blue  } }

union {
    sphere { < 0,  0,  2>, SphereRadius pigment { White } }
    sphere { < 0,  0, -2>, SphereRadius pigment { Red   } }
    sphere { < 2,  0,  0>, SphereRadius pigment { Green } }
    sphere { <-2,  0,  0>, SphereRadius pigment { Blue  } }
    translate 0.5*y
}

background { color Gray80 }

light_source { <1, 1, -1>*100 White }
light_source { <0, 0, 0> Gray20 }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

Goto Latest 10 Messages Next 8 Messages >>>

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