Pages

Showing posts with label global illumination. Show all posts
Showing posts with label global illumination. Show all posts

Sunday, 31 October 2010

Bluestone GPU - Light volumes

Following on from my previous post I've been working with some of my old test scenes to see how well light volumes stack up against light maps. Obviously the resolution is no where near the same but the results are still pretty good.

Here I'm using the street scene again with three 32x64x32 volume textures to store indirect lighting for the entire scene. Light leaks do occur so I've had to resort to additional "blocker" geometry to help solve the problem. Thin double sided geometry like the hanging shades in this scene also pose a problem I've yet to tackle. Sample points close to this sort of geometry will need to be handled slightly differently.

Unlit scene showing offset volume samples.


The screenshot above shows the scene and each of the repositioned volume samples. Each line represents a volume sample which has been moved to a more suitable location. This also gives a good indication of the resolution of the light volume. In this scene, only the exterior surface geometry is set to distort the lighting volume. For more info see my previous post.

The video below shows the scene being rendered. Direct light is first rendered into lightmaps. This direct light is then sampled when rendering the indirect light volumes. Render times are as follows:

Direct light (light map): ~1.5 sec
Indirect light 1st pass (light volume): 3 seconds (512 rays)
Indirect light 2nd pass (light volume): 15 seconds (2512 rays)


Some additional screenshots as the video quality isn't the greatest...



Monday, 25 October 2010

Light volume sampling

With Bluestone now running nicely under SlimDX I've turned my attention back to light volumes. After seeing how well the technique worked on the sponza scene I've decided to go with volumes over lightmaps for the project I have in mind.

The issue I've been looking at recently is how best to sample a light volume for a scene containing angled or curved geometry. This wasn't an issue with the sponza scene as it fit nicely inside a rectangular volume, it was enough to simply sample the scene at the centre of each light volume texel.


However, you quickly run into trouble with scenes containing curved or angled geometry. You can see in the image below that if we simply sample each volume texel centre we'll end up sampling “outside” the scene. This often leads to streaks and blotches and ends up looking pretty naff.


The problem is exacerbated by linear texture filtering when sampling the light volume. Incorrectly sampled volume texels can adversely affect their correctly sampled neighbours. It's identical to the problem caused by incorrectly padding lightmap textures, only now the problem is in three dimensions.

Overcoming sampling and linear filtering issues


The above two images show a cross section of a light volume texture. Imagine the red line is a wall, on one side the lighting values are dark, on the other, the light volume texels are not occluded and are now lit by the sky. The dots show the location of each sample. The image on the left looks fine, the geometry is completely covered by valid samples, on the right, we're already in trouble.

 Let's see what happens when the texture is filtered during lookup.



The light volume is leaking all over the place. If we were to view the scene in game the interior wall would have a noticeable blue glow but how do you fix that? In a lightmap it's fairly easy, you just copy and expand the border pixels of each UV chart. In a light volume though it's a bit harder.

In short, the way I've overcome the issue is to move the sample location of any invalid samples.



With the invalid samples moved to valid locations the light leaks have been removed. What constitutes an invalid sample and where to then move it is the topic of a whole other blog post :) But to wrap things up, here are some before and after shots. The lighting and AO for this scene was rendered in Bluestone in about 15 seconds. Direct light and AO are rendered into lightmaps, indirect light is rendered into the light volume.

Sample positions left untouched:

Sample positions fixed:


Another example (click for fullsize)

Friday, 15 October 2010

Bluestone in action

Porting Bluestone over to SlimDX has been a lot easier than I anticipated so I thought I'd post a video of it up and running. There are still a few systems yet to be ported but the core is fully functional.

The video shows a couple of scenes being rendered although I've edited out the sections of video where it's rendering. The render times are quick but still, I figure you have better things to do :) I've noted the actual render times on screen wherever an edit has taken place.


A few words about the technique I use in the videos. I basically start out with a direct light pass and make sure that everything is as it should be. Once I'm happy with that I do a few quick low quality GI bounces to illuminate the shadowed areas. Usually about 256 - 512 rays, depending on the scene. Once that's looking good and I can see that light is getting into all the corners I do a final pass at about 2000 - 4000 rays to get the final result.

I'm really keen to hear peoples thoughts on Bluestone so send me an email or leave a comment. I especially want to hear from you if you're working on something and think Bluestone would be useful as I'm looking for testers.

Monday, 4 October 2010

Untextured lighting stills


Some plain diffuse volume light shots. Click for high res versions.

  





Wednesday, 29 September 2010

Light volumes - animated character

Similar to my previous post but with an animated character this time round.

Animated Character
I went about texturing this model a little differently to usual so I thought I'd mention it. I'd normally lay out the UV's, pick a few nice base textures and start painting away in photoshop. I thought I'd try something different this time round, it's a technique I've seen used in lots of places and I was keen to try it. Instead of manually painting in all the rusted / chipped areas (which is actually a lot of fun) you use a bunch of masks and procedural noise to blend between different surface types. The image below shows a rust mask built from ambient occlusion, cavity, 3d noise and a scratchy bitmap. The ao and cavity maps provide rusted areas in the grooves and worn edges while the noise and scratch maps provide general wear and tear.


Below is the resulting texture map, rendered straight from the material editor. It could definitely use a pass in photoshop to add some more specific detail but it's fine for the time being. Rendering out spec and bump maps was also very easy.


With the textures done I animated a walk and idle cycle and exported the character into the engine. I've spent a lot of time on the mesh and animation exporter so thankfully the process isn't painful.

Video
Okay, onto the actual video which came together pretty quickly. I already had a very basic animation system in place but it doesn't support blending so the animations do pop a bit. I also had to manually control the camera so the camera work isn't as smooth as the other videos. Environment wise I'm still using the same volume textures but I have boosted their contribution to the light buffer.

That's all folks, don't forget to switch it over to HD, hope you enjoy and thanks for reading :)

Thursday, 23 September 2010

Light Volumes – animated objects

Another excellent feature of light volumes not mentioned in my previous post is that both static and animated objects can be lit with the exact same data set. The video below shows this in action. It's in HD this time round so be sure and watch it full screen. As with the previous videos the frames were saved straight from the XNA render engine I'm working on.

Wednesday, 22 September 2010

Light Volumes – Sponza Attrium

In previous months I've posted several simple volume lighting tests. The screen shots were taken in my global illumination lightmap renderer so the results were fairly basic. I wanted to try using light volumes on a more complicated scene so I blew the dust off an old deferred render testbed and modified it to work with light volumes. I was about to build my own environment but remembered that Crytek had released their cracking version of the Sponza model so that's the model you see here. The model is largely unchanged although I've left out a few objects. The plants for one, mainly due to no alpha support in my render engine. I've also added some paper lanterns and a second UV channel for the ambient occlusion maps (see previous post).



Light volume generation

As before, a rough GI solution was first generated for the scene. This solution was then sampled to create the light volume textures. The rough solution, consisting of about 15 512x512 light maps and the light volumes took about 4 minutes to compute.

Screenshots taken from my GI light-map / light-volume renderer

Placing the light volumes was tricky, care needs to be taken that no sample point falls outside the scene or can “see” through to areas it shouldn't. The mid level floor and vaulted ceilings in particular took a few tries to get right. I used two volumes in this scene. It may have been possible to use just one but I wanted to attempt a scene with multiple volumes.

The smaller volume is 8x8x32 and the larger is 32x17x64

Scene rendering with light volumes




The deferred renderer I'm using renders in the following stages.

1. Render compressed view space normals, material roughness and depth to G-Buffer.

2. Render dynamic scene lights to light buffer.

3. Render volume lighting to light buffer.

4. Render final geometry using light buffer.

It wasn't hard to add an extra lighting stage to incorporate light volumes. The extra stage functions much like the existing light buffer stage. Geometry representing the light volume is drawn to the screen and the relevant area of the volume can then be sampled. Below is a breakdown of the lighting stages.

Static ambient occlusion (rendered offline in my lightmap renderer)

Dynamic direct light

Light volume ambient diffuse and specular

Final light buffer

As mentioned in the original paper (see references section) the light volume can also provide local environment specular. I initially underestimated this effect but it certainly makes a difference, especially in areas untouched by direct light. The images below show the effect well. A fresnel term also makes a big difference here, note the increased reflections on the wall in the second image.


In addition, a couple of images showing ambient specular and ambient diffuse in isolation.


Finally, two videos of the scene under seperate lighting conditions.



References / Links


Gamefest 2010, Lighting Volumes

HDR the Bungie way

Engel's Prepass Renderer (SIGGRAPH 2009)

Updated Crytek sponza model