POV-Ray : Newsgroups : povray.text.tutorials : How to make rippling water? : Re: How to make rippling water? Server Time
18 May 2024 10:35:01 EDT (-0400)
  Re: How to make rippling water?  
From: Josh English
Date: 1 Feb 1999 17:35:17
Message: <36B62D04.9C5296EB@spiritone.com>
Tim Soderstrom wrote:

> I've read the docs over and over again about the concept of phasing, and
> I have never figured it out.
> The problem is that I want a water pigment to ripple and I can't figure
> out how to do it properly.
> I've tried using a normal map, but the reflection is not right. I would
> also like to know if there is anyway to fade an entire color to another
> (IE without using a pigment modified like gradient, so the color is
> solid and changes to another solid color). Any help with either would be
> apreciated! :)
>
> Thanks,
> Tim Soderstrm

Here is basic water: it's not very fancy:

// ground under water... gotta have somthing down there
plane { y,-5 pigment { granite } }

// the water itself
plane { y,0
              pigment { rgbf 1 } // this makes the water perfectly clear
              normal { waves phase clock }
              finish { reflection 0.75
                            specular 1 }
              interior { ior 1.333 }
           }

this creates water ripples emating from the center when you animate it with
the clock value going from 0 to 1.

As for the second question about color, try this:

plane { y,0
             pigment { gradient x
                               color_map { [0.0 rgb <1,0,0> ]
                                                     [ 1.0 rgb <0,0,1> ] } }
}

this creates a blend from red to blue, the abruptly changes back to red 1
unit over, blends to blue, and back to red... ad nauseum.
The important thing is that when x=0,1,2,3... (basically, when it reaches an
integer value) it is red. As it approaches the next integer it shifts to
blue.

If you want to have one color change immediately to another look at this
example:

plane { y,0
             pigment { gradient x
                               color_map { [0.0 rgb <1,0,0> ]
                                                      [ 0.5 rgb <1,0,0> ]
                                                      [0.5 rgb<0,0,1> ]
                                                     [ 1.0 rgb <0,0,1> ] } }
}

This creates a band of red then a band of blue, then a band of red, then a
band of blue.... as nauseum

Now, if we make a slight alteration:

plane { y,0
             pigment { gradient x
                               color_map { [0.0 rgb <1,0,0> ]
                                                      [ 0.3 rgb <1,0,0> ]
                                                      [0.6 rgb<0,0,1> ]
                                                     [ 1.0 rgb <0,0,1> ] } }
}

Now we start at red, 0.3 units over we're still at red, then begin to blend
towards blue. We get there at 0.6 units, and stay blue until 1 unit over,
then start back at red and go through the whole exercise again. Now lets
look at how phasing would affect this ( I'll bet you thought I forgot)

plane { y,0
             pigment { gradient x
                               color_map { [0.0 rgb <1,0,0> ]
                                                      [ 0.3 rgb <1,0,0> ]
                                                      [0.6 rgb<0,0,1> ]
                                                     [ 1.0 rgb <0,0,1> ] }
                              phase 0.1 } }

Now the color map starts 0.1 units over, so when x=0, instead of using the
color at 0 in the color map, we start at 0.1 in the color map.
If we set the phase value to 0.3, then when x=0 it will be red, but at
x=0.3, it will be blue.

Now, back to the water. The ripples statement creates a sine wave like bump
pattern, if you have a graphing calculator, you can graph y=sin(x)
phase is altering the formula to y=sin(x + phase). If this doesn't make
sense, try it on a calculator, or just ignore it. But the bump pattern in
the normal statement works similalry to the color_map we used earlier. It
slides the bump pattern from the origin the same way it slides it in the
color_map

Hope this helps
--
Josh English
eng### [at] spiritonecom
www.spiritone.com/~english


Post a reply to this message

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