540 likes | 720 Views
Master Thesis Lighting and materials for real-time game engines. Tobias Kruseborn Supervisors: Per Einarsson, Daniel Johansson. Disposition. Introduction Methods Skin rendering Diffuse and specular reflection , SSS Modified Translucent Shadow Maps Shadows Environment lighting
E N D
Master ThesisLighting and materials for real-time game engines Tobias Kruseborn Supervisors: Per Einarsson, Daniel Johansson
Disposition • Introduction • Methods • Skin rendering • Diffuse and specularreflection, SSS • Modified Translucent Shadow Maps • Shadows • Environment lighting • Median Cut Algorithm • Spherical Harmonics • Wavelets • Conclusions
Introduction Problem definition: to lighten materials with several layers in a physically correct way and in real time Objective: to study and implement advanced real-time rendering techniques for complex materials Methods: skin rendering and environment lighting techniques
Skin rendering Skin rendering 1. Goal 2. Methods • Diffuse and specularreflection, SSS • Modified Translucent Shadow Maps • Shadows 3. Final algorithm 4. Results
Skin rendering Goal To obtain a look as seenbelow (the speed should be an order of magnitude faster) (Doug Jones demo, NVIDIA)
Skin rendering: Diffuse and specularreflection I Specular reflection • The specular light in human skin only reflects 6% of the whole light spectrum • The oil layer doesn't give out a mirror like reflection • The phong lobe doesn’t give an accurate specular falloff • Kelemen-Szmirnay-Kalos, Cook-Torrance
Skin rendering: Diffuse and specularreflection II Diffuse reflection In order to represent diffuse reflection we need to solve the double integral:
Skin rendering: Diffuse and specularreflection III Diffuse profile The diffuse profile provides an approximation for the manner in which light scatters underneath the surface of a highly scattering translucent material.
Skin rendering: Diffuse and specularreflection IV A sum-of-Gaussians The dipole curve plotted for the diffuse profile, can be approximated by summarizing a number of Gaussians functions
Skin rendering: Diffuse and specularreflection V Implementation of diffuse reflection • Render the illumination to a light map • Perform the Gaussian convolution
Skin rendering: Diffuse and specularreflection VI By carefully choosing a sampling pattern, we can represent each Gaussian blur with a 12 jitter sample: blurJitteredWeights[13] = { { 0.220441, 0.437000, 0.635000 }, { 0.076356, 0.064487, 0.039097 }, { 0.116515, 0.103222, 0.064912 }, { 0.064844, 0.086388, 0.062272 }, { 0.131798, 0.151695, 0.103676 }, { 0.025690, 0.042728, 0.033003 }, { 0.048593, 0.064740, 0.046131 }, { 0.048092, 0.003042, 0.000400 }, { 0.048845, 0.005406, 0.001222 }, { 0.051322, 0.006034, 0.001420 }, { 0.061428, 0.009152, 0.002511 }, { 0.030936, 0.002868, 0.000652 }, { 0.073580, 0.023239, 0.009703 }, }; blurJitteredSamples[13] = { { 0.000000, 0.000000 }, { 1.633992, 0.036795 }, { 0.177801, 1.717593 }, { -0.194906, 0.091094 }, { -0.239737, -0.220217 }, { -0.003530, -0.118219 }, { 1.320107, -0.181542 }, { 5.970690, 0.253378 }, { -1.089250, 4.958349 }, { -4.015465, 4.156699 }, { -4.063099, -4.110150 }, { -0.638605, -6.297663 }, { 2.542348, -3.245901 }, };
Skin rendering: TSM Modified Translucent Shadow Maps How do we capture scattering throughthin regions in the Euclidean space?
Skin rendering: Final algorithm Final Algorithm (1) Use the median cut algorithm to get light source positions(2) convert the diffuse light from an environment map to spherical harmonics(3) for each light(4) render a shadow map and apply Gauss filter to it(5) render the shadows and the diffuse light to the a light map(6) apply SSS to the light map(7) apply SSS for translucency(7) read the diffuse light + shadow from the light map(8) Add the rest of the mesh texture to the diffuse light(8) Calculate the specular light from the same positions as the shadows(9) Combine the specular and diffuse light to a final color
Skin rendering Results
Skin rendering: Specularreflection Kelemen-Szmirnay-Kalos vs Phong
Environment lighting Environment lighting 1. Goal 2. Why environment lighting is difficult 3. Methods: • Median Cut Algorithm • Spherical Harmonics • Wavelets 4. Results
Environment lighting Goal • To be able to representboth diffuse and specular reflection from an environmentmap in real time.
Why environment lighting is difficult If we represent light with an environment map, all texels in the texture becomes a light source
Environment lighting: Median CutAlgorithm I Median CutAlgorithm • Median Cut Algorithm converts an HDR light probe image to a set of light sources • The algorithmcan represent a complexenvironmentlighting with a fewpointlights
Environment lighting: Median CutAlgorithm II Median CutAlgorithm • Create a SAT with dynamic programming • Add the entire light probe image to the region list • For each region • Subdivide along the longest dimension until the lightenergy is divided xx evenly using a binary search algorithm • For each region • find the centroid using binary search • Calculate the centroids world position
Environment lighting: Sphericalharmonics I Spherical harmonics • Projection of a function into the orthonormal SH basis is simply done by multiplying the integral of the function to the SH basis function • To create an approximation of the signal, is multiplied with the SH basis.
Environment lighting: Sphericalharmonics II The Halo3 method • BRDFExpressiveness Phong/Blinn Cook Torrance, He, etc Project method • Lightingcomplexity Point lights area/env lights • Performance interactive real time [Ramamoorthi02] • storage large minimum mostgamestoday [Kautz02] [Sloan03]
Environment lighting: Sphericalharmonics III • Basis • Separate material into diffuse parts and low and a high freq glossy parts. • SH irradiance env. map for diffuse reflection • New area specular model for low frequency glossy. • BRDF evaluated directly with point lights for high freq. Diffuse Area Specular Analytical Specular
Environment lighting: Sphericalharmonics IV Z Z/N N V Y Y’ V’ X X’ Isotropic BRDF = any coordinate frame 16 m values, and 8 V directions is enough. C (i=0,2,3,6) D (i=0,2,3,6) C,D (i=7,8)
Environment lighting: Wavelets I Wavelets • Wavelets are a set of non-linear bases. • When projecting a function in terms of wavelets, the wavelet basis functions are chosen according to the function being approximated • why use wavelets? Why not non-linear spherical harmonics, or why not just choose pixels in the cubemap non-linearly?
Environment lighting: Wavelets II Waveletsbases
Environment lighting: Wavelets III (1, 1, 1, 1) (1, 1, -1, -1) (1, -1, 0, 0) (0, 0, 1, -1) (1/2, 1/2, 1/2, 1/2) (1/2, 1/2, -1/2, -1/2) (1/√2, -1/√2, 0, 0) (0, 0, 1/ √2, -1/√2) Vector:(4, 2, 5, 5)
Environment lighting: Wavelets IV Soho wavelets • The Haar wavelet lies in the planar domain and leads to distortion when used for functions in other domains • The Soho Wavelets lies in spherical domain
Environment lighting: Wavelets V First implementation • Haar 2D wavelet combined with self occlusion (1) for each vertex(2) draw a visibility cube map and multiply it with a cosine weight(3) tranform the cube map to wavelets and store it in a transport matrix(4) convert the light to wavelets and apply non-linear approximation to it(5) save the coefficient to disc (1) for each vertex(2) multiply the light wavelets with the vertex occlusion wavelets using sparse matrix multiplication
Environment lighting: Wavelets VI Second implementation • Algorithm:Soho approximation algorithm (1) Create the Soho wavelets for the light(2) Sort the coefficents at the finest level and calculate their world position(3) Send the n largest coefficient with its position to the to GPU (This is done in a pre-process)(4) Calculate the BRDF for n position and tranform it to Soho wavelets(5) Multiply the light and the BRDFs wavelets to get the final color
Environment lighting Results
Environment lighting: Halo3 Cook-Torrance Soho Wavelets Kelemen-Szmirnay-Kalos, Soho Wavelets Cook-Torrance Halo3 method
Environment lighting: Diffuse + specularreflection, Soho wavelets 8 16 32 256 512
Conclusions, skin rendering Diffuse reflection: • makes the skin looks more natural • is 10 times faster than the Doug Jones demo • can be used in real-time game, especially for cut scenes Specular reflection - Kelemen-Szmirnay-Kalos and Cook-Torrance : • gave better results that the Phong model • makes the specular reflection more realistic than when using Phong • can catch reflection at grazing angles
Conclusions, skin rendering TSM: • unsatisfying results when implemented with a jitter kernel • if the results would be compared to the extra cost of computing the TSM, the conclusion would be that the modified TSM method was not worth using in the game engine Shadows: • were distinctly improved when applying Gaussian shadow map filter instead of using a uniform shadow map filter • combination of Gaussian shadow maps and subsurface scattering, provided soft shadows without artifacts.