Sunday, 6 February 2011

Transparency experiments

I've been experimenting with transparency in the deferred engine I'm working on so I thought I'd share some tests. The alien model I used in these tests is the work of Leigh Bamforth and you can grab it here. The original model looks a lot cooler, I'm using a greatly simplified version here.

To begin with, all opaque geometry is drawn as usual. Looks a little weird but it's going somewhere :)


After this the first layer of transparency is drawn. This phase essentially uses the same technique as soft particles. An alpha value is calculated by comparing the depth in the existing frame buffer with the depth of the volume surface being rendered. This is calculated as follows

fade = saturate((scene_depth – surface_depth) * scale);

The surface takes it's colour by sampling the lighting volume at the surface position, along the view direction. This gives the effect of light scattering through the volume and can be seen below, with the light from the thin vertical windows illuminating the volume.


The final transparency stage adds a glass like surface layer and is much simpler. This shader is fairly straightforward as it only has to lookup a reflection map and calculate a fresnel term. The fresnel term is used to control the strength of the cubemap reflections and as an alpha value.


I've captured a video although the quality isn't the greatest. Apologies for the ever present cursor as well, I forgot to disable it before recording the clips in FRAPS.



A few more examples showing different volume colours and densities.





Et voila, lighting volumes now support pickled aliens in glass jars.

2 comments:

Anonymous said...

anti-aliasing really is a problem in the last shot :(.

Following you for some time now, and this is really great work!!

Stefan Kamoda said...

Yeah, the transparent objects get drawn after the AA mask has been generated so they're pretty jaggy. I'll need to look into some other post AA methods to solve it :(

Post a Comment