🌱 faking shaders II

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. hide

The main function takes 2 arguments:

  1. i: input object, containing t, x, y
  2. o: output object, containing r, g, b

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..

show page source

    

back to garten.salat