Hi everyone,
I’m excited to announce that I’ve been working hard to bring shaders to Codea. Right now it’s still in alpha but is coming along very nicely. Currently this feature allows full access to the iPad’s shader hardware, allowing you to set custom attributes, uniforms and samplers (up to 8 texture units at once). This will allow virtually any effect that can be done on iPad to be written directly in Codea.
Here’s an example video of a ripple shader: https://www.youtube.com/watch?v=gxlO5qd6NKc
At the moment you can only do this in code, however Simeon is working on a built-in editor which will allow fast and interactive editing of shaders as well as sample projects to run them. We plan to ship the new feature with a ton of examples, which will be easy for people drop in and use.
The API is fairly straight forward:
quad = mesh()
quad.shader = shader("Effects:Ripple")
quad.texture = "SpaceCute:Background"
quad:addRect(WIDTH/2,HEIGHT/2,100,100)
-- later in draw
-- set the time uniform in the shader to animate the ripples
quad.shader.time = ElapsedTime
quad:draw()
Codea automatically makes shader variables available through the shader api, so there is no need to do any of boilerplate code normally associated with shaders.
Another addition will be buffers. These will allow you to modify vertex data without needing to make copies to and from tables. It will also allow you to perform basic math operations, slicing, resizing, copying and clearing. Shader attributes are exposed as buffers and so you can have access to user defined attributes, such as additional texture coordinates, normals, tangents and whatever else you might need.
Let me know what you think