DOC PREVIEW
OSU CS 519 - Bump Mapping

This preview shows page 1-2 out of 5 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1 22 2013 What is Bump Mapping 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 You saw this before in RenderMan like this Displacement mapped Bump mapped Mike Bailey mjb cs oregonstate edu Oregon State University P P normalize N disp N calculatenormal P N calculatenormal P normalize N disp Oregon State University Computer Graphics Oregon State University Computer Graphics mjb January 22 2013 mjb January 22 2013 The Most Straightforward Type of Bump Mapping is Height Fields terrain vert version 330 compatibility out vec3 vMCposition out vec3 vECposition out vec2 vST void main vST aTexCoord0 st vMCposition aVertex xyz vECposition vec3 uModelViewMatrix aVertex gl Position uModelViewProjectionMatrix aVertex Oregon State University Computer Graphics Oregon State University Computer Graphics mjb January 22 2013 terrain frag terrain frag version 330 compatibility uniform uniform uniform uniform uniform uniform uniform uniform uniform float float vec4 sampler2D bool float float float float in vec3 in vec3 in vec2 mjb January 22 2013 void main 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 uLightX uLightY uLightZ uExag uColor uHgtUnit uUseColor uLevel1 uLevel2 uTol uDelta 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 fFragColor vec4 LightIntensity color 1 else fFragColor vec4 LightIntensity uColor rgb 1 Oregon State University vMCposition vECposition vST out vec4 fFragColor const float DELTA 0 001 const vec3 BLUE const vec3 GREEN const vec3 BROWN const vec3 WHITE vec3 0 1 0 1 0 5 vec3 0 0 0 8 0 0 vec3 0 6 0 3 0 1 vec3 1 0 1 0 1 0 const float LNGMIN 579240 2 const float LNGMAX 579240 2 const float LATMIN 419949 2 Oregon State University const float Graphics LATMAX 419949 2 Computer in meters same as heights mjb January 22 2013 Computer Graphics mjb January 22 2013 1 1 22 2013 Terrain Height Bump mapping Exaggerating the Height Terrain Height Bump mapping Coloring by Height No Exaggeration Exaggerated Oregon State University Computer Graphics Oregon State University Computer Graphics mjb January 22 2013 Terrain Height Bump mapping Coloring by Height mjb January 22 2013 Terrain Height Bump mapping Even Zooming in Looks Good No Exaggeration Portland Salem Crater Lake Corvallis Eugene Exaggerated Oregon State University Computer Graphics Oregon State University Computer Graphics mjb January 22 2013 Terrain Height Bump Mapping on a Globe mjb January 22 2013 The Second Most Straightforward Type of Bump Mapping is Height Field Equations Rock A Dropped Rock B Dropped Both Rocks Dropped This is the coordinate system we will be using The plane is X Y with Z pointing up Visualization by Nick Gebbie Oregon State University Computer Graphics Oregon State University Computer Graphics mjb January 22 2013 mjb January 22 2013 2 1 22 2013 Bump mapping to Create Polar Ripples Bump mapping to Create Polar Ripples Following the pattern from before the normal vector is In 2D a slope m dy dx It can be expressed as the vector 1 m Normal Amp 2 Pd sin 2 x Pd 2 Time 0 1 dy dx dy dx 1 m This is true along just the X axis The trick now is to rotate the normal vector into where we really are Because we are just talking about a rotation the transformation is the same as if we were rotating a vertex 1 The normal to the shape is the vector perpendicular to the vector slope m 1 Note that 1 m Nx Nx cos Ny sin Nx cos m 1 0 as it must be Y R Ny Nx sin Ny cos Nx sin X So if z Amp cos 2 x Pd 2 Time then the slope dz dx is Nz Nz 1 In the final code you would substitute R for x in the slope and normal equations dz dx Amp 2 Pd sin 2 x Pd 2 Time and the vector slope is Also note that you could include some exponential decay to make this behave more like real ripples Slope 1 0 Amp 2 Pd sin 2 x Pd 2 Time Oregon State University Computer Graphics Oregon State University Computer Graphics mjb January 22 2013 mjb January 22 2013 The Most Generalized Type of Bump Mapping but the Trickiest is Surface Local Coordinate Systems Combining Bump and Cube Mapping N is the surface Normal T is the Tangent which must be consistently oriented from vertex to vertex glman does this automatically in the Sphere primitive B is the Bitangent Oregon State University Oregon State University Computer Graphics Computer Graphics mjb January 22 2013 Bump Mapping A Problem mjb January 22 2013 Bump Mapping Converting Between Coordinate Systems The problem is that lighting information is in Eye Coordinates but the bump information is in Surface Local Coordinates Converting from Eye Coordinates to Surface Local Coordinates s Bx t Tx h N x We need to 1 Figure out how to convert from one to the other and 2 Decide which of light information or bump information gets converted to the other s coordinate system By Ty Ny Bz x Tz y N z z The Orange Book uses this to convert the light vector to Surface Local Coordinates Converting from Surface Local Coordinates to Eye Coordinates x Bx y By z B z While we are at it let s also rename the Surface Local coordinates to s t h for texture s texture t bump height This is the same as B T N but uses terminology that is more bump specific Oregon State I University prefer to Computer Graphics Oregon State University Computer Graphics mjb January 22 2013 Tx Ty Tz Nx s Ny t N z h use this one to convert the bump normal to Eye Coordinates mjb January 22 2013 3 1 22 2013 Bump Mapping Two Ways to Establish the Surface Local Coordinate System Gram Schmidt Orthogonalization There are 2 good ways to get the tangent and binormal vectors 1 Have the Tangent already defined glman s Sphere does this 2 Pick a general rule e g Tangent up 2a Use Gram Schmidt to correctly orthogonalize it wrt the Normal 2b Use two cross products to correctly orthogonalize it wrt the Normal


View Full Document

OSU CS 519 - Bump Mapping

Download Bump Mapping
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Bump Mapping and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Bump Mapping 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?