I’ve been looking into Raytracing lately since it’s pretty cool rendering technique and I decided to build a basic raytracer in Codea to see how it would handle it.
Now keep in mind that the video shows a version using the Codea beta (which gives shaders some love shaders), and running at 60 fps (well 30 due to recording cap).
The non-shader version runs at a wicked 0.2 images per second It renders progressively now though, so it’s smooth and gets pretty over time ^^
Anyways, here is a video:
I’m currently adding cool stuff like ambient occlusion and soft shadows, pretty pretty
I’ll post the non shader source as soon as I clean an document it !
Looks very professionnal!
Personally I hope you release the shader version as soon as 1.5 comes out as it could be a real help to people learning about shaders and GPU programming!
ALSO - I meant to ask, which iPad is that running on. I’m wondering what overhead the retina display of a 3rd or 4th gen iPad would have on your demo.
That’s freaking incredible, @Xavier. I am amazed at what you’ve been able to do!
That’s just flat out impressive. I’d never have guessed you could get that kind of performance through shaders.
Ty all for the comments
@TechDojo - it’s running on iPad 3.
That’s even more impressive given the increased res without the extra grunt of the 4th Gen one.
That’s great! Can you make another video rendering something more complex than a sphere? Say read in a 3d object like a simple tree, and something simple like a cube, with a sphere?
@TechDojo It’s actually running at 1/2 resolution. Would love an iPad 4th gen ^^
@aciolino - I added spheres first because they were easy and pretty
I was working on something else, but I’m adding the vector to plane intersection along with soft shadows next, so I can have more interesting scenes.
About how many lines is the render engine?
@aciolino - Well the whole thing is around 500lines, since I build the shaders dynamically from a Scene class (this prevents slow loops and too much branching), render the scene to a texture (so I can use a custom screen resolution) and then display it.
The raw fragment shader is about 100lines (that includes vector to sphere intersection, shadows and lambert and blinn phong lightning), very small.
That’s really the core of the engine.
I tried this shader from a webgl example, and it was quite slow, but fun to try out!
A progressive sounds nice.
@tnlogy - yeah that’s nice a lot of the shaders found on heroku are built targeting a desktop computer with powerful graphic cards, and therefore usually need a rewrite and some tricks in order to run properly on mobile devices (and sometimes they just can’t at a proper resolution).
It’s an excellent exercise IMO
Note that there are lots of good documents about optimizing shaders on powervr devices around.
Hello @Xavier Do you plan to post your shader? I think we should have a shader available for simple shadows, with internal normal computation (with choice facets or smooth), and it is not in codea 1.5 package. So if you don’t post your shader, i’ll try and write one. But it will be not at all as good as yours, since i dont feel comfortable with openGL.
. @Jmv38 well I thought about posting phong and cel-shading shaders, since they’re simple and easy to understand.
However, Codea doesn’t calculate normals (as you know, you need to calculate them yourself). As for calculating normals directly in the shader, unless the mesh can be in the form of an equation (like a sphere), i’m not sure you can do it, so I dropped the idea.
Same goes with normal/bump mapping. I imagine it would be of no use to the “standard” user as it requires a specific texture to be generated with normal values.
In short, lighting effects certainly showcase the power of shaders, but I’m not sure if it’s suitable material to be built into Codea as examples, since they’re supposed to be easily applied to your project and not require specific input/calculations, else I believe the team would have added them themselves.
I really don’t know… I’ll post them however so that those interested can have a look into them…
Coming to think of it, I had a pretty nice and very fast cartoon shader with cel-shading and full outlining (using depth/normal filters), but rendering was glitchy, since setContext doesn’t include depth. I believe @Simeon said it won’t happen as it would cause performance issues /cry
Ok. I think it is possible to embed the normals calculations in the shader, just the way i do it in codea. I’ll give it a try (it may take a while…) and i’ll post the code when ready. Thanks for the comments.