OK, so I finally figured out a good way to do this.
The trick was to represent functions as a code vector (in the sense of βcode - data,β for example
[(Math/sin (* 10 x)) (Math/cos (* 12 y)) (Math/cos (+ (* 5 x) (* 8 y)))]
Then it can be βcompiledβ to create 3 objects that implement the Java interface, with the following method:
public double calc(double x, double y, double z, double t) { ..... }
And these functional objects can be called using primitive values ββto get the values ββof red, green and blue for each pixel. The results look something like this:
Finally, it is possible to compose functions using a simple DSL, for example. to increase the texture you can do:
(vscale 10 some-function-vector)
I have published all the code on GitHub for anyone interested in this:
https://github.com/mikera/clisk
source share