Build 1 of Codea 1.5 is uploading now. It’s still a bit rough around the edges. More example projects are coming, and it’s still missing some documentation, but most of the new features are included.
I’ve set up a small introduction to shaders, here:
Finished reading the docs - can’t wait to try this. It looks like you “did it right” - I have a grin on my face ear-to-ear; the Camera support was icing on the cake. (How do you pick which camera?)
PS. Working on my 3rd gen ipad. Good example app. TIme to dig. I’m wondering how I’m going to get my real work done today - I may have to “put this away” for a few hours to avoid distraction.
PPS. Answering my own question - cameraSource(). W00t!
What’s happened to my z-ordering on my meshes? The triangles seem to be being drawn in the order of specification. Do I need to explicitly set a shader or something?
Yes, the z-buffer is definitely broken. I’ve just tried it with the code from my martrices blog post and the squares are drawn in order of definition, which looks really weird when rotating a cube!
Most of the examples I look at online seem to have the model, view, and projection matrices passed as seperate entities. But - in the vertex shader in Codea, it’s passing ( model * view * projection ). This is puzzling to me. Is this an OpenGL ES 2.0 thing? (it doesn’t seem to be - but my selection so far of working ipad shader stuff is small).
I am thinking that maybe, perhaps, the whole “normalize and clip and present” is already present in Codea itself, and so we don’t do it? We would, presumably, do similar shenanigans by how we set up the mesh we’re embedding the shader in - no?
What I’m trying is to make a simple model (a cube would be fine) and light it. Don’t tell me how! (yet) - This is how I learn. But if there’s still some missing element, let me know.
It’s faster to do the multiplication once, on the CPU than to do modelviewprojection for every vertex.
You can however create custom uniforms for those matrices in your shader and set them in Codea:
MyShader.modelMatrix = modelMatrix()
Edit: To do lighting you will need to use a normal attribute. The intention is to have this link automatically to mesh normals, but I’m not sure if @John has implemented that yet. You can use custom attribute array by using the (currently undocumented) buffer class with meshes.
If the ipad sleeps when you’re in a shader editor, and you go back in - Codea aborts.
When you bring up the keyboard in a shader when you’re toward the bottom of the code, the keyboard slides up to obscure the code you’re editing.
If you get a really long error message (“…rator ‘-’ exists taking ‘int’ and ‘float’ (and no implicit type conversion allowed in GLSL 1.10)”) - it obscures the line you made the error on, so you can’t correct the error. (Hmm - lie. you can backspace. But if you navigate off that line, you can’t put the cursor there. You can exit the shader, go back in, and the syntax errors don’t show yet - and fix it then. Hmm. )
So - do we expect 1.5 to ship with a model loader?
Because I have a teapot (I need to shade something) that’s not going to load itself.
But before I go write a dumb-as-a-box-of-rocks .obj file loader - I figured I’d see if one was likely to be forthcoming. (Hmm - I should search the forum to see if someone beat me to it first…)
PS. Looks like they beat me to it, in that I see a loader and can convert.