I just shared a project on CC that includes a shader with a lot of lighting effects. Normally, if you do this, you slow down your app because of all the if tests you have to do.
But this project creates special shader code with just the features you want, ie it leaves out the parts you don’t want, to make the shader run faster. You can copy this code to your own project.
There is a Notes tab to explain how to use the code, and what the different parameters mean.
(I used Reflector to record this, because it gives you the whole iPad screen, and I played with adding captions on this video, using youTube’s editing options).
@Ignatz - Yeah, if I can find the time and spare mental capacity to get back into some Codea I was thinking of looking at what you’ve built and how bump mapping could be worked into it.
@tnlogy@Ignatz it does not work in the beta due to a shader compile error — the variable reflect which you define is actually a new GLSL function in OpenGL ES 3.0, and GLSL complains that your use is a redefinition. If you rename it to something else then it works.
Hang about, so IOS 7 now gives us OpenGL ES 3.0, and that maybe opens the door to textures in vertex shaders, I HAVE to get Codea back out and try and play with this
Dynamicly deformed meshes from a texture… I guess it breaks compatibility with IOS 6, but still.
Textures in Vertex shaders do now work, I’ve only tested on ipad 3rd gen, but it should work on any ipad as long as it’s IOS 7.
Project is on CC called texture driven hieghtfield. Basically it’s a flat mesh of 20,000 triangles, and dependant on the texture it will height it based on the “brightness” of the pixel for the vertex. For real dynamic, you can even point the camera at it.
The lighting is a bit shabby because I used @Ignatz solution from above, but I think I haven’t plumbed it in correctly
Nice! I’m using perlin noise to make an infinite landscape. should be able to speed it up by saving the height map instead of calculating it for each draw…