POV-Ray : Newsgroups : povray.binaries.images : Scattering media with a color_map - how to do? : Re: Scattering media with a color_map - how to do? Server Time
4 Nov 2024 19:22:19 EST (-0500)
  Re: Scattering media with a color_map - how to do?  
From: Jörg 'Yadgar' Bleimann
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


 

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