Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power...

34
Martin-Karl Lefrançois May 2017 LIGHT BAKING WITH IRAY

Transcript of Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power...

Page 1: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

Martin-Karl Lefrançois May 2017

LIGHT BAKING WITH IRAY

Page 2: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

2

LIGHT BAKING

Computing and storing the information of complex lighting to be used in a real time environment. Freezing lights information and storing the data that paint how the light rays bounce around static geometry. Caching pre-calculated lighting information in textures or per-vertex or some other form to recreate the lighting in real time.

What is it?

Page 3: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

3

IRRADIANCE

The act of irradiating; emission of rays of light. That which irradiates or is irradiated. The radiant power received by unit area of surface (physics)

Source: Wiktionary

What is Irradiance

Page 4: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

4

IRRADIANCE

Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface.

Intensity of Light

"irradiance" and "intensity of light" are the same

Page 5: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

5

TOOLS FOR MEASURING IRRADIANCE

Light meter / Exposure Meter An instrument that measures the intensity of the light reflected from or falling on a subject Calculates the optimum exposure depending on the film speed.

Measuring light intensity

Page 6: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

6

LIGHT METER / LUX METER

Lux meter for measuring illuminances. It is equal to one lumen per square meter.

Measuring Brightness

Page 7: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

7

DIFFUSE LIGHTING

Lambert's cosine law in its reversed form (Lambertian reflection) implies that the apparent brightness of a Lambertian surface is proportional to the cosine of the angle between the surface normal and the direction of the incident light.

Lambertian reflectance

Eθ = E i cos(θ )Cosine Law:

Page 8: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

8

LIGHTS

for(i=0;i<n_lights;++i)result+=lightContribution(L[i],N)*diffuse_color;

ColorlightContribution(light&L,vec3normal){returnL.color*dot(L.direction,normal);//-shadow,-AO,…}

Diffuse lighting

Page 9: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

9

LIGHTS

Colorall_lights(0,0,0)for(i=0;i<n_lights;++i)all_lights+=lightContribution(L[i],N);result+=all_lights*diffuse_color

Total contributions

Lci (Ldi i N )i∑

Page 10: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

10

LIGHTS

Environment High Dynamic Range Image (HDRi) Sun & Sky

Implicit Lights Point, spot, .. Area: sphere, rectangle, ..

Emissive Objects Geometry emitting some energy

Various sources of energy

Page 11: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

11

IRAY PHOTOREAL

Iray Photoreal Path tracer Physically based

MDL (Material Definition Language) Define the properties of the material Absorption, reflectivity Emissivity

Implementing Light Baking

Page 12: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

12

LIGHT BAKING

Gathering lighting effect from ray tracer to realtime • Emission from the Sun & Sky and

other HDRi • Lights and area lights • Bouncing light (Global illumination) • Shadows and ambient occlusion • LPE compatible • Using MDL

Adding all incoming light to a light map (texture)

Page 13: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

13

LIGHT PROBESSampling the Hemisphere

Sampling the hemisphere for all light contribution defined by a point and a normal

Lci (Ldi i N )i∑

Page 14: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

14

LIGHT BAKING

Irradiance probes are used to render the irradiance at certain locations in the scene. Orientation of the camera is irrelevant

Irradiance Probes (capturing elements)

Page 15: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

15

LIGHT BAKINGApplying on Object

Use light probes and place them on the surface of the object

Page 16: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

16

LIGHT BAKING

Sampling the object in 3D space for each texel.

Sampling the object

Page 17: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

17

LIGHT BAKING

For each texel, add a light probe

Irradiance Probes

Page 18: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

18

LIGHT BAKING

Rasterizing all triangles in the UV domain - Output position and normal

Finding 3D position of each texel

Position Normal

Page 19: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

19

UV BAKING

Vertex: gl_Position = vec4(texCoord, 1) * 2.0 - 1.0;

Fragment: fColor1 = vec4(varWorldPos, 1.0); fColor2 = vec4(varNormal, 1.0);

GLSL for UV baking

Position Normal

Page 20: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

20

LIGHT BAKING

Extract all points and normals Construct a list of irradiance probes Render

Convert to Irradiance Probes

Lp = {{p0,n0}, {p1,n1}, {p2,n2},…}

Page 21: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

21

LIGHT BAKING

Render using ‘iray' No tonemapper RGB floating point to receive the irradiance values Use values to put in an image at the earlier extracted positions

Render

Page 22: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

22

LIGHT BAKINGDifferent resolutions

Page 23: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

23

LIGHT BAKINGResult on Object

Without and with light map texture

Page 24: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

24

LIGHTING

vec4cc=color;if(has_texture){//Ajdustingthetexturetolinearspacecc=pow(texture(tex,varTexCoord0.xy),vec4(2.2));}fragcolor=cc*texture(lbk_tex,varTexCoord1.xy);

GLSL Fragment for lighting

Page 25: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

25

LIGHT BAKING ISSUESSeam and borders

Fixed by enlarging the contour

Page 26: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

26

LIGHT BAKINGMissing Texels

Page 27: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

27

LIGHT BAKINGRemoving some noise with Median Blur

Page 28: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

28

LIGHT BAKING

512x512, 100 iterations 1,4 seconds

18 million rays/seconds

Speed

Page 29: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

29

DEMOIray and Live

Iray 2000 iterations Live @60Hz

Page 30: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

30

EXTRA

Light Path Expression One light map per group of lights

L.*’light_group1’I : Path from a light source to the irradiance point, bounce n-times and touch one of the light which is part of group1.

Avoid objects to be part of the lighting contribution: L.*[^’obj1’]I : Any path that goes from any light to the irradiance point, but not touching the object obj1.

LPE

Page 31: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

31

GLOSSINESS

Compute the incoming light from dependent direction. Store the value with the incoming direction and use it for glossy light reflection.

Angle dependent illumination

Page 32: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

32

NEXT

Multisampling to cover the entire area of the texel A radius to the light probe could be better

Enhancement

Page 33: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

33

QUESTIONS?

Page 34: Martin-Karl Lefrançois May 2017 - NVIDIA...4 IRRADIANCE Irradiance is a measurement of solar power and is defined as the rate at which solar energy falls onto a surface. Intensity

THANKS !