Game Development Community

dev|Pro Game Development Curriculum

Shaders Galore! Texture-Space Diffusion, God Rays, and Light Extrusion Mapping!

by Matt Vitelli · 07/29/2008 (2:36 am) · 16 comments

Being several months overdue for a blog, I decided it was time to write one.

A great deal has happened over the past few months. I've done a lot of work with TGEA and have been working on an assortment of post-processing effects.

I am honored to say I am now an associate of Garage Games and hope to continue doing work to improve Torque technology.

For starters, I have written several iterations of deferred renderers. For those unfamiliar with a deferred renderer, the general idea is to save out
position and normal information from the entire scene into a texture. This allows you to control your lighting process almost entirely on the GPU.

I've written my own algorithm for Screen-Space Ambient Occlusion. In ambient occlusion, light comes in from every direction. My algorithms use the
8 surrounding cardinal directions to test for occlusion and shade based on that. It is run completely as a post-process using scene depth information and
requires only 8 samples, unlike many SSAO algorithms. The picture below is a crude example, using 32-bit precision. Good SSAO (and really, most post-processing effects) should use 128-bit textures. This does, however, have many performance drawbacks making a subtle effect such as SSAO somewhat pointless.

i63.photobucket.com/albums/h138/eternaldark112/aoraptor.png
I've also been working on texture-based diffusion. While the terminology may confused some, it is really quite simple. You perform your diffusion and lighting in one pass, saving the result into a texture. You then perform many gaussian blur filters and adjust color operations to suit your needs. Then, the result is reapplied to the mesh and specular is calculated. The results produce soft, realistic skin. So far, the major problem with incorperating this into TGEA has been storing every diffusal texture, seeing as every mesh requires a new one.

i63.photobucket.com/albums/h138/eternaldark112/skinUber3.png
i63.photobucket.com/albums/h138/eternaldark112/skinUber2.png
i63.photobucket.com/albums/h138/eternaldark112/skinUber1.png


SSAO and texture-based diffusion are great, but the real focus of this blog is to expose a new rendering technique I'm coining as "light extrusion mapping". Light is "extruded" from pixels on a texture map and the result is rendered as a post-process. This means NO geometry is being rendered for each ray. Many games are adopting similar effects, including Crysis and STALKER.
Plenty of neat effects can be done, some of which include god rays, foliage sun-scattering, and truely emissive images. Below are some of the results that can be accomplished with such light extrusion maps.


i63.photobucket.com/albums/h138/eternaldark112/lemapping.png
i63.photobucket.com/albums/h138/eternaldark112/lemappingtrees.png
i63.photobucket.com/albums/h138/eternaldark112/lemappingtrees2.png
i63.photobucket.com/albums/h138/eternaldark112/lemappingtrees3.png
The really neat thing about this is that a light extrusion map is just a simple alpha channel, but it can easily be scaled to allow ranges of color from every channel.

#1
07/29/2008 (3:03 am)
Wow. I could definetly think of some places where that light extrusion would be handy. It would sure beat putting volume lights on all windows facing the sun. Keep up the amazing work Matt.
#2
07/29/2008 (4:22 am)
That is incredible looking!
#3
07/29/2008 (4:59 am)
Slick!
#4
07/29/2008 (5:21 am)
Holy Heavenly Beams of Light, Christian Bale!
#5
07/29/2008 (6:03 am)
This stuff looks incredible.
#6
07/29/2008 (6:12 am)
This is really cool stuff Matt.

The 2nd face surface reminds me a bit of the skins in Age of Conan ;)
#7
07/29/2008 (6:19 am)
This looks amazing, can't wait to see more keep up the great work
#8
07/29/2008 (8:24 am)
That looks sweet.

I'm really interested in the SSAO especially, because I've been poking at the idea of downsampling both the depth and the N.L * Atten buffer. The downsampled depth can be used for the SSAO (if the technique requires it), and the downsampled luminance buffer could be processed similar to SSAO to generate a screen space global illumination effect.

Any more info on the light extrusion effect?
#9
07/29/2008 (8:47 am)
Are you planning on releasing any of your code, specifically the light rays? Every time I look that them it makes me wanna put them in my game. =D
#10
07/29/2008 (9:09 am)
Pat,

The major problem I've found when working on depth-based ambient occlusion has been the precision required for the effect. Perhaps with some algorithms, R32 precision is unnecessary and an 8-bit single channel would be just fine. Screen-Space Global Illumination though, that's a neat idea. Would you be employing some type of screen-space ray tracing?

Taylor,

I'm considering it. I really want to get it to a level that gives the user complete control in modifying every detail.
#11
07/29/2008 (10:13 am)
This is really coool stuff, Matt! Thanks for sharing
#12
07/29/2008 (5:20 pm)
Great work!

For SSAO, are you using the depth buffer-only route to save on memory and speed?

I'm working on my own implementation of SSAO for TGE. Using only depth comparison can yield some artifacts. In fact, I think that is one of the reasons that your model gives the per-vertex-shading effect, which makes it look a little flat.

You might want to output the screen-space normal out as well. You might want to bias the sampling for the occlusion points using the normals. That gives better results and removes artifacts.

I'm trying to finish up a post-process framework for TGE soon. I guess I'll be posting more stuff on my blog, and although the source would be GLSL, the algorithm should be the same.

Keep up the good work!
#13
07/29/2008 (5:47 pm)
Koushik,

I'm using a combination of a depth buffer and normals. That image is just using the depth buffer, though the full algorithm uses a combination of the two.

I'll be really eager to see your algorithm when it is finished. Post-processing in general is extremely exciting and it's always great to see different techniques.
#14
07/29/2008 (9:52 pm)
@Matt: very nice effect. by the way, i still have an issue when using FSAA and FullScreen Shader (www.garagegames.com/mg/forums/result.thread.php?qt=74388), do you have the same on your side?
#15
07/29/2008 (11:31 pm)
Well, I know anti-aliasing does not work with multiple render targets(hence why a lot of HDR systems don't work with AA), but I haven't given any FSAA implementations a try. See, anti-aliasing in and of itself is a somewhat hacky solution to emulate smooth edges. What's really great is that with modern GPUs, you can write a fullscreen shader that blurs along edges. ;)
#16
09/09/2008 (7:43 pm)
Very cool! What sorts of implementations do you think you'd want to use for the light extrusion technology?

If you want some additional resource regarding SSAO I just finished creating my own SSAO shader pack for TGEA. You can check out the video's and screenshots on my website. www.ubiqvisuals.com/index.php?option=com_content&view=article&id=46%C2%A0

www.ubiqvisuals.com/images/ssao_sample.jpg