POV-Ray : Newsgroups : povray.off-topic : WebGL : Re: WebGL Server Time
28 Jul 2024 04:26:10 EDT (-0400)
  Re: WebGL  
From: Orchid Win7 v1
Date: 12 Jun 2016 09:30:09
Message: <575d63e1$1@news.povray.org>
On 10/06/2016 07:10 PM, Orchid Win7 v1 wrote:
> On 10/06/2016 07:06 PM, Orchid Win7 v1 wrote:
>> (You never know, maybe there's a file named camera.c or something...)
>
> There is, in fact, a camera.cpp file.

Sadly, it contains the data structures for *describing* the camera, but 
nothing whatsoever to do with *casting rays*.

It seems *that* is in tracepixel.cpp. Looking into it further, it seems 
that TracePixel::CreateCameraRay() has a giant switch-block for every 
possible camera type, but they all end with JitterCameraRay(). This, 
seemingly, is where the focal blur stuff happens.

In full:

void TracePixel::JitterCameraRay(Ray& ray, DBL x, DBL y, size_t ray_number)
{
     DBL xjit, yjit, xlen, ylen, r;
     Vector3d temp_xperp, temp_yperp, deflection;

     r = camera.Aperture * 0.5;

     Jitter2d(x, y, xjit, yjit);
     xjit *= focalBlurData->Max_Jitter * 2.0;
     yjit *= focalBlurData->Max_Jitter * 2.0;

     xlen = r * (focalBlurData->Sample_Grid[ray_number].x() + xjit);
     ylen = r * (focalBlurData->Sample_Grid[ray_number].y() + yjit);

     // Deflect the position of the eye by the size of the aperture, and in
     // a direction perpendicular to the current direction of view.

     temp_xperp = focalBlurData->XPerp * xlen;
     temp_yperp = focalBlurData->YPerp * ylen;

     deflection = temp_xperp - temp_yperp;

     ray.Origin += deflection;

     // Deflect the direction of the ray in the opposite direction we 
deflected
     // the eye position.  This makes sure that we are looking at the 
same place
     // when the distance from the eye is equal to "Focal_Distance".

     ray.Direction *= focalBlurData->Focal_Distance;
     ray.Direction -= deflection;

     ray.Direction.normalize();
}

Good luck *ever* figuring out what the hell any of it means, of course...


Post a reply to this message

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