POV-Ray : Newsgroups : povray.binaries.images : Bezier pigment colours : Bezier pigment colours Server Time
2 Oct 2024 06:27:53 EDT (-0400)
  Bezier pigment colours  
From: Tor Olav Kristensen
Date: 2 Jun 2000 11:48:33
Message: <3937D74E.8B3772EB@hotmail.com>
I wanted to get smoother transisions (no "banding")
between the different colours in a pigment color_map.

A macro I made generates the different colour entries
for the color_map.

Here's two images rendered with the code below.

Any comments ?

Are there other ways to get smooth transitions 
between colours in a color_map ?


Tor Olav
--
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.1;

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#macro Bezier(TT, StartPoint, StartVector, EndPoint, EndVector)

  #local aa =  2*StartPoint - 2*EndPoint + 3*StartVector - 3*EndVector;
  #local bb = -3*StartPoint + 3*EndPoint - 6*StartVector + 3*EndVector;
  #local cc =  3*StartVector;
  #local dd =  StartPoint;

  (((aa*TT + bb)*TT + cc)*TT + dd)
  
#end // macro Bezier

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare FirstColour    = <0.5, 0.0, 0.0>;
#declare FirstDirection = <4.0, 1.0, 0.0>;
#declare LastDirection  = <0.0, 1.0, 1.0>;
#declare LastColour     = <0.0, 0.0, 0.5>;
#declare Bright = 0.3;

/* // Also try this
#declare FirstColour    = <  2,  0,   0>;
#declare FirstDirection = <  0,  2,   0>;
#declare LastDirection  = <  0, -1,   1>;
#declare LastColour     = <  0,  0,   1>;
#declare Bright = 0.5;
*/

#declare NrOfEntries = 100; // min 2, max 256
 
#declare BezierMap = 
color_map {
  #declare TT = 0;
  #while (TT < 1)
    [ TT rgb Bright*Bezier(TT, 
                           FirstColour, FirstDirection, 
                           LastDirection, LastColour) ]
    #declare TT = TT + 1/NrOfEntries;
  #end // while
}

#declare BezierPigment =
pigment {
//  bozo
  gradient y
  turbulence 0.3
  color_map { BezierMap }
}

sky_sphere { pigment { BezierPigment } }

light_source { <0, 0, 0> color 1.5*<1, 1, 1> }

camera {
  location <1, 0, 0>
  look_at <0, 0, 0>
  angle 120
}                                                    

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message


Attachments:
Download 'bezierpigment02.jpg' (11 KB) Download 'bezierpigment03.jpg' (9 KB)

Preview of image 'bezierpigment02.jpg'
bezierpigment02.jpg

Preview of image 'bezierpigment03.jpg'
bezierpigment03.jpg


 

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