diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h index 6ccc48f217e..5ea0960dd4b 100644 --- a/source/blender/makesdna/DNA_camera_types.h +++ b/source/blender/makesdna/DNA_camera_types.h @@ -50,6 +50,7 @@ typedef struct Camera { float passepartalpha, pad1; float clipsta, clipend; float lens, ortho_scale, drawsize; + float shiftx, shifty; /* yafray: dof params */ float YF_dofdist, YF_aperture; diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index 15e7ff63293..a51b4674314 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -455,7 +455,7 @@ void RE_SetCamera(Render *re, Object *camera) Camera *cam=NULL; rctf viewplane; float pixsize, clipsta, clipend; - float lens; + float lens, shiftx=0.0, shifty=0.0, winside; /* question mark */ re->ycor= ( (float)re->r.yasp)/( (float)re->r.xasp); @@ -473,6 +473,8 @@ void RE_SetCamera(Render *re, Object *camera) execute_ipo(&cam->id, cam->ipo); } lens= cam->lens; + shiftx=cam->shiftx; + shifty=cam->shifty; clipsta= cam->clipsta; clipend= cam->clipend; @@ -524,10 +526,11 @@ void RE_SetCamera(Render *re, Object *camera) } /* viewplane fully centered, zbuffer fills in jittered between -.5 and +.5 */ - viewplane.xmin= -0.5f*(float)re->winx; - viewplane.ymin= -0.5f*re->ycor*(float)re->winy; - viewplane.xmax= 0.5f*(float)re->winx; - viewplane.ymax= 0.5f*re->ycor*(float)re->winy; + 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; if(re->flag & R_SEC_FIELD) { if(re->r.mode & R_ODDFIELD) { diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 7e7a790ebad..fb93db8cf93 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -821,11 +821,11 @@ static float Blinn_Spec(float *n, float *l, float *v, float refrac, float spec_p nv= n[0]*v[0]+n[1]*v[1]+n[2]*v[2]; /* Dot product between surface normal and view vector */ if(tangent) nv= sasqrt(1.0f - nv*nv); - if(nv<=0.0) nv= 0.01; /* hrms... */ + if(nv<=0.01) nv= 0.01; /* hrms... */ nl= n[0]*l[0]+n[1]*l[1]+n[2]*l[2]; /* Dot product between surface normal and light vector */ if(tangent) nl= sasqrt(1.0f - nl*nl); - if(nl<=0.0) { + if(nl<=0.01) { return 0.0; } diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index cac9d93d57f..760c0d22648 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -2673,50 +2673,61 @@ static void editing_panel_camera_type(Object *ob, Camera *cam) block= uiNewBlock(&curarea->uiblocks, "editing_panel_camera_type", UI_EMBOSS, UI_HELV, curarea->win); if(uiNewPanel(curarea, block, "Camera", "Editing", 320, 0, 318, 204)==0) return; + uiDefBut(block, LABEL, 10, "Lens:", 10, 180, 150, 20, 0, 0.0, 0.0, 0, 0, ""); + if(cam->type==CAM_ORTHO) { uiDefButF(block, NUM,REDRAWVIEW3D, "Scale:", - 0, 145, 150, 20, &cam->ortho_scale, 0.01, 1000.0, 50, 0, "Specify the ortho scaling of the used camera"); + 10, 160, 150, 20, &cam->ortho_scale, 0.01, 1000.0, 50, 0, "Specify the ortho scaling of the used camera"); } else { uiDefButF(block, NUM,REDRAWVIEW3D, "Lens:", - 0, 145, 150, 20, &cam->lens, 1.0, 250.0, 100, 0, "Specify the lens of the camera"); + 10, 160, 150, 20, &cam->lens, 1.0, 250.0, 100, 0, "Specify the lens of the camera"); } uiDefButS(block, TOG, REDRAWVIEW3D, "Orthographic", - 0, 120, 150, 20, &cam->type, 0, 0, 0, 0, "Render orthogonally"); + 10, 135, 150, 20, &cam->type, 0, 0, 0, 0, "Render orthogonally"); - uiDefBut(block, LABEL, 0, "Clipping:", 0, 90, 150, 20, 0, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Clipping:", 10, 110, 150, 20, 0, 0.0, 0.0, 0, 0, ""); uiBlockBeginAlign(block); uiDefButF(block, NUM,REDRAWVIEW3D, "Start:", - 0, 70, 150, 20, &cam->clipsta, 0.001*grid, 100.0*grid, 10, 0, "Specify the startvalue of the the field of view"); + 10, 90, 150, 20, &cam->clipsta, 0.001*grid, 100.0*grid, 10, 0, "Specify the startvalue of the the field of view"); uiDefButF(block, NUM,REDRAWVIEW3D, "End:", - 0, 50, 150, 20, &cam->clipend, 1.0, 5000.0*grid, 100, 0, "Specify the endvalue of the the field of view"); + 10, 70, 150, 20, &cam->clipend, 1.0, 5000.0*grid, 100, 0, "Specify the endvalue of the the field of view"); uiBlockEndAlign(block); uiDefButF(block, NUM,REDRAWVIEW3D, "Size:", - 0, 25, 150, 20, &cam->drawsize, 0.1*grid, 10.0, 10, 0, "The size that the camera is displayed in the 3D View (different to the object's scale)"); + 170, 25, 150, 20, &cam->drawsize, 0.1*grid, 10.0, 10, 0, "The size that the camera is displayed in the 3D View (different to the object's scale)"); + + uiDefBut(block, LABEL, 0, "Shift:", 10, 45, 150, 20, 0, 0.0, 0.0, 0, 0, ""); + + uiBlockBeginAlign(block); + uiDefButF(block, NUM,REDRAWVIEW3D, "X:", + 10, 25, 75, 20, &cam->shiftx, -2.0, 2.0, 1, 2, "Horizontally shifts the camera view, without changing the perspective"); + uiDefButF(block, NUM,REDRAWVIEW3D, "Y:", + 85, 25, 75, 20, &cam->shifty, -2.0, 2.0, 1, 2, "Vertically shifts the camera view, without changing the perspective"); + uiBlockEndAlign(block); - uiDefBut(block, LABEL, 0, "Show:", 160, 155, 150, 20, 0, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Show:", 170, 180, 150, 20, 0, 0.0, 0.0, 0, 0, ""); uiBlockBeginAlign(block); uiDefButS(block, TOG|BIT|0, REDRAWVIEW3D, "Limits", - 160, 135, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw the field of view"); + 170, 160, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw the field of view"); uiDefButS(block, TOG|BIT|1, REDRAWVIEW3D, "Mist", - 160, 115, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw a line that indicates the mist area"); + 170, 140, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw a line that indicates the mist area"); uiBlockEndAlign(block); uiBlockBeginAlign(block); uiDefButS(block, TOG|BIT|4, REDRAWVIEW3D, "Name", - 160, 90, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw the active camera's name in camera view"); + 170, 115, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw the active camera's name in camera view"); uiDefButS(block, TOG|BIT|3, REDRAWVIEW3D, "Title Safe", - 160, 70, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw a the title safe zone in camera view"); + 170, 95, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw a the title safe zone in camera view"); uiBlockEndAlign(block); uiBlockBeginAlign(block); uiDefButS(block, TOG|BIT|2, REDRAWVIEW3D, "Passepartout", - 160, 45, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw a darkened passepartout over the off-screen area in camera view"); + 170, 70, 150, 20, &cam->flag, 0, 0, 0, 0, "Draw a darkened passepartout over the off-screen area in camera view"); uiDefButF(block, NUMSLI, REDRAWVIEW3D, "Alpha: ", - 160, 25, 150, 20, &cam->passepartalpha, 0.0, 1.0, 0, 0, "The opacity (darkness) of the passepartout"); + 170, 50, 150, 20, &cam->passepartalpha, 0.0, 1.0, 0, 0, "The opacity (darkness) of the passepartout"); uiBlockEndAlign(block); diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index e21b867f697..4ad709c0dba 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -910,6 +910,18 @@ void calc_viewborder(struct View3D *v3d, rctf *viewborder_r) viewborder_r->ymin-= dy; viewborder_r->xmax-= dx; viewborder_r->ymax-= dy; + + if(v3d->camera && v3d->camera->type==OB_CAMERA) { + Camera *cam= v3d->camera->data; + float w = viewborder_r->xmax - viewborder_r->xmin; + float h = viewborder_r->ymax - viewborder_r->ymin; + float side = MAX2(w, h); + + viewborder_r->xmin+= cam->shiftx*side; + viewborder_r->xmax+= cam->shiftx*side; + viewborder_r->ymin+= cam->shifty*side; + viewborder_r->ymax+= cam->shifty*side; + } } void view3d_set_1_to_1_viewborder(View3D *v3d)