POV-Ray : Newsgroups : povray.newusers : How to use self defined functions as patterns? : Re: How to use self defined functions as patterns? Server Time
29 Feb 2024 12:47:52 EST (-0500)
  Re: How to use self defined functions as patterns?  
From: Kenneth
Date: 3 Apr 2018 20:55:00
Message: <web.5ac420fc1863261da47873e10@news.povray.org>
"rastertastic" <nomail@nomail> wrote:

> So basically I'm asking clarification on how to use such self-defined functions
> like  x + y + z  as patterns with, say, color maps.

Here's a simple example...

#declare Foo = function(x,y){2*x + 2*y}

box{<0,0,0>, <1,1,.01>
pigment {
  function {Foo(x,y)}
       sine_wave // otherwise, a default 'ramp' wave is used
              [0 rgb 0]
              [1 rgb 1]

The interesting thing to note is that the resulting sine-wave-like appearance is
actually a sort of 'absolute' sine-wave-- in other words, instead of an expected
'peak and trough', the troughs have been turned into peaks as well. (That's the
visual result, anyway.) I don't yet know how to 'bias' the function or
color_map(?) to get a 'full' sine-wave-- or what looks like one, at least.

BTW, somewhere in the POV-Ray documentation, it states that when using a
function as a pigment or pigment pattern, the 'image' of the function is
actually just an infinitely thin slice, taken in the x/y plane (x from 0.0 to
1.0, y from 0.0 to 1.0). You can change the location of that slice, though:
                 #declare Foo = function(x,y){2*(x + 1.7) + 2*y}

This moves the slice by 1.7 units in x -- although +1.7 actually means -1.7,
strangely enough. Put another way, the imaginary 'camera' that's sampling the
slice has ITSELF moved +1.7 units in x. So the pattern appears to move -1.7

Post a reply to this message

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