POV-Ray : Newsgroups : povray.binaries.images : Bathtub - take 2 : Re: Bathtub - take 2 Server Time
1 Aug 2024 14:31:37 EDT (-0400)
  Re: Bathtub - take 2  
From: Trevor G Quayle
Date: 20 Dec 2008 15:40:01
Message: <web.494d57626655db18c67b294d0@news.povray.org>
"alphaQuad" <alp### [at] earthlinknet> wrote:
> previously had a lego-floor bottom,
>
> bottom tiled at a depth of 65.
>
> #declare RHIT=0.25;
> #declare WHit=0.45;
>
> ripple height
> and
> wave height
>
> Am I understanding your naming convention? Kinda important to grasping the math
> logic.
>
> Ship looks like it sustained damage or landed on the wicked, depraved witch.

OK, my original water pattern was just thrown together using some previously
developed code so it wasn't commented or named with consistency.  I have
reworked it with better naming conventions and commenting and have also
optimizified the code somewhat.  Note that the dimensions used for the declared
values (PoolSiz, PoolDep, WavHt, WavSpac, RipHt, RipSpac) correspond to the
final scene level dimensions for ease of use.

//START
#declare PoolSiz=216+8; //length of pool sides (square)
#declare PoolDep=75;    //depth of pool

#declare WavHt=0.45;    //height of waves
#declare WavSpac=30;    //spacing of waves

#declare RipHt=0.25;    //height of ripples (pool sides)
#declare RipSpac=4;     //spacing of ripples

#declare TotDep=PoolDep+WavHt+RipHt; //total water depth


#declare FWav1 = //wave function
function{
  pigment{
    marble frequency PoolSiz/WavSpac sine_wave
    scale 1/5
    warp{turbulence 1.5}
    scale 5
    warp{turbulence 0.5}

  }
}

#local FWav2 = function {FWav1(x,y,z).gray*0.5+FWav1(y,x,z).gray*0.5} //wave
function 2

#local FRip1 =  //ripple function
function {
  pigment{
    function{pow(max(min(abs(x*2-1),1)-0.5,0)/(1-0.5),3)}
    pigment_map{
      [0.0 rgb 0]
      [1.0 marble frequency PoolSiz/RipSpac sine_wave]
    }
    scale 1/5
    warp{turbulence 0.05*x}
    scale 5

  }
}

#local FRip2 = function {FRip1(x,y,z).gray*0.5+FRip1(y,x,z).gray*0.5}  //ripple
function 2

#declare WHt=WavHt/TotDep; //relative depth of waves (% total depth)
#declare RHt=RipHt/TotDep; //relative depth of ripples (% total depth)

#local FWat = function {FWav2(x,y,z)*WHt+FRip2(x,y,z)*RHt+(1-WHt-RHt)}  //water
surface function

#declare WatHF=  //water heightfield
height_field{
  function 600,600 {pattern{function{FWat(x,y,z)}}}
  smooth
  hollow
  scale <PoolSiz,TotDep,PoolSiz>
}

#declare WatCol=rgb <0.51373, 0.70588, 0.70588>; //Water colour
#local FadeDis=-60/ln(0.58);                     //fade distance

#declare MWater= //water material
  material{
    texture{
      pigment{rgbt 1}
      finish{conserve_energy  diffuse 0.0  ambient 0  reflection{0 1 fresnel on
metallic 0}}
    }
    interior{
      ior 1.33
      media{
        absorption rgb 1-WatCol //coastal
        density{rgb 1/FadeDis}
      }
    }
  }

// water
object{WatHF translate <-8,-76,-8> hollow material { MWater translate
<-10,0,-10>}}
//END

-tgq


Post a reply to this message

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