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

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

CS 5610 / Spring Depth Buffering and Hidden Surface Removal

CS 432 Interactive Computer Graphics

An Interactive Introduction to OpenGL Programming

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

E.Order of Operations

CS4620/5620: Lecture 14 Pipeline

Buffers and Processing Fragments

INF3320 Computer Graphics and Discrete Geometry

Computer Graphics. Bing-Yu Chen National Taiwan University

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Basic GPU techniques Josef Pelikán CGG MFF UK Praha.

Pipeline Operations. CS 4620 Lecture 14

INF3320 Computer Graphics and Discrete Geometry

Computer Graphics. Shadows

CSE 167: Introduction to Computer Graphics Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

CSE 167: Introduction to Computer Graphics Lecture #9: Visibility. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2018

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

Models and Architectures

Pipeline Operations. CS 4620 Lecture 10

PowerVR Series5. Architecture Guide for Developers

1.2.3 The Graphics Hardware Pipeline

Drawing Fast The Graphics Pipeline

Computer Graphics 10 - Shadows

Rasterization Overview

Rendering Techniques for Hardware-Accelerated Imaged-Based CSG

Introduction to Computer Graphics with WebGL

Hidden surface removal. Computer Graphics

Rasterization. COMP 575/770 Spring 2013

Computer Graphics. Lecture 9 Environment mapping, Mirroring

Today. CS-184: Computer Graphics. Lecture #10: Clipping and Hidden Surfaces. Clipping. Hidden Surface Removal

POWERVR MBX. Technology Overview

CSE 167: Introduction to Computer Graphics Lecture #5: Visibility, OpenGL

Image Processing. CSCI 420 Computer Graphics Lecture 22

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

CS 179 GPU Programming

Image Processing. Alpha Channel. Blending. Image Compositing. Blending Errors. Blending in OpenGL

Deferred Rendering Due: Wednesday November 15 at 10pm

CSE 167: Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

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

Tutorial 4: Depth and Transparency

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Graphics Pipeline & APIs

The Rasterization Pipeline

Drawing Fast The Graphics Pipeline

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

Volume Graphics Introduction

Performance OpenGL Programming (for whatever reason)

CS GPU and GPGPU Programming Lecture 2: Introduction; GPU Architecture 1. Markus Hadwiger, KAUST

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

Order Independent Transparency with Dual Depth Peeling. Louis Bavoil, Kevin Myers

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

Scanline Rendering 2 1/42

CSE 167: Introduction to Computer Graphics Lecture #5: Projection. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Graphics Pipeline & APIs

3D Rendering Pipeline

OpenGl Pipeline. triangles, lines, points, images. Per-vertex ops. Primitive assembly. Texturing. Rasterization. Per-fragment ops.

The Traditional Graphics Pipeline

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Intro to OpenGL III. Don Fussell Computer Science Department The University of Texas at Austin

2 Transformations and Homogeneous Coordinates

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

Shadow Image and Special Effects Implementation Techniques for Virtual Shadow Puppet Play

Optimizing DirectX Graphics. Richard Huddy European Developer Relations Manager

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

Computer Graphics II

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

Drawing Fast The Graphics Pipeline

World Coordinate System

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

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

EE 4702 GPU Programming

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

Lecture 2. Shaders, GLSL and GPGPU

PowerVR Performance Recommendations The Golden Rules. October 2015

Lectures Transparency Case Study

The Traditional Graphics Pipeline

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

The Graphics Pipeline

Projection and viewing. Computer Graphics CSE 167 Lecture 4

Hardware-driven visibility culling

Computer Graphics. Chapter 1 (Related to Introduction to Computer Graphics Using Java 2D and 3D)

CSCI 4620/8626. The 2D Viewing Pipeline

Introduction to Visualization and Computer Graphics

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

Graphics Hardware and Display Devices

... Output System Layers. Application 2. Application 1. Application 3. Swing. UIKit SWT. Window System. Operating System

Shadows in the graphics pipeline

Computergrafik. Matthias Zwicker. Herbst 2010

Point-Based rendering on GPU hardware. Advanced Computer Graphics 2008

Real - Time Rendering. Graphics pipeline. Michal Červeňanský Juraj Starinský

GPU Programming EE Practice Midterm Examination

Lectures OpenGL Introduction

WebGL (Web Graphics Library) is the new standard for 3D graphics on the Web, designed for rendering 2D graphics and interactive 3D graphics.

ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL

CS130 : Computer Graphics Lecture 2: Graphics Pipeline. Tamar Shinar Computer Science & Engineering UC Riverside

Transcription:

Blending & Compositing COMP 3003 Autumn 2005 Definition Blending combines geometric objects e.g. transparency Compositing combines entire images multi-pass textures accumulating results Both depend on details of frame-buffer OpenGL Pipeline The Frame Buffer An image is a rectangular array of data OpenGL computes 1 image per frame Stores the image in the frame buffer A special array on the video card Frame buffer has several components Front & Back Buffers We have already seen double-buffering drawing one image, displaying another flip between them with glutswapbuffers() The image displayed is in the front buffer The image being drawn is in the back buffer OpenGL can actually draw into either Left & Right Buffers It s possible to draw stereo images one image for each eye so we have left and right buffers Can be combined with front / back: for details, see the Red Book

Frame Buffer Components Frame buffer has: colour buffer for RGBA depth buffer for z-depth stencil buffer accumulation buffer Stencil Buffer Used for masking: covering up parts of frame buffer like using masking tape for painting Each pixel is on or off marks whether to draw there or not Accumulation Buffer A spare copy of the frame often with higher precision used to composite images multi-pass images generally higher quality Pixel Buffers Relatively new addition Extra buffer(s) you can draw into but never display on screen Typically used to create textures Sometimes specialized for this purpose We won t worry about them Setting the Buffer gldrawbuffer(): which to draw into defaults to GL_FRONT_LEFT you won t need this glreadbuffer(): which to read from useful for screen captures also used to create textures Clearing Buffers glclear(): clears the buffers specified very slow, so only do once / frame uses colour specified by glclearcolor() sets every pixel to that colour often has specialized hardware

Masking Buffers By default, all buffers can be changed We can turn this on and off: gldepthmask(gl_true) gldepthmask(gl_false) Also have glstencilmask(), glcolormask() How it works Rasterization converts triangle to pixels OpenGL calls pixels fragments fragments are processed in parallel colour, lighting, &c. computed, then: several tests performed on fragments Fragment Operations For each fragment (pixel), OpenGL does: scissor test alpha test stencil test depth test blending, dithering and logical operations Scissor Test Scissoring is for rectangular regions defined with glscissor(x,y,width,height) fragments inside are kept fragments outside are discarded Alpha Test Compares alpha to a fixed value Discards fragment if comparison fails Comparisons possible: <,!, =, ", >, # Set comparison with glalphafunc() Stencil Test A stencil is a shape you paint through e.g. military lettering on jeeps Fragment compared to stencil: glstencilfunc() glstencilop() changes stencil (if desired) Set the stencil with glstencilop(gl_keep)

Depth Test We ve already used this Fragment s depth compared to buffer failure means fragment is discarded success means depth in buffer is reset Comparison set with gldepthfunc() defaults to GL_LESS (keep closer value) Depth Quantization Depth buffer has only a few bits - e.g. 16 Fragments can only be at 2 16 distances Quantizes distance from near to far clipping planes Objects too close to each other render incorrectly Usually see a mixture of pixels from each So keep near & far clipping planes close Blending Operations Blending mixes old & new colours usually based on alpha value alpha usually means opacity specifies how to mix colours more in a minute on this Dithering Older cards don t have many colours Approximate colours by dithering mixing darker and lighter pixels hardware does it OpenGL only lets you turn it on / off Logical Operations Again, mostly for older machines bitwise boolean operations restricted form of blending Accumulation Buffer Combines multiple versions of a frame Draw image in back buffer first Call glaccum(gl_accum,x) to add (x!*!image) to accumulation buffer Repeat for each version of the frame Copy back with glaccum(gl_return,x)

Reading from Buffers Use glreadbuffer() to specify which one defaults to GL_FRONT Allocate memory with malloc() Then call glreadpixels() copies from buffer to CPU memory Generating Movies Use glreadbuffer() to save frame to RAM Write each frame to disk Combine frames to get a movie Don t try this in lab it burns disk space (1 MB+/frame) From Buffer to Texture Use glreadbuffer() to move image to RAM Use gltexture() to specify it as texture Better to keep it in the video card newest OpenGL allows pixel buffers keeps image / texture on video card Translucency We can see through transparent objects More accurately, translucent objects allow some light through from behind specify opacity with alpha component takes alpha * new + (1-alpha) * old Alpha Transparency Set alpha as part of material properties Call glenable(gl_blend) to enable Use glblendfunc(gl_src_alpha, GL_ONE_MINUS_SRC_ALPHA); takes alpha * source (new value) adds (1-alpha) * destination (old value) Rendering Order Alpha blending has to come last draw solid objects first then translucent objects Back to painter s algorithm & sort order Use carefully