Friday, June 27, 2014

Tegra Glass Fracture Demo

At GTC a few years back I was tasked with taking a really cool GPU rigid-body + fracturing demo and making it look pretty for the keynote (something I always seem to get suckered into every year). I decided to trick it out with some fancy glass rendering, caustics, etc. Some of the techniques were invented just for the demo (how I came up with a way of using a geometry shader to do caustics probably involves a severe blow to the head I imagine). This demo ran on a high end PC with a GTX 690 in it.

After that demo I started fiddling around with the idea of bringing it to Tegra. I actually rewrote everything with a keen eye on performance. Starting with Tegra 3 I was able to get the refraction/reflection actually working at around 30fps. Tegra 4 allowed me to hit 60fps and turn the shadows on (using a little mip-chain hack to achieve the penumbra). K1 though allows me to blow all that out of the water and bring the full experience of the PC version to mobile using desktop class OpenGL 4.4 feature set. And Nathan Reed took my crazy geometry shader for doing the caustics and added the even crazier use of the tessellator to make the caustics truly mind blowing and better than the original PC version.

Anyways, the Tegra version of this demo didn't get a lot of attention, but we have shown it at our booth at a few trade shows, so figured it was time for the interwebs to get a taste.

Continue reading for high resolution screenshots...




5 comments:

Unknown said...

This is a very impressive achievement! What resolution is this demo running at? I notice the youtube video seems to be capped to 480p.

James Dolan said...

The demo runs at native res. On the device it was captured on that is 1920x1200. I should probably re-up the video at some point, I got a little carried away with compression settings.

Unknown said...

Wow, it's even more impressive knowing that it is running at that resolution! Hardware aside, it seems that there are some nifty tricks used to get tracing running at these resolutions, and if so I hope that they will find a general usefulness in future implementations.

oscarbg said...

Wow that's impressive..
some questions:
This demo uses Physx GPU acceleration or custom physics CUDA kernels for the simulation?
If using Physx does this mean we will get Physx GPU acceleration for K1? Will be awesome to see also upcoming tech like FLEX coming to K1 Android devices also..
Second question is I also assumed rendering was using Optix for the demo.. Optix for Android coming?
Third question: seems Faceworks demo is already on Play store does Nvidia plan to post this demo for Android K1 devices?
thanks..

James Dolan said...

So I can only answer questions about the demo, other products will have to wait until more official announcements.

The demo uses stock PhysX 3.3 and APEX Destruction. The PC version shown at GTC was GPU accelerated (entire RB pipeline), but the Tegra version is on the CPU and is setup to use 3 cores for PhysX and the fourth for rendering. The PC version was also using dynamic fracture (you could break things down as far as you wanted), whereas the Tegra version is using the pre-fracture path that Apex provides.

It does not use OptiX on either PC or Tegra. Rendering is performed just in OpenGL. Glass takes 2 render passes, once for the back-face depths and normals into a texture, and finally for the front faces which does the reflection and refraction+absorption (by sampling back faces) into the backbuffer. The background is sampled by casting rays exiting the glass against the geometry, which in this case is just two quads, if it misses it samples a cubemap. Caustics are done in a geometry shader by reflecting *and* refracting a third and fourth pass of the glass geometry and projecting and clipping it against the 2 scene quads. Tessellation is applied to the caustics passes to smooth things out a bit.

So yeah, its just lots big complicated shaders. Doesn't use compute.