Let's continue with faking shaders.. I felt the single line approach was a bit painful, so let's introduce a main function. We can now write regular JavaScript and the main function is what runs for every pixel.
💡 hit ctrl+enter to update the code. hideThe main function takes 2 arguments:
This format seems more flexible, and it allows to implement typical shader functions. It's kind of comparable to GLSL, although we don't have vector primitives and a standard library for common operations..