POV-Ray : Newsgroups : povray.programming : Camera shift Server Time
20 Apr 2024 11:47:19 EDT (-0400)
  Camera shift (Message 1 to 2 of 2)  
From: karpov
Subject: Camera shift
Date: 20 Jan 2008 19:10:00
Message: <web.4793e1de38aeb96eb61d2a840@news.povray.org>
Hi all,

I'm not really a programmer but I'm trying to get Blender's Camera shift to
Povray....
The idea : for a given camera ( and related perspective ) , it allows to shift
the position of the "image plane" and so being able to trace for this camera a
portion of image normally not inside the current "image plane" without changing
the perspective....

So I create a new token in povray : shifty

It's working...well half the way, I'm trying to get exact result between Blender
and Povray

BLENDER :

<a href="http://opendesk.ovh.org/blender.jpg"><img
src="http://opendesk.ovh.org/blender.jpg" border="0"></a>

POVRAY

<a href="http://opendesk.ovh.org/povray.png"><img
src="http://opendesk.ovh.org/povray.png" border="0"></a>


I'm using blend2pov from RCRuiz to export from blender
Here is the code for camera object:



                    pov<<" perspective";

                    pov<<" angle "<<2.0 *
(atan(1/(2.0*mainCamLens/(f_aspect*32.f))))*(180/M_PI);

                }

            }

            else{

                while (line){

                    pov<<line->line<<endl;

                    line=line->next;

                }

            }

            pov<<" location
<"<<maincam_obj->obmat[3][0]<<","<<maincam_obj->obmat[3][2]<<","<<maincam_obj->obmat[3][1]<<">";

            if (cam->type & CAM_ORTHO){

                pov<<" right "<<cam->ortho_scale<<"*x ";

                pov<<" up
"<<cam->ortho_scale/(float(re->r.xsch)/float(re->r.ysch))<<"*y ";

            } else

                pov<<" right "<<float(re->r.xsch)/float(re->r.ysch)<<"*x";
    //pov<<" up y*"<<1+shifty/2;

            pov<<" sky
<"<<re->viewmat[0][1]<<","<<re->viewmat[2][1]<<","<<re->viewmat[1][1]<<">";

And here is the Blender internal code with shiftx and shifty

 /* viewplane fully centered, zbuffer fills in jittered between -.5 and +.5 */
 winside= MAX2(re->winx, re->winy);
 viewplane.xmin= -0.5f*(float)re->winx + shiftx*winside;
 viewplane.ymin= -0.5f*re->ycor*(float)re->winy + shifty*winside;
 viewplane.xmax=  0.5f*(float)re->winx + shiftx*winside;
 viewplane.ymax=  0.5f*re->ycor*(float)re->winy + shifty*winside;

And I've made this change in Povray

    case PERSPECTIVE_CAMERA:

      /* Convert the x coordinate to be a DBL from -0.5 to 0.5. */

      x0 = x / (DBL)Frame.Screen_Width - 0.5  ;

      /* Convert the y coordinate to be a DBL from -0.5 to 0.5. */

      y0 = ((DBL)(Frame.Screen_Height - 1  ) - y  ) / (DBL)Frame.Screen_Height -
0.5 + Frame.Camera->shifty ;

Any Help ?


Post a reply to this message

From: karpov
Subject: Re: Camera shift
Date: 23 Jan 2008 07:55:00
Message: <web.479738255b1ff7e1b61d2a840@news.povray.org>
....Done !

correct code in render.cpp :

x0 = ( x / (DBL)Frame.Screen_Width - 0.5) + shiftx  ;
y0 = (((DBL)(Frame.Screen_Height ) - y -1)  / (DBL)Frame.Screen_Height -0.5  ) +
shifty * right ;


Post a reply to this message

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