POV-Ray : Newsgroups : povray.general : media ignores an EVEN number of samples Server Time: 22 Oct 2017 21:05:10 GMT
 media ignores an EVEN number of samples (Message 3 to 12 of 12)
 From: clipka Subject: Re: media ignores an EVEN number of samples Date: 20 May 2017 07:28:06 Message: <591ff006\$1@news.povray.org>
```Am 20.05.2017 um 00:47 schrieb Kenneth:

> Media (with default settings, at least) does not actually make use of an EVEN
> number of samples, but ignores that and reverts to the previous ODD value,
> visually. For example, an even value-- say 8, between 7 and 9-- shows NO change
> to media from 7 samples. I tried it with both scattering and absorption medias.

You are right in that when using sampling method 3, POV-Ray indeed
always uses an ODD minimum number of samples per interval.

However, POV-Ray actually always takes MORE samples than specified: If
the specified number is even, POV-Ray takes at least one more sample. If
the specified number is odd, POV-Ray takes at least two more.

The reason behind the odd minimum number of samples per interval with
method 3 is that POV-Ray subdivides the interval into N sub-intervals,
takes samples at the N+1 boundaries of those sub-intervals (avoiding
duplicates) and then for each of the N sub-intervals takes another
sample at the center to determine if it that sub-interval needs to be
sub-divided even more. Thus, a minimum of (N+1)+N = 2N+1 samples are
taken per interval, which is an odd number.

For some reason, N is computed as (S+1)/2 rounded down (where S is the
specified minimum number of samples), rather than S/2 rounded down,
which gives one more sub-interval than strictly needed if S is odd.

This may have to do with the fact that when there is more than one
interval, the first sample for any interval is taken at about the same
place as the last sample of the previous one [*], so that with M
intervals, of the M*(2N+1) samples taken, M-1 are actually duplicates
(give or take some jitter), so the effective total minimum number of
samples would be M*(2N+1)-(M-1) = M*2N+1, so for even S POV-Ray does not
effectively take one surplus sample per interval, but just one

[*The careful observer may notice a potential for performance
improvement here.]

> Perhaps it's some kind of now-and-then interplay between all the various
> media options like extinction, confidence, ratio, etc. OR, maybe a math
> interplay re: the number of scene lights vs. the number of media intervals--
> which the docs allude to in an arcane way (although I've never understood it).
> From the paragraph about 'ratio':
> "Note that the total number of intervals must exceed the number of illuminated
> intervals. If a ray passes in and out of 8 spotlights but you have only
> specified 5 intervals then an error occurs."

That section is only relevant for the old sampling methods 1 and 2.
```
 From: Kenneth Subject: Re: media ignores an EVEN number of samples Date: 20 May 2017 14:55:01 Message:
```"omniverse" <omn### [at] charternet> wrote:

>
> Gave it a try with good old 3.7, not quite the same. 10, 11 and 12 samples are
> identical. Likewise 20, 21 and 22.

That is indeed odd! But in light of Clipka's analysis, it could be the result of
3.7's possibly mixed-up treatment of intervals, etc. My guess, anyway.
```
 From: clipka Subject: Re: media ignores an EVEN number of samples Date: 20 May 2017 15:03:42 Message: <59205ace@news.povray.org>
```Am 20.05.2017 um 16:53 schrieb Kenneth:
> "omniverse" <omn### [at] charternet> wrote:
>
>>
>> Gave it a try with good old 3.7, not quite the same. 10, 11 and 12 samples are
>> identical. Likewise 20, 21 and 22.
>
> That is indeed odd! But in light of Clipka's analysis, it could be the result of
> 3.7's possibly mixed-up treatment of intervals, etc. My guess, anyway.

Maybe. I'm not going to re-visit the old code unless there's some
absolutely compelling reason to do so. ;)
```
 From: Kenneth Subject: Re: media ignores an EVEN number of samples Date: 20 May 2017 15:20:00 Message:
```clipka <ano### [at] anonymousorg> wrote:

>
> The reason behind the odd minimum number of samples per interval with
> method 3 is that POV-Ray subdivides the interval into N sub-intervals,
> takes samples at the N+1 boundaries of those sub-intervals (avoiding
> duplicates) and then for each of the N sub-intervals takes another
> sample at the center to determine if it that sub-interval needs to be
> sub-divided even more...
[snip]

Wow, that is a deep and thorough analysis of the situation. Congratulations and
thanks for such quick detective work!
>
> > From the paragraph about 'ratio':
> > "Note that the total number of intervals must exceed the number of
> > illuminated intervals. If a ray passes in and out of 8 spotlights but
> > you have onlyspecified 5 intervals then an error occurs."
>
> That section is only relevant for the old sampling methods 1 and 2.

I keep wondering if that small section needs some re-wording, to make better
sense. For example, the meaning of 'illuminated intervals' vs. non-illuminated
intervals isn't at all clear (to me, anyway.) And the 2nd sentence might be
re-worded like this (IF I'm correct about it):
"If a CAMERA 'ray' passes in and out of 8 spotlight CONES but you have only
specified 5 intervals [in your single large media container?], then an error
occurs."

By the way...
[Kenneth wrote:}
"...8, between 7 and 9..."

Duh.
Yes indeed, the number 8 IS between 7 and 9!! I made *that* astounding discovery
last night as well!

Sorry. ;-P
```
 From: Kenneth Subject: Re: media ignores an EVEN number of samples Date: 20 May 2017 16:45:00 Message:
```"Kenneth" <kdw### [at] gmailcom> wrote:

>
> I keep wondering if that small section needs some re-wording... [snip]

It just occurred to me that, if I *am* correct about the re-wording of the
sentence, then 'illuminated intervals' vs. non-illuminated ones does make
sense-- but it assumes that the lights in the scene are all SPOTLIGHTS, with
clearly-defined 'illuminated' cone areas vs. areas outside the cones... the
latter being the 'non-illuminated' media intervals. (And it makes sense with
either a "large media container" OR just atmospheric media, with no container.)

Trouble is, the docs don't make any distinctions between using spotlights vs.
point lights, for example. With point lights, there would be NO
'non-illuminated' intervals, the way I understand it.
```
 From: Alain Subject: Re: media ignores an EVEN number of samples Date: 21 May 2017 15:43:16 Message: <5921b594\$1@news.povray.org>
```Le 17-05-20 Ã  12:42, Kenneth a Ã©crit :
> "Kenneth" <kdw### [at] gmailcom> wrote:
>
>>
>> I keep wondering if that small section needs some re-wording... [snip]
>
> It just occurred to me that, if I *am* correct about the re-wording of the
> sentence, then 'illuminated intervals' vs. non-illuminated ones does make
> sense-- but it assumes that the lights in the scene are all SPOTLIGHTS, with
> clearly-defined 'illuminated' cone areas vs. areas outside the cones... the
> latter being the 'non-illuminated' media intervals. (And it makes sense with
> either a "large media container" OR just atmospheric media, with no container.)
>
> Trouble is, the docs don't make any distinctions between using spotlights vs.
> point lights, for example. With point lights, there would be NO
> 'non-illuminated' intervals, the way I understand it.
>

You forgot the cases where there is shadows involved. You may have a
single light and an object with a gradient pattern that alternate
between opaque and transparent. That can cause A LOT of illuminated
intervals, possibly over 100...
Imagine:
sampling_method 1
intervals 500
samples 1,5

OUCH!
```
 From: Kenneth Subject: Re: media ignores an EVEN number of samples Date: 21 May 2017 16:30:01 Message:
```Alain <kua### [at] videotronca> wrote:

>
> You forgot the cases where there is shadows involved.

Yeah, the media's self-shadowing behavior is another aspect of this. Regarding
intervals, are those *partial* shadows in the category of 'illuminated
intervals' or not? It's a mystery to me!
```
 From: clipka Subject: Re: media ignores an EVEN number of samples Date: 21 May 2017 20:35:17 Message: <5921fa05\$1@news.povray.org>
```Am 21.05.2017 um 18:28 schrieb Kenneth:
> Alain <kua### [at] videotronca> wrote:
>
>>
>> You forgot the cases where there is shadows involved.
>
> Yeah, the media's self-shadowing behavior is another aspect of this. Regarding
> intervals, are those *partial* shadows in the category of 'illuminated
> intervals' or not? It's a mystery to me!

I've never really looked at the intervals mechanism in detail (I just
know that they exist), but I can't imagine it being able to detect such
cases. I wouldn't even know how it could possibly detect the shadows of
objects. Such effects can only be detected on a sub-interval basis.

So from what I know, the intervals mechanism can only identify the
boundaries of spotlights, and/or possibly overlapping media containers
(though I guess the latter is handled at a higher level).
```
 From: Kenneth Subject: Re: media ignores an EVEN number of samples Date: 21 May 2017 21:55:01 Message:
```clipka <ano### [at] anonymousorg> wrote:
> Am 21.05.2017 um 18:28 schrieb Kenneth:
> >
> > Regarding intervals, are those *partial* shadows in the category of
> > 'illuminated intervals' or not? It's a mystery to me!
>
> I've never really looked at the intervals mechanism in detail (I just
> know that they exist), but I can't imagine it being able to detect such
> cases. I wouldn't even know how it could possibly detect the shadows of
> objects. Such effects can only be detected on a sub-interval basis.
>
> So from what I know, the intervals mechanism can only identify the
> boundaries of spotlights, and/or possibly overlapping media containers
> (though I guess the latter is handled at a higher level).

Well, it heartens me to know that bigger brains than mine are having a bit of
trouble with this too ;-)

sentence in 'ratio' that may--or may not?-- need clarifying: "The ratio keyword
distributes intervals differently between lit and unlit areas." I think it
should say SAMPLES rather than 'intervals', because the following sentence then
makes more sense: "The default value of ratio 0.9 means that lit intervals get
more samples than unlit intervals." Are INTERVALS actually "distributed
differently" too??

That little paragraph about 'ratio' has given me WAY too much trouble in the
past; it's now my sworn duty to try and improve it ;-)
```
 From: Alain Subject: Re: media ignores an EVEN number of samples Date: 23 May 2017 00:29:27 Message: <59238267\$1@news.povray.org>
```Le 17-05-21 Ã  17:53, Kenneth a Ã©crit :
> clipka <ano### [at] anonymousorg> wrote:
>> Am 21.05.2017 um 18:28 schrieb Kenneth:
>>>
>>> Regarding intervals, are those *partial* shadows in the category of
>>> 'illuminated intervals' or not? It's a mystery to me!
>>
>> I've never really looked at the intervals mechanism in detail (I just
>> know that they exist), but I can't imagine it being able to detect such
>> cases. I wouldn't even know how it could possibly detect the shadows of
>> objects. Such effects can only be detected on a sub-interval basis.
>>
>> So from what I know, the intervals mechanism can only identify the
>> boundaries of spotlights, and/or possibly overlapping media containers
>> (though I guess the latter is handled at a higher level).
>
> Well, it heartens me to know that bigger brains than mine are having a bit of
> trouble with this too ;-)
>
> sentence in 'ratio' that may--or may not?-- need clarifying: "The ratio keyword
> distributes intervals differently between lit and unlit areas." I think it
> should say SAMPLES rather than 'intervals', because the following sentence then
> makes more sense: "The default value of ratio 0.9 means that lit intervals get
> more samples than unlit intervals." Are INTERVALS actually "distributed
> differently" too??
>
> That little paragraph about 'ratio' has given me WAY too much trouble in the
> past; it's now my sworn duty to try and improve it ;-)
>
>
>
>

When using sampling method 3, the default, ratio have no meaning.
You only need to think about total samples count. ratio, confidence and
variance are not used. intervals need to stay at it's default value of 1.
Leave them out unless you use method 1 or 2 and save yourself from