4 ms·
Functional programming can make advanced shaders -- particularly distance field stuff -- significantly simpler. I pass first-class functions around all over the
by daeken 6y ago
Functional programming can make advanced shaders -- particularly distance field stuff -- significantly simpler. I pass first-class functions around all over the place in this example, which compiles down to GLSL: https://github.com/daeken/DaeForth/blob/master/FragmentToy/test.dfr https://github.com/daeken/DaeForth/blob/master/FragmentToy/t...
A good example there is `twist-func' which takes in a world-space position, a block that hands back a twist factor, and a block that receives the transformed position (in object space). Once you start doing things that way, you end up with ridiculously rapid development, which is the whole reason I created this family of languages; started as an experiment to take APL/K, Lisp, and Forth and smash them all together, and it ended up working out well enough that I've kept it going for 7 years now.