Computer Graphics Blending CO2409 Computer Graphics Week 14.

Slides:



Advertisements
Similar presentations
15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
Advertisements

16.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 16 – Some Special Rendering Effects.
8.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 8 Polygon Rendering.
POST-PROCESSING SET09115 Intro Graphics Programming.
Compositing and Blending Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
CS 4363/6353 BASIC RENDERING. THE GRAPHICS PIPELINE OVERVIEW Vertex Processing Coordinate transformations Compute color for each vertex Clipping and Primitive.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
Texture and Colour in Virtual Worlds Programming for 3D Applications.
Compositing and Blending Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Compositing and Blending - Chapter 8 modified by Ray Wisman Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Image Compositing Angel 8.11 Angel: Interactive Computer Graphics5E © Addison-Wesley
CHAPTER 10 Alpha Blending and Fog © 2008 Cengage Learning EMEA.
Hank Childs, University of Oregon November 15 th, 2013 Volume Rendering, Part 2.
CS 4731: Computer Graphics Lecture 19: Shadows Emmanuel Agu.
1Notes. 2Atop  The simplest (useful) and most common form of compositing: put one image “atop” another  Image 1 (RGB) on top of image 2 (RGB)  For.
1 Lecture 11 Scene Modeling. 2 Multiple Orthographic Views The easiest way is to project the scene with parallel orthographic projections. Fast rendering.
Course Website: Computer Graphics 5: Line Drawing Algorithms.
Ch 1 Intro to Graphics page 1CS 367 First Day Agenda Best course you have ever had (survey) Info Cards Name, , Nickname C / C++ experience, EOS experience.
7/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 4: Visual Appearance.
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
SET09115 Intro Graphics Programming
Tools for Raster Displays CVGLab Goals of the Chapter To describe pixmaps and useful operations on them. To develop tools for copying, scaling, and rotating.
Computer Graphics Texture Mapping
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Filtering and Color To filter a color image, simply filter each of R,G and B separately Re-scaling and truncating are more difficult to implement: –Adjusting.
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
Emerging Technologies for Games Alpha Sorting and “Soft” Particles CO3303 Week 15.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics Module Review CO2409 Computer Graphics.
CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass.
Computer Graphics Bitmaps & Sprites CO2409 Computer Graphics Week 3.
3D Graphics for Game Programming Chapter IV Fragment Processing and Output Merging.
3.2. G RAPHICS I Alpha blending within games. An exploration of the use of alpha blending within games.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
Real-Time rendering Chapter 4.Visual Appearance 4.4. Aliasing and antialiasing 4.5. Transparency,alpha,and compositing 4.6. Fog 4.7. Gamma correction
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Games Development 1 Camera Projection / Picking CO3301 Week 8.
Advanced Computer Graphics Shadow Techniques CO2409 Computer Graphics Week 20.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Compositing and Blending
Emerging Technologies for Games Deferred Rendering CO3303 Week 22.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
Sort-Independent Alpha Blending Houman Meshkin
Graphics Graphics Korea University cgvr.korea.ac.kr 1 7. Speed-up Techniques Presented by SooKyun Kim.
Maths & Technologies for Games Advanced Graphics: Scene Post-Processing CO3303 Week
Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
UniS CS297 Graphics with Java and OpenGL Blending.
Maths & Technologies for Games Graphics Optimisation - Batching CO3303 Week 5.
Graphics for Games Particle Systems CO2301 Games Development 1 Week 23.
Compositing and Blending Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
Computer Graphics I, Fall 2008 Compositing and Blending.
Com·pos·ite k ə m ˈ päz ə t/ verb Compositing is the combining of visual elements from separate sources into single images, often to create the illusion.
Week 7 - Monday CS361.
Draw a Simple Object.
Deferred Lighting.
Hank Childs, University of Oregon
CS451Real-time Rendering Pipeline
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Alpha blending within games
UMBC Graphics for Games
Computer Graphics Module Review
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Computer Graphics Module Overview
Chapter X Output Merger.
Computer Graphics Introduction to Shaders
Computer Graphics Material Colours and Lighting
blending blending textures reflection fog
Presentation transcript:

Computer Graphics Blending CO2409 Computer Graphics Week 14

Lecture Contents 1.Pixel Rendering 2.Additive / Multiplicative Blending 3.Alpha Testing 4.Alpha Blending 5.Depth Buffer / Sorting Issues

Pixel Rendering The output-merger stage is the final stage in the rendering pipeline –We have looked (in part) at all the other stages now Blends final pixel colours for the primitive being rendered with those pixels already on the viewport Can be used to create various forms of transparency: –Semi-transparent objects: glass, plastic, membranes –Effects that brighten the scene: fire, glow, lens flare –Or obscure (darken) the scene: smoke, dust, shadows –Plus other effects: e.g. detail textures, UI sprites etc. –[Same list as for sprites] Simpler blending methods combine the colours red, green and blue components, other methods use alpha values

Blending Recap The multiplicative blending equation is: Final.Red = Source.Red * Destination.Red Similar for green and blue, RGB range must be [0-1] (or need to scale) –Source colour is the pixel colour output from the pixel shader –Destination colour is the existing viewport pixel colour –Final colour the new colour written to the viewport –We previously used this to blend smoke sprites A darkening effect, suitable for representation of glass, shadows, smoke etc –If source pixel is white, destination colour stays same –As source pixel tends to black, destination is darkened

Multiplicative Blending Example Test Pattern RGB, but no alpha channel Multiplicative Smoke

Additive Blending and Others The additive blending equation is: Final.Red = Source.Red + Destination.Red Similar for green and blue, RGB range can be [0-1] or [0-255] This is a lightening effect, mainly used for the representation of lights –Source black = no effect, brightens as source -> white –We previously used this to blend fire and flare sprites Many other blending equations are possible, e.g.: Final.Red = 2 * (Source.Red * Destination.Red) –Darkens & lightens depending on source colour Final.Red = (Source.Red + Destination.Red) / 2 –Average of source and destination colour

Additive Blending Example Test Pattern RGB, but no alpha channel Additive Flare

Blending using Alpha Recall that pixel colours often contain a fourth component, the alpha value/channel Some blending methods use this alpha channel to regulate the blending –Key methods are alpha testing & alpha blending Usually only the source alpha value is used –Generally avoid use of destination (viewport) alpha So the alpha value is output from the pixel shader –Typically, the alpha value comes directly from the texture –Can come from vertex data/colours or from specialised pixel shader work (wiggle!)

Alpha Testing Alpha testing is a method to test the alpha channel quickly without a blending equation –Although it can be combined with blending methods The test checks the alpha value of each source (polygon) pixel before rendering it Pixel is only rendered if the alpha level is within a user- defined limit –E.g. If alpha >= 128 render pixel, otherwise discard This allows for areas of a polygon to be cut out, similar to the cut-out sprites from the 2D work –Efficient method to discard fully transparent pixels –Sorting problems discussed later do not affect alpha testing

Alpha Testing Example Test Pattern RGB Channel Alpha Channel Using Alpha >= 128 Test

Alpha Blending The alpha blending equation is: Final.Red = Source.Red * Source.Alpha + Destination.Red * (1 – Source.Alpha) Similar for green and blue, RGBA range is [0-1] This blending allows for variable transparency based on the alpha value –Low alpha = very transparent, high alpha = very opaque –It can be used for smooth & precise transparency effects –Previously used as an alternative for smoke sprites Alpha blending can create technical challenges due to the difficulties in sorting described later

Alpha Blending Example Test Pattern RGB Channel Alpha Channel Alpha provides variable transparency

3D Blending & Depth Buffers The depth buffer causes issues with blending in 3D –We will cover the depth buffer in detail in a later lecture –Idea: Store each pixel’s distance in the depth buffer, if another pixel needs to be drawn in same place, compare its depth first By default, pixels are recorded in the depth buffer regardless of transparency, e.g: –A nearby pixel is rendered with additive blending Its depth (distance) is recorded in the depth buffer –Another pixel is rendered in the same place, but further away: It should be visible through the additive pixel There should be an additive blend between them –However, the depth buffer contains a closer pixel, so it rejects this new further pixel – the depth buffer doesn’t ‘know’ about blending

Quick Fix for Depth Problems The visual effect of this depth buffer problem with blending is illustrated below –Occurs with any blending mode except alpha testing Simple solution: Don’t write blended polygons to the depth buffer –Still test (read) the depth buffer to see if the blended polygons are obscured by something opaque Pixels behind the blended polygon will not be rejected Depth buffer causing errors when blending

Quick Fix for Sorting Problems This fix only works if: –Blended polygons are rendered last in the scene –Blending method is order independent (symmetrical) I.e. Formula result same if source & destination are swapped Additive and multiplicative are order independent: A + B = B + A A * B = B * A But alpha blending is not symmetrical –Full solution is to manually sort polygons by depth –Draw polygons from back to front to avoid the issue There is also an alternative “Alpha-to-Coverage” technique

Sorting Alpha Blended Polygons Sorting polygons in 3D is non-trivial: –Beyond scope of this module –Covered in 3 rd year games module