Buffers and Processing Fragments

Size: px
Start display at page:

Download "Buffers and Processing Fragments"

Transcription

1 Buffers and Processing Fragments 2017 Autumn Animação e Visualização Tridimensional 2017/2018 1

2 OGL Framebuffer Color Buffers: (front back)- (left right) Depth Buffer Stencil Buffer 2

3 Buffers Intro Buffer n x m elements of k bits 3

4 Buffers Intro Clearing Buffers Define the clearing values: void glclearcolor(glclampf red, GLclampf green, GLclampf blue, Glclampf alpha); void glcleardepth(glclampd depth); void glcleardepthf(glclampf depth); void glclearstencil(glint s); Glclampf and Glclampd: [0, 1] Default values: depth-clearing is 1 and 0 for all the others Clear the specified buffer: void glclear(glbitfield mask); GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, and GL_STENCIL_BUFFER_BIT 4

5 Buffers Intro Masking the buffers: void glcolormask(glboolean r, GLboolean g, GLboolean b, GLboolean alpha); void gldepthmask(glboolean flag); void glstencilmask(glboolean mask); 5

6 OpenGL Pipeline Application GPU Data Flow Framebuffer Vertices Vertices Fragments Fragments Vertex Processing Assembly Rasterizer Interpolator Fragment Processing Tests and Blending Pixels Vertex Shader Fragment Shader 6

7 Fragments Operations Fragment tests Blend operations After these operations we get the pixels 8

8 Fragments tests In this order: Scissor test Culls fragments in a 2D box on screen Stencil test Restrict drawing to certain portions of the screen Compares value of stencil buffer with reference constant Culls fragments conditionally Can apply different operation to stencil value based on: Stencil-fail / S-pass & Z-fail / S-pass & Z-pass Operations: Set, increment, decrements, Depth test (visibility/occlusion test) Compares Z value with value from Z-buffer Culls fragments conditionally, otherwise updates Z-buffer 9

9 Blend Operations Merge fragments with color buffer content (pixels) Order of operations: Blending operations (aka. compositing) Weighted combination of fragment and pixel values Dithering operation Approximation of color by spatial averaging Different rounding based pixel location Half-Toning Logical operations 16 combinations of fragment and pixel values (NOT, AND, OR, XOR) 10

10 Scissor Test Window Coordinates (OpenGL API) void glscissor (GLint x, GLint y, GLsizei width, GLsizei height) GLint x, GLint y: lower left position 11

11 How to use stencil buffer? 1. glutinitdisplaymode(glut_stencil); 2. glenable(gl_stencil_test); 3. glclearstencil(0); 4. glclear(gl_stencil_buffer_bit); 12

12 Stencil Testing 1/2 void glstencilfunc( GLenum func, GLint ref, GLuint mask ); sets the function and reference value for stencil testing. func: test function, see next page. ref: reference value mask:a mask that is ANDed with both the reference value and the stored stencil value when the test is done. 13

13 Stencil Testing 2/2 param GL_NEVER GL_LESS GL_LEQUAL GL_GEQUAL GL_NOTEQUAL GL_ALWAYS Meaning Always fails. Passes if ( ref & mask) < ( stencil & mask). Passes if ( ref & mask) ( stencil & mask). Passes if ( ref & mask) ( stencil & mask). Passes if ( ref & mask)!= ( stencil & mask). Always passes. 14

14 Modify stencil buffer 1/2 void glstencilop( GLenum fail, GLenum zfail, GLenum zpass ); sets the actions to change the stencil buffer. fail: The action to take when the stencil test fails zfail: Stencil action when the stencil test passes, but the depth test fails. zpass: both the stencil test and the depth test pass 15

15 Modify stencil buffer 2/2 param GL_KEEP GL_ZERO GL_REPLACE GL_INCR GL_DECR GL_INVERT Meaning keep the current value set the value in stencil buffer to zero set the value in stencil buffer to ref in glstencilfunc() increase the current value in stencil buffer decrease the current value in stencil buffer bitwise inverse the current value in stencil buffer 16

16 Stencil buffer + Z buffer 17

17 Stencil buffer example 1/2 Void display(){ glenable(gl_depth_test); glenable(gl_stencil_test); glclearstencil(0x0); glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT GL_STENCIL_BUFFER_BIT); glstencilfunc(gl_always, 1, 1); glstencilop(gl_replace, GL_REPLACE, GL_REPLACE); DrawCube(16.0); // draw a blue cube glclear(gl_depth_buffer_bit); // init z_buffer glstencilop(gl_keep, GL_KEEP, GL_KEEP); glstencilfunc(gl_equal, 1, 1); DrawTeapot(8); // White Teapot glswapbuffers(); } 18

18 Stencil buffer example 2/2 19

19 Other example 1/2 Void display(){ glenable(gl_depth_test); glenable(gl_stencil_test); glclearstencil(0x0); glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT GL_STENCIL_BUFFER_BIT); glstencilfunc(gl_always, 0x1, 0x1); glstencilop(gl_replace, GL_REPLACE, GL_REPLACE); DrawCube(16.0); //Blue Cube desenhado glclear(gl_depth_buffer_bit); // incializa o z-buffer glstencilop(gl_keep, GL_KEEP, GL_INVERT); glstencilfunc(gl_equal, 0x1, 0x1); DrawTeapot(8); //White Teapot glstencilfunc(gl_notequal, 0x1, 0x1); glstencilop(gl_keep, GL_KEEP, GL_KEEP); PushMatrix(); gltranslatef(10, 0, 0); DrawSphere(); //Yellow Sphere PopMatrix(); glswapbuffers(); } 20

20 Other example 2/2 21

21 How to Use Blending? Remember to enable glenable(gl_blend); Set up blend function glblendfunc(, ) 22

22 Blending Equation We can define source and destination blending factors for each RGBA component s = [s r, s g, s b, s a ] d = [d r, d g, d b, d a ] Suppose that the source and destination colors are b = [b r, b g, b b, b a ] c = [c r, c g, c b, c a ] 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 a s a + c a d a ] 23

23 OpenGL Blending and Compositing Must enable blending and pick source and destination factors glenable(gl_blend) glblendfunc(source_factor, destination_factor) Only certain factors supported GL_ZERO, GL_ONE GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA See Redbook for complete list 24

24 Blend Function 2/2 Constant RGB Blend Factor Alpha Blend Factor GL_ZERO (0, 0, 0) 0 GL_ONE (1, 1, 1) 1 GL_SRC_COLOR (Rs,Gs, Bs) As GL_ONE_MINUS_SRC_COLOR (1, 1, 1) (Rs,Gs, Bs) 1 As GL_DST_COLOR (Rd,Gd, Bd) Ad GL_ONE_MINUS_DST_COLOR (1, 1, 1) (Rd,Gd, Bd) 1 Ad GL_SRC_ALPHA (As, As, As) As GL_ONE_MINUS_SRC_ALPHA (1, 1, 1) (As,As,As) 1 As GL_DST_ALPHA (Ad,Ad, Ad) Ad GL_ONE_MINUS_DST_ALPHA (1, 1, 1) (Ad, Ad,Ad) 1 Ad GL_CONSTANT_COLOR (Rc,Gc, Bc) Ac GL_ONE_MINUS_CONSTANT_COLOR (1, 1, 1) (Rc,Gc, Bc) 1 Ac GL_CONSTANT_ALPHA (Ac, Ac,Ac) Ac GL_ONE_MINUS_CONSTANT_ALPHA (1, 1, 1) (Ac,Ac, Ac) 1 Ac 25

25 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,a 1 ) Select GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA as the source and destination blending factors R 1 = a 1 R 1 +(1- a 1 ) R 0, Note this formula is correct if polygon is either opaque or transparent 26

26 Order Dependency Is this image correct? Probably not Polygons are rendered in the order they pass down the pipeline Blending functions are order dependent 27

27 Billboard texture mapping A billboard is a textured rectangle Sometimes called impostors Always aligned with the viewing direction Texture is static Fast to render: a single textured polygon versus many 28

28 Billboard texture mapping Need to remove texture background Two ways: Masking Alpha blending 29

29 Using Masking Billboard fragments alpha values are 0 or 1 (very rare) Draw billboard fragments with alpha equal to 1 in the fragment shader check the alpha channel of the fragment s color tell the fragment shader it shouldn't write any pixel: use discard statement. uniform float alpha_threshold; void main() { vec4 color =...; if(color.a <= alpha_threshold) // Or whichever comparison here discard; } colorout = color; 30

30 Using Blending Billboard fragments alpha values between [0, 1] 1. Discard fragments with alpha values equal to 0 (optional) 2. Blend the other fragments glblendfunc(gl_src_alpha, GL_ONE_MINUS_SRC_ALPHA) glenable(gl_blend) 31

31 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 the depth buffer Render with gldepthmask(gl_false) which makes depth buffer read-only Sort polygons first to remove order dependency 32

32 3D Blending with the Depth Buffer Steps: Enable Depth Buffering Draw all the opaque objects (how?) Make the depth-buffer read-only (why?) Draw the translucent objects with blending. Figure out the correct order of rasterization 33

33 How to implement Fog? Classic OpenGL 2.0: glenable(gl_fog); Set up fog function glfogf(, ) Fog deprecated in OpenGL 3.1 Use shaders 34

34 Classic Fog Function 1/2 glfog{f,i}[v]{glenum pname, param} Pname param GL_FOG_MODE GL_LINEAR, GL_EXP, GL_EXP2 GL_FOG_DENSITY default : 1.0 GL_FOG_START default : 0.0 GL_FOG_END default : 1.0 GL_FOG_INDEX default : 0.0 GL_FOG_COLOR default : (0,0,0,0) 35

35 Fog Function 2/2 ColorOut = f C i + (1 - f ) C f where C i represents the incoming fragment's RGBA values and C f the fog-color values assigned with GL_FOG_COLOR. f fog amount: LINEAR: EXP: EXP2: 36

36 Exponential fog-density 37

37 Fog Implementation Exponential Fog: vec3 applyfog( in vec3 rgb, // original color of the fragment in float distance ) // camera to point distance { float fogamount = exp( -distance*0.05 ); // clamp(fogamount, 0, 1.0); necessary only if linear vec3 fogcolor = vec3(0.5,0.6,0.7); vec 3 final_color = return mix(fogcolor, rgb, fogamount ); out_color = vec4(final_color, 1); } 38

38 Distance: Z-depth versus length Solution: use the length Plane-based: z-depth Fog start 39

39 Distance in Fog shader Vertex Shader: pos = view * model * vertex_position //in eye coordinates Fragment shader: //compute distance used in fog equations if(depthfog == 0)//select plane based vs range based { //plane based dist = abs(pos.z); //fragment depth in eye coordinates //dist = (gl_fragcoord.z / gl_fragcoord.w); } else { //range based dist = length(pos) //use it; } 40

CS 5610 / Spring Depth Buffering and Hidden Surface Removal

CS 5610 / Spring Depth Buffering and Hidden Surface Removal Define a buffer by its spatial resolution (n x m) and its depth (or precision) k, the number of bits/pixel Buffers pixel Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015 2 Depth

More information

An Interactive Introduction to OpenGL Programming

An Interactive Introduction to OpenGL Programming Define a buffer by its spatial resolution (n n x m) ) and its depth (or precision) k,, the number of bits/pixel Buffers pixel Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015 2

More information

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

Pixels and Buffers. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science Pixels and Buffers CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science 1 Objectives Introduce additional OpenGL buffers Learn to read from / write to buffers Introduce

More information

CS 432 Interactive Computer Graphics

CS 432 Interactive Computer Graphics CS 432 Interactive Computer Graphics Lecture 09 Part 1 Compositing and Anti-Aliasing Matt Burlick - Drexel University - CS432 1 Composite Techniques Compositing is the method of compositing an image from

More information

Testing and Operating on Fragments

Testing and Operating on Fragments Additionally, multisampling using sample shading can add a lot more work in computing the color of a pixel. If your system has four samples per pixels, you ve quadrupled the work per pixel in rasterizing

More information

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

Definition. Blending & Compositing. Front & Back Buffers. Left & Right Buffers. Blending combines geometric objects. e.g. 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

More information

INF3320 Computer Graphics and Discrete Geometry

INF3320 Computer Graphics and Discrete Geometry INF3320 Computer Graphics and Discrete Geometry The OpenGL pipeline Christopher Dyken and Martin Reimers 12.10.2011 Page 1 Pipeline operations Page 2 OpenGL fixed-function pipeline: Implements a fixed

More information

Computer Graphics. Bing-Yu Chen National Taiwan University

Computer Graphics. Bing-Yu Chen National Taiwan University Computer Graphics Bing-Yu Chen National Taiwan University Introduction to OpenGL General OpenGL Introduction An Example OpenGL Program Drawing with OpenGL Transformations Animation and Depth Buffering

More information

INF3320 Computer Graphics and Discrete Geometry

INF3320 Computer Graphics and Discrete Geometry INF3320 Computer Graphics and Discrete Geometry The OpenGL pipeline Christopher Dyken and Martin Reimers 07.10.2009 Page 1 The OpenGL pipeline Real Time Rendering: The Graphics Processing Unit (GPU) (Chapter

More information

Lectures Transparency Case Study

Lectures Transparency Case Study Lectures Transparency Case Study By Tom Duff Pixar Animation Studios Emeryville, California and George Ledin Jr Sonoma State University Rohnert Park, California 2004, Tom Duff and George Ledin Jr 1 How

More information

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

Basic GPU techniques Josef Pelikán CGG MFF UK Praha. Basic GPU techniques 2005-2018 Josef Pelikán CGG MFF UK Praha pepca@cgg.mff.cuni.cz http://cgg.mff.cuni.cz/~pepca/ Basic GPU 2018 Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 1 / 22 Content visibility

More information

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

Shadow Algorithms. CSE 781 Winter Han-Wei Shen Shadow Algorithms CSE 781 Winter 2010 Han-Wei Shen Why Shadows? Makes 3D Graphics more believable Provides additional cues for the shapes and relative positions of objects in 3D What is shadow? Shadow:

More information

Computergrafik. Matthias Zwicker. Herbst 2010

Computergrafik. Matthias Zwicker. Herbst 2010 Computergrafik Matthias Zwicker Universität Bern Herbst 2010 Today Bump mapping Shadows Shadow mapping Shadow mapping in OpenGL Bump mapping Surface detail is often the result of small perturbations in

More information

Chapter 10 The Framebuffer Buffers and Their Uses Color Buffers Clearing Buffers Selecting Color Buffers for Writing and Reading Masking Buffers

Chapter 10 The Framebuffer Buffers and Their Uses Color Buffers Clearing Buffers Selecting Color Buffers for Writing and Reading Masking Buffers Chapter 10 The Framebuffer Buffers and Their Uses Color Buffers Clearing Buffers Selecting Color Buffers for Writing and Reading Masking Buffers Testing and Operating on Fragments Scissor Test Alpha Test

More information

Image Processing. CSCI 420 Computer Graphics Lecture 22

Image Processing. CSCI 420 Computer Graphics Lecture 22 CSCI 42 Computer Graphics Lecture 22 Image Processing Blending Display Color Models Filters Dithering [Ch 7.13, 8.11-8.12] Jernej Barbic University of Southern California 1 Alpha Channel Frame buffer Simple

More information

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

Rasterization Computer Graphics I Lecture 14. Scan Conversion Antialiasing Compositing [Angel, Ch , ] 15-462 Computer Graphics I Lecture 14 Rasterization March 13, 2003 Frank Pfenning Carnegie Mellon University http://www.cs.cmu.edu/~fp/courses/graphics/ Scan Conversion Antialiasing Compositing [Angel,

More information

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

Image Processing. Alpha Channel. Blending. Image Compositing. Blending Errors. Blending in OpenGL CSCI 42 Computer Graphics Lecture 22 Image Processing Blending Display Color Models Filters Dithering [Ch 6, 7] Jernej Barbic University of Southern California Alpha Channel Frame buffer Simple color model:

More information

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

Computer Graphics. Three-Dimensional Graphics VI. Guoying Zhao 1 / 73 Computer Graphics Three-Dimensional Graphics VI Guoying Zhao 1 / 73 Texture mapping Guoying Zhao 2 / 73 Objectives Introduce Mapping Methods Texture Mapping Environment Mapping Bump Mapping Consider basic

More information

E.Order of Operations

E.Order of Operations Appendix E E.Order of Operations This book describes all the performed between initial specification of vertices and final writing of fragments into the framebuffer. The chapters of this book are arranged

More information

/opengl/docs/man_pages/hardcopy/gl/html/gl/

/opengl/docs/man_pages/hardcopy/gl/html/gl/ Index of /opengl/docs/man_pages/hardcopy/gl/html/gl/ Index of /opengl/docs/man_pages/hardcopy/gl/html/gl/ Name Last modified Size Description Parent Directory accum.html 09-Sep-97 16:16 5K alphafunc.html

More information

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

Intro to OpenGL III. Don Fussell Computer Science Department The University of Texas at Austin Intro to OpenGL III Don Fussell Computer Science Department The University of Texas at Austin University of Texas at Austin CS354 - Computer Graphics Don Fussell Where are we? Continuing the OpenGL basic

More information

Deferred Rendering Due: Wednesday November 15 at 10pm

Deferred Rendering Due: Wednesday November 15 at 10pm CMSC 23700 Autumn 2017 Introduction to Computer Graphics Project 4 November 2, 2017 Deferred Rendering Due: Wednesday November 15 at 10pm 1 Summary This assignment uses the same application architecture

More information

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

Order Independent Transparency with Dual Depth Peeling. Louis Bavoil, Kevin Myers Order Independent Transparency with Dual Depth Peeling Louis Bavoil, Kevin Myers Document Change History Version Date Responsible Reason for Change 1.0 February 9 2008 Louis Bavoil Initial release Abstract

More information

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

Discrete Techniques. 11 th Week, Define a buffer by its spatial resolution (n m) and its depth (or precision) k, the number of Discrete Techniques 11 th Week, 2010 Buffer Define a buffer by its spatial resolution (n m) and its depth (or precision) k, the number of bits/pixel Pixel OpenGL Frame Buffer OpenGL Buffers Color buffers

More information

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

Intro to OpenGL III. Don Fussell Computer Science Department The University of Texas at Austin Intro to OpenGL III Don Fussell Computer Science Department The University of Texas at Austin University of Texas at Austin CS354 - Computer Graphics Don Fussell Where are we? Continuing the OpenGL basic

More information

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

Buffers, Textures, Compositing, and Blending. Overview. Buffers. David Carr Virtual Environments, Fundamentals Spring 2005 Based on Slides by E. 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,

More information

Shadows in Computer Graphics. by Björn Kühl im/ve University of Hamburg, Germany

Shadows in Computer Graphics. by Björn Kühl im/ve University of Hamburg, Germany Shadows in Computer Graphics by Björn Kühl im/ve University of Hamburg, Germany Importance of Shadows Shadows provide cues to the position of objects casting and receiving shadows to the position of the

More information

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

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing EECE 478 Rasterization & Scenes Rasterization Learning Objectives Be able to describe the complete graphics pipeline. Describe the process of rasterization for triangles and lines. Compositing Manipulate

More information

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

The Application Stage. The Game Loop, Resource Management and Renderer Design 1 The Application Stage The Game Loop, Resource Management and Renderer Design Application Stage Responsibilities 2 Set up the rendering pipeline Resource Management 3D meshes Textures etc. Prepare data

More information

Textures. Texture Mapping. Bitmap Textures. Basic Texture Techniques

Textures. Texture Mapping. Bitmap Textures. Basic Texture Techniques Texture Mapping Textures The realism of an image is greatly enhanced by adding surface textures to the various faces of a mesh object. In part a) images have been pasted onto each face of a box. Part b)

More information

GPU Image Processing. SIGGRAPH 2004 Frank Jargstorff

GPU Image Processing. SIGGRAPH 2004 Frank Jargstorff GPU Image Processing SIGGRAPH 2004 Frank Jargstorff Overview Image Processing GPU how? Blending Porter-Duff and beyond Painting Image Processing Overview Image Processing is the creation of a new image

More information

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

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11 Pipeline Operations CS 4620 Lecture 11 1 Pipeline you are here APPLICATION COMMAND STREAM 3D transformations; shading VERTEX PROCESSING TRANSFORMED GEOMETRY conversion of primitives to pixels RASTERIZATION

More information

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

More Visible Surface Detection. CS116B Chris Pollett Mar. 16, 2005. More Visible Surface Detection CS116B Chris Pollett Mar. 16, 2005. Outline The A-Buffer Method The Scan-Line Method The Depth Sorting Method BSP Trees, Area Subdivision, and Octrees Wire-frame Visibility

More information

Rendering Objects. Need to transform all geometry then

Rendering Objects. Need to transform all geometry then Intro to OpenGL Rendering Objects Object has internal geometry (Model) Object relative to other objects (World) Object relative to camera (View) Object relative to screen (Projection) Need to transform

More information

CS4620/5620: Lecture 14 Pipeline

CS4620/5620: Lecture 14 Pipeline CS4620/5620: Lecture 14 Pipeline 1 Rasterizing triangles Summary 1! evaluation of linear functions on pixel grid 2! functions defined by parameter values at vertices 3! using extra parameters to determine

More information

Pipeline Operations. CS 4620 Lecture 14

Pipeline Operations. CS 4620 Lecture 14 Pipeline Operations CS 4620 Lecture 14 2014 Steve Marschner 1 Pipeline you are here APPLICATION COMMAND STREAM 3D transformations; shading VERTEX PROCESSING TRANSFORMED GEOMETRY conversion of primitives

More information

Tutorial on GPU Programming #2. Joong-Youn Lee Supercomputing Center, KISTI

Tutorial on GPU Programming #2. Joong-Youn Lee Supercomputing Center, KISTI Tutorial on GPU Programming #2 Joong-Youn Lee Supercomputing Center, KISTI Contents Graphics Pipeline Vertex Programming Fragment Programming Introduction to Cg Language Graphics Pipeline The process to

More information

COMP371 COMPUTER GRAPHICS

COMP371 COMPUTER GRAPHICS COMP371 COMPUTER GRAPHICS SESSION 12 PROGRAMMABLE SHADERS Announcement Programming Assignment #2 deadline next week: Session #7 Review of project proposals 2 Lecture Overview GPU programming 3 GPU Pipeline

More information

Graphics Pipeline & APIs

Graphics Pipeline & APIs Graphics Pipeline & APIs CPU Vertex Processing Rasterization Fragment Processing glclear (GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT); glpushmatrix (); gltranslatef (-0.15, -0.15, solidz); glmaterialfv(gl_front,

More information

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation Lecture 17: Shading in OpenGL CITS3003 Graphics & Animation E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 Objectives Introduce the OpenGL shading methods - per vertex shading

More information

1.2.3 The Graphics Hardware Pipeline

1.2.3 The Graphics Hardware Pipeline Figure 1-3. The Graphics Hardware Pipeline 1.2.3 The Graphics Hardware Pipeline A pipeline is a sequence of stages operating in parallel and in a fixed order. Each stage receives its input from the prior

More information

Real-time volumetric shadows for dynamic rendering

Real-time volumetric shadows for dynamic rendering Imperial College London Department of Computing Real-time volumetric shadows for dynamic rendering by Alexandru Teodor V.L. Voicu Submitted in partial fulfilment of the requirements for the MSc Degree

More information

Adaptive Point Cloud Rendering

Adaptive Point Cloud Rendering 1 Adaptive Point Cloud Rendering Project Plan Final Group: May13-11 Christopher Jeffers Eric Jensen Joel Rausch Client: Siemens PLM Software Client Contact: Michael Carter Adviser: Simanta Mitra 4/29/13

More information

Advanced Shading and Texturing

Advanced Shading and Texturing Real-Time Graphics Architecture Kurt Akeley Pat Hanrahan http://www.graphics.stanford.edu/courses/cs448a-01-fall Advanced Shading and Texturing 1 Topics Features Bump mapping Environment mapping Shadow

More information

Image Processing Computer Graphics I Lecture 15

Image Processing Computer Graphics I Lecture 15 15-462 Computer Graphics I Lecture 15 Image Processing Blending Display Color Models Filters Dithering Image Compression March 18, 23 Frank Pfenning Carnegie Mellon University http://www.cs.cmu.edu/~fp/courses/graphics/

More information

Image Processing. Blending. Blending in OpenGL. Image Compositing. Blending Errors. Antialiasing Revisited Computer Graphics I Lecture 15

Image Processing. Blending. Blending in OpenGL. Image Compositing. Blending Errors. Antialiasing Revisited Computer Graphics I Lecture 15 15-462 Computer Graphics I Lecture 15 Image Processing Blending Display Color Models Filters Dithering Image Compression March 18, 23 Frank Pfenning Carnegie Mellon University http://www.cs.cmu.edu/~fp/courses/graphics/

More information

Lighting and Texturing

Lighting and Texturing Lighting and Texturing Michael Tao Michael Tao Lighting and Texturing 1 / 1 Fixed Function OpenGL Lighting Need to enable lighting Need to configure lights Need to configure triangle material properties

More information

The Rasterization Pipeline

The Rasterization Pipeline Lecture 5: The Rasterization Pipeline (and its implementation on GPUs) Computer Graphics CMU 15-462/15-662, Fall 2015 What you know how to do (at this point in the course) y y z x (w, h) z x Position objects

More information

Lectures OpenGL Introduction

Lectures OpenGL Introduction Lectures OpenGL Introduction By Tom Duff Pixar Animation Studios Emeryville, California and George Ledin Jr Sonoma State University Rohnert Park, California 2004, Tom Duff and George Ledin Jr 1 What is

More information

Computer Graphics with OpenGL ES (J. Han) Chapter VII Rasterizer

Computer Graphics with OpenGL ES (J. Han) Chapter VII Rasterizer Chapter VII Rasterizer Rasterizer The vertex shader passes the clip-space vertices to the rasterizer, which performs the following: Clipping Perspective division Back-face culling Viewport transform Scan

More information

CS 428: Fall Introduction to. Polygon rendering: additional topics. Andrew Nealen, Rutgers, /14/2009 1

CS 428: Fall Introduction to. Polygon rendering: additional topics. Andrew Nealen, Rutgers, /14/2009 1 CS 428: Fall 2009 Introduction to Computer Graphics Polygon rendering: additional topics Andrew Nealen, Rutgers, 2009 10/14/2009 1 z-buffer algorithm The depth buffer was suggested in 1974 but not implemented

More information

Lecture 2. Shaders, GLSL and GPGPU

Lecture 2. Shaders, GLSL and GPGPU Lecture 2 Shaders, GLSL and GPGPU Is it interesting to do GPU computing with graphics APIs today? Lecture overview Why care about shaders for computing? Shaders for graphics GLSL Computing with shaders

More information

Rasterization Overview

Rasterization Overview Rendering Overview The process of generating an image given a virtual camera objects light sources Various techniques rasterization (topic of this course) raytracing (topic of the course Advanced Computer

More information

Graphics Pipeline & APIs

Graphics Pipeline & APIs 3 2 4 Graphics Pipeline & APIs CPU Vertex Processing Rasterization Processing glclear (GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT); glpushmatrix (); gltranslatef (-0.15, -0.15, solidz); glmaterialfv(gl_front,

More information

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer Real-Time Rendering (Echtzeitgraphik) Michael Wimmer wimmer@cg.tuwien.ac.at Walking down the graphics pipeline Application Geometry Rasterizer What for? Understanding the rendering pipeline is the key

More information

Recall: Indexing into Cube Map

Recall: Indexing into Cube Map Recall: Indexing into Cube Map Compute R = 2(N V)N-V Object at origin Use largest magnitude component of R to determine face of cube Other 2 components give texture coordinates V R Cube Map Layout Example

More information

Objectives Shading in OpenGL. Front and Back Faces. OpenGL shading. Introduce the OpenGL shading methods. Discuss polygonal shading

Objectives Shading in OpenGL. Front and Back Faces. OpenGL shading. Introduce the OpenGL shading methods. Discuss polygonal shading Objectives Shading in OpenGL Introduce the OpenGL shading methods - per vertex shading vs per fragment shading - Where to carry out Discuss polygonal shading - Flat - Smooth - Gouraud CITS3003 Graphics

More information

Supplement to Lecture 22

Supplement to Lecture 22 Supplement to Lecture 22 Programmable GPUs Programmable Pipelines Introduce programmable pipelines - Vertex shaders - Fragment shaders Introduce shading languages - Needed to describe shaders - RenderMan

More information

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

CSE 167: Introduction to Computer Graphics Lecture #9: Visibility. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2018 CSE 167: Introduction to Computer Graphics Lecture #9: Visibility Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2018 Announcements Midterm Scores are on TritonEd Exams to be

More information

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE UGRAD.CS.UBC.C A/~CS314 Mikhail Bessmeltsev 1 WHAT IS RENDERING? Generating image from a 3D scene 2 WHAT IS RENDERING? Generating image

More information

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

Programming Guide. Aaftab Munshi Dan Ginsburg Dave Shreiner. TT r^addison-wesley OpenGUES 2.0 Programming Guide Aaftab Munshi Dan Ginsburg Dave Shreiner TT r^addison-wesley Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid

More information

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology Ulf Assarsson Department of Computer Engineering Chalmers University of Technology Lecture 1: Real-time Rendering The Graphics Rendering Pipeline Three conceptual stages of the pipeline: Application (executed

More information

CHAPTER 1 Graphics Systems and Models 3

CHAPTER 1 Graphics Systems and Models 3 ?????? 1 CHAPTER 1 Graphics Systems and Models 3 1.1 Applications of Computer Graphics 4 1.1.1 Display of Information............. 4 1.1.2 Design.................... 5 1.1.3 Simulation and Animation...........

More information

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

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL OpenGL: Open Graphics Library Introduction to OpenGL Part II CS 351-50 Graphics API ( Application Programming Interface) Software library Layer between programmer and graphics hardware (and other software

More information

Models and Architectures

Models and Architectures Models and Architectures Objectives Learn the basic design of a graphics system Introduce graphics pipeline architecture Examine software components for an interactive graphics system 1 Image Formation

More information

Shading. Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Shading. Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Shading Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Overview of today s lecture l A simple most basic real-time lighting model

More information

OUTLINE. Learn the basic design of a graphics system Introduce pipeline architecture Examine software components for a graphics system

OUTLINE. Learn the basic design of a graphics system Introduce pipeline architecture Examine software components for a graphics system GRAPHICS PIPELINE 1 OUTLINE Learn the basic design of a graphics system Introduce pipeline architecture Examine software components for a graphics system 2 IMAGE FORMATION REVISITED Can we mimic the synthetic

More information

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

lecture 21 volume rendering - blending N layers - OpenGL fog (not on final exam) - transfer functions - rendering level surfaces lecture 21 volume rendering - blending N layers - OpenGL fog (not on final exam) - transfer functions - rendering level surfaces - 3D objects Clouds, fire, smoke, fog, and dust are difficult to model with

More information

What for? Shadows tell us about the relative locations. Vienna University of Technology 2

What for? Shadows tell us about the relative locations. Vienna University of Technology 2 Shadows What for? Shadows tell us about the relative locations and motions of objects Vienna University of Technology 2 What for? Shadows tell us about the relative locations and motions of objects And

More information

Scanline Rendering 2 1/42

Scanline Rendering 2 1/42 Scanline Rendering 2 1/42 Review 1. Set up a Camera the viewing frustum has near and far clipping planes 2. Create some Geometry made out of triangles 3. Place the geometry in the scene using Transforms

More information

Introduction to Computer Graphics with WebGL

Introduction to Computer Graphics with WebGL Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science Laboratory University of New Mexico Models and Architectures

More information

Shading. Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Shading. Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Shading Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Overview of today s lecture l A simple most basic real-time lighting model

More information

Reflections, Shadows, Transparency, and Fog

Reflections, Shadows, Transparency, and Fog GDC Tutorial: Advanced OpenGL Game Development Reflections, Shadows, Transparency, and Fog March 8, 2000 Mark J. Kilgard Graphics Software Engineer NVIDIA Corporation Quick Tutorial on Stencil Testing

More information

Introduction to Shaders.

Introduction to Shaders. Introduction to Shaders Marco Benvegnù hiforce@gmx.it www.benve.org Summer 2005 Overview Rendering pipeline Shaders concepts Shading Languages Shading Tools Effects showcase Setup of a Shader in OpenGL

More information

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

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic. Shading Models There are two main types of rendering that we cover, polygon rendering ray tracing Polygon rendering is used to apply illumination models to polygons, whereas ray tracing applies to arbitrary

More information

Computer Graphics. Lecture 9 Environment mapping, Mirroring

Computer Graphics. Lecture 9 Environment mapping, Mirroring Computer Graphics Lecture 9 Environment mapping, Mirroring Today Environment Mapping Introduction Cubic mapping Sphere mapping refractive mapping Mirroring Introduction reflection first stencil buffer

More information

Tutorial 4: Depth and Transparency

Tutorial 4: Depth and Transparency Tutorial 4: Depth and Transparency Summary In this tutorial, you are going to learn about how OpenGL determines which objects are in front of others in a scene - it s not as easy at it seems! Alpha blending

More information

CPSC 436D Video Game Programming

CPSC 436D Video Game Programming CPSC 436D Video Game Programming OpenGL/Shaders Opengl RENDERING PIPELINE Copyright: Alla Sheffer 1 Opengl RENDERING PIPELINE C/C++ OpenGL GLSL (automatic) (automatic) GLSL (automatic) opengl Low-level

More information

Mali Demos: Behind the Pixels. Stacy Smith

Mali Demos: Behind the Pixels. Stacy Smith Mali Demos: Behind the Pixels Stacy Smith Mali Graphics: Behind the demos Mali Demo Team: Doug Day Stacy Smith (Me) Sylwester Bala Roberto Lopez Mendez PHOTOGRAPH UNAVAILABLE These days I spend more time

More information

PowerVR Performance Recommendations The Golden Rules. October 2015

PowerVR Performance Recommendations The Golden Rules. October 2015 PowerVR Performance Recommendations The Golden Rules October 2015 Paul Ly Developer Technology Engineer, PowerVR Graphics Understanding Your Bottlenecks Based on our experience 3 The Golden Rules 1. The

More information

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

Module 13C: Using The 3D Graphics APIs OpenGL ES Module 13C: Using The 3D Graphics APIs OpenGL ES BREW TM Developer Training Module Objectives See the steps involved in 3D rendering View the 3D graphics capabilities 2 1 3D Overview The 3D graphics library

More information

Blis: Better Language for Image Stuff Project Proposal Programming Languages and Translators, Spring 2017

Blis: Better Language for Image Stuff Project Proposal Programming Languages and Translators, Spring 2017 Blis: Better Language for Image Stuff Project Proposal Programming Languages and Translators, Spring 2017 Abbott, Connor (cwa2112) Pan, Wendy (wp2213) Qinami, Klint (kq2129) Vaccaro, Jason (jhv2111) [System

More information

Lecture 19: OpenGL Texture Mapping. CITS3003 Graphics & Animation

Lecture 19: OpenGL Texture Mapping. CITS3003 Graphics & Animation Lecture 19: OpenGL Texture Mapping CITS3003 Graphics & Animation E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 Objectives Introduce the OpenGL texture functions and options

More information

Geometry Shaders. And how to use them

Geometry Shaders. And how to use them Geometry Shaders And how to use them OpenGL Pipeline (part of it) Vertex data Vertex shader Vertices Primitives Geometry shader Primitives Fragments Fragment shader Color Depth Stencil Vertex Data Attributes

More information

CS 432 Interactive Computer Graphics

CS 432 Interactive Computer Graphics CS 432 Interactive Computer Graphics Lecture 2 Part 1 Primitives and Buffers Matt Burlick - Drexel University - CS 432 1 Rendering in OpenGL Ok, so now we want to actually draw stuff! OpenGL (like most

More information

Volume Graphics Introduction

Volume Graphics Introduction High-Quality Volume Graphics on Consumer PC Hardware Volume Graphics Introduction Joe Kniss Gordon Kindlmann Markus Hadwiger Christof Rezk-Salama Rüdiger Westermann Motivation (1) Motivation (2) Scientific

More information

WebGL and GLSL Basics. CS559 Fall 2015 Lecture 10 October 6, 2015

WebGL and GLSL Basics. CS559 Fall 2015 Lecture 10 October 6, 2015 WebGL and GLSL Basics CS559 Fall 2015 Lecture 10 October 6, 2015 Last time Hardware Rasterization For each point: Compute barycentric coords Decide if in or out.7,.7, -.4 1.1, 0, -.1.9,.05,.05.33,.33,.33

More information

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU FROM VERTICES TO FRAGMENTS Lecture 5 Comp3080 Computer Graphics HKBU OBJECTIVES Introduce basic implementation strategies Clipping Scan conversion OCTOBER 9, 2011 2 OVERVIEW At end of the geometric pipeline,

More information

Computer Graphics. Shadows

Computer Graphics. Shadows Computer Graphics Lecture 10 Shadows Taku Komura Today Shadows Overview Projective shadows Shadow texture Shadow volume Shadow map Soft shadows Why Shadows? Shadows tell us about the relative locations

More information

Billboards!! A texture mapped polygon, which always faces the viewer

Billboards!! A texture mapped polygon, which always faces the viewer 38(58) Information Coding / Computer Graphics, ISY, LiTH Billboards A texture mapped polygon, which always faces the viewer 38(58) Billboards 2D images placed on surfaces that are always facing the camera

More information

CS Computer Graphics: Hidden Surface Removal

CS Computer Graphics: Hidden Surface Removal CS 543 - Computer Graphics: Hidden Surface Removal by Robert W. Lindeman gogo@wpi.edu (with help from Emmanuel Agu ;-) Hidden Surface Removal Drawing polygonal faces on screen consumes CPU cycles We cannot

More information

Spring 2011 Prof. Hyesoon Kim

Spring 2011 Prof. Hyesoon Kim Spring 2011 Prof. Hyesoon Kim Application Geometry Rasterizer CPU Each stage cane be also pipelined The slowest of the pipeline stage determines the rendering speed. Frames per second (fps) Executes on

More information

Information Coding / Computer Graphics, ISY, LiTH. OpenGL! ! where it fits!! what it contains!! how you work with it 11(40)

Information Coding / Computer Graphics, ISY, LiTH. OpenGL! ! where it fits!! what it contains!! how you work with it 11(40) 11(40) Information Coding / Computer Graphics, ISY, LiTH OpenGL where it fits what it contains how you work with it 11(40) OpenGL The cross-platform graphics library Open = Open specification Runs everywhere

More information

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

OpenGl Pipeline. triangles, lines, points, images. Per-vertex ops. Primitive assembly. Texturing. Rasterization. Per-fragment ops. OpenGl Pipeline Individual Vertices Transformed Vertices Commands Processor Per-vertex ops Primitive assembly triangles, lines, points, images Primitives Fragments Rasterization Texturing Per-fragment

More information

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3) Computer Graphics (Fall 2008) COMS 4160, Lecture 9: OpenGL 1 http://www.cs.columbia.edu/~cs4160 To Do Start thinking (now) about HW 3. Milestones are due soon. Course Course 3D Graphics Pipeline 3D Graphics

More information

Radeon R3xx 3D Register Reference Guide

Radeon R3xx 3D Register Reference Guide Radeon R3xx 3D Register Reference Guide Proprietary 1 Trademarks AMD, the AMD Arrow logo, Athlon, and combinations thereof, ATI, ATI logo, Radeon, and Crossfire are trademarks of Advanced Micro Devices,

More information

Shader Programming. Daniel Wesslén, Stefan Seipel, Examples

Shader Programming. Daniel Wesslén, Stefan Seipel, Examples Shader Programming Daniel Wesslén, dwn@hig.se Stefan Seipel, ssl@hig.se Examples 1 Per-pixel lighting Texture convolution filtering 2 Post-processing, animated procedural textures Vertex displacement mapping

More information

Real-time Graphics 6. Reflections, Refractions

Real-time Graphics 6. Reflections, Refractions 6. Reflections, Refractions Blending Simulating transparent materials Alpha value, RGBA model Using alpha test fragment alpha value is tested against given constant Using blending of colors fragment color

More information

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

Buffers. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015 Buffers 1 Objectives Introduce additional WebGL buffers Reading and writing buffers Buffers and Images 2 Buffer Define a buffer by its spatial resolution (n x m) and its depth (or precision) k, the number

More information

Spring 2009 Prof. Hyesoon Kim

Spring 2009 Prof. Hyesoon Kim Spring 2009 Prof. Hyesoon Kim Application Geometry Rasterizer CPU Each stage cane be also pipelined The slowest of the pipeline stage determines the rendering speed. Frames per second (fps) Executes on

More information