|
 |
So, I was going to spend some time converting some cool Shadertoy code into SDL,
and I was annoyed (as usual) that I couldn't do certain things.
I specifically wanted to create a function that performed a rotational matrix
transform on a vector given a variable angle.
Well, the function VM doesn't allow transform functions to take user-defined
arguments ("parameter names").
And we all "know" that you can't use vectors in functions.
Hell you can't even use vector dot-notation in functions.
2.2.1.6.4 Declaring User-Defined Vector Functions
Right now you may only declare vector functions using one of the special
function types. Supported types are transform and spline functions. For example:
#declare foo = function {
transform {
rotate <90, 0, 0>
scale 4
}
}
#declare myvector = foo(4, 3, 7);
#declare foo2 = function {
spline {
linear_spline
0.0, <0,0,0>
0.5, <1,0,0>
1.0, <0,0,0>
}
}
#declare myvector2 = foo2(0.7);
Function splines take the vector size into account. That is, a function
containing a spline with five components will also return a five component
vector (aka a color), a function containing a spline with two components will
only return a two component vector and so on.
Note: the number of parameters of special function types is determined
automatically, so you do not need to specify parameter names.
But, me being ME, that got a few things wiggling up in the ole' brain, and I
started to follow a few tenuous ides.
Round and round I went in circles, trying to make vector functions work, and
trying to bridge the gap between the SDL parser and the function VM.
And I have mostly done that as you'll see in the attached file.
The only thing that would make this FULLY functional would be to find a way to
shoehorn the actual vector into an argument allowable by some sort of special
function syntax.
But I hope that this inspires people to start playing around with the functions,
macros, reading the docs, exploring the various include files in the
distribution, and doing some experiments that reveal things that we can do (but
were told we couldn't).
- Bill "Bald Eagle" Walker
Post a reply to this message
Attachments:
Download 'functionselectvectorcomponent.pov.txt' (4 KB)
|
 |