POV-Ray : Newsgroups : povray.general : media ignores an EVEN number of samples Server Time
31 Oct 2024 10:20:52 EDT (-0400)
  media ignores an EVEN number of samples (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: Kenneth
Subject: media ignores an EVEN number of samples
Date: 19 May 2017 18:50:00
Message: <web.591f75ea5dfea5f4883fb31c0@news.povray.org>
(running v3.7.1 beta 7 in Windows 7 64-bit)

I was doing a media animation experiment, and noticed what could be a subtle,
undocummented bit of behavior that I had never noticed before. Not an
Earth-shattering discovery, but worth mentioning.

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.

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."

Anmyway, I've written a small animation scene example to show this, with
purposely crude samples values so it renders faster. Animate 10 frames, clock 0
to 1, AND with Cyclic_Animation on (to get 'clock' values to be exact multiples
of 0.1, which is important.) A small-size render is good enough to see it, like
320 X 240.

------
(scene is a scattering-media 'cloud' with a green box embedded in it, to easily
show shadowing behavior and samples/intervals changes)

#version 3.71; // or 3.7

global_settings{assumed_gamma 1.0 max_trace_level 5}

#declare SAM = 5 + 10*clock; // to go from 5 to 14, integers only;
// using Cyclic-Animation, the clock is always 0.0 on the first
// animation frame

camera {
  perspective
  location  <0, 0, -3.5>
  look_at   <.32, .05,  0>
  right     x*image_width/image_height
  angle 16  // 16 for close-up view; 35 shows full media sphere
}

light_source {
  0*x
  color rgb 2.0*<1,1,1>
  translate <10, 30, -10>
}

background {rgb .2}

plane{y,-.61
    texture{
    pigment{cells scale .5 rotate 15*y}
    finish{emission .1 diffuse .4}
    }
    }

text{
ttf "timrom.ttf" concat("samples = ",str(SAM,1,5))
    .01, 0
    texture{
        pigment{rgb 1}
        finish{emission 1 diffuse 0}
        }
    scale .07
    translate <-.03,.24,-.8>
    no_shadow
    }

text{
ttf "timrom.ttf" concat("clock = ",str(clock,1,5))
    .01, 0
    texture{
        pigment{rgb 1}
        finish{emission 1 diffuse 0}
        }
    scale .06
    translate <.07,.19,-.8>
    no_shadow
    }

// long box
box{<-.025,-1,-.025>, <.025,1,.025>
    texture{
        pigment{rgb <.4,1,.4>}
        finish{emission .1 diffuse .9}
        }
        rotate 30*y
        rotate 90*x
        rotate -20*y
        translate <.2,.15,0>
       }

sphere{0,1
hollow on
texture{
    pigment {rgbt 1}
    finish {emission 0 diffuse 0}
    }
    interior{
        media{
            scattering{1, 10 extinction 2.1}
            method 3
            intervals 1
            samples SAM
            density{
                spherical
                    color_map{
                            [0.22 rgb 0]
                            [0.32 rgb <.4,.6,1>]
                            [1.0 rgb <.4,.6,1>]
                             }
                   scale 2.5
                   warp{turbulence .9 omega .6}
                   scale 1/2.5
                   }
              }
             }
          scale <1,.6,1>
         }


Post a reply to this message

From: omniverse
Subject: Re: media ignores an EVEN number of samples
Date: 20 May 2017 01:15:01
Message: <web.591fd00c1d3e97559c5d6c810@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
>
> 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.

Quick look at this to see if it continued same way past samples 14 and it did.

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.
Not only is that different but the media brightens. Darker in the beta. And
there's a change in how the green box shows through the media.

I made the light_source color just <1,1,1> to eliminate that as a potential
problem. I don't know enough to say why the brightness is not the same between
official 3.7 and the latest beta but I remember plenty was being discussed about
correctness for transparent textures, of which the sphere container is. Don't
know how that would apply here though, so maybe not.

Posting both renders at p.b.images for those of you wondering about it.

Bob


Post a reply to this message

From: clipka
Subject: Re: media ignores an EVEN number of samples
Date: 20 May 2017 03: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
additional sample in total.

[*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.


Post a reply to this message

From: Kenneth
Subject: Re: media ignores an EVEN number of samples
Date: 20 May 2017 10:55:01
Message: <web.592057211d3e9755883fb31c0@news.povray.org>
"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.


Post a reply to this message

From: clipka
Subject: Re: media ignores an EVEN number of samples
Date: 20 May 2017 11: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. ;)


Post a reply to this message

From: Kenneth
Subject: Re: media ignores an EVEN number of samples
Date: 20 May 2017 11:20:00
Message: <web.59205d801d3e9755883fb31c0@news.povray.org>
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


Post a reply to this message

From: Kenneth
Subject: Re: media ignores an EVEN number of samples
Date: 20 May 2017 12:45:00
Message: <web.592071871d3e9755883fb31c0@news.povray.org>
"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.


Post a reply to this message

From: Alain
Subject: Re: media ignores an EVEN number of samples
Date: 21 May 2017 11: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!


Post a reply to this message

From: Kenneth
Subject: Re: media ignores an EVEN number of samples
Date: 21 May 2017 12:30:01
Message: <web.5921bfbe1d3e9755883fb31c0@news.povray.org>
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!


Post a reply to this message

From: clipka
Subject: Re: media ignores an EVEN number of samples
Date: 21 May 2017 16: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).


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

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