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.
Looks good. I'd like to run this, but your website is still down.
ReplyDeleteAt 12 fps, a 1 fps improvement is significant. If the branch was not coherence, I can see this improving performance.
Yes unfortunately the server's still undergoing maintenance. The code is also hosted on here in the meantime:
ReplyDeletewww.seas.upenn.edu/~pjia/raymarch