POV-Ray : Newsgroups : povray.documentation.inbuilt : Mysterious function argument : Re: Mysterious function argument Server Time
5 Dec 2021 16:20:40 EST (-0500)
  Re: Mysterious function argument  
From: William F Pokorny
Date: 2 Oct 2021 09:02:32
Message: <61585868$1@news.povray.org>
On 10/1/21 3:13 PM, Kenneth wrote:
> #declare F0 = function {pattern {bozo}}
> ...throws a fatal error just by itself, "Expected 'Rvalue to declare', pattern
> found instead"

Hmm. Do others on windows see this sort of fail?

The code parses for me with v3.7 and v3.8.

---
What I had in mind when asking myself whether u & v were also set with 
function{pattern{}} was the function{pattern{function{}}} usage. It's 
what one does to enable all the pattern modifiers for the the pattern 
wrapped function(a). The answer is the u and v values are indeed set to 
the x and y values passed through the pattern mechanism.

// povr parse test
#declare Fn00 = function {
     pattern { function { f_boom(x,y,z,u,v,0) }
         // turbulence, warps... - can applied
     }
}
#declare V00  = Fn00(1,2,3);
//---

Returns:

f_boom
1(x) -> 1,
2(y) -> 2,
3(z) -> 3,
4(0) -> 1,  // u
5(1) -> 2,  // v
6(2) -> 0

(a) - This is easier to do in the povr branch due the raw_wave and 
function_interval pattern modifiers.

---
Posting too the following v3.7..v4.0 generic code to highlight a couple 
other function {pattern | pigment} traps / concerns.

// povray +mv3.8 +iThisParseTest.inc
#declare F0 = function {pattern {bozo}}
#declare F1 = function {pigment {bozo}}
#declare F2 = function {pigment {bozo
         color_map {[0,rgbft 0][1,rgbft 1]}
     }}
#declare F3 = function { F0(x+1,y/2,z) }
//#declare V0 = F0(x+1,y/2,z);
// Parse Error: Float expected but vector or color expression found.
#declare V1 = F1(1,2,3);
#declare V2 = F2(1,2,3);
#declare V3 = F3(1,2,3);
#debug concat("\nV1 = ",vstr(5,V1,",",1,3),"\n")
#debug concat("V2 = ",vstr(5,V2,",",1,3),"\nV3 = ",str(V3,1,3),"\n\n")

#error "Parse Test. Stop early"
//---

v3.7/v.38 returns:
------------------
V1 = 0.000,1.000,0.000,0.000,0.000 (*)
V2 = 0.421,0.421,0.421,0.421,0.421 (***)
V3 = 0.489

The povr branch returns:
------------------------
V1 = 0.421,0.421,0.421,0.000,0.000 (**)
V2 = 0.421,0.421,0.421,0.421,0.421 (***)
V3 = 0.489

(*) - POV-Ray proper has unique default color maps for each continuous 
pattern. Be sure to always specify the color map you want!
(**) - The povr branch defaults to rgb [0..1] color maps for all 
continuous patterns.
(***) - The function{pigment{}} mechanism uses a full 5D color vector 
which, in all current versions of POV-Ray of which I'm aware, use only 
single float channels; Making this mechanism to pass around values more 
problematic - especially for isosurface / parametric function use. The 
function{pattern{}} mechanism returns a double float and it's faster 
than using function{pigment{}}.

Bill P.


Post a reply to this message

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