Download presentation
Presentation is loading. Please wait.
Published byViolet Carpenter Modified over 8 years ago
1
Physics fundamentals of 3D rendering Szirmay-Kalos László Science is either physics or stamp collecting. Rutherford
2
3D rendering Tone mapping Real worldcolor pixelVirtual world
3
Radiance = Power radiated by a unit projected area into a unit solid angle [W/sr/m 2 ] L(x, V ) = A cos A pixel A surface Wanted: pixel = surface pixel surface surface Geometry: pixel cos pixel pixel = surface cos surface surface Radiance: L(x, V)
4
L(x, V ) = L in (x, L) cos ’ f r (L,x,V) Radiance = Irradiance BRDF x ’’ ’’ L in f r (L,x,V) = f r (V,x,L) Helmholtz law: V L f r (L,x,V) = L (x,V)I(x,L)L (x,V)I(x,L) def Light-matter interaction
5
Wavelenths are independent Relativistic mass is small: m=E/c 2 = hf/c 2 Photon energy (frequency) does not change in elastic scattering e-e- e-e-
6
F =F = cos ’ - (n+k j ) cos cos ’+ (n+k j ) cos 2 cos - (n+k j ) cos ’ cos + (n+k j ) cos ’ ’’ n =n = sin ’ sin 2 ’’ 1212 1212 + F F0 + (1-F0) (1-cos ’) 5, F0 = (n -1) 2 + k 2 (n+1) 2 + k 2 L in F L in (1-F) L in „Smooth” = surface visible in a single pixel is a plane Smooth surfaces: Fresnel equation
7
’’ ’’ gold silver F (, ’) Fresnel function
8
v r = v + 2 N cos vrvr v v + N cos N N cos cos = - ( v ·N) x vec3 reflect(vec3 inDir, vec3 normal) { return inDir - normal * dot(normal, inDir) * 2.0f; }; Reflection direction
9
v t = v n + N (cos n - 1- (1 - cos 2 )/ n 2 ) vtvt v v + Ncos N NN N sin -Ncos v Ncos sin N =N = n =n = sin Snellius-Descartes v t = N sin Ncos v t = v n + N (cos n cos ) cos 1- sin 2 1- sin 2 / n 2 Refraction direction
10
v t = v n + N (cos n - 1- (1 - cos 2 )/ n 2 ) class SmoothMaterial { vec3 F0;// F0 float n;// n public: vec3 reflect(vec3 inDir, vec3 normal) { return inDir - normal * dot(normal, inDir) * 2.0f; } vec3 refract(vec3 inDir, vec3& normal) { // may flip the normal float ior = n; float cosa = -dot(normal, inDir); if (cosa < 0) { cosa = -cosa; normal = -normal; ior = 1/n; } float disc = 1 - (1 - cosa * cosa)/ior/ior; if (disc < 0) return reflect(inDir, normal); return inDir/ior + normal * (cosa/ior - sqrt(disc)); } vec3 Fresnel(vec3 inDir, vec3 normal) { float cosa = fabs(dot(normal, inDir)); return F0 + (float3(1, 1, 1) – F0) * pow(1-cosa, 5); } }; SmoothMaterial class
11
’’ Cook-Torrance He-Torrance Surface visible in a pixel Black-box model Rough surfaces
12
l Radiance = Irradiance BRDF is independent of the viewing direction l BRDF is independent of the viewing direction l Helmholtz: BRDF is independent of the illumination direction l BRDF is constant: l Diffuse reflection = very rough surfaces –Multiple light-matter interaction –colorful ! f r (L,x,V) = k d (x, ) ’’ L N V x Diffuse reflection
13
BRDF is constant, BUT the reflected radiance does depend on the illumination direction L ref = L in k d cos + ’ ’’ L N cos ’ N·L Lambert’s law
14
’’ = diffuse + R V ’’ Halfway vector V L H N H = (L+V)/|L+V| cos · L ref = L in k d cos + ’+ L in k s (cos + s k s ( cos + s Specular (glossy) reflection (Phong-Blinn model)
15
Diffuse+glossy materials 5 10 20 50 shininess = diffuse glossy diffuse + glossy Single light-matter Interaction Wavelength independent for non- metals Multiple light-matter interaction ”own color”
16
RoughMaterial class class RoughMaterial { vec3 kd, ks; float shininess; public: vec3 shade( vec3 normal, vec3 viewDir, vec3 lightDir, vec3 inRad) { vec3 reflRad(0, 0, 0); float cosTheta = dot(normal, lightDir); if(cosTheta < 0) return reflRad; reflRad = inRad * kd * cosTheta; vec3 halfway = (viewDir + lightDir).normalize(); float cosDelta = dot(normal, halfway); if(cosDelta < 0) return reflRad; return reflRad + inRad * ks * pow(cosDelta,shininess); } };
17
l Geometry + emitter radiance: l Abstract light sources: –Directional: rays are parallel, intensity is constant –Positional: rays connect the light source to the shaded point, intensity decrases with the square of the distance DirectionalPositional d L e (x,V, ) V x Light sources
18
Rendering pixelVirtual world f r LeLe l Visible surface determination l Radiance calculation l R, G, B conversion L L L L R, G, B
19
pixel Local illumination Recursive ray tracing Global illumination Rendering models
20
color: r, g, b 400700500600 r(r( g(g( b(b( r, g, b 645526444 nm 1 2 Color perception: Monochromatic light
21
r = r d g = g d b = b d Color perception: Polychromatic light
22
model Rendering on many wavelengths R,G,B image Visible spectrum R, G, B Color matching model Rendering on 3 wavelengths R,G,B image R, G, B Spectral versus RGB rendering
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.