Download presentation
Presentation is loading. Please wait.
Published byLynne Montgomery Modified over 9 years ago
1
CS 638, Fall 2001 Admin Grad student TAs may have had their accounts disabled –Please check and email the lab if there is a problem If you plan on graduating with any degree in the coming year, you should see Lorene and collect a questionnaire –List compiled from questionnaires will be provided to employers Sooner, or later, LithTech install CDs will be available to borrow overnight –Arrangements yet to be finalized
2
CS 638, Fall 2001 NTSC vs. PAL Two major differences: –Vertical resolution: 625 vs. 525 (not all useable) –Frame rate: 50 Hz vs. 60 Hz (approx) Issues: –Artwork appearance, particularly for menus and other 2D art –Animation timing: Detach animation clock from frame rate clock, which is good practice anyway
3
CS 638, Fall 2001 Graphics Review Recall the standard graphics pipeline (OpenGL in this case):
4
CS 638, Fall 2001 Normal Vectors The surface normal vector describes the orientation of the surface at a point –Mathematically: Vector that is perpendicular to the tangent plane of the surface What’s the problem with this definition? –Just “the normal vector” or “the normal” –Will use N to denote Many lighting calculations are parameterized by the normal vector –Later, see how to exploit this
5
CS 638, Fall 2001 Local Shading Models Local shading models provide a way to determine the intensity and color of a point on a surface –The models are local because they don’t consider other objects at all –We use them because they are fast and simple to compute –They do not require knowledge of the entire scene, only the current piece of surface Works well for pipelined architectures, because pipeline only knows about one piece of geometry at a time
6
CS 638, Fall 2001 “Traditional” Shading Model What it captures: –Direct illumination from light sources –Diffuse and Specular components –(Very) Approximate effects of global lighting What it doesn’t do: –Shadows –Mirrors –Refraction –Lots of other stuff …
7
CS 638, Fall 2001 “Standard” Lighting Model Consists of three terms linearly combined: –Diffuse component for the amount of incoming light reflected equally in all directions –Specular component for the amount of light reflected in a mirror-like fashion –Ambient term to approximate light arriving via other surfaces It doesn’t do shadows, mirrors, refraction, lots of other stuff …
8
CS 638, Fall 2001 Diffuse Illumination Incoming light, I i, from direction L, is reflected equally in all directions –No dependence on viewing direction Amount of light reflected depends on: –Angle of surface with respect to light source Actually, determines how much light is collected by the surface, to then be reflected –Diffuse reflectance coefficient of the surface, k d Don’t want to illuminate back side. Use
9
CS 638, Fall 2001 Diffuse Example Where is the light?
10
CS 638, Fall 2001 Specular Reflection (Phong Model) Incoming light is reflected primarily in the mirror direction, R. (H is half vector, N is normal) –Perceived intensity depends on the relationship between the viewing direction, V, and the mirror direction –Bright spot is called a specularity Intensity controlled by: –The specular reflectance coefficient, k s –The parameter, n, controls the apparent size of the specularity Higher n, smaller highlight L R V H
11
CS 638, Fall 2001 Specular Example
12
CS 638, Fall 2001 Putting It Together Global ambient intensity, I a : –Gross approximation to light bouncing around of all other surfaces –Modulated by ambient reflectance k a Just sum all the terms If there are multiple lights, sum contributions from each light Several variations, and approximations
13
CS 638, Fall 2001 Flat shading Compute shading at a representative point and apply to whole polygon –OpenGL uses one of the vertices Advantages: –Fast - one shading value per polygon Disadvantages: –Inaccurate –Discontinuities at polygon boundaries
14
CS 638, Fall 2001 Gourand Shading Shade each vertex with it’s own location and normal Linearly interpolate across the face Advantages: –Fast - incremental calculations when rasterizing –Much smoother - use one normal per shared vertex to get continuity between faces Disadvantages: –Specularities get lost
15
CS 638, Fall 2001 Phong Interpolation Interpolate normals across faces Shade each pixel Advantages: –High quality, narrow specularities Disadvantages: –Expensive –Still an approximation for most surfaces Not to be confused with Phong’s specularity model
16
CS 638, Fall 2001
17
Texture Mapping The problem: Colors, normals, etc. are only specified at vertices. How do we add detail between vertices? Solution: Specify the details in an image (the texture) and specify how to apply the image to the geometry (the map) Works for shading parameters other than color, as we shall see –The basic underlying idea is the mapping
18
CS 638, Fall 2001 Basic Mapping The texture lives in a 2D space –Parameterize points in the texture with 2 coordinates: (s,t) –These are just what we would call (x,y) if we were talking about an image, but we wish to avoid confusion with the world (x,y,z) Define the mapping from (x,y,z) in world space to (s,t) in texture space With polygons: –Specify (s,t) coordinates at vertices –Interpolate (s,t) for other points based on given vertices
19
CS 638, Fall 2001 Basic Mapping
20
CS 638, Fall 2001 I assume you recall… Texture sampling (aliasing) is a big problem –Mipmaps and other filtering techniques are the solution The texture value for points that map outside the texture image can be generated in various ways –Repeat, Clamp, … Texture coordinates are specified at vertices and interpolated across triangles Width and height of texture images is constrained (powers of two, sometimes must be square)
21
CS 638, Fall 2001 Textures in Games The game engine provides some amount of texture support Artists are supplied with tools to exploit this support –They design the texture images –They specify how to apply the image to the object Commonly, textures are supplied at varying resolutions to support different hardware performance –Note that the texture mapping code does not need to be changed - just load different sized maps at run time Textures are, without doubt, the most important part of a game’s look
22
CS 638, Fall 2001 Example Texture Tool
23
CS 638, Fall 2001 Packing textures Problem: The limits on texture width/height make it inefficient to store many textures –For example: long, thin objects Solution: Artists pack the textures for many objects into one image –The texture coordinates for a given object may only index into a small part of the image –Care must be taken at the boundary between sub-images to achieve correct blending –Mipmapping is restricted –Best for objects that will be at known resolution (weapons, for instance)
24
CS 638, Fall 2001 Combining Textures
25
CS 638, Fall 2001 Texture Matrix Normally, the texture coordinates given at vertices are interpolated and directly used to index the texture The texture matrix applies a homogeneous transform to the texture coordinates before indexing the texture What use is this? –Two examples in this lecture: Animating textures and projective texturing
26
CS 638, Fall 2001 Animating Texture (method 1) The texture matrix can be used to translate or rotate the texture If the texture matrix is changed from frame to frame, the texture will appear to move on the object This is particularly useful for things like flame, or swirling vortices, or pulsing entrances, …
27
CS 638, Fall 2001 Demo
28
CS 638, Fall 2001 Projective Texturing The texture should appear to be projected onto the scene, as if from a slide projector Solution: –Equate texture coordinates with world coordinates –Think about it from the projector’s point of view: wherever a world point appears in the projector’s view, it should pick up the texture –Use a texture matrix equivalent to the projection matrix for the projector – maps world points into texture image points Details available in many places Problems? What else could you do with it?
29
CS 638, Fall 2001 Multitexturing Some effects are easier to implement if multiple textures can be applied –Future lectures: Light maps, bump maps, shadows, … Multitexturing hardware provides a pipeline of texture units, each of which applies a standard texture map operation –Fragments are passed through the pipeline with each step working on the result of the previous stage –Texture parameters are specified independently for each unit, further improving functionality –For example, the first stage applies a color map, the next modifies the illumination to simulate bumps, the third modifies opacity –Not the same as multi-pass rendering - all applied in one pass
30
CS 638, Fall 2001 What’s in a Texture? The graphics hardware doesn’t know what is in a texture –It applies a set of operations using values it finds in the texture, the existing value of the fragment (pixel), and maybe another color –The programmer gets to decide what the operations are, within some set of choices provided by the hardware –Examples: the texture may contain scalar “luminance” information, which simply multiplies the fragment color. What use is this? the texture might contain “alpha” data that multiplies the fragment’s alpha channel but leaves the fragment color alone. What use is this? –Future lectures will look at creative interpretations of textures
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.