blending blending textures reflection fog

Slides:



Advertisements
Similar presentations
Compositing and Blending Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics.
Advertisements

Hank Childs, University of Oregon Nov. 25th, 2014 CIS 441/541: Introduction to Computer Graphics Lecture 15: animation, transparency.
OpenGL Fragment Operations
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
Compositing and Blending Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Blending MAE152 Computer Graphics for Engineers and Scientists Fall 03.
Compositing and Blending - Chapter 8 modified by Ray Wisman Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
COMP Advanced Graphics Advanced Graphics - Part 6 The big picture: –Still working on advanced polygonal techniques with a special focus on OpenGL.
Image Compositing Angel 8.11 Angel: Interactive Computer Graphics5E © Addison-Wesley
Objectives Introduce OpenGL buffers and read/write Introduce OpenGL buffers and read/write Introduce texture mapping Introduce texture mapping Introduce.
Warm-Up Use a ray diagram to explain how light behaves differently when it contacts: A rough object vs a smooth object? An opaque object vs a transparent.
Chapter 6. More on Color and Material Presented by Garrett Yeh.
Raster Displays Images are composed of arrays of pixels displayed on a raster device. Two main ways to create images: –Scan and digitize an existing image.
7/2/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 4: Visual Appearance.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Creating Tessellations With Paint. Open Microsoft Paint. Go to: Start, Programs, Accessories, Paint.
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
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.
CS324e - Elements of Graphics and Visualization Compositing.
Chapter 2 Getting Started: Drawing Figures. The Framebuffer Lecture 2 Fri, Aug 29, 2003.
Lecture 12 Blending, Anti-aliasing, Fog, Display Lists.
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.
DREAM PLAN IDEA IMPLEMENTATION Introduction to Computer Graphics Dr. Kourosh Kiani
Light and color.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS559: Computer Graphics Lecture 27: Texture Mapping Li Zhang Spring 2008 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys, UVA and Rosalee.
Compositing and Blending
Computer Graphics Blending CO2409 Computer Graphics Week 14.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
UniS CS297 Graphics with Java and OpenGL Blending.
OpenGL Special Effects Jian-Liang Lin 2002 Blending: Alpha Channel Alpha value can be specify by glColor* When blending is enabled, the alpha value is.
Chapter 13 Special Visual Techniques. Blending ◦ Without blending, a source fragment’s color values are supposed to overwrite those of its destination.
PyGame - Unit 1 PyGame Unit – – Introduction to PyGame.
Compositing and Blending Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Computer Graphics I, Fall 2008 Compositing and Blending.
Chapter 6. Blending, Antialiasing, Fog, and Polygon Offset Computer Graphics (spring, 2009) School of Computer Science University of Seoul.
Pixels, Colors and Shapes
Visible Light & Color (SNB page 52)
Week 7 - Monday CS361.
Introduction to Computer Graphics with WebGL
Inequalities and their Graphs
Inequalities and their Graphs
Here’s the Situation Suppose you have a choice of two different jobs at graduation Start at $30,000 with a 6% per year increase Start at $40,000 with $1200.
Visual Appearance Chapter 4
Multimedia Summer Camp
Color Theory.
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
I = a I + ( ) 1 – a I BLENDING, ANTIALIASING, AND FOG l l 1 l 2 Earth
Learning to program with Logo
Optical Illusions.
Computer Graphics.
CSc4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Fog and Transparency.
B16 Mineral Identification
Inequalities and their Graphs
Making the Applications Interesting
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Lighting.
Pixels.
blending blending textures reflection fog
Inequalities and their Graphs
Blending CSCI 440 textbook section 7.10
Color Theory.
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Computer Graphics Practical Lesson 7
Question Does my dog prefer a light color, like yellow, or a dark color, like blue? My research showed that dogs can see some colors. They see color.
Chapter X Output Merger.
Color Theory.
Color Theory.
Computer Graphics Image processing 紀明德
Presentation transcript:

blending blending textures reflection fog

blendRectangles1.cpp

Fragments color and depth information destination - the pixel that is already on the screen source - the pixel that might be written to the screen

Recall with Blending OFF and Depth testing OFF How does the computer decide if source pixel replaces the destination pixel?

Recall with Blending OFF and Depth testing OFF source pixel replaces destination pixel always

Recall with Blending OFF and Depth testing ON How does the computer decide if source pixel replaces the destination pixel?

Recall with Blending OFF and Depth testing ON if source fragments's z-value is less than (closer than) destination fragments's z-value then source replaces destination. if source fragments's z-value is greater than or equal to (further than) destination fragments's z-value then source fragment is discarded.

With Blending ON and Depth testing ON or OFF if source fragment would be discarded without blending, it is still discarded. if source fragments would replace the destination fragment without blending, now they will be blended.

Blending formula terms Let X be a color (R,G,B,A) Let SX be the X color value for the source fragment and DX for the destination fragment Let SbX be the X color blending factor for the source fragment and DbX for the destination fragment.

Blending Formula DX = SbX * SX + DbX * DX

Some ways to set SbX and DbX glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); SbX = SA DbX = 1- SA

Some other ways to set SbX and DbX glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA); SbX = DA DbX = 1- DA glBlendFunc(GL_ONE, GL_ZERO); SbX = 1 DbX = 0 Lots more.

Experiment 1: blendRectangles1.cpp Left side of room: compute red rectangle pixels after blending with white background, and then pixels in the overlap after blending. Right side of room: compute blue rectangle pixels after blending with white background, and then pixels in the overlap after blending.

Experiment 1 results Red first: ( , , , ) after 1st rect. ( , , , ) after 2nd rect. Blue first: ( , , , ) after 1st rect.

Experiment 2 Change the background color to black and run. Are the colors the same?

blendRectangles2.cpp What we want: red and blue rectangles transparent and green rectangle opaque red closest, then green, then blue.

blendRectangles2.cpp Why do we get what we get? Check setup note alpha values of r,b, and g rectangles note z values of all three rectangles note gluLookAt

Experiment 3 Make blendRectangles2 do what is intended.

Experiment 4 Change the viewpoint to glLookAt(0.0, 0.0, -3.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ); Does it still work correctly? (Now blue should be closest)

Strategy for drawing opaque and translucent objects Turn on depth testing. Draw all the opaque items. Make the depth buffer read only : glDepthMask(GL_FALSE); Draw the transparent objects. (set the depth buffer back to read/write: glDepthMask(GL_TRUE);

Experiment 5 try it!

sphereInGlassBox.cpp run it and observe.

Review Textures In loadExternalTextures () we have glBindTexture(GL_TEXTURE_2D, texture[0]); This says texture[0] is the active texture (the state). Here we set some of its properties. In drawScene() we have At this point we are setting the state, so that texture[0] will be used to draw the following polygon(s). Start here for 21

Blending Textures Run fieldAndSkyTexturesBlended.cpp notice the blending functions used ONE and ZERO GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA variable alpha

Blending to simulate reflection run ballAndTorusReflected.cpp discuss technique glScalef(1.0, -1.0, 1.0); glFrontFace(GL_CW); //good choice? different alphas for transparent (reflective) and opaque. smooth vs flat

Fog Run fieldAndSkyFogged.cpp glEnable(GL_FOG); glFogfv(GL_FOG_COLOR,fogColor); fogColor is a pointer to a color glFogi(GL_FOG_MODE,fogmode); fogmode can be GL_LINEAR,GL_EXP, or GL_EXP2

parameters for fog for GL_LINEAR glFogf(GL_FOG_START, fogstart); glFogf(GL_FOG_END, fogend); for GL_EXP and GL_EXP2 glFogf(GL_DENSITY,fogdensity); glHint(GL_FOG, GL_NICEST);