Viewport render and camera FOV

  • Hi!
    In my renderer plugin, I use the following code to get the camera FOV:

    Float aperture = camera->GetAperture();
    Float focus = camera->GetFocus();
    float horizontal_fov = (float)RadToDeg(2 * ATan(0.5*aperture / focus));

    This matches perfectly when rendering to the picture viewer, but when I render to the viewport there is a slight mismatch in the camera FOV.

    Any suggestions on how to get the correct camera field of view for viewport rendering?

    (I should add that I am determining render resolution by the size of the buffers obtained in the renderer videopost, like this:

    VPBuffer* colorBuf = vps->render->GetBuffer(VPBUFFER_RGBA, NOTOK);

    maxon::Int32 const xres = colorBuf->GetInfo(VPGETINFO::XRESOLUTION);
    maxon::Int32 const yres = colorBuf->GetInfo(VPGETINFO::YRESOLUTION);


  • hello,

    From the execute command you can retrieve the RayCamera using the VolumeData stored inside the VideoPostStruct

    const RayCamera* cam = vps->vd->GetRayCamera();

    You can get the off parameter of the RayCamera that is the offset of the camera (so double it to have the resolution)

    Using the zoom factor should help you to retrieve the aperture and determine the ray direction.

    This RayCamera will change depending on where the render is done, (viewport or picture viewer)

    in the Execute Function :

    	       const RayCamera* cam = vps->vd->GetRayCamera();
    	       	if (cam == nullptr)
    	         	return RENDERRESULT::OUTOFMEMORY;
    		ppx_ = cam->off.x;
    		ppy_ = cam->off.y;
    		zoomRatio_ = 1.0 / cam->zoom;

    in the CalculateRay function

    			maxon::Float newx = x - ppx_;
    			maxon::Float newy = y - ppy_;
    			maxon::Vector focalPoint;
    			// Sets the value of the focal point in local space, the plan is put at the image size * ration in Z axis
    			focalPoint =  Vector(newx, -newy, xres_ /  zoomRatio_);
    			// go to goal space
    			focalPoint = camMg_ * focalPoint;
    			// remove the camera position so we have a direction
    			focalPoint -=;
    			// set the ray position
    			dst.p =;
    			// set the ray direction
    			dst.v =  focalPoint;

    Hope this help a bit.