POV-Ray : Newsgroups : povray.advanced-users : Function logic? : Re: Function logic? Server Time
28 Jul 2024 16:15:10 EDT (-0400)
  Re: Function logic?  
From: Mike Williams
Date: 6 Dec 2004 13:26:03
Message: <jEBA9BAwPKtBFwS8@econym.demon.co.uk>
Wasn't it Tim Nikias who wrote:
>> SNIPPED Function-Pigment/Pattern-Issue
>
>Ah, thank you, now I understand. It does make sense after all... ;-)
>
>> To make things even better, you could try rewriting the whole thing to
>> use patterns instead of pigments. The code will probably be simpler and
>> the processing more efficient without those unwanted .blue and .green
>> channels.
>
>Care to give a small starter with how to use patterns with functions? What I
>do now is simply use a pattern and use a colormap ranging from rgb 0 to rgb
>1, but not just {[0 rgb 0][1 rgb 1]}, so I'm not sure if that is possible
>with just patterns.

Patterns naturally produce a value in the range 0 to 1. The colour map
specifies what colours correspond to those values.
So by using {[0 rbg <0,0,0>][1 rgb <1,1,1>]} and then using only the red
channel (.x) you actually just get back the value that the pattern
returned in the fist place.

So if you had something like

#declare F1=function {
  pigment {
   granite turbulence 1 
   colour_map {[0 rgb 0][1 rgb 1]}
  }
}
#declare F2 = function {F1(x,y,z).x}


You can, instead, write just

#declare F2=function {
  pattern {
    granite turbulence 1
  }
}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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