Hacker News new | ask | show | jobs
by mikekchar 4033 days ago
Obviously I'm showing my lack of knowledge here. I really only know enough about Open GL to look stupid on the internet ;-)

I've often wondered, though, how hard it would be to write a lisp compiler that outputted ARB, rather than use GLSL for coding shaders. Is this possible?

I may be completely wrong, but my gut feeling is that shader coding seems like it would be a natural fit for functional languages.

1 comments

I think there have been a few efforts to do such a thing. A quick search of github and I found https://github.com/kovasb/gamma/blob/master/README.md
I stumbled upon gamma when I first starting looking into shaders--it's pretty incredible what it's doing. mikekchar is exactly right, I think, in thinking that lisp is a good candidate for creating what's described as embedded domain-specific languages (EDSLs). When I first explored writing my own shader for this project, I opted for doing it myself just so I could get a better understanding of what's happening under the covers, with the intention of maybe introducing gamma later. It ended up that my shader was super simple--just a for loop and some basic trig math, so it wasn't super necessary to migrate. But, from what I've heard, even mildly complex shaders can get out of hand quickly, so gamma and projects like it are super promising.