POV-Ray : Newsgroups : povray.advanced-users : Function logic? Server Time
28 Jul 2024 20:22:40 EDT (-0400)
  Function logic? (Message 2 to 11 of 11)  
<<< Previous 1 Messages Goto Initial 10 Messages
From: Mike Williams
Subject: Re: Function logic?
Date: 6 Dec 2004 11:28:02
Message: <NWhr5BAxhItBFw36@econym.demon.co.uk>
Wasn't it Tim Nikias who wrote:

>Now to the problem: Why is it that I have to put a ".x" after the function
>the first time I use it, but not afterwards?

There are two sorts of functions, ordinary functions and pigment
functions. When you evaluate a pigment function you get a colour rather
than a value. 

POV doesn't currently allow you to perform arithmetic on pigment
functions, but you can choose one of the components of the pigment
function, by adding ".red" (or, equivalently ".x") to convert it into an
ordinary function.

Somewhere outside your macro you must have declared SnowFunction to
initially be a pigment function, but when you redeclare it you are
making it into an ordinary function.

Once you've performed that conversion, you've not got a pigment function
any more, so appending ".x" to the result is wrong.

What you need to change is the original declaration of Snowfunction,
which is somewhere outside your macro. Stick a ".x" on that declaration
and you'll be working with non-pigment functions throughout.


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.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Tim Nikias
Subject: Re: Function logic?
Date: 6 Dec 2004 11:56:37
Message: <41b48f45$1@news.povray.org>
> 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.

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Tim Nikias
Subject: Re: Function logic?
Date: 6 Dec 2004 12:15:41
Message: <41b493bd$1@news.povray.org>
> What you need to change is the original declaration of Snowfunction,
> which is somewhere outside your macro. Stick a ".x" on that declaration
> and you'll be working with non-pigment functions throughout.

Another thing: Where exactly do I put that ".x"? I've got
#declare Snow_Pig_Turb = pigment{bozo color_map{[0 rgb 1][1 rgb .85]}}
#declare SnowFunction = function{pigment{Snow_Pig_Turb}}

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Mike Williams
Subject: Re: Function logic?
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

From: Mike Williams
Subject: Re: Function logic?
Date: 6 Dec 2004 13:28:15
Message: <$0FHxEAjSKtBFwyl@econym.demon.co.uk>
Wasn't it Tim Nikias who wrote:
>> What you need to change is the original declaration of Snowfunction,
>> which is somewhere outside your macro. Stick a ".x" on that declaration
>> and you'll be working with non-pigment functions throughout.
>
>Another thing: Where exactly do I put that ".x"? I've got
>#declare Snow_Pig_Turb = pigment{bozo color_map{[0 rgb 1][1 rgb .85]}}
>#declare SnowFunction = function{pigment{Snow_Pig_Turb}}

I think you need to add an extra step

#declare Snow_Pig_Turb = pigment{bozo color_map{[0 rgb 1][1 rgb .85]}}
#declare Pig_Function = function{pigment{Snow_Pig_Turb}}
#declare SnowFunction = function{Pig_Function(x,y,z).x}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Tim Nikias
Subject: Re: Function logic?
Date: 6 Dec 2004 17:19:10
Message: <41b4dade$1@news.povray.org>
> 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.

Yes, I knew that. Perhaps I phrased my question wrong.
When I use a color_map like this:
color_map{[0 rgb .5][.4 rgb .9][.6 rgb .2][1 rgb 0]}

How could I achieve that when using just the pattern? Is that even possible?

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Tim Nikias
Subject: Re: Function logic?
Date: 6 Dec 2004 17:20:59
Message: <41b4db4b$1@news.povray.org>
> I think you need to add an extra step
>
> #declare Snow_Pig_Turb = pigment{bozo color_map{[0 rgb 1][1 rgb .85]}}
> #declare Pig_Function = function{pigment{Snow_Pig_Turb}}
> #declare SnowFunction = function{Pig_Function(x,y,z).x}

Thanks, this works nicely. Should have come to that conclusion by myself,
but once you get someone telling you how to do things, you trust them... :-)

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Alain
Subject: Re: Function logic?
Date: 6 Dec 2004 17:26:21
Message: <41b4dc8d$1@news.povray.org>
Mike Williams nous apporta ses lumieres ainsi en ce 2004-12-06 13:27... :

>Wasn't it Tim Nikias who wrote:
>  
>
>>>What you need to change is the original declaration of Snowfunction,
>>>which is somewhere outside your macro. Stick a ".x" on that declaration
>>>and you'll be working with non-pigment functions throughout.
>>>      
>>>
>>Another thing: Where exactly do I put that ".x"? I've got
>>#declare Snow_Pig_Turb = pigment{bozo color_map{[0 rgb 1][1 rgb .85]}}
>>#declare SnowFunction = function{pigment{Snow_Pig_Turb}}
>>    
>>
>
>I think you need to add an extra step
>
>#declare Snow_Pig_Turb = pigment{bozo color_map{[0 rgb 1][1 rgb .85]}}
>#declare Pig_Function = function{pigment{Snow_Pig_Turb}}
>#declare SnowFunction = function{Pig_Function(x,y,z).x}
>
>  
>
Acording to the documentation spotted is identical to bozo, without a 
default colour_map. Try:
#declare Pat_Function = function{pattern{spotted}}
#declare SnowFunction = function{Pat_Function(x,y,z) * 0.15 +0.85}// 
limit to the 0.85 to 1 range

Alain


Post a reply to this message

From: Christoph Hormann
Subject: Re: Function logic?
Date: 6 Dec 2004 17:30:03
Message: <cp2m89$t61$1@chho.imagico.de>
Tim Nikias wrote:
> 
> Yes, I knew that. Perhaps I phrased my question wrong.
> When I use a color_map like this:
> color_map{[0 rgb .5][.4 rgb .9][.6 rgb .2][1 rgb 0]}
> 
> How could I achieve that when using just the pattern? Is that even possible?

No but you can use a spline function (which would also allow smooth 
curves while a color map is always piecewise linear).

Use of spline functions is explained in Mike's isosurface tutorial AFAIK.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 23 Sep. 2004 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Tim Nikias
Subject: Re: Function logic?
Date: 6 Dec 2004 17:49:13
Message: <41b4e1e9@news.povray.org>
> Use of spline functions is explained in Mike's isosurface tutorial AFAIK.

Ah, thanks, I'll have a look at it. Might be useful for later macros...
Hm... ;-)

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

<<< Previous 1 Messages Goto Initial 10 Messages

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