DOC PREVIEW
GT ECE 4893 - Environment & Bump Mapping
School name Georgia Tech
Pages 20

This preview shows page 1-2-19-20 out of 20 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 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 20 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 20 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 20 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Environment & Bump Mapping Prof. Aaron Lanterman School of Electrical and Computer Engineering Georgia Institute of TechnologyReal-time graphics has come a long way Slide from from “Teaching Cg” Powerpoint presentation: developer.nvidia.com/object/cg_tutorial_teaching.htmlThe Cg Tutorial • Can get Cg Toolkit, example code, text of the entire book, etc. here: http://developer.nvidia.com/object/cg_tutorial_home.html Image from “Teaching Cg” Powerpoint presentation: developer.nvidia.com/object/cg_tutorial_teaching.htmlNice framework for experimentation Image from “Teaching Cg” Powerpoint presentation: developer.nvidia.com/object/cg_tutorial_teaching.htmlCube 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 η2Vertex 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. 177Pixel 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. 180Vertex 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. 187Pixel 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. 188Different 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. 184Chromatic 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.htmlFresnel 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. 189Bump 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.htmlBump 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.phpShader 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-ofgStoring 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. 202Creating 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. 203Vertex 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 = mul(modelViewProj, position);


View Full Document

GT ECE 4893 - Environment & Bump Mapping

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