DOC PREVIEW
GT ECE 4893 - Environment and 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 Lecture 13: Environment and Bump Mapping Prof. Aaron Lanterman School of Electrical and Computer Engineering Georgia Institute of Technology Real-time graphics has come a long way Slide from from “Teaching Cg” Powerpoint presentation: developer.nvidia.com/object/cg_tutorial_teaching.html The Cg Tutorial • Can get Cg Toolkit, example code, etc. here: http://developer.nvidia.com/object/cg_tutorial_home.html Image from “Teaching Cg” Powerpoint presentation: developer.nvidia.com/object/cg_tutorial_teaching.html Nice framework for experimentation Image from “Teaching Cg” Powerpoint presentation: developer.nvidia.com/object/cg_tutorial_teaching.html2 Cube maps Images from “OpenGL Cube Map Texturing,” developer.nvidia.com/object/cube_map_ogl_tutorial.html Back Front Right Bottom Left Top texCUBE((samplerCUBE) envMap,(float3) vec) Reflection and refraction € θI€ θR€ θI€ θTIncident vector I Refracted vector T Incident vector I Reflected vector R Normal vector N Normal vector N € θI=θR€ η1sin(θI) =η2sin(θT)T=refract(I,N,etaRatio) R=reflect(I,N) € η1/η2etaRatio= € η1€ η2Cg vertex shader for reflective mapping void C7E1v_reflection(float4 position : POSITION, float2 texCoord : TEXCOORD0, float3 normal : NORMAL, out float4 oPosition : POSITION, out float2 oTexCoord : TEXCOORD0, out float3 R : TEXCOORD1, uniform float3 eyePositionW, uniform float4x4 modelViewProj, uniform float4x4 modelToWorld) { oPosition = mul(modelViewProj, position); oTexCoord = texCoord; // Compute position and normal in world space float3 positionW = mul(modelToWorld, position).xyz; float3 N = mul((float3x3)modelToWorld, normal); N = normalize(N); // Compute the incident and reflected vectors float3 I = positionW - eyePositionW; R = reflect(I, N); } From “The Cg Tutorial,” p. 177 Cg pixel shader for reflective mapping void C7E2f_reflection(float2 texCoord : TEXCOORD0, float3 R : TEXCOORD1, out float4 color : COLOR, uniform float reflectivity, uniform sampler2D decalMap, uniform samplerCUBE environmentMap) { // Fetch reflected environment color float4 reflectedColor = texCUBE(environmentMap, R); // Fetch the decal base color float4 decalColor = tex2D(decalMap, texCoord); color = lerp(decalColor, reflectedColor, reflectivity); } From “The Cg Tutorial,” p. 1803 Different indices of refraction Around water (1.333) 0.8 Images from Thomas Kerwin, “Refraction in OpenGL,” www.cse.ohio-state.edu/~kerwin/refraction.html Vacuum: 1.0 Air: 1.0003 Water: 1.333 Glass: 1.5 (ordinary window glass) Plastic: 1.5 Diamond: 2.417 Data from “The Cg Tutorial,” p. 184 Cg vertex shader for refractive mapping void C7E3v_refraction(float4 position : POSITION, float2 texCoord : TEXCOORD0, float3 normal : NORMAL, out float4 oPosition : POSITION, out float2 oTexCoord : TEXCOORD0, out float3 T : TEXCOORD1, uniform float etaRatio, uniform float3 eyePositionW, uniform float4x4 modelViewProj, uniform float4x4 modelToWorld) { oPosition = mul(modelViewProj, position); oTexCoord = texCoord; // Compute position and normal in world space float3 positionW = mul(modelToWorld, position).xyz; float3 N = mul((float3x3)modelToWorld, normal); N = normalize(N); // Compute the incident and refracted vectors float3 I = positionW - eyePositionW; T = refract(I, N, etaRatio); } From “The Cg Tutorial,” p. 187 Cg pixel shader for refractive mapping void C7E4f_refraction(float2 texCoord : TEXCOORD0, float3 T : TEXCOORD1, out float4 color : COLOR, uniform float transmittance, uniform sampler2D decalMap, uniform samplerCUBE environmentMap) { // Fetch the decal base color float4 decalColor = tex2D(decalMap, texCoord); // Fetch refracted environment color float4 refractedColor = texCUBE(environmentMap, T); // Compute the final color color = lerp(decalColor, refractedColor, transmittance); } From “The Cg Tutorial,” p. 188 Chromatic dispersion € θIRefracted vectors Incident vector I Normal vector N T blue T red T green Without CD With CD Images from Thomas Kerwin, “Refraction in OpenGL,” www.cse.ohio-state.edu/~kerwin/refraction.html4 Fresnel effect € reflectCoeff = max(0, min(1,bias + scale(1 + I • N)power))€ Cfinal= reflectCoeff × Creflected+ (1− reflectCoeff )Crefracted• Some light reflects and some refracts • Think about looking into water – At shallow angles, a lot of reflection and little refraction – Looking straight in, a lot of refraction and a little reflection • Empirical approximation: From “The Cg Tutorial,” p. 189 Bump mapping Drawing from Søren Dreijer, “Bump Mapping Using Cg (3rd Edition),” www.blacksmith-studios.dk/projects/downloads/bumpmapping_using_cg.php Images from Paul Baker, “Simple Bumpmapping,” www.paulsprojects.net/tutorials/simplebump/simplebump.html Bump mapping examples Height map Normal map Top row from Wikipedia entry on “bump mapping” Bottom row from Søren Dreijer, “Bump Mapping Using Cg (3rd Edition),” www.blacksmith-studios.dk/projects/downloads/bumpmapping_using_cg.php Shader effect movies • Bump mapping demo with the Cimg library http://video.google.com/videoplay?docid=1570416667092534064 • Bump mapping and reflective textures – (HLEH - Half Life mod???) http://www.youtube.com/watch?v=FmpyHc6hXc4 • Bump mapping on the Nintendo DS http://www.youtube.com/watch?v=6ypt5JE-ofg5 Storing normals in textures • Textures don’t have to store color; we can store other things as well, like normals – Use r, g, b components to store, x, y, z of normal • Problem: Textures take [0,1] values; normals need [-1,1] values • Easy solution: “Range Compression” colorComponent = 0.5 * normalComponent + 0.5; normalComponent = 2 * (colorComponent - 0.5); From “The Cg Tutorial,” p. 202 Creating normal map from height field • Height field H(u,v) € normal =Hg− Hr,Hg− Ha,1( )Hg− Hr,Hg− Ha,1( )€ Hg€ Hr€ Ha• In flat regions, normal is (0,0,1), i.e. pointing “up” From “The Cg Tutorial,” p. 203 Cg vertex shader for bump mapping void C8E1v_bumpWall(float4 position : POSITION, float2 texCoord : TEXCOORD0, out float4 oPosition : POSITION, out float2 oTexCoord : TEXCOORD0, out float3 lightDirection : TEXCOORD1, uniform float3 lightPosition, // Objectspace uniform float4x4 modelViewProj) { oPosition =


View Full Document

GT ECE 4893 - Environment and Bump Mapping

Documents in this Course
Load more
Download Environment and 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 Environment and 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 Environment and 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?