In the last couple of weeks I began researching into high quality global illumination rendering. I finally started reading “Physically Based Rendering” by Pharr et al., which was kindly donated by Luis Alvarado. A few months ago I devoured “Realistic Image Synthesis Using Photon Mapping” by Jensen; it’s an excellent book. I’ve been wanting to do this for a while now because GI is growing more relevant to real-time rendering at an accelerated rate.
The first step was to build a framework to read and process scene information. I decided to go for FBX; turns out the sdk is a bit dodgy but functional. The next step was to build an acceleration structure and a raytracing core and this is what I’m working on right now. Here’s the first image with basic diffuse lighting and shadows from a point light:
It took around 2 seconds at 140K rays/second (including shading). I have my Centrino Duo mobile CPU down clocked to 1GHz because of overheating; this will force me to optimize the raytracing core before I can start investing time on something like path tracing. Right now I’m working on replacing the unoptimized Octree with a KdTree or BVH with packed ray traversal. My goal is to achieve a minimum of 2 million rays/second per-core on the same scene.
Randomcontrol, the makers of fryrender, recently announced “fryrenderRT” the first commercial unbiased render engine with real-time visualization capabilities. They provide a player app that allows you to move the camera freely within a pre-computed scene and still have view-dependent glossy surfaces behaving accurately; pre-computing scenes with unbiased lighting may take up to hours or even days.
Here’s a sneak peek showing off glossy materials:
From what I’ve gathered it seems to work by storing global lighting information at each point (vertex/texel), much like the Precomputed Radiance Transfer techniques currently used in games. These tend to focus on Spherical Harmonic encoding due to efficient representation of low frequency lighting; it’s possible that RC’s technique is similar but instead based on encoding of nonlinear wavelets or gaussians which have been shown to work well for all-frequency relighting.
What does this mean for games?
- The video above runs on a mid-range ATI 4850 at 20 frames per second which is VERY promising.
- Static geometry is also a limitation for light maps.
- The high offline rendering times already exist when developing games that rely on high-quality directional or SH-based lightmaps. However, a biased version of the offline renderer could help reduce the hardware costs and generate good enough results for most games.
- Local memory requirements are certainly much higher than lightmaps. However, more compact representations trading quality for memory footprint could be used. e.g. partial wavelet coefficients.
- Local memory on GPUs will eventually outpace or be merged with system ram. A virtual page-based approach could also be used to help keep most of the data in disk.
I believe this technique has potential for use in games in the near future. These could very well be the next generation light maps.
I’ve been following the state of real-time Instant Radiosity for a while now. I see it as one of the best options for a gpu-friendly transition to more complex global illumination techniques like photon mapping. Unfortunately I never got around to implement it myself in order to verify it’s feasibility. Today I stumbled upon one of the best examples so far:
Flavien Brebion, aka Ysaneya, is the guy behind Infinity. He is also the guy behind the bold attempt at Instant Radiosity in the shots above. In his journal he talks about the technique and provides some statistics on its effectiveness when combined with deferred lighting. Follow this link to read all about it.
These past few days I’ve been patiently experimenting with Mono. Getting libmono to compile on Visual Studio was straightforward. However, if you’re compiling from the trunk be aware that the win32 build gets broken every once in a while.
Compiling the class libraries, however, is a different kind of challenge. After installing cygwin and following all the steps in this tutorial, I get compiler errors for undefined symbols in a few libraries. Of course, if the mono daily-builds were operational I wouldnt have to compile them myself.
In the meantime I’ve just downloaded the Unity 2.5 trial to see what all the fuss is about. It uses Mono as a scripting platform, something I’m looking to achieve for my development framework.
As promised by O2, my broadband internet was activated on friday. I’m done with the skin shader but still haven’t given up on Mono.
I took the liberty to take some screenshots of the several steps required for the final composition. The only step I didn’t bother to implement was the translucent shadow maps which are used to simulate light transfer through thin regions such as ears. The RenderMonkey project is available here; it includes the media files created by johny.
The diffusion profiles:
The composition of diffuse, sum of diffusion profiles and specular:
Comparison of a basic shader (left) with the skin shader (right):
Final result in high resolution:
Note that the seams are back because I added support for shadow maps and that basically killed my initial workaround. This issue could be addressed through the use of a spherical parameterization.
It’s been a few days now since I finally purchased an iPhone. Even after 6 months in the UK, for some reason, I wasn’t eligible for an iPhone contract with O2 but I still managed to set up a phone line with BT and broadband with.. yes.. O2. Had no choice but to purchase a Pay and Go version and I have to say it is worth every penny.
I haven’t been working a lot at home lately but the skin shader is practically done. If I get broadband till the end of the week then I shall roll out the RenderMonkey project (yes, decided to stick with it) this weekend.
Got more stuff done last night. This time the pics show a non-exagerated version of the subsurface diffusion and using recommended settings for human skin. I got rid of the seams and added gamma conversion to keep all computations in linear color space. Both have the same specular highlights.
Since I’m using a world-space normal map, I was able to remove the seams by switching to a paralell light. That reduces the irradiance pass to a screen-space quad which takes advantage of extra information available outside the mesh (in uv space) which was initially intended to avoid mip-mapping issues.
The diffuse texture should probably be redone at this point. Actually, both the model and textures could use extra work to take real advantage of the shader. Slightly more tesselation on the mesh and more detail in both normal and diffuse textures.
The stretching method described in the book requires a certain amount of tesselation due to the use of partial derivatives; big polygons in uv space can cause discontinuities. My test model is not very dense so I’m still trying to figure out a way of doing it efficiently.
This weekend I got some free time to add subsurface diffusion to the skin shader.
Right now I have both the specular and subsurface diffusion working. The images below show a comparison between a simple lighting shader and the current skin shader. Because the diffusion effect works in image space there’s some issues at UV seams and unnatural darkness at small UV regions with large shadow areas closeby.
The next step is to use a stretch texture to help reduce image-space filtering artifacts.
The pressure at work has been relieved for now. I’ll be moving to the new flat today and I’m looking forward to assemble furniture.
Yesterday I started reducing the Mono codebase to the absolute minimum, isolate all the system calls and disabling unnecessary features. I will need to build a native application that can perform ahead-of-time compilation on the platform itself; first on Windows then iPhone. Care must be taken not to break the integration of future Mono updates.
I also got around to work a bit more on the Skin shader based onjohny’s model. This image below is not using the skin shader yet.
I’m a bit worried that the diffuse map, while looking good, may not be adequate for this technique as it contains diffuse, ambient occlusion and specular information. I’ll probably try a quick clean to remove everything but the unshaded skin tone.
I started implementing the physically-based Kelemen/Szirmay-Kalos specular surface reflectance model described in the article. I’ll post shots as soon as I have interesting results.
n0n4m3 is working hard to improve our Visual Studio experience. He just released a modified version of Jonathan Payne’s VSFileFinder with support for wildcards, regular expressions, tooltip personalization and project filters.