POV-Ray : Newsgroups : povray.advanced-users : Color function : Re: Color function Server Time
28 Jul 2024 14:34:18 EDT (-0400)
  Re: Color function  
From: PM 2Ring
Date: 7 Apr 2005 12:50:00
Message: <web.425563e2d92a72013d6ca37a0@news.povray.org>
"val" <val### [at] carraraus> wrote:

> So, I realized I need a way to color the pixel in position (x, y, z), or, in
> other words, I need a function like this one:
>
>       texture {
>           pigment { color { function { fun_color(x, y, z) }
>           }
>           finish { ambient 1 diffuse 0 }
>       }
>
> but, of course, POV doesn't recognize this sintaxe.
> Suggestions?

Here's one possibility below. You may also like to know that POV can cope
with negative colour values. I'll post a relevant example soon.

// Persistence of Vision Ray Tracer Scene Description File
// File: PigFunc.pov
// Vers: 3.6
// Desc: Pigment function demo
// Date: 2005.02.19
// Auth: PM 2Ring
//
//  -D +A0.1 +AM2 +R3
//  -F -A0.4 +AM2 +R1
//

#version 3.6;

global_settings {
  assumed_gamma 1
}

camera {
  location <0, 5, -1> * 2.4
  look_at  0
  right x*image_width/image_height up y

  angle 40
}

light_source {
   <0, 2, -1> * 30
   rgb 1
}

//Make a color_map from a0 to a1
#macro CMRange(a0, a1)color_map{[0 a0][1 a1]}#end

//Make a color_map from Black to a
#macro CMFull(a)CMRange(rgb 0, a)#end

#declare TestPig = pigment{hexagon rgb<1 .9 .5>, rgb <.85 .5 .6>, rgb <0 0
..8>}

#declare f_Pig = function{pigment{TestPig}}

//Turn a pigment function into a real-live pigment!
#declare PigRGB =
pigment{
  average
  pigment_map {
    [1 function{f_Pig(x,y,z).red} CMFull(red 3)]
    [1 function{f_Pig(x,y,z).green} CMFull(green 3)]
    [1 function{f_Pig(x,y,z).blue} CMFull(blue 3)]
  }
}

cylinder{
  -.1*y, .1*y, 3

  pigment{
    PigRGB
    //TestPig
  }
}

//---------------------------------------------------------


Post a reply to this message

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