POV-Ray : Newsgroups : povray.newusers : Calculating the pigment RGB values with functions? Server Time
1 Nov 2024 08:11:46 EDT (-0400)
  Calculating the pigment RGB values with functions? (Message 1 to 2 of 2)  
From: Hadmut Danisch
Subject: Calculating the pigment RGB values with functions?
Date: 17 Sep 2009 18:53:51
Message: <4AB2BDFF.4010805@msgid.danisch.de>
Hi,

a newbie question:


I want to create objects, where I want to calculate the r,g,b and
transparency values of the pigment rgb color with self written functions.

Unfortunately, I could not find a way to declare this. Whatever I try,
povray does not accept it as correct. It looks as if the povray language
is not really orthogonal.

How would I achieve to have texture where all four channels (rgbt) are
calculated with function?

Is this restricted to 1-dimensional calculations and mapping with a
color map?

regards
Hadmut


Post a reply to this message

From: clipka
Subject: Re: Calculating the pigment RGB values with functions?
Date: 17 Sep 2009 19:51:18
Message: <4ab2cb76$1@news.povray.org>
Hadmut Danisch schrieb:
> 
> How would I achieve to have texture where all four channels (rgbt) are
> calculated with function?

At present, the virtual machine used to implement functions in POV-Ray 
does not support vectors. However, you can achieve the desired effect 
with average pigments as follows:

- Declare four functions, one for each of R, G and B and T.

- Mix and color the RGB components using the 'average' pattern (note 
that each component is "colorized" with a factor of 3):

    #declare MyPigmentRGB = pigment {
      average
      pigment_map {
        [1 function { MyFnR(x,y,z) } color_map [0 rgb 0][1 red   3]]
        [1 function { MyFnG(x,y,z) } color_map [0 rgb 0][1 green 3]]
        [1 function { MyFnB(x,y,z) } color_map [0 rgb 0][1 blue  3]]
      }
    }

- To mix in the transparency, use another pigment map to fade between 
the RGB pigment as above, and a purely transparent pigment:

    #declare MyPigmentRGBT = pigment {
      function { MyFnT(x,y,z) }
      pigment_map {
        [0 MyPigmentRGB]
        [1 color rgbt 1]
      }
    }

(Didn't test either of these; I may have introduced one or two syntax 
errors.)


Post a reply to this message

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