It looks like you're new here. If you want to get involved, click one of these buttons!
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).
And before Jmv38 asks, here is an alternative link:
https://gist.github.com/dermotbalson/8574361
Comments
Very nice. I particularly like that you are using this to generate a shader with just what you need.
That's really clever, dynamically building a shader. The results look great too.
Nice, fogs look really good as well, great way of building the right lighting environment!
@spacemonkey - you got me started with shaders - and I still haven't got my head around bump mapping!
Nice idea. Just a black screen when using Codea beta though. I haven't figured out why..
That is really nice... Will be useful.
I couldn't find it on CC, so just copied from the gist.
@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.
Very nice! Thank you.
@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.http://www.opengl.org/sdk/docs/manglsl/xhtml/reflect.xml
Edit: corrected OpenGL version
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.
Edit: I'm sad again
https://developer.apple.com/library/ios/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/OpenGLESPlatforms/OpenGLESPlatforms.html
Suggests it's only latest gen ipads that support 3.0...
ReEdit: although the same page in the OpenGL ES 2.0 on Power VR suggests maybe you can now have textures in the vertex... I'll have to have a look.
@ignatz lol! Thanks. Looks really good!
@ignatz This is very cool, great idea.
I updated to fix the problem with the name reflect, affecting 2.0 beta versions
Also it wasn't sharing on CC, fixed now
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..
@tnlogy - I'm interested in that, would appreciate seeing it if possible ;;)
Aw, I had dynamically built shaders in my projects... You beat me to posting it.
<):)
@Ignatz here is it, without using a texture though. http://twolivesleft.com/Codea/Talk/discussion/4445/infinite-3d-heightmap-landscape#Item_2
@tnlogy - thanks, I'll have a look
My height field code is a bit rubbish, mainly in terms of the recalculating normals which I only half did as I only had time to prove the concept to myself. But hopefully it gives a good feel for what can be done.
Textures in vertex shaders are commonly used for height fields, and also for things like waves on water effects and such. It should also be usable for user deformable objects, so you could let a user dent your mesh by taping it by just updating a texture for their touch.
I guess you could save the normal as RGB for each pixel so save some GPU? Is there a list of new features for GLSL in iOS 7?
@tnlogy - I modified your shader to take a texture. There are two issues I'd like to fix. One is that the furthest vertices flicker, and the other is that additional "tiles" are added periodically as you move forward, and it is very obvious when it happens. I'd like it to be more subtle.
I finally got a chance to try it. The printing the shader option doesn't seem to be working (I'm running the beta). Other than that, it seems very useful.
Thanks!
Cool, looking forward to seeing your code.
Yes, I've seen those issues as well, haven't had time to fix them though, was thinking about adding a fog to solve it. I don't know if my light shader code is so elegant either.
Did you see any speed improvements?
@tnlogy - my understanding is that IOS 7 introduces OpenGL ES 3.0 which has some new features, and also includes a bunch of capabilities which (like compressed textures) which were optional in the previous version.
HOWEVER, OpenGL ES 3.0 is only usable on the latest "Air" versions of Ipads (and I'm not sure how Codea works with this), however IOS 7 also made available some capabilities to OpenGL ES 2.0 that were previously disabled, the only one I've used/looked into being textures in the vertex shaders.