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

Similar documents
Shaders. Oscar. 1/43 Apodaca and Gritz, Advanced RenderMan

w Foley, Section16.1 Reading

Topic 9: Lighting & Reflection models 9/10/2016. Spot the differences. Terminology. Two Components of Illumination. Ambient Light Source

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

Topic 9: Lighting & Reflection models. Lighting & reflection The Phong reflection model diffuse component ambient component specular component

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Reading. Shading. An abundance of photons. Introduction. Required: Angel , 6.5, Optional: Angel 6.4 OpenGL red book, chapter 5.

Computer Graphics. Illumination and Shading

CS5620 Intro to Computer Graphics

CPSC 314 LIGHTING AND SHADING

Shading I Computer Graphics I, Fall 2008

CS130 : Computer Graphics Lecture 8: Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside

Comp 410/510 Computer Graphics. Spring Shading

Deferred Rendering Due: Wednesday November 15 at 10pm

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

Pipeline Operations. CS 4620 Lecture 10

Illumination & Shading: Part 1

Illumination and Shading

Illumination Models & Shading

Computer Graphics (CS 543) Lecture 7b: Intro to lighting, Shading and Materials + Phong Lighting Model

Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1)

Pipeline Operations. CS 4620 Lecture 14

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

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

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Shading. Reading. Pinhole camera. Basic 3D graphics. Brian Curless CSE 557 Fall Required: Shirley, Chapter 10

Shading. Brian Curless CSE 457 Spring 2015

Illumination & Shading

Reading. Shading. Introduction. An abundance of photons. Required: Angel , Optional: OpenGL red book, chapter 5.

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

CS230 : Computer Graphics Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside

Virtual Reality for Human Computer Interaction

Illumination and Shading

Shading. CSE 457 Winter 2015

Shading. Brian Curless CSE 457 Spring 2017

Shading. Brian Curless CSE 557 Autumn 2017

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

Lighting and Shading Computer Graphics I Lecture 7. Light Sources Phong Illumination Model Normal Vectors [Angel, Ch

Illumination and Shading

Local Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

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

Shading & Material Appearance

WHY WE NEED SHADING. Suppose we build a model of a sphere using many polygons and color it with glcolor. We get something like.

The Rasterization Pipeline

Computer Graphics MTAT Raimond Tunnel

Lighting and Materials

Introduction to Computer Graphics 7. Shading

Interactive Real-Time Raycasting

Introduction. Lighting model Light reflection model Local illumination model Reflectance model BRDF

Shading. Why we need shading. Scattering. Shading. Objectives

CS452/552; EE465/505. Intro to Lighting

Lighting and Shading. Slides: Tamar Shinar, Victor Zordon

CSE 167: Lecture #7: Color and Shading. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

CGT520 Lighting. Lighting. T-vertices. Normal vector. Color of an object can be specified 1) Explicitly as a color buffer

CS 4620 Program 3: Pipeline

CS580: Ray Tracing. Sung-Eui Yoon ( 윤성의 ) Course URL:

Introduction to Visualization and Computer Graphics

Sung-Eui Yoon ( 윤성의 )

Computer Graphics. Shading. Based on slides by Dianna Xu, Bryn Mawr College

CEng 477 Introduction to Computer Graphics Fall

Raytracing CS148 AS3. Due :59pm PDT

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

CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

INF3320 Computer Graphics and Discrete Geometry

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

CS 5625 Lec 2: Shading Models

CSE 681 Illumination and Phong Shading

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

Rasterization Overview

Rendering. Illumination Model. Wireframe rendering simple, ambiguous Color filling flat without any 3D information

Objectives. Introduce Phong model Introduce modified Phong model Consider computation of required vectors Discuss polygonal shading.

Scanline Rendering 2 1/42

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

University of British Columbia CPSC 314 Computer Graphics Sep-Dec Tamara Munzner (guest lecturing) Lighting/Shading

Shading. Shading = find color values at pixels of screen (when rendering a virtual 3D scene).

Computer Graphics. Illumination and Shading

Ray-Tracing. Misha Kazhdan

C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics V. Guoying Zhao 1 / 65

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

Computergrafik. Matthias Zwicker. Herbst 2010

Illumination & Shading

CPSC / Illumination and Shading

Computer Graphics. Shadows

Overview. Shading. Shading. Why we need shading. Shading Light-material interactions Phong model Shading polygons Shading in OpenGL

Complex Shading Algorithms

Game Technology. Lecture Physically Based Rendering. Dipl-Inform. Robert Konrad Polona Caserman, M.Sc.

CS 488. More Shading and Illumination. Luc RENAMBOT

CS4620/5620: Lecture 14 Pipeline

Illumination. Illumination CMSC 435/634

Shading and Illumination

Visualisatie BMT. Rendering. Arjan Kok

Computer Graphics. Ray Tracing. Based on slides by Dianna Xu, Bryn Mawr College

Lighting. Figure 10.1

Shading 1: basics Christian Miller CS Fall 2011

Methodology for Lecture. Importance of Lighting. Outline. Shading Models. Brief primer on Color. Foundations of Computer Graphics (Spring 2010)

Reflection and Shading

Today s class. Simple shadows Shading Lighting in OpenGL. Informationsteknologi. Wednesday, November 21, 2007 Computer Graphics - Class 10 1

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007

Transcription:

OpenGl Pipeline Individual Vertices Transformed Vertices Commands Processor Per-vertex ops Primitive assembly triangles, lines, points, images Primitives Fragments Rasterization Texturing Per-fragment ops Shaded Fragments Framebuffer ops pixels in the framebuffer Display

Frame Buffer Operations Operation Test window ownership Test scissor and stencil mask Test alpha (transparency) Test depth (z-buffer) Blending or compositing Textured Fragments Framebuffer Pixels

Depth Buffer (Z-Buffer) Initialize z-buffer to z max Interpolate z across the triangle Draw fragment if closer if(frag.z<z[frag.x][frag.y]){ Z[frag.X][frag.Y]=frag.Z; C[frag.X][frag.Y]=frag.C; } http://en.wikipedia.org/wiki/file:z_buffer.svg

Framebuffer Example Framebuffer: 1440 x 900 Viewport (256x256) The viewport is the portion of the window that can be drawn in, no pixels will appear outside the viewport Window (512 x 512) All coordinates are integers; they refer to pixel locations in the framebuffer

Shading

Specifying Colors Specify color only on the vertices of a triangle, instead of every point inside the triangle more efficient for the programmer For each pixel inside a triangle, compute its barycentric coordinates Use barycentric weights to interpolate vertex colors to a pixel

Shading Set the color on each pixel of the image based on how light interacts with objects Shaders combine lighting and material properties to produce a color Different lighting gives different results Material properties specify how light interacts with objects Plastic Oscar Matte Brushed Metal Apodaca and Gritz, Advanced RenderMan

Shading Input a point P on a surface visible through a pixel the geometry surface normal N at P the incoming light direction L at P the outgoing viewing direction V at P Output the intensity vector I=(I R, I G, I B ) of reflected light viewed through the pixel (that hits the film plane)

Lights Ambient light Represents a fixed-intensity light source that hits all objects equally Used to uniformly brighten/darken the entire scene Useful as a hacky model for indirect lighting so shadows aren t completely black Directional light Lights all objects equally, but only from a specified direction Infinitely large light & infinitely far away Good approximation to sunlight, because the sun is far away and rays of sunlight are approximately parallel

Lights Point light Light emitted from a single point in space Uniformly lights all directions Spotlight Light emitted from a single point in space Spreads outwards in a cone Angular subset of a point light Area light light emitted from a surface Objects behind the surface are not illuminated Can be thought of (and treated) as a large collection of point lights on a surface

Phong Reflection Model an empirical model, only an approximation of reality fast, and widely used models three types of reflection: Ambient reflection an approximation of the total effect of all indirect lighting (many bounces) in the real world Diffuse reflection an approximation to dull/matte surfaces (such as chalk) that reflect light equally out to all directions Specular reflection an approximation to glossy surfaces (highlights) that reflect most light out to the directions that are close to the mirror reflection direction

Ambient Reflection shadows are completely black unless one does something special to treat indirect lighting (where light bounces around a number of times) could alternatively use a directional light with no occlusion, but triangles parallel to that direction still receive no light models a constant illumination independent of the incident light angle, the viewing angle, and occlusions/shadows objects are uniformly lit I = ka IL ka - ambient reflection coefficient IL intensity of the light source

Ambient Reflection Options/Hacks ( IR, IG, IB )= ( kr ILR, kg ILG, kb ILB ) The incoming light intensity can be any color you wish (ILR, ILG, ILB) The refection coefficients can be set to vary based on color (kr, kb, kg) For example, if the incoming light is set to white, adjusting the reflection coefficients gives the object a certain color But one could alternatively set the incoming light color independently for each object as well

Diffuse/Lambertian Reflection N θ reflected intensity varies based on the direction of the incoming light reflected intensity does not vary based upon on the direction of the viewer multiplies ambient lighting by an extra geometry term I = kd IL max(cosθ, 0) = kd IL max(n L, 0) kd - diffuse reflection coefficient IL - intensity of the light source N - unit vector surface normal L unit vector direction of the light source (from the point to the light)

Diffuse Reflection models reflection from a rough surface with lots of tiny microfacets models the reflection of an ideally diffuse/dull/matte surface, such as chalk Note how the shading changes as the light moves around

Mirror Reflection Mirror - ideally smooth and specular surface Law of reflection θ = θ i o N θi θo Incident light direction L, surface normal vector N, and reflected light direction R are all coplanar

Specular Reflection accounts for highlights on objects important for smooth glossy surfaces For a glossy but not completely smooth surface, the microscopic spatial variation of normal directions smooths the refection function into a lobe I = ks IL max(v R,0) s ks - specular reflection coefficient IL - intensity of the light source V unit vector viewing direction R unit vector mirror reflection direction s - shininess constant

Specular Reflection s = 1 Larger s gives narrower highlight s = 64 Converges to mirror reflection as s

Specular Reflection L N H R V Is = ks IL (N H) s Blinn-Phong model - popular variation of Phong using the bisector vector of L and V H = (L + V) / L + V more accurate than Phong for many types of surfaces reflected light intensity is still viewing direction dependent, since H depends on V N H is always positive, so no need to clamp If the viewer and the light source are infinitely far away, L and V are unchanged for all pixels and H only need be computed once for the entire image

Phong Reflection Model Ambient (k a ) Diffuse (k d ) Specular (k s, s) Final Image I = ( ) k I j + k I j max(n L j,0) + k I j max(v R j,0) s a L d L s L j lights Ambient Diffuse specular One equation for each channel: R,G,B

Phong Reflection Model I = ( ) k I j + k I j max(n L j,0) + k I j max(v R j,0) s a La d Ld s Ls j lights ambient light diffuse light specular light OpenGL allows one to independently set the ambient, diffuse and specular lights, for added modeling convenience E.g. to increase the diffuse reflected light intensity of the whole scene, one only needs to increase the diffuse light intensity without changing the diffuse reflection coefficients of every object