POV-Ray : Newsgroups : povray.binaries.images : Re: Regarding the defocus module Server Time
7 Nov 2024 09:28:08 EST (-0500)
  Re: Regarding the defocus module (Message 1 to 10 of 16)  
Goto Latest 10 Messages Next 6 Messages >>>
From: clipka
Subject: Re: Regarding the defocus module
Date: 4 Aug 2016 20:13:33
Message: <57a3da2d@news.povray.org>
Am 04.08.2016 um 18:59 schrieb clipka in povray.general:

>>> To compare this with a real camera lens, the camera location can be
>>> thought of as the center of the diaphragm (or, more precisely, the
>>> diaphragm's virtual image as seem through the lens), and the jittering
>>> of the rays accounts for the fact that the diaphragm's aperture is not
>>> infinitesimally small.
>>
>> I didn't really get this part. How would jittering account for the aperture
>> size? Would it be possible for you to explain this with the help of an image?
>> It would be really helpful.
> 
> I'll try to throw together something.

The attached image shows key elements of a real-life camera; from left
to right we can see:

- The "image plane", representing the camera's image recording element
(e.g. photographic film or CCD sensor).

- The "virtual aperture", representing the aperture's /apparent/
location and size when viewed through the lens.

- The "aperture", representing the primary limiting element in the beam
path (note that in real-life cameras this is usually the
variable-diameter opening of a diaphragm, /not/ the lens opening).

- The "lens", representing the optical assembly that focuses the light
onto the image recording element.

- A "plane out of focus", representing an arbitrary plane parallel to
the image plane that is currently not in focus.

- The "plane in focus", representing the plane parallel to the image
plane that is currently in focus.


To visualize what is happening in such a camera assembly, a few selected
points and light rays are shown:

- P represents an arbitrary point on the image plane, e.g. a grain on a
photographic film or a single pixel on a CCD sensor.

- The red, green and blue lines represent different selected light rays
that would all register at P. The red line represents the ray passing
right through the center of the aperture, while the green and blue lines
represent two rays traveling as far off the red ray as the aperture allows.

- P' represents the one and only point in space from which all three
light rays could originate. In fact, /any/ ray originating from this
point would inevitably register at P (provided they make it through the
aperture). As a result, P' would show up on the image at P as a single
crisp spot.

- P'1 and P'2 represent arbitrary alternate points from which the green
and blue rays, respectively, could originate. Note that in contrast to
P', /any other/ ray from these two points would inevitably register at a
point /different/ from P (again provided they make it through the
aperture at all). As a result, P'1 and P'2 would show up on the image as
big faint splotches, both covering (but not centered at) P.

- Q1 and Q2 represent the points at which the green and blue light rays,
respectively, pass through the aperture.

- Q1' and Q2' represent the points in the virtual aperture corresponding
to Q1 and Q2 in the actual aperture.


POV-Ray's focal blur mechanism can be thought of as follows:

(1) The nominal camera location always corresponds to the center of the
virtual aperture.

(2) From the camera settings, POV-Ray computes the parameters for a
simple pinhole camera equivalent, with the pinhole at the nominal camera
location.

(3) For a given point P in the image space, POV-Ray first uses the
simple pinhole model to compute the ray shown in red as originating from
the nominal camera location (= center of virtual aperture).

(4) POV-Ray now computes P' as the intersection of the red ray with the
plane in focus.

(5) POV-Ray now jitters the ray origin within the virtual aperture to
come up with a point Q'; for example, it might come up with point Q1' or
Q2'.

(6) POV-Ray computes a new ray, using Q' as the origin and (P'-Q') as
the direction. Note that this ray still travels through P'.

(7) POV-Ray traces the chosen ray; note that it might hit an object at
P', but it might just as well hit an object at P'1 if the origin was
Q1', or P'2 if the origin was Q2', or anywhere else along the ray in
question.

(8) POV-Ray sums up the result colour.

(9) POV-Ray repeats steps (5) to (8) a couple of times.

(10) From the sum of the result colours, POV-Ray computes the average,
and colours the pixel accordingly.

(11) POV-Ray proceeds to the next pixel, repeating steps (3) to (10).


I hope this helps understand what's going on with POV-Ray's focal blur.


Post a reply to this message


Attachments:
Download 'aperture.png' (92 KB)

Preview of image 'aperture.png'
aperture.png


 

From: Bald Eagle
Subject: Re: Regarding the defocus module
Date: 5 Aug 2016 18:25:00
Message: <web.57a51125292338255e7df57c0@news.povray.org>
That's a very nice diagram.   :)

Pretty impressive for something "thrown together"   ;)

{"Wow, that's a great looking dress"
"Oh, this old thing? It's just something I threw on at the last minute..."
}


Thanks for that, it will be a great reference.


Post a reply to this message

From: pkrskr
Subject: Re: Regarding the defocus module
Date: 6 Aug 2016 07:30:01
Message: <web.57a5c94529233825f2ed086a0@news.povray.org>
That was a really nice illustration. It clarified the question asked in the
previous post quite well. Thanks!

I hope you can help with another small clarification. You mentioned to udyank
previously that the virtual aperture plane could indeed be anywhere and could
also thus be at the plane of the lens. But in your illustration, isn't there a
change in direction of the ray between say Q1' and P1 because of the presence of
the lens in between? Wouldn't it be incorrect to assume a ray straight from Q1'
to P' without tracing the deviation caused due to refraction?

If we were to assume that the virtual aperture was actually at the location of
the (thin-)lens , then does this jittering exactly correspond to simulating a
thin-lens by tracing multiple points on the lens and shooting rays towards P' on
the object side and towards P on the image side?

Again, thanks a lot for your explanation. It has really helped understanding the
focal blur pipeline of POVRay.


Post a reply to this message

From: clipka
Subject: Re: Regarding the defocus module
Date: 6 Aug 2016 11:32:07
Message: <57a602f7$1@news.povray.org>
Am 06.08.2016 um 13:25 schrieb pkrskr:

> I hope you can help with another small clarification. You mentioned to udyank
> previously that the virtual aperture plane could indeed be anywhere and could
> also thus be at the plane of the lens. But in your illustration, isn't there a
> change in direction of the ray between say Q1' and P1 because of the presence of
> the lens in between? Wouldn't it be incorrect to assume a ray straight from Q1'
> to P' without tracing the deviation caused due to refraction?

No, there is no such deviation through refraction.

First of all, it may be necessary to clarify a potential cause for
misunderstanding: POV-Ray does /not/ actually simulate a lens at the
position shown in the diagram.

Instead, POV-Ray uses the "virtual aperture" as the ray origin
/specifically/ to /avoid/ having to simulate the lens. The whole idea of
the virtual aperture is that (to the extent required by POV-Ray) it
gives the same results /without/ the lens as the true aperture does
/with/ the lens.


> If we were to assume that the virtual aperture was actually at the location of
> the (thin-)lens , then does this jittering exactly correspond to simulating a
> thin-lens by tracing multiple points on the lens and shooting rays towards P' on
> the object side and towards P on the image side?

I'm not sure I understand exactly what you are asking.

In a simple camera with no diaphragm, in which the lens opening also
constitutes the effective aperture, the aperture plane does indeed
coincide with the lens.

Consequently, in such a scenario, jittering of the ray origin does
indeed occur at the lens plane, and across the entire lens opening.

(Shooting rays toward P on the image side is not necessary, as P' is
computed from P using a quite simple formula, and there are no
intervening objects between the aperture and the image plane.)


In a scenario with a diaphragm in a different plane than the lens, this
simplification does not hold, as we would have to place the virtual
aperture at different X/Y coordinates depending on the point P (compare
the diagram, in which the red ray -- which should be at the center of
the virtual aperture -- passes through the lens at an offset from the
camera axis).


Post a reply to this message

From: architype
Subject: Re: Regarding the defocus module
Date: 7 Aug 2016 12:45:00
Message: <web.57a7649529233825bd10344a0@news.povray.org>
Thank you very much for setting out such a detailed explanaition, I have wanted
to try out this feature for quite some time. Best wishes! /A


Post a reply to this message

From: pkrskr
Subject: Re: Regarding the defocus module
Date: 8 Aug 2016 03:35:01
Message: <web.57a8352929233825f2ed086a0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 06.08.2016 um 13:25 schrieb pkrskr:
>

> No, there is no such deviation through refraction.
>
> First of all, it may be necessary to clarify a potential cause for
> misunderstanding: POV-Ray does /not/ actually simulate a lens at the
> position shown in the diagram.
>
> Instead, POV-Ray uses the "virtual aperture" as the ray origin
> /specifically/ to /avoid/ having to simulate the lens. The whole idea of
> the virtual aperture is that (to the extent required by POV-Ray) it
> gives the same results /without/ the lens as the true aperture does
> /with/ the lens.
>

Understood!


> I'm not sure I understand exactly what you are asking.
>
> In a simple camera with no diaphragm, in which the lens opening also
> constitutes the effective aperture, the aperture plane does indeed
> coincide with the lens.
>
> Consequently, in such a scenario, jittering of the ray origin does
> indeed occur at the lens plane, and across the entire lens opening.
>

This was what I was trying to say earlier, about the method being similar to
simulating a camera where the aperture stop and the lens are effectively at the
same location.

> (Shooting rays toward P on the image side is not necessary, as P' is
> computed from P using a quite simple formula, and there are no
> intervening objects between the aperture and the image plane.)

Yes this is true. I used the 'tracing both sides' phrase loosely. Apologies for
that.


>
> In a scenario with a diaphragm in a different plane than the lens, this
> simplification does not hold, as we would have to place the virtual
> aperture at different X/Y coordinates depending on the point P (compare
> the diagram, in which the red ray -- which should be at the center of
> the virtual aperture -- passes through the lens at an offset from the
> camera axis).

This is the most interesting point. In your first explanation, you mentioned
that the red ray is originally drawn through the center of the nominal camera
location (which is the virtual aperture), and I thus presumed that the ray went
through the pole of this virtual aperture (since we were tracing through a
pinhole). However, now that you mention it, I see that the pinhole ray was
traced through the center of the real aperture and thus happens to be shifted in
X/Y on the plane of the virtual aperture and the jitter is applied across this
shifted point. This is indeed different from the above scenario where the lens
and the diaphragm are at the same plane.

However, could you clarify how the locations of the real aperture and the
virtual aperture are decided? And does this mean that the nominal camera
location is the position of the real aperture?

Thanks for spending time on such detailed explanations. You have been very
helpful.


Post a reply to this message

From: clipka
Subject: Re: Regarding the defocus module
Date: 8 Aug 2016 10:20:45
Message: <57a8953d$1@news.povray.org>
Am 08.08.2016 um 09:32 schrieb pkrskr:

>> In a scenario with a diaphragm in a different plane than the lens, this
>> simplification does not hold, as we would have to place the virtual
>> aperture at different X/Y coordinates depending on the point P (compare
>> the diagram, in which the red ray -- which should be at the center of
>> the virtual aperture -- passes through the lens at an offset from the
>> camera axis).
> 
> This is the most interesting point. In your first explanation, you mentioned
> that the red ray is originally drawn through the center of the nominal camera
> location (which is the virtual aperture), and I thus presumed that the ray went
> through the pole of this virtual aperture (since we were tracing through a
> pinhole). However, now that you mention it, I see that the pinhole ray was
> traced through the center of the real aperture and thus happens to be shifted in
> X/Y on the plane of the virtual aperture and the jitter is applied across this
> shifted point. This is indeed different from the above scenario where the lens
> and the diaphragm are at the same plane.

No, that's a misunderstanding there. The pinhole ray is also traced
through the center of the /virtual/ aperture.

> However, could you clarify how the locations of the real aperture and the
> virtual aperture are decided? And does this mean that the nominal camera
> location is the position of the real aperture?

As I said before:

"(1) The nominal camera location always corresponds to the center of the
virtual aperture."

As a matter of fact, POV-Ray /never/ actually "thinks" of the real
camera geometry in the first place, since the geometry is only specified
indirectly. When you set up a camera in POV-Ray, you are essentially
specifying:

- The camera location = center of the virtual aperture.
- The direction of the camera axis (via `direction` or `look_at`).
- The distance between the virtual aperture and the plane in focus
(again via `direction` or `look_at`).
- The effective horizontal and vertical opening angle of the camera
(either via `up`/`right` and `direction`, or via `angle`).

There is an infinite number of physical cameras that satisfy any given
combination of these parameters.


Post a reply to this message

From: pkrskr
Subject: Re: Regarding the defocus module
Date: 9 Aug 2016 06:00:00
Message: <web.57a9a8db29233825f2ed086a0@news.povray.org>
>
> No, that's a misunderstanding there. The pinhole ray is also traced
> through the center of the /virtual/ aperture.
>

Okay. So it seems like in the illustration you provided earlier, the red ray
should be corrected to pass through the center of the virtual aperture and not
the real aperture, since it represents the pinhole ray. And then it seems like
the jitter is applied around the location of the pinhole?

>
> As I said before:
>
> "(1) The nominal camera location always corresponds to the center of the
> virtual aperture."
>
> As a matter of fact, POV-Ray /never/ actually "thinks" of the real
> camera geometry in the first place, since the geometry is only specified
> indirectly. When you set up a camera in POV-Ray, you are essentially
> specifying:
>
> - The camera location = center of the virtual aperture.
> - The direction of the camera axis (via `direction` or `look_at`).
> - The distance between the virtual aperture and the plane in focus
> (again via `direction` or `look_at`).
> - The effective horizontal and vertical opening angle of the camera
> (either via `up`/`right` and `direction`, or via `angle`).
>
> There is an infinite number of physical cameras that satisfy any given
> combination of these parameters.

Okay. I think I understand what you are saying here. You are right about the
existence of several cameras for which the same parameter combination holds.


Post a reply to this message

From: clipka
Subject: Re: Regarding the defocus module
Date: 9 Aug 2016 07:21:18
Message: <57a9bcae$1@news.povray.org>
Am 09.08.2016 um 11:56 schrieb pkrskr:
>>
>> No, that's a misunderstanding there. The pinhole ray is also traced
>> through the center of the /virtual/ aperture.
> 
> Okay. So it seems like in the illustration you provided earlier, the red ray
> should be corrected to pass through the center of the virtual aperture and not
> the real aperture, since it represents the pinhole ray.

No, the illustration is correct in that the _refracted_ red ray passes
through the center of the _real_ aperture, while the _unrefracted_ red
ray (shown semi-transparent) passes through the center of the _virtual_
aperture.

> And then it seems like
> the jitter is applied around the location of the pinhole?

Yes.


Post a reply to this message

From: pkrskr
Subject: Re: Regarding the defocus module
Date: 9 Aug 2016 07:55:00
Message: <web.57a9c41729233825f2ed086a0@news.povray.org>
>
> No, the illustration is correct in that the _refracted_ red ray passes
> through the center of the _real_ aperture, while the _unrefracted_ red
> ray (shown semi-transparent) passes through the center of the _virtual_
> aperture.
>

I see the semi-transparent ray and that it originates at the center of the
virtual aperture. This precisely clarifies the method you detailed in elaborate
steps earlier.

Can you elaborate on how the nominal pinhole camera location is computed as
mentioned in step 2?

>
> (2) From the camera settings, POV-Ray computes the parameters for a
> simple pinhole camera equivalent, with the pinhole at the nominal camera
> location.
>


Post a reply to this message

Goto Latest 10 Messages Next 6 Messages >>>

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