Monday, April 23, 2012

Mass Instancing + OIT

A couple weeks ago I set out to do a project where a scene of millions of objects could be rendered fast using OpenGL and OpenCL performing frustum culling. This is a screenshot of a fraction of the world: only 169,112 out of 20,000,000 instances are drawn.  

Tonight I decided to expand this project to include Order Independent Transparency. The program is the same as before, but every object now has an alpha of 0.5. Click the image to see it in full detail.

As I expected, the frame rate went WAY down. Before transparency I had roughly 118 fps, and now with transparency it's at 33 fps. Though I may not ever achieve 60 fps, I believe that it is possible and I will try to do it.

(Edit - added a better picture)

Sunday, April 22, 2012

Long time, no blog

I've been a combination of very busy and very lazy lately, but now I'm back in work mode with some new results:

Finally something a little more interesting than the cube. This alien model is 14,192 triangles and the frame rate is still well above 60 fps (hovers around 650, though I shouldn't fool myself yet, there are lots of improvements I can still make).

I have fixed some of the artifacts in my previous posts. The depth issue where the transparent stuff is always above the rest of the scene is gone now that I render the opaque scene before I render the transparent objects. Along with this, I use a very handy GLSL command layout(early_fragment_tests) in; to discard transparent fragments that fail the depth test before they ever reach the fragment shader. This ensures that transparent fragments that are behind opaque fragments are never processed. Finally I disallowed the transparent pass to write to the depth buffer because otherwise transparent fragments would fail the depth test against other transparent fragments.

There are still a couple of things I would like to do in the next 2 days. First, I still have not coded the linearized approach to OIT (I'm doing the linked list version). Second, I want to put transparency into a mass-instancing program that I did a couple weeks ago. This is where OIT would really shine.

Monday, April 9, 2012

Fixed Blending

After a bit of a hiatus, I'm back to working on transparency.

The first thing I did was fix the blending issues I was having. You can see the difference below:

No blending:


Before resolving the transparency with the full-screen quad, I enable blending. My blending function and equation are:


This achieves the effect where final color = alpha*source + (1-alpha)*destination