CS计算机代考程序代写 12/22/2020

12/22/2020
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License
Bump Mapping
Mike Bailey mjb@cs.oregonstate.edu
bumpmapping.pptx
1
Computer Graphics
mjb – December 22, 2020
What is Bump-Mapping?
Bump-mapping is the process of creating the illusion of 3D depth by using a manipulated surface normal in the lighting, rather than actually creating the extra surface detail.
Displacement-mapped Bump-mapped
Computer Graphics
2
mjb – December 22, 2020
This is a good optimization! Displacement-mapping requires a lot of triangles, bump-mapping doesn’t.
12
The Most Straightforward Type of Bump-Mapping is
Height Fields
Computer Graphics
mjb – December 2
3
2, 2020
Definition of Height Fields — Think of the Pin Box! 4
Computer Graphics
mjb – December 22, 2020
34
terrain.vert
5
#version 330 compatibility
out vec3 out vec3 out vec2
void main( ) {
vMCposition; vECposition; vST;
vST = gl_MultiTexCoord0.st;
vMCposition = gl_Vertex .xyz;
vECposition = ( gl_ModelViewMatrix * gl_Vertex ).xyz; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
Computer Graphics
mjb – December 22, 2020
terrain.frag, I
6
#version 330 compatibility
uniform float uniform float uniform vec4 uniform sampler2D uniform bool uniform float uniform float uniform float uniform float
in vec3 in vec3 in vec2
const float DELTA =
const vec3 BLUE =
const vec3 GREEN =
const vec3 BROWN = vec3( 0.6, 0.3, 0.1 ); const vec3 WHITE = vec3( 1.0, 1.0, 1.0 );
const float LNGMIN = -579240./2.; const float LNGMAX = 579240./2.; const float LATMIN = -419949./2.; const float LATMAX = 419949./2.;
uLightX, uLightY, uLightZ; uExag;
uColor;
uHgtUnit;
uUseColor; uLevel1; uLevel2; uTol; uDelta;
vMCposition; vECposition; vST;
0.001;
vec3( 0.1, 0.1, 0.5 ); vec3( 0.0, 0.8, 0.0 );
Floating-point texture whose .r components contain the heights (in meters)
It turns out that textures are a great place to “hide” data. They are allowed to be very large and they are fast to lookup values in.
// in meters, same as heights
Computer Graphics
mjb – December 22, 2020
56
1

78
9 10
12/22/2020
terrain.frag, II
7
void main( ) {
{
} else {
} Comp}uter Graphics
vec2 stp0 = vec2( DELTA, 0. );
vec2 st0p = vec2( 0. , DELTA );
float west = texture2D( uHgtUnit, vST-stp0 ).r; float east = texture2D( uHgtUnit, vST+stp0 ).r; float south = texture2D( uHgtUnit, vST-st0p ).r; float north = texture2D( uHgtUnit, vST+st0p ).r;
vec3 stangent = vec3( 2.*DELTA*(LNGMAX-LNGMIN), 0., uExag * ( east – west ) ); vec3 ttangent = vec3( 0., 2.*DELTA*(LATMAX-LATMIN), uExag * ( north – south ) ); vec3 normal = normalize( cross( stangent, ttangent ) );
float LightIntensity = dot( normalize( vec3(uLightX,uLightY,uLightZ) – vMCposition ), normal ); if( LightIntensity < 0.1 ) LightIntensity = 0.1; if( uUseColor ) float here = texture2D( uHgtUnit, vST ).r; vec3 color = BLUE; if( here > 0. )
{
float t = smoothstep( uLevel1-uTol, uLevel1+uTol, here ); color = mix( GREEN, BROWN, t );
}
if( here > uLevel1+uTol ) {
float t = smoothstep( uLevel2-uTol, uLevel2+uTol, here ); color = mix( BROWN, WHITE, t );
}
gl_FragColor = vec4( LightIntensity*color, 1. );
gl_FragColor= vec4( LightIntensity*uColor.rgb, 1. );
Remember that the cross product of two vectors gives you a vector that is perpendicular to both. So, the cross product of two tangent vectors gives you a good approximation to the surface normal.
mjb – Decem
ber 22, 2020
Terrain Height Bump-mapping: Exaggerating the Height
No Exaggeration
8
This entire geometry consists of just a single quadrilateral!
Exaggerated
Computer Graphics
mjb – December 22, 2020
Terrain Height Bump-mapping: Coloring by Height
9
Computer Graphics
mjb – December 22, 2020
Terrain Height Bump-mapping: Coloring by Height
No Exaggeration
10
Exaggerated
Computer Graphics
mjb – December 22, 2020
Terrain Height Bump-mapping: Even Zooming-in Looks Good
11
Portland Salem
Corvallis
Eugene
Crater Lake
Computer Graphics
mjb – December 22, 2020
Several textures are being mixed onto the surface of the globe
Terrain Height Bump-Mapping on a Globe 12
Computer Graphics
11 12
mjb – December 22, 2020
Visualization by Nick Gebbie
2

12/22/2020
The Second Most Straightforward Type of Bump-Mapping is 13 Height Field Equations
Rock Dropped
This is the coordinate system we will be using. The plane is X-Y with Z pointing up
Computer Graphics
mjb – December 22, 2020
The Second Most Straightforward Type of Bump-Mapping is 14 Height Field Equations
𝑧 􏰂 𝐴𝑐𝑜𝑠􏰃2𝜋𝐵𝑟 􏰄 𝐶􏰅𝑒􏰆􏰇􏰈 normal 􏰂 𝑥𝑡𝑎𝑛𝑔𝑒𝑛𝑡 x 𝑦𝑡𝑎𝑛𝑔𝑒𝑛𝑡
𝑥𝑡𝑎𝑛𝑔𝑒𝑛𝑡 􏰂 𝑣𝑒𝑐3􏰃1. , 0. , 𝜕𝑧􏰅 𝜕𝑥
𝜕𝑧 􏰂 𝜕𝑧 𝜕𝑟 𝜕𝑥 𝜕𝑟 𝜕𝑥
Radial-ripple equation with height decay
If we can get the two tangent vectors, then their cross product will give us the surface normal
𝑦𝑡𝑎𝑛𝑔𝑒𝑛𝑡 􏰂 𝑣𝑒𝑐3􏰃0. , 1. , 𝜕𝑧􏰅 𝜕𝑦
𝜕𝑧 􏰂 𝜕𝑧 𝜕𝑟 𝜕𝑦 𝜕𝑟 𝜕𝑦
􏰉􏰊 􏰂 􏰋𝐴𝑠𝑖𝑛􏰃2𝜋𝐵𝑟 􏰄 𝐶􏰅􏰃2𝜋𝐵􏰅𝑒􏰆􏰇􏰈+𝐴𝑐𝑜𝑠􏰃2𝜋𝐵𝑟 􏰄 𝐶􏰅􏰃􏰋𝐷􏰅𝑒􏰆􏰇􏰈 􏰉􏰈
𝑟􏰁 􏰂 𝑥􏰁 􏰄 𝑦􏰁
2𝑟 𝜕𝑟 􏰂 2𝑥 𝜕𝑟 􏰂 𝑥 𝜕𝑥 𝜕𝑥𝑟
2𝑟 𝜕𝑟 􏰂 2𝑦 𝜕𝑟 􏰂 𝑦 𝜕𝑦 𝜕𝑦𝑟
Computer Graphics
mjb – December 22, 2020
(Note: x/r and y/r are actually the cosine and sine of the polar angle.)
13
14
You can sum the individual height field equations and get the same result as summing the height field displacements
The Second Most Straightforward Type of Bump-Mapping is
15
Combining Bump and Cube Mapping
16
Rock A Dropped
Height Field Equations
Rock B Dropped
Both Rocks Dropped
Computer Graphics
15
mjb – December 22, 2020
Computer Graphics
16
mjb – December 22, 2020
3