DOC PREVIEW
GT ECE 4893 - Environment and 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:

Lecture 10: Environment and Bump MappingProf. Aaron LantermanSchool of Electrical and Computer EngineeringGeorgia Institute of TechnologyReal-time graphics has come a long wayVirtua Virtua FighterFighter(SEGA Corporation)(SEGA Corporation)NV1NV150K triangles/sec50K triangles/sec1M pixel ops/sec1M pixel ops/sec19951995Dead or Alive 3Dead or Alive 3((Tecmo Tecmo Corporation)Corporation)Xbox (NV2A)Xbox (NV2A)100M triangles/sec100M triangles/sec1G pixel ops/sec1G pixel ops/sec20012001DawnDawn(NVIDIA Corporation)(NVIDIA Corporation)GeForce FX (NV30)GeForce FX (NV30)200M triangles/sec200M triangles/sec2G pixel ops/sec2G pixel ops/sec20032003Slide from from “Teaching Cg” Powerpoint presentation:developer.nvidia.com/object/cg_tutorial_teaching.htmlThe Cg Tutorial• Can get Cg Toolkit, example code, etc. here:http://developer.nvidia.com/object/cg_tutorial_home.htmlImage from “Teaching Cg” Powerpoint presentation:developer.nvidia.com/object/cg_tutorial_teaching.htmlNice framework for experimentationImage from “Teaching Cg” Powerpoint presentation:developer.nvidia.com/object/cg_tutorial_teaching.htmlCube mapsImages from “OpenGL Cube Map Texturing,”developer.nvidia.com/object/cube_map_ogl_tutorial.htmlBack FrontRightBottom Left ToptexCUBE((samplerCUBE) envMap,(float3) vec)Reflection and refraction θI θR θI θTIncidentvector IRefractedvector TIncidentvector IReflectedvector RNormalvector NNormalvector N θI=θR η1sin(θI) =η2sin(θT)T=refract(I,N,etaRatio)R=reflect(I,N) η1/η2etaRatio= η1 η2Cg vertex shader for reflective mappingvoid 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. 177Cg pixel shader for reflective mappingvoid 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. 180Different indices of refractionAround water (1.333)0.8Images from Thomas Kerwin, “Refraction in OpenGL,”www.cse.ohio-state.edu/~kerwin/refraction.htmlVacuum: 1.0Air: 1.0003Water: 1.333Glass: 1.5 (ordinary window glass)Plastic: 1.5Diamond: 2.417Data from “The Cg Tutorial,” p. 184Cg vertex shader for refractive mappingvoid 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. 187Cg pixel shader for refractive mappingvoid 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. 188Chromatic dispersion θIRefractedvectorsIncidentvector INormalvector NT blueT redT greenWithout CDWith CDImages 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 mappingDrawing from Søren Dreijer, “Bump Mapping Using Cg (3rd Edition),”www.blacksmith-studios.dk/projects/downloads/bumpmapping_using_cg.phpImages from Paul Baker, “Simple Bumpmapping,”www.paulsprojects.net/tutorials/simplebump/simplebump.htmlBump mapping examplesHeight mapNormal mapTop row from Wikipediaentry 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 libraryhttp://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 DShttp://www.youtube.com/watch?v=6ypt5JE-ofgStoring normals in textures• Textures don’t have to store color; we can storeother things as well, like normals– Use r, g, b components to store, x, y, z of normal• Problem: Textures take [0,1] values; normalsneed [-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. 203Cg vertex shader for bump mappingvoid C8E1v_bumpWall(float4 position : POSITION, float2 texCoord : TEXCOORD0, out float4


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?