POV-Ray : Newsgroups : povray.general : user_define camera and undefined location and direction Server Time
28 Nov 2025 04:06:54 EST (-0500)
  user_define camera and undefined location and direction (Message 1 to 4 of 4)  
From: Paul Bourke
Subject: user_define camera and undefined location and direction
Date: 25 Nov 2025 04:45:00
Message: <web.69257a6a703910fd54975956784a083c@news.povray.org>
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.


Post a reply to this message

From: ingo
Subject: Re: user_define camera and undefined location and direction
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

From: Kenneth
Subject: Re: user_define camera and undefined location and direction
Date: 25 Nov 2025 20:25:00
Message: <web.692654fe8ef58e1de83955656e066e29@news.povray.org>
"ingo" <nomail@nomail> wrote:
> "Paul Bourke" <pau### [at] gmailcom> wrote:
> >
> > 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?
> [code]
>

I have not yet played with the new user-defined camera, so I ran your code just
to see what it produces. ;-)

I changed your background{rgb 1} to rgb <0,1,0>, to give myself a better
understanding of the rendered result and how it relates to Paul Bourke's
question.

The background *within* your box map does indeed show up as green now-- but does
PB's question concern the *surrounding* area? That renders as black, regardless
of the background color.


Post a reply to this message

From: Bald Eagle
Subject: Re: user_define camera and undefined location and direction
Date: 26 Nov 2025 08:10:00
Message: <web.6926fb0f8ef58e1d9839f6ab25979125@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:

> The background *within* your box map does indeed show up as green now-- but does
> PB's question concern the *surrounding* area? That renders as black, regardless
> of the background color.

Go to the camera page on the wiki.

User defined projection
New to version 3.8 a user defined camera capability was added.
Similar to the mesh camera  <---

Mesh:
Keep in mind that a ray that is not associated with a face is not the same thing
as a ray that is but that, when shot, hits nothing.

The latter will return a pixel (even if it is transparent or the background
color),

whereas the former causes the ray to not be shot in the first place; hence, it
is not included in the calculation of the average for the pixel.

So hopefully you can parse that and see why the two are different.

- BW


Post a reply to this message

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