POV-Ray : Newsgroups : povray.binaries.images : Scattering media with a color_map - how to do? Server Time
4 Nov 2024 21:23:43 EST (-0500)
  Scattering media with a color_map - how to do? (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: Jörg 'Yadgar' Bleimann
Subject: Scattering media with a color_map - how to do?
Date: 22 Nov 2009 17:44:45
Message: <4b09bedd$1@news.povray.org>
High!

Still trying to get believable Saturnian rings... so I worked through 
the media section of the manual to finally get scattering media which 
shows cylindrical banding - but my attempts failed so far.

Here is the code for the test scene attached below:

union
{
   sphere
   {
     0, 1
     texture
     {
       pigment { color rgb <0.6, 0.4, 0> }
       finish { ambient 0.02 diffuse 1 brilliance 0.8 }
     }
   }
   difference
   {
     cylinder
     {
       <0, -0.001, 0>, <0, 0.001, 0>, 3.68
     }
     cylinder
     {
       <0, -0.0011, 0>, <0, 0.0011, 0>, 1.75
     }
     hollow
     pigment { rgbt 1 }
     interior
     {
       media
       {
         emission 0.75
         scattering
         {
           1, 0.1
           extinction 1
         }
         density
         {
           cylindrical
           color_map
           {
             [0 rgbf <1, 0.8, 0.7, 0.1> ]
             [0.3 rgbf <1, 0.8, 0.7, 0.1> ]
             [0.3 rgbf <0.1, 0.3, 0.1, 0.95>]
             [0.35 rgbf <0.1, 0.3, 0.1, 0.95>]
             [0.35 rgbf <0.9, 0.83, 0.3, 0.2>]
           }
           scale 3.68
         }
       }
     }
   }
   rotate <-4, 7, 0>
   scale 10000
   translate z*50000
}

// end of code

Whatever I tried, the cylindrical pattern never showed up - instead I 
got a uniformly white ring! What's my mistake?

See you in Khyberspace!

Yadgar


Post a reply to this message


Attachments:
Download '2009-11-22 media test, take 41.jpg' (11 KB)

Preview of image '2009-11-22 media test, take 41.jpg'
2009-11-22 media test, take 41.jpg


 

From: BitViper
Subject: Re: Scattering media with a color_map - how to do?
Date: 22 Nov 2009 18:16:33
Message: <4b09c651$1@news.povray.org>


> High!

Not yet, working on it though. =)

> Still trying to get believable Saturnian rings... so I worked through 
> the media section of the manual to finally get scattering media which 
> shows cylindrical banding - but my attempts failed so far.

I'll have a look at your code later, but I built the following a while 
back then got distracted by real life. I had a similar issue with the 
rings. I have bitmaps representing a slice of the rings from inside to 
outside, one for color, and one for alpha. However I never figured out 
how to apply them to the rings. Perhaps we can help each other, or find 
a common solution that will work for both of us.

http://www.bitviper.org/solarsystem

bit


Post a reply to this message

From: Jörg 'Yadgar' Bleimann
Subject: Re: Scattering media with a color_map - how to do?
Date: 22 Nov 2009 18:40:59
Message: <4b09cc0b@news.povray.org>
High!

BitViper wrote:

> I'll have a look at your code later, but I built the following a while 
> back then got distracted by real life. I had a similar issue with the 
> rings. I have bitmaps representing a slice of the rings from inside to 
> outside, one for color, and one for alpha. However I never figured out 
> how to apply them to the rings. Perhaps we can help each other, or find 
> a common solution that will work for both of us.

I originally started with a 1500-part color and transparency map (inside 

(http://www.mmedia.is/~bjj/)... to make them work, I had to read out the 
  color and transparency values with eval_pigment() (contained in 
"functions.inc"), and, as a color_map cannot have more than 255 entries, 
  to divide the whole color and transparency maps into six color_maps, 
which then were used in a texture_map:

#declare Saturn_Rings_Colors =
pigment
{
   image_map
   {
     png "solarsys/sat_ring_color_bjoernjonsson.png"
   }
}

#declare Saturn_Rings_Transparency =
pigment
{
   image_map
   {
     png "solarsys/transparency_bjoernjonsson.png"
   }
}

#declare Saturn_Rings_UnlitSide =
pigment
{
   image_map
   {
     png "solarsys/unlitside_bjoernjonsson.png"
   }
}


#declare Ring_Color_Map_1_to_255 =
texture
{
   pigment
   {
     cylindrical
     color_map
     {
       #declare a=0;
       #while (a<255)
         #declare c=eval_pigment(Saturn_Rings_Colors, <2999/3000-a/1500, 
0.5, 0>);
         #declare f=eval_pigment(Saturn_Rings_Transparency, 
<2999/3000-a/1500, 0.5, 0>);
         [a*(((140390-74510)/140390)/1500) rgb c filter f.gray]
         #declare a=a+1;
       #end
     }
   }
   finish { F_Saturn_Rings }
}

#declare Ring_Color_Map_256_to_510 =
texture
{
   pigment
   {
     cylindrical
     color_map
     {
       #declare a=255;
       #while (a<510)
         #declare c=eval_pigment(Saturn_Rings_Colors, <2999/3000-a/1500, 
0.5, 0>);
         #declare f=eval_pigment(Saturn_Rings_Transparency, 
<2999/3000-a/1500, 0.5, 0>);
         [a*(((140390-74510)/140390)/1500) rgb c filter f.gray]
         #declare a=a+1;
       #end
     }
   }
   finish { F_Saturn_Rings }
}

#declare Ring_Color_Map_511_to_765 =
texture
{
   pigment
   {
     cylindrical
     color_map
     {
       #declare a=510;
       #while (a<765)
         #declare c=eval_pigment(Saturn_Rings_Colors, <2999/3000-a/1500, 
0.5, 0>);
         #declare f=eval_pigment(Saturn_Rings_Transparency, 
<2999/3000-a/1500, 0.5, 0>);
         [a*(((140390-74510)/140390)/1500) rgb c filter f.gray]
         #declare a=a+1;
       #end
     }
   }
   finish { F_Saturn_Rings }
}

#declare Ring_Color_Map_766_to_1020 =
texture
{
   pigment
   {
     cylindrical
     color_map
     {
       #declare a=765;
       #while (a<1020)
         #declare c=eval_pigment(Saturn_Rings_Colors, <2999/3000-a/1500, 
0.5, 0>);
         #declare f=eval_pigment(Saturn_Rings_Transparency, 
<2999/3000-a/1500, 0.5, 0>);
         [a*(((140390-74510)/140390)/1500) rgb c filter f.gray]
         #declare a=a+1;
       #end
     }
   }
   finish { F_Saturn_Rings }
}

#declare Ring_Color_Map_1021_to_1275 =
texture
{
   pigment
   {
     cylindrical
     color_map
     {
       #declare a=1020;
       #while (a<1275)
         #declare c=eval_pigment(Saturn_Rings_Colors, <2999/3000-a/1500, 
0.5, 0>);
         #declare f=eval_pigment(Saturn_Rings_Transparency, 
<2999/3000-a/1500, 0.5, 0>);
         [a*(((140390-74510)/140390)/1500) rgb c filter f.gray]
         #declare a=a+1;
       #end
     }
   }
   finish { F_Saturn_Rings }
}

#declare Ring_Color_Map_1276_to_1500 =
texture
{
   pigment
   {
     cylindrical
     color_map
     {
       #declare a=1275;
       #while (a<1500)
         #declare c=eval_pigment(Saturn_Rings_Colors, <2999/3000-a/1500, 
0.5, 0>);
         #declare f=eval_pigment(Saturn_Rings_Transparency, 
<2999/3000-a/1500, 0.5, 0>);
         [a*(((140390-74510)/140390)/1500) rgb c filter f.gray]
         #declare a=a+1;
       #end
     }
   }
   finish { F_Saturn_Rings }
}


#declare Ring_UnlitSide_Map_1_to_255 =
texture
{
   pigment
   {
     cylindrical
     color_map
     {
       #declare a=0;
       #while (a<255)
         #declare c=eval_pigment(Saturn_Rings_UnlitSide, 
<2999/3000-a/1500, 0.5, 0>);
         #declare f=eval_pigment(Saturn_Rings_Transparency, 
<2999/3000-a/1500, 0.5, 0>);
         [a*(((140390-74510)/140390)/1500) rgb c filter f.gray]
         #declare a=a+1;
       #end
     }
   }
   finish { F_Saturn_Rings_UnlitSide }
}

#declare Ring_UnlitSide_Map_256_to_510 =
texture
{
   pigment
   {
     cylindrical
     color_map
     {
       #declare a=255;
       #while (a<510)
         #declare c=eval_pigment(Saturn_Rings_UnlitSide, 
<2999/3000-a/1500, 0.5, 0>);
         #declare f=eval_pigment(Saturn_Rings_Transparency, 
<2999/3000-a/1500, 0.5, 0>);
         [a*(((140390-74510)/140390)/1500) rgb c filter f.gray]
         #declare a=a+1;
       #end
     }
   }
   finish { F_Saturn_Rings_UnlitSide }
}

#declare Ring_UnlitSide_Map_511_to_765 =
texture
{
   pigment
   {
     cylindrical
     color_map
     {
       #declare a=510;
       #while (a<765)
         #declare c=eval_pigment(Saturn_Rings_UnlitSide, 
<2999/3000-a/1500, 0.5, 0>);
         #declare f=eval_pigment(Saturn_Rings_Transparency, 
<2999/3000-a/1500, 0.5, 0>);
         [a*(((140390-74510)/140390)/1500) rgb c filter f.gray]
         #declare a=a+1;
       #end
     }
   }
   finish { F_Saturn_Rings_UnlitSide }
}

#declare Ring_UnlitSide_Map_766_to_1020 =
texture
{
   pigment
   {
     cylindrical
     color_map
     {
       #declare a=765;
       #while (a<1020)
         #declare c=eval_pigment(Saturn_Rings_UnlitSide, 
<2999/3000-a/1500, 0.5, 0>);
         #declare f=eval_pigment(Saturn_Rings_Transparency, 
<2999/3000-a/1500, 0.5, 0>);
         [a*(((140390-74510)/140390)/1500) rgb c filter f.gray]
         #declare a=a+1;
       #end
     }
   }
   finish { F_Saturn_Rings_UnlitSide }
}

#declare Ring_UnlitSide_Map_1021_to_1275 =
texture
{
   pigment
   {
     cylindrical
     color_map
     {
       #declare a=1020;
       #while (a<1275)
         #declare c=eval_pigment(Saturn_Rings_UnlitSide, 
<2999/3000-a/1500, 0.5, 0>);
         #declare f=eval_pigment(Saturn_Rings_Transparency, 
<2999/3000-a/1500, 0.5, 0>);
         [a*(((140390-74510)/140390)/1500) rgb c filter f.gray]
         #declare a=a+1;
       #end
     }
   }
   finish { F_Saturn_Rings_UnlitSide }
}

#declare Ring_UnlitSide_Map_1276_to_1500 =
texture
{
   pigment
   {
     cylindrical
     color_map
     {
       #declare a=1275;
       #while (a<1500)
         #declare c=eval_pigment(Saturn_Rings_UnlitSide, 
<2999/3000-a/1500, 0.5, 0>);
         #declare f=eval_pigment(Saturn_Rings_Transparency, 
<2999/3000-a/1500, 0.5, 0>);
         [a*(((140390-74510)/140390)/1500) rgb c filter f.gray]
         #declare a=a+1;
       #end
     }
   }
   finish { F_Saturn_Rings_UnlitSide }
}

union // Saturn with rings
{
   sphere // Saturn
   {
     0, 1
     texture
     {
       pigment
       {
         image_map
         {
           jpeg "solarsys/saturn_bjoernjonsson.jpg"
           map_type 1
           interpolate 2
         }
       }
       finish { F_Standard_Planetary_Surface }
     }
     scale <bodies[72][1], bodies[72][2], bodies[72][3]>/sc
   }
   difference
   {
     cylinder
     {
       <0, -0.11, 0>/sc, <0, 0.1, 0>/sc, 140390/sc
     }
     cylinder
     {
       <0, -0.12, 0>/sc, <0, 0.11, 0>/sc, 74510/sc
     }
     cylinder // unlit side!
     {
       <0, -0.15, 0>/sc, <0, -0.1, 0>/sc, 150000/sc
       texture
       {
         cylindrical
         texture_map
         {
           [0 
Ring_UnlitSide_Map_1_to_255 ]
           [255*(((140390-74510)/140390)/1500) 
Ring_UnlitSide_Map_256_to_510]
           [510*(((140390-74510)/140390)/1500) 
Ring_UnlitSide_Map_511_to_765]
           [765*(((140390-74510)/140390)/1500) 
Ring_UnlitSide_Map_766_to_1020]
           [1020*(((140390-74510)/140390)/1500) 
Ring_UnlitSide_Map_1021_to_1275]
           [1275*(((140390-74510)/140390)/1500) 
Ring_UnlitSide_Map_1276_to_1500]
         }
         scale 140390/sc
       }
     }
       texture
       {
         cylindrical
         texture_map
         {
           [0                                   Ring_Color_Map_1_to_255]
           [255*(((140390-74510)/140390)/1500)  Ring_Color_Map_256_to_510]
           [510*(((140390-74510)/140390)/1500) 
Ring_Color_Map_511_to_765]
           [765*(((140390-74510)/140390)/1500) 
Ring_Color_Map_766_to_1020]
           [1020*(((140390-74510)/140390)/1500) Ring_Color_Map_1021_to_1275]
           [1275*(((140390-74510)/140390)/1500) Ring_Color_Map_1276_to_1500]
         }
         scale 140390/sc
       }
   }
   SetAxis(bodies[72][10], bodies[72][11])
   translate Pos_Saturn/sc
}

Attached below are two views of Saturn: one showing the sunlit side of 
the rings, the other showing the unlit side - but with a conventionally 
texture rather than media, I can't get Saturn's shadow becoming visible 
on the unlit side. With the real thing, some sunlight instead would be 
scattered through to the unlit side, so I started trying scattering media...

See you in Khyberspace!

Yadgar


Post a reply to this message


Attachments:
Download '2009-11-10 saturn, take 6.jpg' (52 KB) Download '2009-11-10 saturn, take 8.jpg' (27 KB)

Preview of image '2009-11-10 saturn, take 6.jpg'
2009-11-10 saturn, take 6.jpg

Preview of image '2009-11-10 saturn, take 8.jpg'
2009-11-10 saturn, take 8.jpg


 

From: clipka
Subject: Re: Scattering media with a color_map - how to do?
Date: 22 Nov 2009 23:00:01
Message: <4b0a08c1$1@news.povray.org>


> Whatever I tried, the cylindrical pattern never showed up - instead I 
> got a uniformly white ring! What's my mistake?

You simply underestimated the effect of scale on media. Scaling does 
increase the volume, but leaves the density unaffected, so there's more 
matter to emit / absorb / scatter the light.

Reduce the "emission" value (something like 0.005 should get you 
started), and you should be fine.

But didn't you want to use scattering media anyway?


Post a reply to this message

From: Alain
Subject: Re: Scattering media with a color_map - how to do?
Date: 22 Nov 2009 23:13:18
Message: <4b0a0bde@news.povray.org>

> High!
> 
> Still trying to get believable Saturnian rings... so I worked through 
> the media section of the manual to finally get scattering media which 
> shows cylindrical banding - but my attempts failed so far.
> 
> Here is the code for the test scene attached below:
> 
> union
> {
>   sphere
>   {
>     0, 1
>     texture
>     {
>       pigment { color rgb <0.6, 0.4, 0> }
>       finish { ambient 0.02 diffuse 1 brilliance 0.8 }
>     }
>   }
>   difference
>   {
>     cylinder
>     {
>       <0, -0.001, 0>, <0, 0.001, 0>, 3.68
>     }
>     cylinder
>     {
>       <0, -0.0011, 0>, <0, 0.0011, 0>, 1.75
>     }
>     hollow
>     pigment { rgbt 1 }
>     interior
>     {
>       media
>       {
>         emission 0.75
Considering the final thickness and the view point, that's huge...
>         scattering
>         {
>           1, 0.1
>           extinction 1
>         }
>         density
>         {
>           cylindrical
>           color_map
>           {
>             [0 rgbf <1, 0.8, 0.7, 0.1> ]
>             [0.3 rgbf <1, 0.8, 0.7, 0.1> ]
>             [0.3 rgbf <0.1, 0.3, 0.1, 0.95>]
>             [0.35 rgbf <0.1, 0.3, 0.1, 0.95>]
>             [0.35 rgbf <0.9, 0.83, 0.3, 0.2>]
>           }
>           scale 3.68
>         }
>       }
>     }
>   }
>   rotate <-4, 7, 0>
>   scale 10000
>   translate z*50000
> }
> 
> // end of code
> 
> Whatever I tried, the cylindrical pattern never showed up - instead I 
> got a uniformly white ring! What's my mistake?
> 
> See you in Khyberspace!
> 
> Yadgar
> 
> ------------------------------------------------------------------------
> 

Personaly, I'd start by removing the emissive media, or tone it down a 
lot. No more than emission 0.001.

Next, use scattering type 5 with a negative exentricity for the outer 
rings: most of the incoming light is scattered back. Use a second media 
with type 2 or 3 for the inner ring, also, with a much lower density.

Not sure about your use of a filtering component in your color_map.

You scale the rings by 10 000. That means that there is 10 000 times 
more media. The thickness of the ring goes from 0.002 to 20. Then, with 
your very oblique view, you probably travel at least 5 times longer 
through the media. This may explain, toggether with your emissive media, 
why you get that saturated white ring.



Alain


Post a reply to this message

From: Agustin Britait Molina
Subject: Re: Scattering media with a color_map - how to do?
Date: 23 Nov 2009 00:30:00
Message: <web.4b0a1d9aff4a7d13312e3e870@news.povray.org>
Some off-topic: The ring's shadow over the planet surface show other shape in
the real Saturn, you can see this in some real photos of the planet.

http://www.jpl.nasa.gov/images/saturn/saturn1208-browse.jpg

Maybe if you scale all the scene 10.000 in size and put the light source very
very far, the shadow appear more real.


Post a reply to this message

From: Thomas de Groot
Subject: Re: Scattering media with a color_map - how to do?
Date: 23 Nov 2009 03:18:17
Message: <4b0a4549@news.povray.org>
"Alain" <aze### [at] qwertyorg> schreef in bericht 
news:4b0a0bde@news.povray.org...
> You scale the rings by 10 000. That means that there is 10 000 times more 
> media. The thickness of the ring goes from 0.002 to 20. Then, with your 
> very oblique view, you probably travel at least 5 times longer through the 
> media. This may explain, toggether with your emissive media, why you get 
> that saturated white ring.

In other words, and as a general rule of thumb, always divide your 
scattering media by the *same amount* (or the same vector) with which you 
scaled the object containing the media. You can fine tune around that of 
course.

Thomas


Post a reply to this message

From: Jörg 'Yadgar' Bleimann
Subject: Re: Scattering media with a color_map - how to do?
Date: 23 Nov 2009 03:26:12
Message: <4b0a4724$1@news.povray.org>
High!

Agustin Britait Molina wrote:
> Some off-topic: The ring's shadow over the planet surface show other shape in
> the real Saturn, you can see this in some real photos of the planet.
> 
> http://www.jpl.nasa.gov/images/saturn/saturn1208-browse.jpg
> 
> Maybe if you scale all the scene 10.000 in size and put the light source very
> very far, the shadow appear more real.
> 

Thank you, but this is only a small test scene, not intended to be 
realistic!

See you in Khyberspace!

Yadgar


Post a reply to this message

From: Jörg 'Yadgar' Bleimann
Subject: Re: Scattering media with a color_map - how to do?
Date: 23 Nov 2009 03:36:53
Message: <4b0a49a5$1@news.povray.org>
High!


> Personaly, I'd start by removing the emissive media, or tone it down a 
> lot. No more than emission 0.001.
> 
> Next, use scattering type 5 with a negative exentricity for the outer 
> rings: most of the incoming light is scattered back. Use a second media 
> with type 2 or 3 for the inner ring, also, with a much lower density.
> 
> Not sure about your use of a filtering component in your color_map.
> 
> You scale the rings by 10 000. That means that there is 10 000 times 
> more media. The thickness of the ring goes from 0.002 to 20. Then, with 
> your very oblique view, you probably travel at least 5 times longer 
> through the media. This may explain, toggether with your emissive media, 
> why you get that saturated white ring.

Meanwhile, I tried this with my original Saturn scene (see my second 
posting in this thread)... but then, a new problem occurs: as the 
original color and transparency maps consist of 1500 values each, I had 
to compose the original color_map from six single color_map put together 
in one texture_map (a color_map can only contain up to 255 entries).

As I now reworked the whole thing as a media statement, I got the error 
message "Keyword 'texture_map' can only be used in a texture statement."
How can I still build multi-partite color_maps? Or do I have to reduce 
the entries to 255?

See you in Khyberspace!

Yadgar


Post a reply to this message

From: clipka
Subject: Re: Scattering media with a color_map - how to do?
Date: 23 Nov 2009 08:50:50
Message: <4b0a933a$1@news.povray.org>

> As I now reworked the whole thing as a media statement, I got the error 
> message "Keyword 'texture_map' can only be used in a texture statement."
> How can I still build multi-partite color_maps? Or do I have to reduce 
> the entries to 255?

"There may be from 2 to 256 entries in the map.

Density maps may be nested to any level of complexity you desire. The 
densities in a map may have color maps or density maps or any type of 
density you want."


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

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