Thursday, April 19, 2012

Initial Test + Micro Optimization

Implemented Inigo Quilez's menger sponge, by following his tutorial. This is to test if the framework can handle scenes that are getting more complex. The frame rate is still acceptable, on my puny laptop graphics card.

I also implemented a micro optimization that came to my mind. Before I had:

if (t>0.0) {
  // compute col
  gl_FragColor = vec4(col, 1.0);
else {
  gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);

Instead, I use built-in functions to eliminate the branching altogether.

t = max(sign(t), 0.0);
gl_FragColor = vec4(t*col, 1.0);

I'm not sure if this helps performance, might be by a difference of 1 fps at the moment.


  1. Looks good. I'd like to run this, but your website is still down.

    At 12 fps, a 1 fps improvement is significant. If the branch was not coherence, I can see this improving performance.

  2. Yes unfortunately the server's still undergoing maintenance. The code is also hosted on here in the meantime: