Scalable Height Field Self-Shadowing - wili
Scalable Height Field Self-Shadowing - wili
Scalable Height Field Self-Shadowing - wili
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Algorithm 1 Processinganew heightmap sample new<br />
v1 ← VECTOR(peek1 →new)<br />
while size >1 do<br />
v2 ← VECTOR(peek2 →new)<br />
if h(v2)d(v1) ≥h(v1)d(v2)then<br />
v1 ←v2<br />
pop<br />
else<br />
break<br />
end if<br />
end while<br />
push(new)<br />
return π h(v1)<br />
2 −tan−1 d(v1)<br />
Popand pusharestandardstackoperations, peek1 returns<br />
the last element without modifying the stack, and peek2 returns<br />
the second to last. The inverse tangent can be efficiently<br />
calculated using [Has53] as introduced in [SN08],<br />
whichrequiresonlyonefloatingpointdivisionandtwocomputationally<br />
lightbranches.<br />
For a thread processing N elements, there will be exactly<br />
N pushes on the stack and less than N pops. One iteration<br />
performsn+1comparisonoperationsfornpops,andtherefore<br />
the total number of comparisons for an entire thread is<br />
at most 2N, yielding a total time complexity of O(N). This<br />
property of the algorithm gives it its desired performance<br />
charasteristics. Another desired feature of the algorithm is<br />
that it does not skip, or use an approximation for, even distantoccluders,andcanreturnhorizonanglesinthefullrange<br />
of 0...π.<br />
6. Lighting<br />
As it is possible to extract high-resolution horizon maps using<br />
the algorithms described in Sections 4 and 5, it is useful<br />
tohaveascalablelightingmodelcapableofrepresentingthe<br />
full resolution. As our second contribution we first present<br />
incidentlightinginananalyticalform,andthenshowhowit<br />
canbeefficientlycalculatedinreal-timeforuniformambient<br />
lightingand for arbitrarylightenvironments.<br />
We first recapitulate the rendering equation [Kaj86] in<br />
this context. We assume the surfaces to exhibit Lambertian<br />
reflectance and to emit no radiance. While our method is<br />
notrestrictedtoLambertiansurfaces,itssuitabilityforother<br />
BRDFswouldwarrantaseparateinvestigationandisbeyond<br />
the scope of this paper. Lighting calculations are performed<br />
in the coordinate system of the height field plane, where the<br />
equation for outputradiance becomes<br />
Lo(Li,o,�N,x) = 1<br />
π<br />
V. Timonen &J. Westerholm / <strong>Scalable</strong><strong>Height</strong> <strong>Field</strong> <strong>Self</strong>-<strong>Shadowing</strong><br />
Z<br />
Li(�e)o(x,�e)(�N ·�e)d�e, (3)<br />
Ω<br />
�N ·�e ≥0<br />
Theintegralextendsoverthehemispherearoundthepoint<br />
c○ 2010The Author(s)<br />
Journalcompilation c○2010TheEurographicsAssociationandBlackwellPublishingLtd.<br />
xwiththenormal �N.Li istheinputradianceasafunctionof<br />
direction�e, and o is a binary visibility term as a function of<br />
the point xand direction�e.<br />
Iftheintegralisdiscretizedintonequallysizedazimuthal<br />
swaths,itcan beexpressed as<br />
Lo(Li,o ′ ,�N,x) = 1<br />
n−1 Z π<br />
n<br />
π ∑<br />
k=0<br />
(2k+1)<br />
π<br />
n (2k−1)<br />
Z θk<br />
Li(�e)(�N ·�e)sinθdθdφ,<br />
0<br />
�<br />
θk =min o ′ (x,k),tan −1<br />
�<br />
�Nxcos( π n2k)+�Nysin( π n2k) ��<br />
�Nz<br />
(4)<br />
Theangle θk isthehorizonangleo ′ (x,k)fromzenithforthe<br />
azimuthal direction k at x clamped to satisfy �N ·�e ≥ 0. The<br />
clamping is evaluated at φ = π n 2k.<br />
6.1. Uniform ambient lighting<br />
Solving the integrals in Equation 4 with �e expressed in<br />
spherical coordinates and assuming constant input lighting<br />
(Li =c) gives<br />
Lo(o ′ ,�N,x) =c �Nz<br />
n−1<br />
n ∑ sin<br />
k=0<br />
2 θk +c sin( π n ) n−1<br />
π ∑ (5)<br />
k=0<br />
��<br />
θk − 1<br />
2 sin(2θk)<br />
���Nxcos �<br />
π<br />
n 2k<br />
� �<br />
π<br />
+�Nysin<br />
n 2k<br />
��� As cos � π n 2k � and sin � π n 2k � remain constant for one azimuthal<br />
direction throughout the height field, only sin 2 θk<br />
and sin(2θk) will have to be calculated for each height field<br />
point. Also, if the inverse tangent in Algorithm 1 is calculated<br />
after clamping the slope by the normal, Equations 4<br />
and5canbeevaluatedwiththreefloatingpointdivisionsand<br />
lessthantenmultiplicationsandadditions.Figure5features<br />
uniformlighting.<br />
Figure5:A1024 2 heightfieldunderuniformambientlighting(φN<br />
=64,24 fps)