Skylight to enhance outdoor scenes 02564 Real-Time Graphics Skylight and irradiance environment maps Jeppe Revall Frisvad March 2016 Esplanade, Saint Clair, Dunedin, New ealand: -45.9121, 170.4893 The atmosphere Kamaole Beach Park, Maui, Hawaii, USA: 20.717, -156.447 Rayleigh scattering Quote from Lord Rayleigh [On the light from the sky, its polarization and colour. Philosophical Magazine 41, pp. 107 120, 274 279, 1871]: f represent the intensity of the primary light after traversing a thickness x of the turbid medium, we have 4 d = k λ dx, where k is a constant independent of λ. On integration, Reference - Bele m, A. L. Modeling Physical and Biological Processes in Antarctic Sea ce. PhD Thesis, Fachbereich Biologie/Chemie der Universita t Bremen, February 2002. = 0 e kλ 4 x, if 0 correspond to x = 0, a law altogether similar to that of absorption, and showing how the light tends to become yellow and finally red as the thickness of the medium increases.
Solar radiation Colorimetry - - XY gamut RGB gamut CRT/LCD monitor gamut CE color matching functions R = G = B = The chromaticity diagram Cλ) rλ) dλ V Cλ)ḡλ) dλ V Cλ) bλ) dλ, V [Source: http://en.wikipedia.org/wiki/sunlight] where V is the interval of visible wavelengths and Cλ) is the spectrum that we want to transform to RGB. Gamut mapping Dynamic range Gamut mapping is mapping one tristimulus color space to another. Gamut mapping is a linear transformation. Example: X 0.4124 0.3576 0.1805 R Y = 0.2126 0.7152 0.0722 G. 0.0193 0.1192 0.9505 B R 3.2405 1.5371 0.4985 X G = 0.9693 1.8760 0.0416 Y B 0.0556 0.2040 1.0572 Y in the XY color space is called luminance. Luminance is a measure of how bright a scene appears. From the linear transformation above, we have Y = 0.2126 R + 0.7152 G + 0.0722 B. Ambient luminance levels for some common lighting environments: Reference Condition llumination cd/m 2 ) Starlight Moonlight 10 1 ndoor lighting 10 2 Sunlight 10 5 10 3 Maximum intensity of common monitors 10 2 - Reinhard, E., Ward, G., Pattanaik, S., Debevec, P., Heidrich, W., and Myszkowski, K. High Dynamic Range maging: Acquisition, Display and mage-based Lighting, second edition, Morgan Kaufmann/Elsevier, 2010.
Tone mapping Analytical sky models [Preetham et al. 1999] input parameters) Simplistic tone mapping: scale and gamma correct: R, G, B ) = s R 1/γ, G 1/γ, B 1/γ). where s and γ are user-defined parameters. The framework uses s = 0.025 and γ = 1) for the sun and sky. Another tone mapping operator: R, G, B ) = 1 e R ) 1/γ, 1 e G ) 1/γ, 1 e B ) 1/γ). This is useful for avoiding overexposed pixels. Other tone mapping operators use sigmoid functions based on the luminance levels in the scene [Reinhard et al. 2010]. Solar declination angle: Solar position: ) 2πJ 81) δ = 0.4093 sin. 368 θ s = π 2 arcsin sin l sin δ cos l cos δ cos πt ) 12 cos δ sin πt ) 12 φ s = arctan cos l sin δ sin l cos δ cos πt, 12 where J [1, 365] is Julian day, t is solar time, and l is latitude., Direct sunlight Skylight Assume the Sun is a diffuse emitter of total power Φ = 3.91 10 26 W and surface area A = 6.07 10 18 m 2. m 2 sr. Radiance from the Sun to the Earth: L = Φ πa 2.05 107 W Assume the Sun is in zenith and at a distance to the Earth of r = 1.5 10 11 m. The solid angle subtended by the Sun as seen from Earth: ω = As = A 6.74 10 5 sr. r 2 4r 2 Energy received in a 1 1 m 2 patch of Earth atmosphere: E = Lω 1383 W m 2. A directional source with its color set to the solar irradiance at Earth will deliver the same energy in a square meter. Environment mapping: Map an omnidirectional image onto everything surrounding the scene. Cube mapping: Use a direction to perform look-ups into an omnidirectional image consisting of six texture images square resolution, 90 field of view). We use Preetham s analytical model to precompute a sky cube map. Look-ups then return the radiance L sky ω) received from the sky when looking in the direction ω.
Precomputing a cube map Environment mapping +y We precompute by storing L sky v ijk ) in the texel at index i, j of face k. v ijk = a k + u k 2 i )+ res 1 b k 2 j ) res 1, -z -x +z Folded where the faces are numbered from 0 to 5 and ordered as follows: left, right, top, bottom, front, back a k is the major axis direction of face k, u k is the up direction of face k, and bk is the right direction of face k. +z Right +z Top Front -z Left -x Back Reflective environment mapping: i = p e p e ), r = i 2 n i n. We need world space directions when looking up in a cube map. -z B ottom Unfolded r w = V 1) 3 3 r, where V is the view matrix and A 3 3 takes the upper left 3 3 part of A. Environment mapping - filling the background The Rendering Equation Object World Eye Model View Clip W divide Normalized device Projection Viewport Window Given window space pixel coordinates x p, y p find the direction from the eye to the corresponding point on the image plane. 0 i w = V 1 ) 2 xp W 1 3 3 0 0 P 1 p n, p n = 2 yp H 1 0. 0 0 0 0 1 When rendering surfaces, the equation we try to evaluate is [Kajiya 1986] L o x, ω) = L e x, ω) + f r x, ω, ω)l i x, ω ) cos θ dω, 2π where L o is outgoing radiance, L e is emitted radiance, L i is incoming radiance, x is a surface position, ω is the direction of the light, ω is the direction toward the light source, f r is the bidirectional reflectance distribution function BRDF), dω is an element of solid angle, θ is the angle between ω and the surface normal n at x, such that cos θ = ω n. References - Kajiya, J. The Rendering Equation. Computer Graphics Proceedings of ACM SGGRAPH 86) 204), pp. 143 150, 1986. Note that depth is unimportant as i w is the direction of an eye ray.
Splitting the evaluation Sky irradiance Esky and ambient occlusion A Distinguishing between: Direct illumination Ldirect. Light reaching a surface directly from the source. ndirect illumination Lindirect. Light reaching a surface after at least one bounce. where The rendering equation is then L = Le + Ldirect + Lindirect. Le is emission. Ldirect is sampling of lights. Lindirect is sampling of the BRDF excluding lights. n a real-time skylight setting: Ldirect is direct sunlight using the Phong illumination model without ambient). Lindirect is integrated skylight and specular reflection of the sky. ntegrating skylight Excluding direct sunlight from Li, we have Lindirect x, ω ~o) = fr x, ω ~ 0, ω ~ )Li x, ω ~ i )~ 2π ρd V x, ω ~ i )Lsky ~ ωi )~ + ρs V x, ~r )Lsky ~rw ), = π 2π Li x, ω ~ i ) = V x, ω ~ i )Lsky ~ ωi ) is incident skylight, fr x, ω ~ 0, ω ~ ) = ρd /π is the BRDF of perfectly diffuse Lambertian) materials, ρd is the diffuse reflectance diffuse color), and ρs is the specular reflectance. The remaining integral is called the irradiance E, and E x, n~) = V x, ω ~ i )Lsky ~ ωi )~ 2π 1 V x, ω ~ i )~ Lsky ~ ωi )~ π 2π Ω = Ax)Esky ~ n). rradiance environment map The sky irradiance integral neglecting visibility): Esky ~ n) = Lsky ~ ωi )~. 2π Monte Carlo estimator: Esky,N ~ n) = N ωi,j )~ ~ i,j ) 1 X Lsky ~. N pdf~ ωi,j ) skylight j=1 to sky irradiance ~ ~ n ω A good choice of pdf would be pdf~ ωi,j ) = πi,j. We sample ω ~ i,j on a cosine-weighted hemisphere using p θi, φi ) = cos 1 1 ξ1, 2πξ2 ), ξ1, ξ2 [0, 1) random numbers) x, y, z) = cos φi sin θi, sin φi sin θi, cos θi ) nx ny /1 + nz ) 1 nx2 /1 + nz ) nx ω ~ i,j = x nx ny /1 + nz ) + y 1 ny2 /1 + nz ) + z ny. nx nz ny Precompute cube map on the GPU using layered rendering and sampling. n the geometry shader integrator.geom): emit triangle vertices to each cube map face using a loop and gl Layer. n the fragment shader integrator.frag): implement the cosine-weighted sampling of the skylight with n~ = ~vijk use rndt) to get a random number). The framework progressively improves the sky irradiance map using these shaders.
llumination model for skylight where L r = ρ d π n l ) )V L sun + A E sky n w ) + ρ s r l ) ) p V L sun + L sky r w ), L sun is the radiance color) of the directional light, L sky is a look-up into the skylight environment map, E sky is a look-up into the sky irradiance map, V is the visibility term obtained from shadow mapping, A is the factor from screen-space ambient occlusion SSAO), n is the normal, l is the direction toward the sun, r is the reflection of the view vector around the normal, n w is the normal in world coordinates, r w is the reflected vector in world coordinates, ρ d is a diffuse reflectance, ρ s is a specular reflectance, and p is a shininess.