Buffers, Textures, Compositing, and Blending. Overview. Buffers. David Carr Virtual Environments, Fundamentals Spring 2005 Based on Slides by E.

Similar documents
Discrete Techniques. 11 th Week, Define a buffer by its spatial resolution (n m) and its depth (or precision) k, the number of

CS 5600 Spring

Buffers. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Surface Rendering. Surface Rendering

Texture Mapping. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

CISC 3620 Lecture 7 Lighting and shading. Topics: Exam results Buffers Texture mapping intro Texture mapping basics WebGL texture mapping

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Computer Graphics. Three-Dimensional Graphics VI. Guoying Zhao 1 / 73

Buffers. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Pixels and Buffers. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Introduction to Computer Graphics with WebGL

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

Objectives. Texture Mapping and NURBS Week 7. The Limits of Geometric Modeling. Modeling an Orange. Three Types of Mapping. Modeling an Orange (2)

CHAPTER 1 Graphics Systems and Models 3

E.Order of Operations

Introduction to Computer Graphics. Overview. What is Computer Graphics?

CS 432 Interactive Computer Graphics

Scan line algorithm. Jacobs University Visualization and Computer Graphics Lab : Graphics and Visualization 272

Graphics Hardware and Display Devices

Rasterization Computer Graphics I Lecture 14. Scan Conversion Antialiasing Compositing [Angel, Ch , ]

0. Introduction: What is Computer Graphics? 1. Basics of scan conversion (line drawing) 2. Representing 2D curves

Chapter 3. Texture mapping. Learning Goals: Assignment Lab 3: Implement a single program, which fulfills the requirements:

3D Rendering Pipeline

CS 354R: Computer Game Technology

Spring 2009 Prof. Hyesoon Kim

Texture mapping. Computer Graphics CSE 167 Lecture 9

CS451Real-time Rendering Pipeline


EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing

Fog example. Fog is atmospheric effect. Better realism, helps determine distances

8/5/2012. Introduction. Transparency. Anti-Aliasing. Applications. Conclusions. Introduction

Module 13C: Using The 3D Graphics APIs OpenGL ES

Institutionen för systemteknik

HE COMPLETE OPENGL PROGI FOR WINDOW WIND

Mali Demos: Behind the Pixels. Stacy Smith

Definition. Blending & Compositing. Front & Back Buffers. Left & Right Buffers. Blending combines geometric objects. e.g.

Computer Graphics I Lecture 11

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

CSE 167: Introduction to Computer Graphics Lecture #8: Textures. Jürgen P. Schulze, Ph.D. University of California, San Diego Spring Quarter 2016

Interactive Computer Graphics A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL

Rasterization and Graphics Hardware. Not just about fancy 3D! Rendering/Rasterization. The simplest case: Points. When do we care?

CPSC / Texture Mapping

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

Rendering Grass with Instancing in DirectX* 10

Animation & Rendering

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Computer Graphics. Bing-Yu Chen National Taiwan University

1.2.3 The Graphics Hardware Pipeline

Texturas. Objectives. ! Introduce Mapping Methods. ! Consider two basic strategies. Computação Gráfica

Computer Graphics: Programming, Problem Solving, and Visual Communication

Spring 2011 Prof. Hyesoon Kim

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4620/8626 Computer Graphics Spring 2014 Homework Set 1 Suggested Answers

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

Texture Mapping and Special Effects

Rendering Grass Terrains in Real-Time with Dynamic Lighting. Kévin Boulanger, Sumanta Pattanaik, Kadi Bouatouch August 1st 2006

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL

Chapter IV Fragment Processing and Output Merging. 3D Graphics for Game Programming

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Graphics and Interaction Rendering pipeline & object modelling

CS559: Computer Graphics. Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008

Computer Graphics (CS 563) Lecture 4: Advanced Computer Graphics Image Based Effects: Part 2. Prof Emmanuel Agu

lecture 21 volume rendering - blending N layers - OpenGL fog (not on final exam) - transfer functions - rendering level surfaces

Adaptive Point Cloud Rendering

More Visible Surface Detection. CS116B Chris Pollett Mar. 16, 2005.

Computer Graphics. Shadows

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

Models and Architectures. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Real-Time Shadows. Last Time? Today. Why are Shadows Important? Shadows as a Depth Cue. For Intuition about Scene Lighting

Last Time. Why are Shadows Important? Today. Graphics Pipeline. Clipping. Rasterization. Why are Shadows Important?

The Application Stage. The Game Loop, Resource Management and Renderer Design

Lecture 13: Reyes Architecture and Implementation. Kayvon Fatahalian CMU : Graphics and Imaging Architectures (Fall 2011)

CS 431/636 Advanced Rendering Techniques

Render-To-Texture Caching. D. Sim Dietrich Jr.

Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

3D graphics, raster and colors CS312 Fall 2010

The Rasterization Pipeline

Drawing Fast The Graphics Pipeline

CIS 581 Interactive Computer Graphics (slides based on Dr. Han-Wei Shen s slides) Requirements. Reference Books. Textbook

Computer Viewing and Projection. Overview. Computer Viewing. David Carr Fundamentals of Computer Graphics Spring 2004 Based on Slides by E.

CS 543: Computer Graphics. Rasterization

Real-Time Shadows. Last Time? Textures can Alias. Schedule. Questions? Quiz 1: Tuesday October 26 th, in class (1 week from today!

For Intuition about Scene Lighting. Today. Limitations of Planar Shadows. Cast Shadows on Planar Surfaces. Shadow/View Duality.

COMP environment mapping Mar. 12, r = 2n(n v) v

Topics and things to know about them:

Deferred Rendering Due: Wednesday November 15 at 10pm

CS602 Midterm Subjective Solved with Reference By WELL WISHER (Aqua Leo)

INF3320 Computer Graphics and Discrete Geometry

Soft Particles. Tristan Lorach

World Coordinate System

Synthesis of Textures with Intricate Geometries using BTF and Large Number of Textured Micropolygons. Abstract. 2. Related studies. 1.

lecture 18 - ray tracing - environment mapping - refraction

Normalized Device Coordinate System (NDC) World Coordinate System. Example Coordinate Systems. Device Coordinate System

Computer Graphics. Chapter 4 Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

Programming Guide. Aaftab Munshi Dan Ginsburg Dave Shreiner. TT r^addison-wesley

The Traditional Graphics Pipeline

POWERVR MBX. Technology Overview

Transcription:

INSTITUTIONEN FÖR SYSTEMTEKNIK LULEÅ TEKNISKA UNIVERSITET Buffers, Textures, Compositing, and Blending David Carr Virtual Environments, Fundamentals Spring 2005 Based on Slides by E. Angel Compositing, and Blending 1 L Overview Buffers - Additional OpenGL buffers - Reading and writing buffers - Blending Texture mapping - Mapping Methods + Texture mapping + Environmental Mapping + Bump Mapping - Basic strategies + Forward versus backward mapping + Point sampling versus area averaging Compositing and Blending - Blending for translucent surfaces - Compositing images - Antialiasing Compositing, and Blending 2 L INSTITUTIONEN FÖR SYSTEMTEKNIK LULEÅ TEKNISKA UNIVERSITET Buffers Compositing, and Blending 3 L 1

Buffer Define a buffer by its spatial resolution (n x m) and its depth k, the number of bits/pixel pixel Compositing, and Blending 4 L OpenGL Buffers Color buffers - Front - Back - Auxiliary + Undisplayed + System dependent - Overlay + Chroma key animation Depth Accumulation - High resolution buffer Stencil - Holds masks Compositing, and Blending 5 L Writing in Buffers Conceptually, we can consider all of memory as a large twodimensional array of pixels We read and write rectangular block of pixels - Bit block transfer (bitblt) operations The frame buffer is part of this memory memory source writing into frame buffer frame buffer (destination) Compositing, and Blending 6 L 2

Writing Model Read destination pixel before writing source Compositing, and Blending 7 L Writing Modes Source and destination bits are combined bitwise 16 possible functions (one per column in table) replace XOR OR Compositing, and Blending 8 L XOR Mode Recall from Chapter 3 that we can use XOR by enabling logic operations and selecting the XOR write mode XOR is especially useful for swapping blocks of memory such as menus that are stored off screen If S represents screen and M represents a menu the sequence S S M M S M ([S M] M) S S M ([S M] S) swaps the S and M Compositing, and Blending 9 L 3

The Pixel Pipeline OpenGL has a separate pipeline for pixels - Writing pixels involves + Moving pixels from processor memory to the frame buffer + Format conversions + Mapping, Lookups, Tests - Reading pixels + Format conversion Compositing, and Blending 10 L Raster Position Raster position is the association between the bitmap and object vertices OSG maintains raster position as part of the Geometry - Each vertex gets a corresponding 2D position in the bitmap - Geometry.setTexCoordArray(int unit, Vec2Array) - Each element in the Vec2Array is a bitmap coordinate (usually 0.-1.) The raster position is a geometric entity - Passes through geometric pipeline - Eventually yields a 2D position in screen coordinates - This position in the frame buffer is where the raster primitive is drawn Compositing, and Blending 11 L Buffer Selection OpenGL can draw into or read from any of the color buffers (front, back, auxiliary) Default to the back buffer Note that format of the pixels in the frame buffer is different from that of processor memory and these two types of memory reside in different places - Need packing and unpacking - Drawing and reading can be slow Compositing, and Blending 12 L 4

Bitmaps OpenGL treats 1-bit pixels (bitmaps) differently than multi-bit pixels (pixelmaps) Bitmaps are masks which determine if the corresponding pixel in the frame buffer is drawn with the present raster color - 0 color unchanged - 1 color changed based on writing mode Bitmaps are useful for raster text fonts Bitmaps can have a color associated with them Compositing, and Blending 13 L Drawing Bitmaps gl.glbitmap(width, height, x0, y0, xi, yi, bitmap) first raster position offset from raster position increments in raster position after bitmap drawn second raster position Compositing, and Blending 14 L Pixel Maps OpenGL works with rectangular arrays of pixels called pixel maps or images JavaOSG uses an Image class Pixels are in one byte (8 bit) chunks - Luminance (gray scale) images 1 byte/pixel - RGB 3 bytes/pixel Image read/write via supported plug-ins - Formats: JPEG, PNG, GIF, Compositing, and Blending 15 L 5

INSTITUTIONEN FÖR SYSTEMTEKNIK LULEÅ TEKNISKA UNIVERSITET Texture Mapping Compositing, and Blending 16 L Application Want to: - Map realistic variation onto an object - Limit model complexity Solution directly map a digital pattern to an object Example, mapping reflections to Geri s glasses Image Box texture map Centered on the lens Compositing, and Blending 17 L The Limits of Geometric Modeling Graphics cards can render over 10 million polygons per second But, that is insufficient for many phenomena - Clouds - Grass - Terrain - Skin Compositing, and Blending 18 L 6

Modeling an Orange Consider the problem of modeling an orange (the fruit) Start with an orange-colored sphere - Too simple Replace sphere with a more complex shape - Does not capture surface characteristics (small dimples) - Takes too many polygons to model all the dimples Compositing, and Blending 19 L Modeling an Orange (Alternate) Take a picture of a real orange, scan it, and paste onto simple geometric model - This process is texture mapping Still might not be sufficient because resulting surface will be smooth - Need to change local shape - Bump mapping Compositing, and Blending 20 L Three Types of Mapping Texture Mapping - Uses images to fill inside of polygons Environmental (reflection mapping) - Uses a picture of the environment for texture maps - Allows simulation of highly specular surfaces Bump mapping (Note! doesn t work in JavaOSG) - Emulates altering normal vectors during the rendering process Compositing, and Blending 21 L 7

Texture Mapping Geometric Model Texture Mapped Compositing, and Blending 22 L Environment Mapping Compositing, and Blending 23 L Bump Mapping Compositing, and Blending 24 L 8

Where Does Mapping Take Place? Mapping techniques are implemented at the end of the rendering pipeline - Very efficient because few polygons pass down the geometric pipeline Compositing, and Blending 25 L Is It Simple? Although the idea is simple - Map an image to a surface - There are 3 or 4 coordinate systems involved 2D image 3D surface Compositing, and Blending 26 L Coordinate Systems Parametric coordinates - May be used to model curved surfaces Texture coordinates - Used to identify points in the image to be mapped World Coordinates - Conceptually, where the mapping takes place Screen Coordinates - Where the final image is really produced Compositing, and Blending 27 L 9

Texture Mapping parametric coordinates texture coordinates world coordinates screen coordinates Compositing, and Blending 28 L Mapping Functions Basic problem is how to find the maps Consider mapping from texture coordinates to a point a surface Appear to need three functions x = x(s,t) (x,y,z) y = y(s,t) t z = z(s,t) But we really want to go s the other way Compositing, and Blending 29 L Backward Mapping We really want to go backwards - Given a pixel, we want to know to which point on an object it corresponds - Given a point on an object, we want to know to which point in the texture it corresponds + Need a map of the form s = s(x,y,z) t = t(x,y,z) Such functions are difficult to find in general Compositing, and Blending 30 L 10

Two-Part Mapping One solution to the mapping problem is to first map the texture to a simple intermediate surface Example: map to cylinder Compositing, and Blending 31 L Cylindrical Mapping Parametric cylinder x = r cos 2πu y = r sin 2πu z = v/h Maps rectangle in u,v space to cylinder of: - Radius r and height h in world coordinates s = u t = v Maps from texture space Compositing, and Blending 32 L Spherical Map We can similarly use a parametric sphere x = r cos 2πu y = r sin 2πu cos 2πv z = r sin 2πu sin 2πv But, must decide where to put the distortion Spheres are use in environmental maps Compositing, and Blending 33 L 11

Box Mapping Easy to use with simple orthographic projection Also used in environmental maps Compositing, and Blending 34 L actual Second Mapping Map from intermediate object to actual object - Normal vectors from intermediate to actual - Normal vectors from actual to intermediate - Vectors from center of intermediate intermediate Compositing, and Blending 35 L Aliasing Point sampling of the texture can lead to aliasing errors miss blue stripes point samples in u,v (or x,y,z) space point samples in texture space Compositing, and Blending 36 L 12

Area Averaging A better but slower option is to use area averaging pre image pixel Note that pre image of pixel is curved Compositing, and Blending 37 L OSG Example Remember TextureDemo.java The tower bitmap is mapped to the pyramid Five vertices to image locations: - 0 (0.00, 0.00) - 1 (0.25, 0.00) - 2 (0.50, 0.00) - 3 (0.75, 0.00) - 4 (tip) (0.50, 1.00) Compositing, and Blending 38 L Another OSG Example LightDemo2.java Compositing, and Blending 39 L 13

INSTITUTIONEN FÖR SYSTEMTEKNIK LULEÅ TEKNISKA UNIVERSITET Compositing and Blending Compositing, and Blending 40 L Overview The α component in RGBα color for - Blending for translucent surfaces - Compositing images - Antialiasing Compositing, and Blending 41 L Opacity and Transparency Opaque surfaces permit no light to pass through Transparent surfaces permit all light to pass Translucent surfaces pass some light translucency = 1 opacity (α) opaque surface α =1 Compositing, and Blending 42 L 14

Physical Models Dealing with translucency in a physically correct manner is difficult due to - The complexity of the internal interactions of light and matter - Using a pipeline renderer - Revert to writing model Compositing, and Blending 43 L Writing Model Use A component of RGBA (RGBα) to store opacity During rendering we can expand our writing model to use RGBA values source component source blending factor destination blending factor blend Color Buffer destination component Compositing, and Blending 44 L Blending Equation We can define source and destination blending factors for each component s = [s r, s g, s b, s α ] d = [d r, d g, d b, d α ] Source and destination colors b = [b r, b g, b b, b α ] c = [c r, c g, c b, c α ] Blend as c = [b r s r + c r d r, b g s g + c g d g, b b s b + c b d b, b α s α + c α d α ] Compositing, and Blending 45 L 15

Example Suppose that we start with the opaque background color (R 0,G 0,B 0,1) - This color becomes the initial destination color We now want to blend in a translucent polygon with color (R 1,G 1,B 1,α 1 ) Select: α as the source blending factor (1-α) as the destination blending factor R 1 = α 1 R 1 +(1- α 1 ) R 0, Note this formula is correct even if polygon is either opaque or transparent Compositing, and Blending 46 L Clamping and Accuracy All the components (RGBA) are clamped and stay in the range (0,1) However, in a typical system, RGBA values are only stored to 8 bits - Can easily loose accuracy if we add many components together - Example: add together n images + Divide all color components by n to avoid clamping + Blend with source factor = 1, destination factor = 1 + But division by n loses bits Compositing, and Blending 47 L Is this image correct? - Probably not - Polygons are rendered in the order they pass down the pipeline - Blending functions are order dependent Order Dependency Compositing, and Blending 48 L 16

Opaque and Translucent Polygons Suppose that we have a group of polygons some of which are opaque and some translucent How do we use hidden-surface removal? Opaque polygons block all polygons behind them and affect the depth buffer Translucent polygons should not affect depth buffer - Render with gl.gldepthmask(gl.gl_false) which makes depth buffer read-only Sort polygons first to remove order dependency Compositing, and Blending 49 L Fog We can composite with a fixed color and have the blending factors depend on depth - Simulates a fog effect Blend source color C s and fog color C f by C s =f C s + (1-f) C f f is the fog factor - Exponential - Gaussian - Linear (depth cueing) Compositing, and Blending 50 L Fog Functions Compositing, and Blending 51 L 17

Fog Effects Compositing, and Blending 52 L Line Aliasing Ideal raster line is one pixel wide All line segments, other than vertical and horizontal segments, partially cover pixels Simple algorithms color only whole pixels Lead to the jaggies or aliasing Similar issue for polygons Compositing, and Blending 53 L Antialiasing Can try to color a pixel by adding a fraction of its color to the frame buffer - Fraction depends on percentage of pixel covered by fragment - Fraction depends on whether there is overlap no overlap overlap Compositing, and Blending 54 L 18

Area Averaging Use average area α 1 +α 2 -α 1 α 2 as blending factor Compositing, and Blending 55 L Accumulation Buffer Compositing and blending are limited by resolution of the frame buffer - Typically 8 bits per color component The accumulation buffer is a high resolution buffer (16 or more bits per component) that avoids this problem Write into it or read from it with a scale factor Slower than direct compositing into the frame buffer Compositing, and Blending 56 L Applications Composites Image Filtering (convolution) Whole scene anti-aliasing Motion effects Compositing, and Blending 57 L 19

Summary Buffers - Additional OpenGL buffers - Reading and writing buffers - Blending Texture mapping - Mapping Methods + Texture mapping + Environmental Mapping + Bump Mapping - Basic strategies + Forward versus backward mapping + Point sampling versus area averaging Compositing and Blending - Blending for translucent surfaces - Compositing images - Antialiasing Compositing, and Blending 58 L Questions? Compositing, and Blending 59 L 20