POV-Ray : Newsgroups : povray.newusers : Pigment colour from RGB functions : Re: Pigment colour from RGB functions Server Time
28 May 2024 16:27:28 EDT (-0400)
  Re: Pigment colour from RGB functions  
From: Samuel Benge
Date: 21 May 2013 12:50:01
Message: <web.519ba54783779f7f826ce7c10@news.povray.org>
Scott,

Not sure how much it helps, but here's the method I use:

#declare PFunc = function{pigment{bozo}}

#macro RGBFunc(Channel)
 PFunc(x, y, z)
 #switch(Channel)#case(0).x#break #case(1).y#break #case(2).z#break #end
#end

sphere{
 0, 1
 pigment{
  average
  pigment_map{
   [1 function{RGBFunc(0)} color_map{[0 rgb 0][1 rgb x*3]}]
   [1 function{RGBFunc(1)} color_map{[0 rgb 0][1 rgb y*3]}]
   [1 function{RGBFunc(2)} color_map{[0 rgb 0][1 rgb z*3]}]
  }
 }
}

That's just the bare-bones setup; there's still a lot of room for adjustment.

scott <sco### [at] scottcom> wrote:
> I had thought of doing such a thing but I don't know in my code how
> large the return values of the function will be (certainly not limited
> to 1). If there is no better alternative then I'll end up with something
> like this:
>
>   #local K = 1e8;
>   #local P_R=pigment{
>      function{ functionR(x,y,z)/K }
>      color_map{ [0,rgb <0,0,0>] [1,rgb <3*K,0,0>] }
>   };
>
> But obviously I have to choose K large enough for all possible return
> values (maybe I can determine the upper limit with some maths).

I've had to do it that way, too. In my case I wanted to cover the entire color
range of an hdr image... but I think I just used 256 in the end. Might account
for some color banding I've seen since then ;)

Sam


Post a reply to this message

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