POV-Ray : Newsgroups : povray.binaries.images : Transition between two medias : Re: Transition between two medias Server Time
30 Jul 2024 08:15:00 EDT (-0400)
  Re: Transition between two medias  
From: Thomas de Groot
Date: 24 Apr 2012 08:06:06
Message: <4f96972e@news.povray.org>
On 24-4-2012 12:58, Christian Froeschlin wrote:
> are you looking for something like this:
>
> #declare f_gradient_x_non_repeating = function
> {
> select(x,0,select(x-1,x-1,1))
>
> // of course you can also construct something using
> // f_spherical here depending on desired geometry
> }
>
> box
> {
> <-2,-1,0>,<2,1,1> hollow
> pigment {color rgbt 1}
> interior
> {
> media
> {
> method 3
> absorption 10
> density
> {
> function {f_gradient_x_non_repeating(x,y,z)}
> translate -0.5*x
> scale 2*x
> rotate 45*z
> color_map
> {
> [0.0 color Navy]
> [1.0 color Khaki]
> }
> }
> }
> }
> }
Thank you both, Le_Forgeron and Christian. I feel Le_Forgeron's solution 
to be rather complicated and I do not yet understand everything yet, 
although it might be the best approach in the end.

Christians solution is elegant and promises to be my favourite choice. 
Using my own water colours, and tweaking the code in the following way:

//=======================================================================
#declare Sea_col = srgb <0.51373, 0.70588, 0.70588>;   //clear water
#declare Mud_col = srgb <0.74118, 0.71765, 0.41961>+<0.2, 0.2, 0>; 
//muddy water
#declare Dist    = 200;  //determines the depth transparency of the 
water column

#local FD = -(Dist/(6*25.4))/ln(0.58);	//fade distance

#declare f_gradient_x_non_repeating = function {select(x,0,select(x-1,x,1))}

box {
   <-3,-1,-1>, <3,1,1>
   hollow
   pigment {color rgbt 1}
   finish {
     conserve_energy
     diffuse 0.2
     ambient 0
     reflection {0.01, 0.2 fresnel on metallic 0}
   }
   normal {crackle 0.15 scale <0.45,0.25,0.25>*2 turbulence 0.5 }
   interior {
     ior 1.33
     media {
       method 3
       absorption 5
       density {rgb 1/FD}
       //next commented out to follow original fading on line above
       /*density {
         function {f_gradient_x_non_repeating(x,y,z)}
         translate 0.25*x
         scale 2*x
         rotate 70*z
         color_map {
           [0.0 color Sea_col]
           [1.0 color Mud_col]
         }
       }*/
     }
     media {
       method 3
       scattering {3, Sea_col}
       density {
         function {f_gradient_x_non_repeating(x,y,z)}
         translate 0.25*x
         scale 1*x
         rotate 60*z
         color_map {
           [0.0 color Mud_col]
           [1.0 color Sea_col]
         }
       }
     }
   }
}
//=======================================================================

This is going in the right direction! I have see how to tweak the 
colours to obtain approximately my original water aspect.

Thomas


Post a reply to this message


Attachments:
Download 'mediatest2.png' (33 KB)

Preview of image 'mediatest2.png'
mediatest2.png


 

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