A Few Things about Graphics Jian Huang Computer Science University of Tennessee Graphics • Graphics studies light transport in 3D scene, sometimes over time as well. • Example applications abound nowadays in movies, MTVs, … • In a nutshell, it’s some math and methods to compute such math efficiently on processors, memory banks and buses (lots of parallelism) • Well, everything should start with that Rendering Equation The Rendering Equation • I(x,x’) = intensity passing from x’ to x • g(x,x’) = geometry term (1, or 1/r2, if x visible from x’, 0 otherwise) • e(x,x’) = intensity emitted from x’ in the direction of x • r(x,x’,x’’) = scattering term for x’ (fraction of intensity arriving at x’ from the direction of x’’ scattered in the direction of x) • S = union of all surfaces It’s not analytically solvable • So, instead of simply doing the math, can we use computer to compute this equation in some simplified version (oftentimes, immensely)? • When approximations are made, priorities are set accordingly to what is the most appealing to viewer given the current hardware capability • The consumer of the result is human being, so the measurement of good and bad is not as conventional as other computer science disciplines What does it take to get that equation done? • First, one has to model the scene – – – – What color model is used (RGB, HSV) Surfaces as geometrical meshes (volumes …) Materials as lighting and texturing parameters Light sources • Second, compute the result for a screen device as it would appear on a retina – the rendering process – – – – The graphics pipeline Speed and high quality (30 fps, 60 fps, 120 fps) Framebuffer: 320x240, 640x480, …, 1024x768, … 6000x6000. Popular engines use OpenGL or DX, D3D libraries Geometric Primitives • All geometric primitives are specified by vertices Transformations • Modeling transformations • build complex models by positioning simple components • Viewing transformations • place virtual camera in the world • transform from world coordinates to eye coordinates • Vary transformations over time creates motion - Animation EYE OBJECT WORLD Affine Transformation in 3D • Translation • Rotate • Scale • Shear 1. 2. 3. 4. 5. 6. 3D Models - The Mesh Assembled scene A Virtual World • Objects – Shape: meshed geometry (and topology) – Appearance: lighting, shading and texture • Scene – Camera and viewing – Light position – Scene composition Appearance • Having just the geometry, objects don’t look right yet. • The first step is to use light sources • The second step is to put textures on Multiple Light Source • IL: light intensity • For multiple light sources – Repeat the diffuse and specular calculations for each light source – Add the components from all light sources – The ambient term contributes only once • The different reflectance coefficients can differ. – Simple “metal”: ks and kd share material color, – Simple plastic: ks is white • Remember, when cosine is negative lighting term is zero! Un-lit Smooth Shaded What is a Texture? • • • • • • Color Specular ‘color’ (environment map) Normal vector perturbation (bump map) Displacement mapping Transparency ... Rendering Textures Make A Difference • Good textures, when applied correctly, make a world out of nothing! Examples Examples (cont.) Examples (cont.) Before and After “Good” Texture Before and After “Good” Texture More Every Renderer is a State Machine • All rendering attributes are encapsulated in the as states • Transformations • Viewing • Rendering styles • Shading • Lighting • Texture mapping The Punch Line • Graphics models the world with geometry and appearance attributes • The rendering process is extremely computationintensive. What processor won Processor-Of-TheYear award last year? • The graphics state is complicated to maintain. • The requirement is high interactivity Distributed Graphics • Systems for distributing the shared graphical state of multi-display, multi-person, distributed, interactive applications Distributed Graphics • Two key problems: – The graphics database needs to be distributed • Replication is a standard go-around – The graphics states are distributed • This is the tricky part Distributed Graphics • Two major categories: – Data can be replicated (let’s do this!) – Data can not be replicated • Dependent on the choice – Drastically different approach – Specific pros and cons • Let’s make sure graphics states are shared properly Distributed vs. Monolithic Apps • Distributed control – In a non-trivial distributed application, different components need to be notified of changes to the distributed state • Interactivity – Network latency bandwidth limitations make updates to distributed state much slower. For performance, need to perform some operations locally • Local variations – There are times when a shared graphical scene may need to be modified locally