POV-Ray : Newsgroups : povray.general : color shift Server Time
30 Nov 2024 01:37:34 EST (-0500)
  color shift (Message 1 to 4 of 4)  
From: Barehunter
Subject: color shift
Date: 18 Feb 2005 23:55:01
Message: <web.4216c6382eb3d6e338ac41b0@news.povray.org>
Ok I am trying to make a box that starts at the top with a red color, ends
at the bottem with black and the color morphs from red to black as you go
from top to bottem. I am reading the manual to try to figure this but I am
lost. and I have the strong feeling that this is in there somewhere


Post a reply to this message

From: Slime
Subject: Re: color shift
Date: 19 Feb 2005 00:04:51
Message: <4216c8f3$1@news.povray.org>
> Ok I am trying to make a box that starts at the top with a red color, ends
> at the bottem with black and the color morphs from red to black as you go
> from top to bottem. I am reading the manual to try to figure this but I am
> lost. and I have the strong feeling that this is in there somewhere

This can be done with a simple color_map:

box {
    <1,2,3>, <4,5,6>
    pigment {
        gradient y // pattern that goes from 0 to 1 over and over as you go
upwards
        color_map {
            [0 rgb <0,0,0>] // black at bottom
            [1 rgb <1,0,0>] // red at top
        }
        scale <1, 3.001, 1> // scale by slightly more than the box's height
in the y-direction
        translate 1.9995*y // translate so the bottom almost matches up with
the bottom of the box
    }
}

Note that I scaled the pattern slightly higher than the box's height so that
the top and bottom surface of the box would not be right at the place where
the red abruptly transitions into black, causing possible artifacts.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Barehunter
Subject: Re: color shift
Date: 19 Feb 2005 00:20:00
Message: <web.4216cb55999180fe38ac41b0@news.povray.org>
That worked perfectly. Thanks Dude!


Post a reply to this message

From:
Subject: Re: color shift
Date: 19 Feb 2005 11:17:03
Message: <4217667f$1@news.povray.org>
// Hi Barehunter,
//
// the possible artifacts mentioned by Slime are most easily
// avoided with triangle_wave. Note the multiplication by 2
// in the scale; this is neccesary because the triangle_wave
// pattern contains 2 repetitions of the gradient pattern
// (one "forward" and one "backward").
//
// If you delete the key word "triangle-wave", remove "2*"
// from the scale, and render without anti-alias, the artifacts
// become visible, esp. on the black underside.
//
//    Sputnik


#declare BoxX = 1;
#declare BoxY = 2;
#declare BoxZ = 3;

#declare Box =
  box { 0, <BoxX, BoxY, BoxZ>
    pigment {
      gradient y
      triangle_wave
      color_map { [0 red 0] [1 red 1] }
      scale <1, 2*BoxY, 1>
      }
    finish { ambient 1 diffuse 0 }
    translate -<BoxX, BoxY, BoxZ>/2
    }

background { rgb 0.3 }

object { Box rotate -20*x translate <-BoxX, 0, 1.5*BoxZ> }
object { Box rotate  20*x translate < BoxX, 0, 1.5*BoxZ> }


Post a reply to this message

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