POV-Ray : Newsgroups : povray.newusers : Changing the colour of a surface depending on its height : Re: Changing the colour of a surface depending on its height Server Time
4 Jul 2024 14:09:19 EDT (-0400)
  Re: Changing the colour of a surface depending on its height  
From: Kenneth
Date: 6 Oct 2010 05:35:00
Message: <web.4cac3f51e58419fa196b08580@news.povray.org>
"Colaroid" <nomail@nomail> wrote:

> Does anybody know if this is possible or not?
>

Yes indeed.  The simplest way is with a 'gradient y' color_map. You can blend
one color into another over a distance. (The default distance of the gradient y
pattern is from a height of 0.0 to a height of 1.0, but you can scale that.)
Since the base of your height_field is at 0.0 by default, you can get the color
blend to go from the base, up to the tip of your highest mountain peak. (The
color_map repeats after that.)

For example:
height_field{.....
     texture{
          pigment{
               gradient y
               color_map{
                       [0.0 rgb <.3,1,.3>] // green--starts at bottom
                       [1.0 rgb .6] // gray--ends at top
                        }
                       scale 2.5 // or whatever (to match the height of
                                 // your height_field)
                 }
             finish{ambient .2 diffuse .8}
            }
            } // end of height_field

BTW, you can have *many* colors in the color_map, between the 0.0-to-1.0 values
of the index list.

Hope this helps.

Ken


Post a reply to this message

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