Environmental Maps Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University.

Slides:



Advertisements
Similar presentations
Lecture 8 Transparency, Mirroring
Advertisements

Virtual Realism TEXTURE MAPPING. The Quest for Visual Realism.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Building Models modified by Ray Wisman Ed Angel Professor of Computer Science,
Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
OpenGL Texture Mapping
Week 9 - Wednesday.  What did we talk about last time?  Fresnel reflection  Snell's Law  Microgeometry effects  Implementing BRDFs  Image based.
University of New Mexico
Projection Matrices Ed Angel
Texture Mapping CPSC /24/03 Abhijeet Ghosh.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Representation Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
GLSL I Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico.
University of New Mexico
OpenGL Texture Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
TA: Zhicheng Yan, Sushma S Kini, Mary Pietrowicz
Environmental Mapping CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Sampling and Aliasing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Models and Architectures Ed Angel Professor of Computer Science, Electrical and Computer.
Reflection and Transmission Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Environment Mapping. Examples Fall Motivation Silver candlestick No appropriate texture for it “ environment ” map Simulates the results of ray-tracing.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Programmable Pipelines Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University.
More on Environment Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, December 10, 2003.
October 9, 2002Serguei A. Mokhov, 1 COMP471 – Computer Graphics OpenGL: Texture Mapping.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS5500 Computer Graphics March 12, 2007.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Shader Applications Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CSCE 441: Computer Graphics Ray Tracing
Module 06 –environment mapping Module 06 – environment mapping Module 06 Advanced mapping techniques: Environment mapping.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of.
OpenGL Vertex Arrays OpenGL vertex arrays store vertex properties such as coordinates, normal vectors, color values and texture coordinates. These properties.
Programming with OpenGL Part 3: Shaders Ed Angel Professor of Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive.
Texture Coordinates CS418 Computer Graphics John C. Hart.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
An Introduction to the Cg Shading Language Marco Leon Brandeis University Computer Science Department.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Environment Maps Ed Angel Professor Emeritus of Computer Science
Introduction to Computer Graphics with WebGL
University of New Mexico
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Models and Architectures
OpenGL Texture Mapping
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
GLSL I Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico.
Building Models Ed Angel
CSC461: Lecture 23 Shading Computation
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
OpenGL Texture Mapping
Environment Mapping.
Reflection and Transmission
Presentation transcript:

Environmental Maps Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico

2 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Introduction Environmental mapping is way to create the appearance of highly reflective surfaces without ray tracing which requires global calculations Examples: The Abyss, Terminator 2 Is a form of texture mapping ­Supported by OpenGL and Cg

3 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Example

4 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Reflecting the Environment V N R

5 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Mapping to a Sphere V N R

6 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Hemisphere Map as a Texture If we map all objects to hemisphere, we cannot tell if they are on the sphere or anywhere else along the reflector Use the map on the sphere as a texture that can be mapped onto the object Can use other surfaces as the intermediate ­Cube maps ­Cylinder maps

7 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Issues Must assume environment is very far from object (equivalent to the difference between near and distant lights) Object cannot be concave (no self reflections possible) No reflections between objects Need a reflection map for each object Need a new map if viewer moves

8 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 OpenGL Implementation OpenGL supports spherical and cube maps First must form map ­Use images from a real camera ­Form images with OpenGL Texture map it to object

9 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Cube Map

10 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Forming Cube Map Use six cameras, each with a 90 degree angle of view

11 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Indexing into Cube Map V R Compute R = 2(N·V)N-V Object at origin Use largest magnitude component of R to determine face of cube Other two components give texture coordinates

12 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Example R = (-4, 3, -1) Same as R = (-1, 0.75, -0.25) Use face x = -1 and y = 0.75, z = Not quite right since cube defined by x, y, z = ± 1 rather than [0, 1] range needed for texture coordinates Remap by s = ½ + ½ y, t = ½ + ½ z Hence, s =0.875, t = 0.375

13 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Doing it in OpenGL glTextureMap2D(GL_TEXTURE_CUBE_ MAP_POSITIVE_X, level, GL_RGBA, rows, columns, border, GL_RGBA, GL_UNSIGNED_BYTE, image1) Same for other five images Make one texture object out of the six images

14 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 OpenGL Cube Map (cont) Parameters apply to all six images glTEXParameteri(GL_TEXTURE_CUBE_ MAP, GL_TEXTURE_MAP_WRAP_S, GL_REPEAT) Same for t and r Note that texture coordinates are in 3D space (s, t, r)

15 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 OpenGL Cube Map (cont) Usually use automatic texture coordinate generation via glTexGen*() glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP); glEnable(GL_TEXTURE_GEN, S); Same for t and r glEnable(GL_TEXTURE_CUBE_MAP);

16 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Normal Mapping Similar to texture mapping from cube glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP); Idea is that we can store normals as textures on cube Provides fast normal access Works even if textures are stored at low precision (8 bits/component)

17 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Texture Objects Allows us to store more than one texture (the current texture) in texture memory Texture object stores texels and all parameters Four steps ­Get name ­Bind ­Check for space (optional) ­Bind and rebind

18 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Naming Texture Objects Names are unsigned ints glGenTextures( GLsize n, Glint *tnames) returns n unused texture names in array tnames GLuint tnames[10], decal; glGenTextures(10, tnames); decal = tnames[0] Can pass decal to Cg program

19 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Binding Textures First call moves object to texture memory Subsequent calls make this object the current texture glBindTexture(GLenum target, GLuint tname) glBindTexture(GL_TEXTURE_CUBE_ MAP, decal) Can also prioritize, check if space available, and delete

20 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Passing Texture Objects to Cg From earlier fragment program example void FragmentProgram( in float4 color : COLOR0, in float4 texCoord: TEXCOORD0, out floar4 color0: COLOR0, const uniform sampler2D BaseTexture, const uniform float4 SomeColor) { Color0 = color * tex2D(BaseTexture, texCoord) + SomeColor;

21 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Parameter Passing (OpenGL) GLuint texture; /* texture object name */ CGparameter baseTexture, someColor baseTexture = cgGetNamedParameter(fragmentProgram, “BaseTexture”); someColor = cgGetNamedParemeter(fragmentProgram, “SomeColor”); cgGLSetTextureParameter(baseTexture, texture); cgGLEnableTextureParameter(baseTexture);

22 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Cg Example (vertex program) 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) {

23 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Vertex program (cont) 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); }

24 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Cg Example (fragment program) void C7E2f_reflection(float2 texCoord : TEXCOORD0, float3 R : TEXCOORD1, out float4 color : COLOR, uniform float reflectivity, uniform sampler2D decalMap, uniform samplerCUBE environmentMap) {

25 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 fragment program (cont) // Fetch reflected environment color float4 reflectedColor = texCUBE(environmentMap, R); // Fetch the decal base color float4 decalColor = tex2D(decalMap, texCoord); color = lerp(decalColor, reflectedColor, reflectivity); }

26 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Spherical Map Original environmental mapping technique proposed by Blinn and Newell

27 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Spherical Map

28 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Unraveled

29 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Dome Master and Final Image

30 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Slicing Dome Master sequence is sliced, feathered, and gamma corrected for 6 projector system