POV-Ray : Newsgroups : povray.general : user_define camera and undefined location and direction : Re: user_define camera and undefined location and direction Server Time
28 Nov 2025 02:35:46 EST (-0500)
  Re: user_define camera and undefined location and direction  
From: ingo
Date: 25 Nov 2025 06:10:00
Message: <web.69258e148ef58e1d17bac71e8ffb8ce3@news.povray.org>
"Paul Bourke" <pau### [at] gmailcom> wrote:
> As some of you may know I'm now a huge fan of the user_defined camera in version
> 3.8.
>
> A question, how does one deal with positions that are undefined for the
> particular camera. For example, for a fisheye the points outside the circle are
> usually deemed to be undefined and shaded as per the background.
>
> How does one do this with the user_defined camera? That is, specify that some
> positions should be assigned the background colour.

I thought it did it automatic?


box map:
---%<------%<------%<---
#include "transforms.inc"

/*== Map input value x in range(y, z) to range(-0.5, 0.5)*/
#declare Map05 = function(x,y,z){((x-y)/(z-y))-0.5};



#macro udcCubeCross(Loc)
  /*==
  Renders cross shaped image for cube map.
  Image aspect ratio 4:3
  //+w800 +h600 +a0.1 +am3

  Look at:
     +Y
  +X,-Z,-Y,+Z
     -Y

  Loc: location of the camera.
  */
  #local CadreX = function(u,v){
    select(//+Y
      (v>1/6 & u>-0.25 & u<0),
      0,
      select(
        (v<1/6 & v>-1/6),
        0,
        select(//-Y
          (v<1/6 & u>-0.25 & u<0),
          0,
          0,
          Map05(u,0,-0.25) //-Y true
        ),
        select(//-X
          (u<-0.25),
          0,
          select(//-Z
            (u>-0.25 & u<0),
            0,
            select(//+X
              (u>0 & u<0.25),
              0,
              select(//+Z
                (u>0.25),
                0,
                0,
                Map05(u,0.25,0.5)//+Z true
              ),
              -0.5//-X true
            ),
            Map05(u,0,-0.25)//-Z true
          ),
          0.5//+X true
        )
      ),
      Map05(u,0,-0.25)//+Ytrue
    )
  };
  #local CadreY = function(u,v){
    select(//+Y
      (v>1/6 & u>-0.25 & u<0),
      0,
      select(
        (v<1/6 & v>-1/6),
        0,
        select(//-Y
          (v<1/6 & u>-0.25 & u<0),
          0,
          0,
          -0.5//-Y true
        ),
        select(//-X
          (u<-0.25),
          0,
          select(//-Z
            (u>-0.25 & u<0),
            0,
            select(//+X
              (u>0 & u<0.25),
              0,
              select(//+Z
                (u>0.25),
                0,
                0,
                Map05(v,-1/6,1/6)//+Z true
              ),
              Map05(v,-1/6,1/6)//+X true
            ),
            Map05(v,-1/6,1/6)//-Z true
          ),
          Map05(v,-1/6,1/6)//-X true
        )
      ),
      0.5//+Ytrue
    )
  };
  #local CadreZ = function(u,v){
    select(//+Y
      (v>1/6 & u>-0.25 & u<0),
      0,
      select(
        (v<1/6 & v>-1/6),
        0,
        select(//-Y
          (v<1/6 & u>-0.25 & u<0),
          0,
          0,
          Map05(v,-1/6,-0.5)//-Y true
        ),
        select(//-X
          (u<-0.25),
          0,
          select(//-Z
            (u>-0.25 & u<0),
            0,
            select(//+X
              (u>0 & u<0.25),
              0,
              select(//+Z
                (u>0.25),
                0,
                0,
                0.5//+Z true
              ),
              Map05(u,0,0.25)//-X true
            ),
            -0.5//-Z true
          ),
          Map05(u,-0.25,-0.5) //+X true
        )
      ),
      Map05(v,1/6,0.5)//+Ytrue
    )
  };
  camera{
    user_defined
    location Loc
    direction {
      function{CadreX(u,v)}
      function{CadreY(u,v)}
      function{CadreZ(u,v)}
    }
  }
#end

udcCubeCross(<0,0,0>)

background{rgb 1}

light_source {<0,0,0> rgb 1}
light_source {<2,0,0> rgb 1}
light_source {<0,2,0> rgb 1}
light_source {<0,0,2> rgb 1}

light_source {<-2,0,0> rgb 1}
light_source {<0,-2,0> rgb 1}
light_source {<0,0,-2> rgb 1}

sphere{< 2,0  ,0>,0.5 pigment{rgb x}}  //X:<1,v,u> +X
sphere{< 2,0.5,0>,0.1 pigment{rgb x}}  //          +X
sphere{<-2,0  ,0>,0.5 pigment{rgb x+z}}
sphere{<-2,0.5,0>,0.1 pigment{rgb x+z}}

sphere{< 0, 2,0>,0.5 pigment{rgb y}}   //Y:<u,1,v>
sphere{<.5, 2,0>,0.1 pigment{rgb y}}
sphere{< 0,-2,0>,0.5 pigment{rgb y+z}}
sphere{<.5,-2,0>,0.1 pigment{rgb y+z}}

sphere{<0,0  , 2>,0.5 pigment{rgb z}}   //Z:<u,v,1>  +Z
sphere{<0,0.5, 2>,0.1 pigment{rgb z}}
sphere{<0,0  ,-2>,0.5 pigment{rgb x+y}} //           -Z
sphere{<0,0.5,-2>,0.1 pigment{rgb x+y}}

#declare Radius = 2;
#for(I,1,18,1)
 torus{1,0.04 sturm rotate<90,0,0> rotate<0,I*10,0> pigment{rgb I/36}  }
#end


box{-0.3,0.3 translate < 1,-1, 1> pigment{rgb x}}
box{-0.3,0.3 translate <-1,-1, 1> pigment{rgb y}}
box{-0.3,0.3 translate < 1,-1,-1> pigment{rgb z}}
box{-0.3,0.3 translate <-1,-1,-1> pigment{rgb .5}}

box{-0.3,0.3 translate < 1, 1, 1> pigment{rgb x+y}}
box{-0.3,0.3 translate <-1, 1, 1> pigment{rgb x+z}}
box{-0.3,0.3 translate < 1, 1,-1> pigment{rgb y+z}}
box{-0.3,0.3 translate <-1, 1,-1> pigment{rgb 1}}
---%<------%<------%<---
ingo


Post a reply to this message

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