The goal for this week was to set up a working scene graph so that the framework would be ready for the main global illumination pipeline.

I decided to implement the scene graph building in the shader itself. However, I soon ran into problems. The first problem was that GLSL ES does not support pointers, and therefore, I would not be able to build a real scene graph on the shader. So I decided that I would leave the scene graph for later and work with individual objects with their own individual transformations (with respect to the world.) This would require matrix math to create translation, rotation, and scale matrices along with several other matrix operations in order to apply and undo transformations. I was planning to use GLM for the math library. However, I found out that GLSL ES does not support the #include directive. I tried looking around for options, but could not find anything useful. So I then decided I would work with very basic sphere and cube structs that have position and radius values.

Once I have the basic structs, I keep them in an array of shapes. I then proceeded to write the intersection code for the structs, as well as the intersection code for the world, iterating over the array of shapes and finding an intersection.

Once I had intersection code, I started writing the recursive ray tracing function that will utilize the intersection checks I just added. After I wrote the ray tracing code, complete with reflection and refraction, I encountered an unknown compilation error. And after a long time of looking over my code and Googling for answers, I realized that GLSL ES does not allow for recursive function calls. (I found the reference for GLSL ES which is useful.) So I had to revert my code back to the original non-recursive ray tracing.

A lot of time this week was spent troubleshooting and figuring out the limitations of GLSL ES, the hard way. At the moment, I don't have ray tracing working perfectly with my new intersection code. The spheres have a fuzzy grainy texture, which I assume is attributed to floating point precision error.

Over the next few days, I hope to have complete and debug the intersection code for both spheres and cubes. The reason that I focused on having just the basic ray tracing working with my new code is because photon casting will be using the same code.

I do have some concerns for recursion support. I'm not sure if photon scattering will work without recursion. I will have to look into that.

Wow Opengl ES awesomeness.

ReplyDeleteBut in seriousness you have to build the transformation matrix yourself and apply it through a uniform.

You pretty much have to dumb down a lot of the newer opengl features you are used to building your scene graph to build one in ES which is a bit annoying.

After the headaches I went through this week, I'm planning to just skip the scene graph stuff for now and come back to it later, since it's not the focus.

ReplyDeleteI want to move with the photon casting, scatter, and storing steps first. And I'm anticipating a lot of issues there as well, seeing how many issues there were just doing the simple stuff I already know how to do.

ERROR: 0:175: '[]' : Index expression must be constant.

ReplyDelete??!??!!?!??!?!

REALLY?! Is this true??? Is there a way around this?