• No results found

GPU Programming: Environment Mapping Bump Mapping Displacement Mapping Shadow Mapping. Spring 2021

N/A
N/A
Protected

Academic year: 2021

Share "GPU Programming: Environment Mapping Bump Mapping Displacement Mapping Shadow Mapping. Spring 2021"

Copied!
35
0
0

Loading.... (view fulltext now)

Full text

(1)

GPU Programming:

Environment Mapping

Bump Mapping

Displacement Mapping

Shadow Mapping

Spring 2021 Daniel G. Aliaga

Department of Computer Science Purdue University

(2)
(3)

Environment Mapping

(or Reflection Mapping)

• Blinn, J. F. and Newell, M. E. Texture and reflection in computer generated images. Communications of the ACM Vol. 19, No. 10 (October 1976), 542-547

• The Abyss

(4)

Environment Mapping

Approximation

– if the object is small compared to the distance to the

environment, the illumination on the surface only depends on the direction of the reflected ray, not on the point

position on the object

Algorithm

– pre-compute the incoming illumination and store it in a texture map

(5)

Environment Mapping

Eye Object E-Map V N R=?

(6)

Environment Mapping

Eye Object E-Map V N R=V-2(N∙V)N

(7)

Environment Maps Forms

Spherical Mapping

Cubical Mapping (or Cube Map)

Paraboloidal Mapping

(8)
(9)
(10)
(11)
(12)
(13)
(14)

Bump Mapping

• Blinn, "Simulation of Wrinkled

Surfaces", Computer Graphics, (Proc.

Siggraph), Vol. 12, No. 3, August 1978, pp. 286-292. [PDF]

• Simulates small surface variations • Key idea: tweak normals used for lighting (geometry stays the asme) • Benefit: much more efficient,

geometry-wise, than creating an approximation using very small triangles

(15)

Bump Mapping

(16)

Bump Mapping Demo

(17)

Normal Map (used for Bump Mapping)

Use texel values to modify vertex/pixel normals

of polygon

Texel values correspond to normals (or heights)

modifying the current normals

RGB = (

n+1)/2

(18)

Bump Mapping

The light source direction L and pixel normal N are

represented in the global coord x, y, z

The bump map normal n is in its local coordinates,

which is called tangent space or texture space

T: tangent vectorN: surface normalB: bitangentHow to compute TNB? x y z T B N n L T B N n L’

(19)

Bump Mapping

Given triangle {v

1

, v

2

, v

3

}:

T = (v2-v1) / | v2-v1| N = T’ / | T’ | (or (v2-v1) x (v3-v1)) B = T x N B T N n L’

(20)

Bump Mapping

Issue: adjacent triangles do not necessarily

have similarly aligned T and B vectors which

causes bump discontinuity

Solutions:

1: Compute TNB per triangle, and flip when it

seems necessary

(21)

Bump Mapping

Solutions:

2: Assume a nicely

organized mesh of

triangles

• Works, but assume a nicely organized mesh of

(22)

Bump Mapping

Solutions:

3: Use or compute a 2D parameterization of the

object

(23)

Bump Mapping

3: Use or compute a 2D parameterization of

the object

• Use projective texture mapping to generate 2D texture coordinates

(24)

Bump Mapping

3: Use or compute a 2D parameterization of

the object

• Use projective texture mapping to generate 2D texture coordinates

• Compute TNB frame at each triangle, then “rotate” the light (for example) to the orientation of the triangle, and compute L dot N’ (N’ is the bumped normal).

(25)

Bump Mapping

Compute TNB frame at each triangle (note: they do not

necessarily align and thus relative light direction does not match which causes incorrect lighting)

(26)

Bump Mapping

• Compute TNB frame at each triangle…

• Then “rotate” the light (for example) to the orientation of the triangle, and compute L dot N’ (N’ is the bumped

normal).

– Use 2D texture coordinates to walk around surface of the object – Compute TNB frames and then how to rotate from one TNB

frame to the other (effectively a rotation matrix)

– Compute the inverse of the matrix (e.g., its transpose) – Rotate light to a common frames and compute lighting

(27)

Bump Mapping

• Compute TNB frame at each triangle “rotate” the light (for example) to the orientation of the triangle, then compute L dot N’ (N’ is the bumped normal).

(28)

Displacement Mapping

Bump mapping

can be at pixel level

has no geometry/shape change

Displacement Mapping

Actually modify the surface geometry (vertices)

re-calculate the normals

(29)

Displacement Mapping

Bump mapped normals are inconsistent with actual

geometry. No shadow.

Displacement mapping affects the surface geometry

(30)

Short Video with Cool Music

https://www.youtube.com/watch?v=1mdR2i

(31)

Light Mapping

Pre-render special lighting effects

Multi-texturing idea: arbitrary texel-by-texel shading

calc’d from multiple texture maps

Reflectance Texture

×

Light Map (Illumination Texture)

(32)

Shadow Mapping

Render scene from light’s point of view

(33)

Shadow Mapping

• Render scene from light’s point of view – Store depth of each pixel

– From light’s point of view, any pixel blocked is in the shadow.

• When shading a surface:

– Transform surface pixel into light coordinates

– Compare current surface depth to stored depth. If depth > stored depth, the pixel is in shadow; otherwise pixel is lit – Note: can be very expensive timewise…

(34)

Resolution Problem:

single shadow map pixel

What can be done?

Higher resolution

helps but does not

(35)

Even More…

Relief Mapping

– https://www.youtube.com/watch?v=_erYebogWUw – https://www.youtube.com/watch?v=5gorm90TXJM

Parallax Mapping

– https://www.youtube.com/watch?v=6PpWqUqeqeQ

References

Related documents

For the high- temperature case (1201 K), the reflected shock pressure increases gradually before the main ignition event; it leads a third stage ignition behavior during the

In recent years, respiratory therapists (RTs) employed in hospitals, emergency departments, home care settings, and clinics have expressed the need for more information about

Set Up As shown in Figure 5.16, the forces acting on the crate are its weight (magnitude w), the force applied by the rope (magnitude T), and the normal and frictional

solar cell concept: interdigitated back-junction structure with virtually 100% emitter coverage of the cell area, in: Proceedings of the 24th European Photovoltaic Solar

While the recent government Discussion Paper suggests that the choice between different legal forms in which to do business should be neutral with respect to taxation, this

HKCS Organizes IT Career Expo and Launches ICT Talent Cultivation Videos September 11, 2012 Hong Kong – Hong Kong Computer Society (HKCS) announced the latest

• We used a regression discontinuity design to compare patients enrolling just before and after this 2014 change to Zambia’s national ART guidelines expanding the CD4 treat-

En fullstendig tabell er inkludert i vedlegget (vedlegg 5, del 5.1). Ut i fra tabell 8.4 ser vi at konvergeringens hastighet er betydelig høyere for denne perioden enn