Pages

Sunday, December 19, 2010

Fast Skin Shading Revisited


A screenshot of the free 3D human head scan model provided by Infinite-Realities rendered in MageDx

Sometime last week, i stumbled upon this website called Infinite-Realities and found out that they are offering a free download of their 3D head scan model. Incidentally around the same time last year, i was working on a skin rendering implementation and was looking around for a detailed 3D human head model (Though in the end i have to make do with an ogre look-alike head). So over the weekend, i decided to download the 3D head scan model and revisit my skin rendering implementation with it.

The first improvement i made on the skin rendering was the addition of the stretch correction map mentioned in GPU Gems 3. Because the distance of a surface in texel space and world space can be different, a naive blur in texture space will cause over blurring of texels around curves surfaces such as around the ears and the nose. The stretch correction map compensates for this over blurring by reducing the blur kernel width around curves surfaces.

The second improvement made was actually a bug fix on the computation of the kelemen/szirmay-kalos specular term. It turns out i was inverting the y-coordinate while sampling into the beckmann distribution texture.

The skin rendering looks more impressive when in motion therefore i have uploaded a video which you can view below. Enjoy!



Saturday, October 9, 2010

Lone Wolf Never Dies

Back in 2006, i joined a game company called Ksatria Gameworks and worked on my first commercial game project named "Lone Wolf: Flight From The Dark". Sadly, due to insufficient funding, the project was cancelled in 2009. It has been close to two years since, the company is no longer around and all the team members have moved on to bigger and better things in life. But there is still a place where remnants of the lone wolf project still lives on...on youtube! Apparently, videos of the lone wolf project that was previously available on the official website was uploaded to youtube as well and till now they are still viewable! All hail the power of the internet!

I have gathered all the video links and posted them below for those who are interested in viewing them...though you might want to skip the first minute for a couple of the videos below. (Ex-Ksatrians will know the reason why :))

Enjoy!







Sunday, May 16, 2010

Ambient Lighting Using Irradiance Environment Maps

Back when i was developing MageDx Tech Demo I & II, i had implemented the scene's ambient lighting using a precomputed diffuse convoluted environment map generated from a static HDR skybox. This solution worked fine until i have added dynamic sky to the engine. The precomputed diffuse convoluted environment map in this case is no longer valid for the scene because of the dynamic nature of the new sky lighting. As a simple temporary workaround, i have used a constant grey color to represent the ambient lighting for the entire scene.

Over the weekend, i had some free time to spare so i thought it would be a good time to revisit this problem and implement a solution for it. After thinking through some potential solutions, i ended up implementing a slimmed-down version of a rendering technique known as Irradiance Volumes.

In my implementation, instead of generating a grid of irradiance samples over the entire scene as described in the paper, i have just one sample measuring the irradiance from only the dynamic sky. This sample is updated whenever the sun moves beyond a certain threshold. Objects in the scene then samples from this irradiance sample using their world normal to get the ambient lighting contribution from the sky. Below is a screenshot showing the same scene in different ambient lighting conditions.


Ambient lighting in the scene under different sky lighting conditions

Because the irradiance sample is sampled using the world normal of an object (or in this case the per-pixel normal from a normalmap transformed to world space), the bumpy details of normal mapping are retained for objects in shadowed areas.


A constant grey color is used to represent the ambient lighting for the scene, objects in the shadows looks flat and dull


The same scene with objects sampling from the irradiance sample for ambient lighting. Notice how the details of normal mapping is still visible in shadowed areas

Although my implementation is not a full accurate ambient solution, it works well enough for the small outdoor scenes that i have been using so far. Perhaps in the future i might revisit and improve on this solution when i start having more complicated scenes.

Thursday, May 6, 2010

PhysX Cloth Physics


A screenshot of PhysX cloth simulation in MageDx

Cloth physics belongs to one of those features that i have been wanting to implement after seeing how they operate in games such as Mirror's Edge and Batman Arkham Asylum. So after spending a few hours coding after work for about a week or two, i finally managed to integrate cloth into MageDx using PhysX. In addition to traditional cloth simulation, i have also incorporated softbody and metal deformations, both using PhysX cloth as well. As usual i have uploaded a video showcasing cloth simulation in MageDx which you can find below. Note that the low framerate in the video was caused by FRAPS video capturing while running the tech demo and under normal circumstances the framerate is a steady >60 FPS. Anyway, enjoy the video!

Friday, April 2, 2010

Crepuscular Rays/God Rays

Have you ever witness a sunset/sunrise and saw rays of light emitting from the sun through gaps in clouds or between buildings? If you have, lucky you! If not, i hope to show you through the use of computer graphics, the beauty of this natural phenomenon known as crepuscular rays.

Crepuscular rays a.k.a god rays, to put it simply, occurs when light from the sun is occluded by various mediums (clouds, buildings, small atmospheric particles) and scattered across the atmosphere. To illustrate these words, below is a screenshot showing crepuscular rays running real-time in MageDx.

Crepuscular rays running real-time in MageDx Tech Demo

My implementation is loosely based around the one described here with a few tweaks mostly pertaining to quality and performance. If you have implemented this technique before, you would almost immediately notice one shortcoming, that is the huge amount of samples (100 samples and above) you would have to take in order to generate moderately smooth crepuscular rays. This means you are limited to using pixel shader 3.0 and above for this technique, and even then, you hit the instruction count limit pretty fast as you increase the number of samples. Luckily in this case, there is an alternative way of doing the sampling that is described in one of the crytek presentation slides found here. In short, instead of brute force sampling, we sample using an iterative process. In my case, i iterate over 3 passes with each pass taking 8 samples. The result is comparable to the brute force method quality wise, is way cheaper and fits well within the instruction count limit of pixel shader 2.0. Also described in the slide is a cheap way to generate the occlusion mask provided that you have scene depth stored.

Screenshots in this case does not do justice to how
crepuscular rays looks like in real-time. As such, i have included 3 videos showcasing crepuscular rays in different environments and light settings. Have fun watching!






Tuesday, March 16, 2010

Screenshot Feast!!!

Recently while cleaning up my hard drive, i stumbled upon a folder that contains pictures of my old work pertaining to graphics programming. If my memory serves me well, these screenshots should be taken during the year 2007~2008. Anyway, i hope you (whoever you are ;) ) enjoyed the screenshots as much as i enjoyed looking through them. Cheers!


Hardware instancing test using 500 hello kitty boxes/spheres with SSAO


Another hardware instancing test with foliage and one hello kitty sphere :P


When bone weights goes horribly wrong...


A multi-layered shader where snow is generated according to the slope of the normal and by the blend influence stored in the vertex color


A strange bug while working on VSDCT (virtual shadow depth cube textures), interestingly it looks like a castle wall during sunset xD


Experiment with ice rendering, the shader is a double layered material where the top layer distorts the bottom layer using a normal map, giving the illusion of refraction between the 2 layers. Thickness of ice is controlled with vertex color and modulated with a fresnel factor


Experiment with ice rendering part 2


Experiment with volumetric cloud rendering, the technique used was based on the chapter "Volumetric Clouds and Mega Particles" found in ShaderX 5


Look in the sky...it's a stickman!


More fun with clouds, the technique works well with animated meshes too


Cotton candy look-alike clouds :) Yummy!


Irradiance volumes 3D grid with uninitialized random values a.k.a "the mentos scene"

Tuesday, February 16, 2010

Sponza Atrium (Improved Version)

Earlier this month, i visited crytek's website and found out that they are offering an improved version of the sponza atrium 3D model to the public for FREE! Grab it over here while stock last!

After a few tweaks to the model in maya, i got it up and running in MageDx. Enjoy the screenshots!

Special thanks to Marko Dabrovic for the original sponza atrium 3D model and Frank Meinl for the improved version!