Presentation is loading. Please wait.

Presentation is loading. Please wait.

Master Thesis Lighting and materials for real-time game engines

Similar presentations


Presentation on theme: "Master Thesis Lighting and materials for real-time game engines"— Presentation transcript:

1 Master Thesis Lighting and materials for real-time game engines
Tobias Kruseborn Supervisors: Per Einarsson, Daniel Johansson

2 Disposition Introduction Methods Conclusions Skin rendering
Diffuse and specular reflection, SSS Modified Translucent Shadow Maps Shadows Environment lighting Median Cut Algorithm Spherical Harmonics Wavelets Conclusions

3 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 Syftet med avhandlingen var att studera och genomföra avancerad realtids-rendering tekniker för komplexa material såsom människohud. Projektet omfattade undersökningen om hur man kan anpassa och förenkla komplicerade hud gör modeller för att passa dagens spel motorer. Även uppgiften ingår att titta på den senaste forskningen om sfäriska övertoner och Wavelets. Målet var att avgöra om de kan användas för att representera både diffusa och spektakulära eftertanke i en miljö belysning i en verklig Temne spelet.

4 Skin rendering 1. Goal 2. Methods 3. Final algorithm 4. Results
Diffuse and specular reflection, SSS Modified Translucent Shadow Maps Shadows 3. Final algorithm 4. Results

5 Goal (Doug Jones demo, NVIDIA) To obtain a look as seen below
Skin rendering Goal To obtain a look as seen below (the speed should be an order of magnitude faster) (Doug Jones demo, NVIDIA) The Doug Jones demo sets the clear standard for high quality skin shading in realtime. The only problem is that “realtime” for a tech demo is quite different from being fast enough to use in a game in real use-cases. The Doug Jones demo fully taxes the processor of a high end graphics card. In contrast, most games must run on less powerful consoles. Also, the commercial games must render an entire world, which only leaves a small fraction of time for skin shading. The Goal of this project is to to scale the Doug Jones demo down so that it is fast enough realtime games, but still retains as much quality as possible.

6 Specular reflection Skin rendering: Diffuse and specular reflection I
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 Den spektakulära reflektionenför huden är mycket lättare att företräda än diffusa reflektion. Detta grundas på det faktum att spektakulära ljuset reflekteras direkt och inte absorbera till ytan. Den spektakulära ljus i människors hud bara återspeglar sex procent av hela ljuset spektrumet. Det översta lagret av huden består av en tunn olja lager och kan modelleras med en BRDF. Oljan ger int ut en spegel vilja eftertanke på grund av ojämnheter. Pga detta ger Blinn-Phong modell leder till en felaktig uppskattning eftersom det utgångar mer energi än den tar emot och dessutom misslyckas med att fånga ökade specularity på bete vinklar. Användningen av en mer exakt fysisk bas reflektionsfaktorn modellen kan förbättra kvaliteten till en kostnad av ett par extra Shader instruktioner

7 Skin rendering: Diffuse and specular reflection II
Diffuse reflection In order to represent diffuse reflection we need to solve the double integral: Den diffusa fall är mycket mer fundamentalt svårt eftersom göra diffus belysning på ett ställe på huden behöver veta det inkommande ljuset intensitet i närliggande punkter. Det första problemet är att simulera denna bakgrund överföring om vi hade oändligt beräkningstid och det andra problem är att utföra denna beräkning snabbt. Den normala BRDF är en uppskattning av BSSRDF, vilket förutsätter att de ingående och utgående är samma Det första problemet är att simulera denna bakgrund överföring om vi hade oändligt computational temne och andra problem är att utföra denna beräkning snabbt

8 Diffuse profile Skin rendering: Diffuse and specular reflection III
The diffuse profile provides an approximation for the manner in which light scatters underneath the surface of a highly scattering translucent material. En spridning profil ger en uppfattning om hur ljuset sprider under ytan av en mycket scattering genomskinligt material När ljus träffar mycket spridda media, ljusdistributionsfältet som tenderar att bli isotropiskt. Varje stråle av ljus som träffar ytan är sannolikt att suddas ut ljuset distribution och därmed ljuset är jämnt spridda över ytan. En spridning profil ger en uppfattning om hur ljuset sprider under ytan av en mycket scattering genomskinligt material I diagrammet i figur 2.2 (a) visar att varje färg har sin egen profil, rött ljus sprider mer än grönt och blått ljus, och den röda färgen i bilden (b) intensifieras ju längre bort vi kommer från träffen punkt.

9 A sum-of-Gaussians Skin rendering: Diffuse and specular reflection IV
The dipole curve plotted for the diffuse profile, can be approximated by summarizing a number of Gaussians functions När konverteringsanläggningar material genom tillämpning av en diffus profil, alla inkommande ljuset konvergera vid ytan innan spridning för att skapa den exakta formen på profilen. Lyckligtvis har problem att hitta en spridning dipolen är nästan ett löst problem. Omfattande analyser har utförts av Donner och Jensen I sitt arbete, de hittade olika kurvor som visar hur intensivt rött, grönt och blått på produktionen poäng ett visst avstånd från källan för inkommande ljus. På Doug Jones demo, d'Eon och Leubke hittades summor Gaussian suddar ut som nära följer de kurvor. Om du använder 5 suddar ut, eftersom guassian oskärpa kan separeras, varje grumla faktiskt två pass, ett för de övergripande och en för lodrät. Vid 7 tapsper pass, varje grumla kräver 14 taps, så den totala kostnaden är 14 * 5 = 70 taps. Sedan senare har vi kostnaderna för behandlingen dessa texturer

10 Implementation of diffuse reflection
Skin rendering: Diffuse and specular reflection V Implementation of diffuse reflection Render the illumination to a light map Perform the Gaussian convolution Konvertering av diffusa belysningen av geometri till en textur utifrån kartan med texturen koordinater som positioner gör att det blir en lightmap flera gånger med Gaussian och sedan kombinerar ihop dem. Vi kan göra den djup och säcken ett hål i djup buffert under vårt lightmap göra passera. Sedan, medan gör suddas ut, vi kan sätta på Hi-Z som gör det möjligt att grumla till endast göras om det synliga pixlar. Detta synsätt hindrar spillo beräkning på antingen svarta områden (som aldrig överlämnats till) eller gråzoner (som inte djupet test).

11 Skin rendering: Diffuse and specular reflection VI
By carefully choosing a sampling pattern, we can represent each Gaussian blur with a 12 jitter sample: blurJitteredWeights[13] = { { , , }, { , , }, { , , }, { , , }, { , , }, { , , }, { , , }, { , , }, { , , }, { , , }, { , , }, { , , }, { , , }, }; blurJitteredSamples[13] = { { , }, { , }, { , }, { , }, { , }, { , }, { , }, { , }, { , }, { , }, { , }, { , }, { , }, }; Det första urvalet representerar inkommande och direkt utgående ljus och följande sex prover motsvarar mitten-nivå scattering. De sista sex prover som står för den stora nivå scattering, och som kan ses om vikter, de används främst för rött ljus. Resultatet är olika suddar ut för varje färg kanal, som kan göras i ett enda pass. Kostnaden för behandlingen från 6 texturer elimineras, eftersom det slutliga Pixel Shader bara läser från en textur. Plugging i dessa siffror, som vi faktiskt har en annan grumla för varje R, G, och B-kanal. Dessutom, alla dessa prover som kan göras i exakt ett pass i stället för 10 passerkort som i hög grad bidrar med minne. Observera att dessa siffror är anpassade efter en konstant. En annan intressant funktion är att eftersom allt detta är gjort på samma pass, vi egentligen inte behöver göra en separat grumla pass. I den slutliga Pixel Shader kan vi utföra 12 textur läser om vi så önskar.

12 Modified Translucent Shadow Maps
Skin rendering: TSM Modified Translucent Shadow Maps How do we capture scattering through thin regions in the Euclidean space? I Texture-space diffusion, vissa regioner som ligger nära varandra i Euclidean space kan vara långt ifrån varandra i textur rymden. Detta innebär att till exempel öron och näsor, kan inte ta hänsyn sändare från båda sidorna, och därför scattering endast kan observeras i den del som är riktad till den ljus. En normal TSM göra djup, irradians och ytan normalt att sedan lagra dessa kvantiteter för den yta som ljuset i varje pixel i texturen. Denna teknik lagrar djup och koordinaterna på det ljus som ytan. I run time varje yta som är i skuggan, kan studera texturen att hitta avståndet till objektet mot ljuset, och få tillgång till convolved version av irradians om ljus som ytan.

13 Final Algorithm Skin rendering: 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

14 Skin rendering Results

15 Kelemen-Szmirnay-Kalos vs Phong
Skin rendering: Specular reflection Kelemen-Szmirnay-Kalos vs Phong

16

17

18

19

20 Skin rendering: TSM

21 Skin rendering: Shadows

22 Shadows Gaussian filter combined with SSS gives suberb shadows

23 Environment lighting 1. Goal 2. Why environment lighting is difficult
3. Methods: Median Cut Algorithm Spherical Harmonics Wavelets 4. Results

24 Environment lighting Goal To be able to represent both diffuse and specular reflection from an environment map in real time.

25 Why environment lighting is difficult
If we represent light with an environment map, all texels in the texture becomes a light source Need to integrate light from all directions. Not trivial to do Specular reflection is also view beroende

26 Environment lighting: Median Cut Algorithm I
Median Cut Algorithm converts an HDR light probe image to a set of light sources The algorithm can represent a complex environment lighting with a few point lights få belysning från en ljussensor är att företräda ljuset som ett antal ljuskällor i allmänhet detta tillvägagångssätt innebär att dividera en ljussensor bilden i ett antal regioner och sedan skapa en ljuskälla motsvarande riktning, storlek, färg och intensitet den totala inkommande ljuset i varje region Med hjälp av de summerade-området tabellen hittar vi 𝑛 i en longitud, latitud bild med högsta intensitet. Detta kan genomföras genom en binär sökning för varje region i 𝑛 iterationer. Användningen av binär sökning är det snabbaste och mest exakta sättet att hitta områden med samma intensitet.

27 Median Cut Algorithm Environment lighting: Median Cut Algorithm II
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 light energy is divided xx evenly using a binary search algorithm find the centroid using binary search Calculate the centroids world position

28 Environment lighting: Spherical harmonics I
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. Spherical Harmonics (SH) is the angular portion of solution to the Laplace's equation in spherical coordinates The SH basis is an orthogonal function on the surface of a sphere. It is similar to the canonical basis of 𝑅3, but differs in the sense that each of the SH coefficients do not correspond to a single direction, but to values of an entire function over the whole sphere. SH basis functions are small pieces of a signal that can be united to an approximation of the original signal To create an approximation signal using SH basis, we must have a scalar value for each base that represents how the original function is similar to the basis function

29 The Halo3 method Environment lighting: Spherical harmonics II
BRDF Expressiveness [Kautz02] [Ramamoorthi02] Project method Phong/Blinn Cook Torrance, He, etc most games today [Sloan03] Lighting complexity Point lights area/env lights Performance interactive real time storage large minimum

30 Environment lighting: Spherical harmonics 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

31 Environment lighting: Spherical harmonics 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)

32 Wavelets Wavelets are a set of non-linear bases.
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? that spherical harmonics are good for representing low frequency light but not for high frequency. Wavelets can capture both low and high frequency light in a compact manner. Some waves are small and as a result they can represent just a pixel, while other waves are bigger, i.e. they can capture light from the whole environment By using wavelets we can represent an environment map with only a few wavelet coefficients. Some coefficients represent just a pixel in the environment, while others represent frequencies over the whole surrounding.

33 Environment lighting: Wavelets II
Wavelets bases

34 Vector:(4, 2, 5, 5) 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) (4, 2, 5, 5) ∙ (1/2, 1/2, 1/2, 1/2) = 8 (4, 2, 5, 5) ∙ (1/2, 1/2, -1/2, -1/2) = -2 (4, 2, 5, 5) ∙ (1/√2, -1/√2, 0, 0) = 2/√2 (4, 2, 5, 5) ∙ (0, 0, 1/√2, -1/√2) = 0 8 * (1/2, 1/2, 1/2, 1/2) = (4, 4, 4, 4) -2 * (1/2, 1/2, -1/2, -1/2) = (-1, -1, 1, 1) 2/√2 * (1/√2, -1/√2, 0, 0) = (1, -1, 0, 0) add the vectors = (4, 2, 5, 5) The input to the multiplication is the lighting environment, here shown as an unfolded cubemap. The input vector contains a linearization of the cubemap pixels. The output of the multiplication is an image of the scene lit by the input environment. The output vector contains relit image pixels. We call the matrix that transforms from input lighting to output image the light-transport matrix. Let’s take a look at two ways that we can precompute the data in this matrix.

35 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

36 First implementation Haar 2D wavelet combined with self occlusion
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

37 Second implementation
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

38 Environment lighting Results

39 Environment lighting: Median Cut Algorithm

40 Environment lighting: Halo3
Cook-Torrance Soho Wavelets Kelemen-Szmirnay-Kalos, Soho Wavelets Cook-Torrance Halo3 method

41

42

43

44 Environment lighting: Diffuse + specular reflection, Soho wavelets
8 16 32 256 512

45

46

47

48

49 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 känner att vår teknik skapar hud som faktiskt ser ut huden, och de olika grumla kärnor för rött, grönt och blått kanalerna är de viktigaste ingrediens. Eftersom den röda blödningar längre än grönt och blått tänka en enda liten bump med ett vitt ljus på ena sidan. På den bump som pekar mot ljuset, intensiteten som kommer in är lika med rött, grönt och blått. Men den röda skingrar längre, vilket ger den sidan av bump en cyanish utseende.

50 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.

51 Conclusions, environment lighting
The Median cut algorithm: can be used for many purposes, such as representing the irradiance from an environment map with points light or to find out the position of the strongest light sources. was very accurate and was helpful in this project, since it could be used as positions for shadow maps and point specular reflection. Wavelets: the approximation method for the Soho wavelets is quite expensive, but on the other hand, it can be run in real-time with the light coming from a whole environment map

52 Conclusions, environment lighting
Spherical harmonics: representing the Cook Torrance BRDF model in spherical harmonics is an efficient and a low storage technique for environment lighting the Halo3 method shows good result in some environments and angles, but for the most, it must be combined with high frequency reflection represented with point lights, in order to generate high quality reflections

53 DEMO

54 THANK YOU Questions?


Download ppt "Master Thesis Lighting and materials for real-time game engines"

Similar presentations


Ads by Google