POV-Ray : Newsgroups : povray.binaries.images : Question about media_attenuation behavior. Server Time
7 Nov 2024 00:19:44 EST (-0500)
  Question about media_attenuation behavior. (Message 1 to 10 of 23)  
Goto Latest 10 Messages Next 10 Messages >>>
From: William F Pokorny
Subject: Question about media_attenuation behavior.
Date: 21 Jan 2018 15:56:13
Message: <5a64fe6d$1@news.povray.org>
I was playing with scattering media today. I happened to stick my light 
source inside the media container and was surprised to find POV-Ray 
suddenly running orders of magnitude faster - seconds instead of minutes.

On digging it looks to me when media is inside a container and the light 
  outside, media_attenuation is on no matter the light source setting in 
the SDL. If the light source is inside the container, media_attenuation 
is off.

If we move the media block to the top level of the scene the 
media_attenuation keyword in any light source behaves as I expect. In 
other words, I can turn media attenuation on and off.

Is this the expected behavior for media_attenuation?

It goes back to 3.7.0 at least. I've for years assumed media_attenuation 
was off unless I turned it on whether or not I had a media container - 
and assumed that media was always really slow.

In the attached image, the light sources for the left column explicitly 
set media_attenuation on. The right column explicitly sets it off. The 
bottom and top row use a media {} block at the top of the scene hierarchy.

The middle two rows use a sphere as a container for the same defined 
media. The first two rows have the light at a position which places it 
inside the sphere container in row 2. The last two rows have the light 
position such that it is outside the containing sphere in row 3.

When the light is inside the container in row 2, media attenuation is 
always off no matter the setting. When the light is outside the 
container (the common use case I think) media_attenuation looks to 
always be on.

Bill P.

//---------- LightMediaAttenuationTest.pov ---------
#version 3.7;
global_settings { assumed_gamma 1 }
#default { finish {ambient 0.0 diffuse 1.0} }
#declare Grey20 = srgb <0.2,0.2,0.2>;
background { color Grey20 }
#declare Camera00 = camera {
     perspective
     location <2.7,2.7,-2.701>
     sky y
     angle 35
     right x*(image_width/image_height)
     look_at <0,0,0>
}
#declare VarDist = 0.207;
#declare VarDistRes = 0.02;
#declare VarDistPos = VarDist+(VarDistRes/2);
#declare White = srgb <1,1,1>;
#declare LightInsideAttenOff = light_source {
     <0.5,0.95,-0.5>, White
     fade_distance VarDistPos
     fade_power 2
     media_attenuation off
}
#declare LightInsideAttenOn = light_source {
     <0.5,0.95,-0.5>, White
     fade_distance VarDistPos
     fade_power 2
     media_attenuation on
}
#declare LightOutsideAttenOff = light_source {
     <0.5,1.05,-0.5>, White
     fade_distance VarDistPos
     fade_power 2
     media_attenuation off
}
#declare LightOutsideAttenOn = light_source {
     <0.5,1.05,-0.5>, White
     fade_distance VarDistPos
     fade_power 2
     media_attenuation on
}
#declare Red = srgb <1,0,0>;
#declare CylinderX = cylinder { -2*x, 2*x, 0.01 pigment { Red } }
#declare Green = srgb <0,1,0>;
#declare CylinderY = cylinder { -2*y, 2*y, 0.01 pigment { Green } }
#declare Blue = srgb <0,0,1>;
#declare CylinderZ = cylinder { -2*z, 2*z, 0.01 pigment { Blue } }
#declare BrightBlue = srgb <0.05882,0.2549,1>;
#declare Box00 = box {
     <-1.001,-1.001,-1.001>,<1.001,0.499,1.001>
     pigment { color BrightBlue }
}
#declare DensitySph = density {
     spherical
     scale 0.4
     translate <0.5,0.5,-0.5>
     scale 3
     turbulence 0.35 octaves 6 omega 0.63 lambda 5
     scale 1/3
}
#declare Sphere00 = sphere { <0.5,0.5,-0.5>, 0.5 hollow }
#declare Media00 = media {
     method       3
     samples      100
     absorption   rgb <0,0,0>
     emission     rgb <0,0,0>
     scattering { 1, rgb <5,5,5> extinction 1 }
     density { DensitySph }
}
#declare Interior00 = interior { ior 1 media { Media00 } }
#declare Clear100 = srgbt <1,1,1,1>;
#declare PigmClear100 = pigment { color Clear100 }
#declare TxtrClear100 = texture { pigment { PigmClear100 } }
#declare MatrClear100 = material {
     texture { TxtrClear100 }
     interior { Interior00 }
}
#declare Obj00 = object { Sphere00 material { MatrClear100 } hollow }

//--- scene ---
camera { Camera00 }
object { Box00 }
object { CylinderX }
object { CylinderY }
object { CylinderZ }

//--- Use one of these
//    Inside position just inside top of Sphere00
//    Outside position just outside top of Sphere00
    light_source { LightInsideAttenOn }
// light_source { LightInsideAttenOff }
// light_source { LightOutsideAttenOn }
// light_source { LightOutsideAttenOff }

//--- Use one of these
// media  { Media00 } // Inside vs Outside means nothing to top media
    object { Obj00 }

//------ End of scene -------


Post a reply to this message


Attachments:
Download 'mediaattensummary.jpg' (141 KB)

Preview of image 'mediaattensummary.jpg'
mediaattensummary.jpg


 

From: Thomas de Groot
Subject: Re: Question about media_attenuation behavior.
Date: 22 Jan 2018 02:54:23
Message: <5a6598af$1@news.povray.org>
On 21-1-2018 21:56, William F Pokorny wrote:
> I was playing with scattering media today. I happened to stick my light 
> source inside the media container and was surprised to find POV-Ray 
> suddenly running orders of magnitude faster - seconds instead of minutes.
> 

This is an interesting/important find indeed! My image 'Cat Alley' 
above, takes about 6 hours to render as you can expect. Like you, I 
always assumed media to severely slow down a render no matter what. I 
need to play with this a bit now. Thanks!

-- 
Thomas


Post a reply to this message

From: Thomas de Groot
Subject: Re: Question about media_attenuation behavior.
Date: 22 Jan 2018 04:04:49
Message: <5a65a931$1@news.povray.org>
Something seems not right to me. The light source is /always/ outside 
the container:

light position: <0.5,0.95,-0.5> or: <0.5,1.05,-0.5>
container size: <0.5,0.5,-0.5>, 0.5

With a radius of 0.5 the container is always smaller.

-- 
Thomas


Post a reply to this message

From: clipka
Subject: Re: Question about media_attenuation behavior.
Date: 22 Jan 2018 05:21:22
Message: <5a65bb22$1@news.povray.org>
Am 21.01.2018 um 21:56 schrieb William F Pokorny:

> Is this the expected behavior for media_attenuation?

The documentation for the feature specifically mentions "fog or
atmospheric media" (as opposed to object-contained media), so I'd say,
yes, that's the intended behaviour. Other portions of that same docs
section refer to "the fog or media", but I'd take that to be just a lazy
reference to the more precise term used earlier.


Post a reply to this message

From: Kenneth
Subject: Re: Question about media_attenuation behavior.
Date: 22 Jan 2018 13:00:01
Message: <web.5a66265d672c2bca47873e10@news.povray.org>
Thomas de Groot <tho### [at] degrootorg> wrote:

>
> This is an interesting/important find indeed! My image 'Cat Alley'
> above, takes about 6 hours to render as you can expect. Like you, I
> always assumed media to severely slow down a render no matter what. I
> need to play with this a bit now. Thanks!
>

Same here; I never noticed this behavior before. I need to play with Bill's
example code.


Post a reply to this message

From: Thomas de Groot
Subject: Re: Question about media_attenuation behavior.
Date: 23 Jan 2018 03:33:02
Message: <5a66f33e@news.povray.org>
Question: The Docs are silent about this, but do fade_distance and 
fade_power have to be added to the light source or not, in order for the 
media attenuation to work?

http://wiki.povray.org/content/Reference:Light_Source#Atmospheric_Attenuation

-- 
Thomas


Post a reply to this message

From: William F Pokorny
Subject: Re: Question about media_attenuation behavior.
Date: 23 Jan 2018 10:57:25
Message: <5a675b65$1@news.povray.org>
On 01/22/2018 05:21 AM, clipka wrote:
> Am 21.01.2018 um 21:56 schrieb William F Pokorny:
> 
>> Is this the expected behavior for media_attenuation?
> 
> The documentation for the feature specifically mentions "fog or
> atmospheric media" (as opposed to object-contained media), so I'd say,
> yes, that's the intended behaviour. Other portions of that same docs
> section refer to "the fog or media", but I'd take that to be just a lazy
> reference to the more precise term used earlier.
> 

Thanks.

Does our documentation then push the use of the media container too much 
if using scattering media?

It looks to me like it's probably not the right thing to do if a user 
doesn't need/want media attenuation. Global media in my testing is quite 
a bit faster than any container with scattering media - except those 
where the light is inside the container.

--- media_attenuation on
1541.79user 0.67system 12:56.48elapsed (global media. outside postion)
                                        (Media Samples: 4,295,692,846)

--- media_attenuation off
403.22user 0.04system 3:22.24elapsed  (container. outside postion)
404.69user 0.05system 3:22.99elapsed  (Media Samples: 1,064,722,061)

32.04user 0.01system 0:16.67elapsed  (global media. outside postion)
32.10user 0.01system 0:16.67elapsed  (Media Samples: 58,877,772)

8.71user 0.01system 0:05.00elapsed  (container. inside postion)
8.63user 0.01system 0:04.94elapsed  (Media Samples: 11,828,518)


While I'm happy to know I can contort my media containers to contain the 
light for really fast scattering media renders, I do wonder a little why 
media attenuation is always off in that case.

Instead of contorting the container shape, would a media {} block 
'media_attenuation off' capability could be useful for those wanting to 
use scattering media and attenuation for final renders, but wanting fast 
working renders?

While you can sort of fake a media initially at much better performance 
using emitting media over scattering, you don't get a very good feel for 
the final scattering look of any given media-density that way.

Bill P.


Post a reply to this message

From: William F Pokorny
Subject: Re: Question about media_attenuation behavior.
Date: 23 Jan 2018 12:23:57
Message: <5a676fad$1@news.povray.org>
On 01/23/2018 03:32 AM, Thomas de Groot wrote:
> Question: The Docs are silent about this, but do fade_distance and 
> fade_power have to be added to the light source or not, in order for the 
> media attenuation to work?
> 
> http://wiki.povray.org/content/Reference:Light_Source#Atmospheric_Attenuation 
> 
> 
By experimentation just now it looks like no. If you have a fade power / 
fade_distance it will of course affect media results apart from or in 
addition to any media_attenuation.

Aside: In running these recent tests I wanted the media on black so I 
could better see any attenuation in addition to noting the run time 
changes when media_attenuation is on. I forgot global media needs a 
terminating shape on which the ray stops & my media disappeared causing 
me a spot of confusion until I thought to put the background box back 
into the scene but colored black.

Bill P.


Post a reply to this message

From: clipka
Subject: Re: Question about media_attenuation behavior.
Date: 23 Jan 2018 15:28:20
Message: <5a679ae4$1@news.povray.org>
Am 23.01.2018 um 16:57 schrieb William F Pokorny:

> Instead of contorting the container shape, would a media {} block
> 'media_attenuation off' capability could be useful for those wanting to
> use scattering media and attenuation for final renders, but wanting fast
> working renders?

I'd say yes, that would be quite useful indeed.

(And maybe also `media_attenuation on` for light sources inside the
media container.)


Post a reply to this message

From: William F Pokorny
Subject: Re: Question about media_attenuation behavior.
Date: 24 Jan 2018 08:59:46
Message: <5a689152$1@news.povray.org>
On 01/23/2018 03:28 PM, clipka wrote:
> Am 23.01.2018 um 16:57 schrieb William F Pokorny:
> 
>> Instead of contorting the container shape, would a media {} block
>> 'media_attenuation off' capability could be useful for those wanting to
>> use scattering media and attenuation for final renders, but wanting fast
>> working renders?
> 
> I'd say yes, that would be quite useful indeed.
> 
> (And maybe also `media_attenuation on` for light sources inside the
> media container.)
> 
Ah yes! A good idea to be able to turn attenuation on inside too if 
possible. Thanks. I've no experience with the media code, but will take 
a look to see if I can figure something out as a start.

Bill P.


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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