Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Codea Shaders

JohnJohn Admin Mod
edited August 2012 in Beta Posts: 616

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:

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

Tagged:

Comments

  • SimeonSimeon Admin Mod
    Posts: 5,363

    This is really exciting. I'm going to try get a beta build of this functionality out for everyone to try.

    At the moment you have to write your shaders in-line, in the code editor. We plan to have a shader picker and built in + custom shader packs.

  • Posts: 2,161

    All this rendering stuff is completely new to me, but what I currently want to do is nice rendering of curves and using a mesh then I can do it, but it seems slow. The first link I found was http://www.mdk.org.pl/2007/8/6/vector-drawing-opengl-shaders-and-cairo which suggests a huge speed-up using shaders instead of triangulating on the software side.

    Is this the sort of thing that you're talking about? If so, get that beta out now!

  • JohnJohn Admin Mod
    Posts: 616

    This looks possible considering that article was written in 2007. Triangulation isn't possible in shaders because OpenGL ES 2.0 doesn't support geometry shaders. However the new buffer object should help with geometry throughput.

  • Posts: 2,161

    Okay, so is there somewhere that I could read up on this where I can be sure I'm reading the right thing? Should I just search for "OpenGL ES 2.0 shaders"?

  • Posts: 2,161

    This is disappointing on that score: http://stackoverflow.com/q/11374902/315213.

  • JohnJohn Admin Mod
    Posts: 616

    Technically the shaders are GLSL-ES, which has diverged from GLSL quite a bit in its' syntax and features. Basically you are limited to a fixed amount of vertices but you can process them pretty much however you like and should work fairly fast even for large numbers of vertices. The fragment shaders will allow you to perform a lot of interesting effects, such as per pixel lighting, normal mapping and blurring. I'm also working on a computation fluid dynamics example.

Sign In or Register to comment.