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

Size: px
Start display at page:

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

Transcription

1 Shading Sides by Uf Assarsson and Tomas Akenine-Möer Department of Computer Engineering Chamers University of Technoogy

2 Overview of today s ecture A simpe most basic rea-time ighting mode It is aso OpenGL s od fixed pipeine ighting mode Fog Gamma correction Transparency and apha

3 Compute ighting at vertices, then interpoate over triange ight bue Rasterizer Geometry red green How compute ighting? We coud set coors per vertex manuay For a itte more reaism, compute ighting from Light sources Materia properties Geometrica reationships Tomas Akenine-Mőer 2002

4 The ambient/diffuse/specuar/emission mode Aso the most basic rea-time mode: Light interacts with materia and change coors at bounces: outcoor rgb ~ materia rgb ightcoor rgb Diffuse ight: the part that spreads in a direction (view independent) due to that the surface is rough on microscopic eve n

5 The ambient/diffuse/specuar/emission mode Aso the most basic rea-time mode: Light interacts with materia and change coors at bounces: outcoor rgb ~ materia rgb ightcoor rgb Diffuse ight: the part that spreads in a direction (view independent) Specuar ight: the part that spreads mosty in the refection direction (often same coor as ight source) n

6 The ambient/diffuse/specuar/emission mode Aso the most basic rea-time mode: Light interacts with materia and change coors at bounces: outcoor rgb ~ materia rgb ightcoor rgb Diffuse ight: the part that spreads in a direction (view independent) Specuar ight: the part that spreads mosty in the refection direction (often same coor as ight source) Ambient ight: incoming background ight from a directions and spreads in a directions (view-independent and ight-position independent coor) n

7 The ambient/diffuse/specuar/emission mode Aso the most basic rea-time mode: Light interacts with materia and change coors at bounces: outcoor rgb ~ materia rgb ightcoor rgb Diffuse ight: the part that spreads in a direction (view independent) Specuar ight: the part that spreads mosty in the refection direction (often same coor as ight source) Ambient ight: incoming background ight from a directions and spreads in a directions (view-independent and ight-position independent coor) Emission: sef-gowing surface n

8 A basic ighting mode Materia: Ambient (r,g,b,a) Diffuse (r,g,b,a) Specuar (r,g,b,a) Light: Ambient (r,g,b,a) Diffuse (r,g,b,a) Specuar (r,g,b,a) DIFFUSE Base coor SPECULAR Highight Coor AMBIENT Low-ight Coor EMISSION Gow Coor SHININESS Emission (r,g,b,a) = sjävysande färg Surface Smoothness Tomas Added Akenine-Mőer by Uf Assarsson,

9 Ambient component: iamb Ad-hoc tries to account for ight coming from other surfaces Just add a constant coor: i amb = m amb Äs amb i.e., (i r, i g, i b, i a ) = (m r, m g, m b, m a ) ( r, g, b, a )

10 Diffuse component : idiff i=iamb+idiff+ispec Diffuse (Lambert s aw): i diff = n Photons are scattered equay in a directions i diff = ( n ) m diff Äs diff = cosf n and are assumed being unit vectors Tomas Akenine-Mőer 2002

11 Lambertian Surfaces Perfecty diffuse refector Light scattered equay in a directions Highy refective surface (specuar) Fuy diffuse surface (Lambertian)

12 Lighting Specuar component : ispec Diffuse is du (eft) Specuar: simuates a highight Tomas Akenine-Mőer 2002

13 Specuar component: Phong Phong specuar highight mode Refect around n: r r = - + 2(n )n i = ( r v) = (cos r) spec m shi m shi ( n ) n - n n must be unit vector n i spec = ((n ) < 0)? 0 : max(0,(r v)) m shi m spec s spec Next: Binns highight formua: (n. h) m Tomas Akenine-Mőer 2002

14 Hafway Vector Binn proposed repacing v r by n h where h = (+v)/ + v (+v)/2 is hafway between and v If n,, and v are copanar: y = f/2 Must then adjust exponent so that (n h) e (r v) e (e 4e)

15 Efficiency The Binn rendering mode is ess efficient than pure Phong shading in most cases, since it contains a square root cacuation. Whie the origina Phong mode ony needs a simpe vector refection, this modified form takes more into consideration. However, as many CPUs and GPUs contain singe and doube precision square root functions (as standard features) and other instructions that can be used to speed up rendering -- the time penaty for this kind of shader wi not be noticed in most impementations. However, Binn-Phong wi be faster in the case where the viewer and ight are treated to be at infinity. This is the case for directiona ights. In this case, the haf-ange vector is independent of position and surface curvature. It can be computed once for each ight and then used for the entire frame, or indeed whie ight and viewpoint remain in the same reative position. The same is not true with Phong's origina refected ight vector which depends on the surface curvature and must be recacuated for each pixe of the image (or for each vertex of the mode in the case of vertex ighting). In most cases where ights are not treated to be at infinity, for instance when using point ights, the origina Phong mode wi be faster.

16 Lighting i=iamb+idiff+ispec + + = This is just a hack! Has itte to do with how reaity works! Tomas Akenine-Mőer 2002

17 Additions to the ighting equation Accounting for distance: 1/(a+bt+ct 2 ) Severa ights: just sum their respective contributions Different ight types: Tomas Akenine-Mőer 2002

18 Carifications Energy is emitted at equa proportions in a directions from a spherica radiator. Due to energy conservation, the intensity is proportiona to the spherica area at distance r from the ight center. A = 4πr 2 Thus, the intensity scaes ~ 1/r 2 r

19 Shading Shading: do ighting (at e.g. vertices) and determine pixe s coors from these Three common types of shading: Fat, Goraud, and Phong Tomas Akenine-Mőer 2002

20 Shading Three common types of shading: Fat, Goraud, and Phong In standard Gouraud shading the ighting is computed per triange vertex and for each pixe, the coor is interpoated from the coors at the vertices. In Phong Shading the ighting is not computed per vertex. Instead the norma is interpoated per pixe from the normas defined at the vertices and fu ighting is computed per pixe using this norma. This is of course more expensive but ooks better. Fat Gouraud Phong Tomas Akenine-Mőer 2002

21 // Vertex Shader #version 130 Gouraud Shading Code in vec3 vertex; in vec3 norma; uniform vec4 mtramb, mtrdiffuse, mtrspec, mtremission; uniform vec4 ightamb, ightdiffuse, ightspec, ightemission; uniform foat shininess; uniform mat4 modeviewprojectionmatrix, normamatrix, modeviewmatrix; uniform vec4 ightpos; // in view space out vec3 outcoor; For one ight source // Fragment Shader: #version 130 in vec3 outcoor; out vec4 fragcoor; void main() { g_position = modeviewprojectionmatrix*vec4(vertex,1); // ambient outcoor = ightamb * mtramb; // diffuse vertex = vec3(modeviewmatrix * vec4(vertex,1)); norma = normaize(normamatrix * norma); vec3 ightdirection = normaize(ightpos vertex.xyz); foat intensity=max(0, dot(norma, ightdirection) outcoor += ightdiffuse*mtrdiffuse*intensity; void main() { } fragcoor = vec4(outcoor,1); } // specuar vec3 viewvec = -vertex.xyz; // because we are in view space vec3 refvec = -ightdirection + norma*(2*dot(norma*ightdirection)) r = - + 2(n )n intensity=pow(max(0,(dot(refvec, viewvec)), shininess)); outcoor += ightspec * mtrspec * max(0,intensity); i spec = ((n ) < 0)? 0 : max(0,(r v)) m shi m spec s spec

22 Phong Shading Code For one ight source // Vertex Shader #version 130 in vec3 vertex; in vec3 norma; uniform vec3 mtramb; uniform vec3 ightamb; uniform vec4 ightpos; uniform mat4 modeviewprojectionmatrix; uniform mat4 normamatrix; uniform mat4 modeviewmatrix; out vec3 outcoor; out vec3 N; out vec3 viewvec; out vec3 ightdirection; void main() { g_position = modeviewprojectionmatrix* vec4(vertex,1); } // ambient outcoor = ightamb * mtramb; N= normaize(normamatrix * norma); ightdirection = normaize(ightpos vertex.xyz); viewvec=-vec3(modeviewmatrix*vec4(vertex,1)); // Fragment Shader: #version 130 in vec3 outcoor, ightdirection, N, pos; in vec3 viewvec; uniform vec3 mtrdiffuse, mtrspec, mtremission; uniform vec3 ightdiffuse, ightspec, ightemission; uniform foat shininess; out vec4 fragcoor; void main() { } N = normaize(n); // renormaize due to the interpoation // diffuse foat intensity=max(0, dot(n, ightdirection) outcoor += ightdiffuse*mtrdiffuse*intensity; // specuar vec3 refvec = -ightdirection + N*(2*dot(N*ightDirection)); intensity=pow(max(0,(dot(refvec, viewvec)), shininess)); outcoor += ightspec * mtrspec * max(0,intensity); fragcoor = vec4(outcoor,1);

23 Transparency and apha Transparency Very simpe in rea-time contexts The too: apha bending (mix two coors) Apha (a) is the forth coor component (r,g,b,a) e.g., of the materia for a triange Represents the opacity 1.0 is totay opaque 0.0 is totay transparent The over operator: c = ac + ( 1-a) c o Rendered object s d

24 Transparency Need to sort the transparent objects Render back to front (bending is order dep.) See next side c = ac + ( 1-a) c Lots of different other bending modes Can store RGBa in textures as we o Rendered fragment s Background d So the texes with a=0.0 do not not hide the objects behind Uf Assarsson 2007

25 Transparency Need to sort the transparent objects First, render a non-transparent trianges as usua. Then, sort a transparent trianges and render them back-to-front with bending enabed. The reason for sorting is that the bending operation (i.e., over operator) is order dependent. Tomas Akenine-Mőer 2002

26 Bending Used for Transparency c = ac + ( 1-a) c o s d gbendfunc(gl_src_alpha, GL_ONE_MINUS_SRC_ALPHA) Effects (shadows, refections) (Compex materias) Quake3 used up to 10 rendering passes, bending toghether contributions such as: Diffuse ighting (for hard shadows) Bump maps Base texture Specuar and emissive ighting Voumetric/atmospheric effects Enabe with genabe(gl_blend) 26 Uf Assarsson 2003

27 Fog Simpe atmospheric effect A itte better reaism Hep in determining distances Tomas Akenine-Mőer 2002

28 Coor of fog: c c p = fc s + (1 f )c f How to compute f? f coor of surface: f [0,1] 3 ways: inear, exponentia, exponentia-squared Linear: f = z z end end - - z z p start cs Tomas Akenine-Mőer 2002

29 Fog exampe Often just a matter of Choosing fog coor Choosing fog mode Od OpenGL just turn it on. New OpenGL program it yoursef in the fragment shader Tomas Akenine-Mőer 2002

30 Fog in up-direction Tomas Akenine-Mőer 2002

31 rgb_out Gamma correction Lighting computes rgb coor intensities in inear space from [0,1] x γ γ = 2.2 darker brighter darker brighter rgb_in screen = rgb_in x γ : perceived in. intensity: inear intensity: However, CRT-monitor output is exponentia. Has more precision for darker regions. Very Good! But we need to adapt the input to utiize this. Ese, our images wi be too dark. Expon. distribution better for humans. Our eyes have noninear sensitivity and monitors have imited brightness Intensities: x γ vs inear Textures: store in gamma space for better ditributed precision. So, store coor intensities with more precision for darker coors: i.e., convert coor to x (1 / γ) before storing in 8- bits in the frame buffer. Conversion to x (1 / γ) is caed gamma correction. x (1 / γ) x γ (x (1 / γ) ) γ x (1 / γ) intensity Shader rgb coors Frame buffer rgb coors. Dark pixes are made brighter Dispayed by CRT Framebuf. rgb: Shader rgb: Linear output again, but redistributed precision.

32 Gamma correction If input to gun is 0.5, then you don t get 0.5 as output in intensity Instead, gamma correct that signa: gives inear reationship Tomas Akenine-Mőer 2002

33 Gamma correction I = a( V +e) g I=intensity on screen V=input votage (eectron gun) a,e, and g are constants for each system Common gamma vaues: Assuming e=0, gamma correction is: c = c i ( 1/ g ) Tomas Akenine-Mőer 2002

34 Why is it important to care about gamma correction? Portabiity across patforms Image quaity Texturing Anti-aiasing One soution is to put gamma correction in hardware srgb asumes gamma=2.2 Can use EXT_framebuffer_sRGB to render with gamma correction directy to frame buffer

35 Gamma correction today Standard is 2.2 Happens to give more efficient coor space when compressing intensity from 32-bit foats to 8-bits. Thus, sti motivated. better distribution for humans Gamma of 2.2 Truth On most dispays (those with gamma of about 2.2), one can observe that the inear intensity output (bottom) has a arge jump in perceived brightness between the intensity vaues 0.0 and 0.1, whie the steps at the higher end of the scae are hardy perceptibe. A inear input that has a nonineary-increasing intensity (upper), wi show much more even steps in perceived brightness.

36 What is important Amb-, diff-, spec-, emission mode + formuas Phong s + Binn s highight mode Fat-, Gouraud- and Phong shading Transparency Fog Tomas Akenine-Mőer 2002

37 THE END

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

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

Computer Graphics (CS 543) Lecture 9b: Shadows and Shadow Maps. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics (CS 543) Lecture 9b: Shadows and Shadow Maps. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI) Computer Graphics (CS 543) Lecture 9b: Shadows and Shadow Maps Prof Emmanue Agu Computer Science Dept. Worcester Poytechnic Institute (WPI) Introduction to Shadows Shadows give information on reative positions

More information

Computer Graphics. - Shading & Texturing -

Computer Graphics. - Shading & Texturing - Computer Graphics - Shading & Texturing - Empirica BRDF Approximation Purey heuristic mode Initiay without units (vaues [0,1] r = r,a + r,d + r,s ( + r,m + r,t r,a : Ambient term Approximate indirect iumination

More information

Shading, lighting, & BRDF Theory. Cliff Lindsay, PHD

Shading, lighting, & BRDF Theory. Cliff Lindsay, PHD Shading, lighting, & BRDF Theory Cliff Lindsay, PHD Overview of today s lecture BRDF Characteristics Lights in terms of BRDFs Classes of BRDFs Ambient light & Shadows in terms of BRDFs Decomposing Reflection

More information

Shading 1: basics Christian Miller CS Fall 2011

Shading 1: basics Christian Miller CS Fall 2011 Shading 1: basics Christian Miller CS 354 - Fall 2011 Picking colors Shading is finding the right color for a pixel This color depends on several factors: The material of the surface itself The color and

More information

Computer Graphics MTAT Raimond Tunnel

Computer Graphics MTAT Raimond Tunnel Computer Graphics MTAT.03.015 Raimond Tunnel The Road So Far... Last week This week Color What is color? Color We represent color values with 3 channels: Red Green Blue Color We represent color values

More information

9. Illumination and Shading

9. Illumination and Shading 9. Illumination and Shading Approaches for visual realism: - Remove hidden surfaces - Shade visible surfaces and reproduce shadows - Reproduce surface properties Texture Degree of transparency Roughness,

More information

Virtual Reality for Human Computer Interaction

Virtual Reality for Human Computer Interaction Virtual Reality for Human Computer Interaction Appearance: Lighting Representation of Light and Color Do we need to represent all I! to represent a color C(I)? No we can approximate using a three-color

More information

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

Today s class. Simple shadows Shading Lighting in OpenGL. Informationsteknologi. Wednesday, November 21, 2007 Computer Graphics - Class 10 1 Today s class Simple shadows Shading Lighting in OpenGL Wednesday, November 21, 27 Computer Graphics - Class 1 1 Simple shadows Simple shadows can be gotten by using projection matrices Consider a light

More information

CS5620 Intro to Computer Graphics

CS5620 Intro to Computer Graphics So Far wireframe hidden surfaces Next step 1 2 Light! Need to understand: How lighting works Types of lights Types of surfaces How shading works Shading algorithms What s Missing? Lighting vs. Shading

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

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

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

More information

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014 ECS 175 COMPUTER GRAPHICS Ken Joy Winter 2014 Shading To be able to model shading, we simplify Uniform Media no scattering of light Opaque Objects No Interreflection Point Light Sources RGB Color (eliminating

More information

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

CSE 167: Lecture #7: Color and Shading. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011 CSE 167: Introduction to Computer Graphics Lecture #7: Color and Shading Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011 Announcements Homework project #3 due this Friday,

More information

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 Computergrafik Thomas Buchberger, Matthias Zwicker Universität Bern Herbst 2008 Today Introduction Local shading models Light sources strategies Compute interaction of light with surfaces Requires simulation

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

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

Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1) Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1) Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Why do we need Lighting & shading? Sphere

More information

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

Computer Graphics (CS 543) Lecture 7b: Intro to lighting, Shading and Materials + Phong Lighting Model Computer Graphics (CS 543) Lecture 7b: Intro to lighting, Shading and Materials + Phong Lighting Model Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Why do we need Lighting

More information

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 Computergrafik Matthias Zwicker Universität Bern Herbst 2009 Today Introduction Local shading models Light sources strategies Compute interaction of light with surfaces Requires simulation of physics Global

More information

Computer Graphics. Illumination and Shading

Computer Graphics. Illumination and Shading () Illumination and Shading Dr. Ayman Eldeib Lighting So given a 3-D triangle and a 3-D viewpoint, we can set the right pixels But what color should those pixels be? If we re attempting to create a realistic

More information

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

Rendering. Illumination Model. Wireframe rendering simple, ambiguous Color filling flat without any 3D information llumination Model Wireframe rendering simple, ambiguous Color filling flat without any 3D information Requires modeling interaction of light with the object/surface to have a different color (shade in

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

The Rasterization Pipeline

The Rasterization Pipeline Lecture 5: The Rasterization Pipeline Computer Graphics and Imaging UC Berkeley CS184/284A, Spring 2016 What We ve Covered So Far z x y z x y (0, 0) (w, h) Position objects and the camera in the world

More information

Computer Graphics. Illumination and Shading

Computer Graphics. Illumination and Shading Rendering Pipeline modelling of geometry transformation into world coordinates placement of cameras and light sources transformation into camera coordinates backface culling projection clipping w.r.t.

More information

Visualisatie BMT. Rendering. Arjan Kok

Visualisatie BMT. Rendering. Arjan Kok Visualisatie BMT Rendering Arjan Kok a.j.f.kok@tue.nl 1 Lecture overview Color Rendering Illumination 2 Visualization pipeline Raw Data Data Enrichment/Enhancement Derived Data Visualization Mapping Abstract

More information

Computer Graphics (CS 543) Lecture 8a: Per-Vertex lighting, Shading and Per-Fragment lighting

Computer Graphics (CS 543) Lecture 8a: Per-Vertex lighting, Shading and Per-Fragment lighting Computer Graphics (CS 543) Lecture 8a: Per-Vertex lighting, Shading and Per-Fragment lighting Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Computation of Vectors To calculate

More information

Illumination in Computer Graphics

Illumination in Computer Graphics Illumination in Computer Graphics Ann McNamara Illumination in Computer Graphics Definition of light sources. Analysis of interaction between light and objects in a scene. Rendering images that are faithful

More information

Illumination Models & Shading

Illumination Models & Shading Illumination Models & Shading Lighting vs. Shading Lighting Interaction between materials and light sources Physics Shading Determining the color of a pixel Computer Graphics ZBuffer(Scene) PutColor(x,y,Col(P));

More information

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker CMSC427 Shading Intro Credit: slides from Dr. Zwicker 2 Today Shading Introduction Radiometry & BRDFs Local shading models Light sources Shading strategies Shading Compute interaction of light with surfaces

More information

CPSC 314 LIGHTING AND SHADING

CPSC 314 LIGHTING AND SHADING CPSC 314 LIGHTING AND SHADING UGRAD.CS.UBC.CA/~CS314 slide credits: Mikhail Bessmeltsev et al 1 THE RENDERING PIPELINE Vertices and attributes Vertex Shader Modelview transform Per-vertex attributes Vertex

More information

INF3320 Computer Graphics and Discrete Geometry

INF3320 Computer Graphics and Discrete Geometry INF3320 Computer Graphics and Discrete Geometry Visual appearance Christopher Dyken and Martin Reimers 23.09.2009 Page 1 Visual appearance Real Time Rendering: Chapter 5 Light Sources and materials Shading

More information

High-Quality Unstructured Volume Rendering on the PC Platform

High-Quality Unstructured Volume Rendering on the PC Platform High-Quaity Unstructured Voume Rendering on the PC Patorm Stean Guthe, Wogang Strasser WSI/GRIS University o Tuebingen Stean Röttger, Andreas Schieber, Thomas Ert II/VIS University o Stuttgart Hardware

More information

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

Methodology for Lecture. Importance of Lighting. Outline. Shading Models. Brief primer on Color. Foundations of Computer Graphics (Spring 2010) Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 11: OpenGL 3 http://inst.eecs.berkeley.edu/~cs184 Methodology for Lecture Lecture deals with lighting (teapot shaded as in HW1) Some Nate

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

Lighting and Materials

Lighting and Materials http://graphics.ucsd.edu/~henrik/images/global.html Lighting and Materials Introduction The goal of any graphics rendering app is to simulate light Trying to convince the viewer they are seeing the real

More information

CS 418: Interactive Computer Graphics. Basic Shading in WebGL. Eric Shaffer

CS 418: Interactive Computer Graphics. Basic Shading in WebGL. Eric Shaffer CS 48: Interactive Computer Graphics Basic Shading in WebGL Eric Shaffer Some slides adapted from Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 205 Phong Reflectance Model Blinn-Phong

More information

Rendering: Reality. Eye acts as pinhole camera. Photons from light hit objects

Rendering: Reality. Eye acts as pinhole camera. Photons from light hit objects Basic Ray Tracing Rendering: Reality Eye acts as pinhole camera Photons from light hit objects Rendering: Reality Eye acts as pinhole camera Photons from light hit objects Rendering: Reality Eye acts as

More information

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

CSE 167: Introduction to Computer Graphics Lecture #6: Lights. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016 CSE 167: Introduction to Computer Graphics Lecture #6: Lights Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016 Announcements Thursday in class: midterm #1 Closed book Material

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

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY 1(84) Information Coding / Computer Graphics, ISY, LiTH TSBK 07 Computer Graphics Ingemar Ragnemalm, ISY 1(84) Lecture 5 3D graphics part 3 Illumination Illumination applied: Shading Surface detail: Mappings

More information

Computer Graphics with OpenGL ES (J. Han) Chapter 6 Fragment shader

Computer Graphics with OpenGL ES (J. Han) Chapter 6 Fragment shader Computer Graphics with OpenGL ES (J. Han) Chapter 6 Fragment shader Vertex and Fragment Shaders The inputs to the fragment shader Varyings: The per-vertex output variables produced by the vertex shader

More information

CS452/552; EE465/505. Intro to Lighting

CS452/552; EE465/505. Intro to Lighting CS452/552; EE465/505 Intro to Lighting 2-10 15 Outline! Projection Normalization! Introduction to Lighting (and Shading) Read: Angel Chapter 5., sections 5.4-5.7 Parallel Projections Chapter 6, sections

More information

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

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 Computer Graphics Three-Dimensional Graphics V Guoying Zhao 1 / 65 Shading Guoying Zhao 2 / 65 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material

More information

Lessons Learned from HW4. Shading. Objectives. Why we need shading. Shading. Scattering

Lessons Learned from HW4. Shading. Objectives. Why we need shading. Shading. Scattering Lessons Learned from HW Shading CS Interactive Computer Graphics Prof. David E. Breen Department of Computer Science Only have an idle() function if something is animated Set idle function to NULL, when

More information

Objectives. Introduce the OpenGL shading Methods 1) Light and material functions on MV.js 2) per vertex vs per fragment shading 3) Where to carry out

Objectives. Introduce the OpenGL shading Methods 1) Light and material functions on MV.js 2) per vertex vs per fragment shading 3) Where to carry out Objectives Introduce the OpenGL shading Methods 1) Light and material functions on MV.js 2) per vertex vs per fragment shading 3) Where to carry out 1 Steps in OpenGL shading Enable shading and select

More information

Illumination and Shading

Illumination and Shading Illumination and Shading Illumination (Lighting)! Model the interaction of light with surface points to determine their final color and brightness! The illumination can be computed either at vertices or

More information

Illumination & Shading I

Illumination & Shading I CS 543: Computer Graphics Illumination & Shading I Robert W. Lindeman Associate Professor Interactive Media & Game Development Department of Computer Science Worcester Polytechnic Institute gogo@wpi.edu

More information

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Lecture 15: Shading-I. CITS3003 Graphics & Animation Lecture 15: Shading-I CITS3003 Graphics & Animation E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 Objectives Learn that with appropriate shading so objects appear as threedimensional

More information

Nearest Neighbor Learning

Nearest Neighbor Learning Nearest Neighbor Learning Cassify based on oca simiarity Ranges from simpe nearest neighbor to case-based and anaogica reasoning Use oca information near the current query instance to decide the cassification

More information

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

Computer Graphics. Shading. Based on slides by Dianna Xu, Bryn Mawr College Computer Graphics Shading Based on slides by Dianna Xu, Bryn Mawr College Image Synthesis and Shading Perception of 3D Objects Displays almost always 2 dimensional. Depth cues needed to restore the third

More information

CS Illumination and Shading. Slide 1

CS Illumination and Shading. Slide 1 CS 112 - Illumination and Shading Slide 1 Illumination/Lighting Interaction between light and surfaces Physics of optics and thermal radiation Very complex: Light bounces off several surface before reaching

More information

Lighting Models. CS116B Chris Pollett Mar 21, 2004.

Lighting Models. CS116B Chris Pollett Mar 21, 2004. Lighting Models CS116B Chris Pollett Mar 21, 2004. Outline Overview Light Sources Surface Lighting Effect Basic Illumination Models Overview An illumination model (lighting model) is used to calculate

More information

CEng 477 Introduction to Computer Graphics Fall

CEng 477 Introduction to Computer Graphics Fall Illumination Models and Surface-Rendering Methods CEng 477 Introduction to Computer Graphics Fall 2007 2008 Illumination Models and Surface Rendering Methods In order to achieve realism in computer generated

More information

Lighting affects appearance

Lighting affects appearance Lighting affects appearance 1 Source emits photons Light And then some reach the eye/camera. Photons travel in a straight line When they hit an object they: bounce off in a new direction or are absorbed

More information

Computer Graphics Coursework 1

Computer Graphics Coursework 1 Computer Graphics Coursework 1 Deadline Deadline: 4pm, 24/10/2016 4pm 23/10/2015 Outline The aim of the coursework is to modify the vertex and fragment shaders in the provided OpenGL framework to implement

More information

CPSC / Illumination and Shading

CPSC / Illumination and Shading CPSC 599.64 / 601.64 Rendering Pipeline usually in one step modelling of geometry transformation into world coordinate system placement of cameras and light sources transformation into camera coordinate

More information

-=Bui Tuong Phong's Lighting=- University of Utah, but with shaders. Anton Gerdelan Trinity College Dublin

-=Bui Tuong Phong's Lighting=- University of Utah, but with shaders. Anton Gerdelan Trinity College Dublin -=Bui Tuong Phong's Lighting=- University of Utah, 1973 but with shaders Anton Gerdelan Trinity College Dublin Before we do anything - normals Q. What does a normal do? Q. How do we usually calculate them?

More information

Lighting and Shading II. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Lighting and Shading II. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015 Lighting and Shading II 1 Objectives Continue discussion of shading Introduce modified Phong model Consider computation of required vectors 2 Ambient Light Ambient light is the result of multiple interactions

More information

CS 432 Interactive Computer Graphics

CS 432 Interactive Computer Graphics CS 432 Interactive Computer Graphics Lecture 6 Part 2 Lighting and Shading in OpenGL Matt Burlick - Drexel University - CS 430 1 OpenGL Shading Need Vertex Normals Material properties Lights Position of

More information

Illumination and Shading

Illumination and Shading Illumination and Shading Computer Graphics COMP 770 (236) Spring 2007 Instructor: Brandon Lloyd 2/14/07 1 From last time Texture mapping overview notation wrapping Perspective-correct interpolation Texture

More information

Chapter 7 - Light, Materials, Appearance

Chapter 7 - Light, Materials, Appearance Chapter 7 - Light, Materials, Appearance Types of light in nature and in CG Shadows Using lights in CG Illumination models Textures and maps Procedural surface descriptions Literature: E. Angel/D. Shreiner,

More information

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

Introduction. Lighting model Light reflection model Local illumination model Reflectance model BRDF Shading Introduction Affine transformations help us to place objects into a scene. Before creating images of these objects, we ll look at models for how light interacts with their surfaces. Such a model

More information

Shading I Computer Graphics I, Fall 2008

Shading I Computer Graphics I, Fall 2008 Shading I 1 Objectives Learn to shade objects ==> images appear threedimensional Introduce types of light-material interactions Build simple reflection model Phong model Can be used with real time graphics

More information

Introduction to Visualization and Computer Graphics

Introduction to Visualization and Computer Graphics Introduction to Visualization and Computer Graphics DH2320, Fall 2015 Prof. Dr. Tino Weinkauf Introduction to Visualization and Computer Graphics Visibility Shading 3D Rendering Geometric Model Color Perspective

More information

Illumination & Shading: Part 1

Illumination & Shading: Part 1 Illumination & Shading: Part 1 Light Sources Empirical Illumination Shading Local vs Global Illumination Lecture 10 Comp 236 Spring 2005 Computer Graphics Jargon: Illumination Models Illumination - the

More information

CS452/552; EE465/505. Lighting & Shading

CS452/552; EE465/505. Lighting & Shading CS452/552; EE465/505 Lighting & Shading 2-17 15 Outline! More on Lighting and Shading Read: Angel Chapter 6 Lab2: due tonight use ASDW to move a 2D shape around; 1 to center Local Illumination! Approximate

More information

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

CSE 167: Lecture #8: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012 CSE 167: Introduction to Computer Graphics Lecture #8: GLSL Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012 Announcements Homework project #4 due Friday, November 2 nd Introduction:

More information

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Shading Models. Welcome!

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Shading Models. Welcome! INFOGR Computer Graphics J. Bikker - April-July 2016 - Lecture 10: Shading Models Welcome! Today s Agenda: Introduction Light Transport Materials Sensors Shading INFOGR Lecture 10 Shading Models 3 Introduction

More information

Shading and Illumination

Shading and Illumination Shading and Illumination OpenGL Shading Without Shading With Shading Physics Bidirectional Reflectance Distribution Function (BRDF) f r (ω i,ω ) = dl(ω ) L(ω i )cosθ i dω i = dl(ω ) L(ω i )( ω i n)dω

More information

CS 4600 Fall Utah School of Computing

CS 4600 Fall Utah School of Computing Lighting CS 4600 Fall 2015 Utah School of Computing Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build a simple reflection

More information

w Foley, Section16.1 Reading

w Foley, Section16.1 Reading Shading w Foley, Section16.1 Reading Introduction So far, we ve talked exclusively about geometry. w What is the shape of an object? w How do I place it in a virtual 3D space? w How do I know which pixels

More information

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

Local Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller Local Illumination CMPT 361 Introduction to Computer Graphics Torsten Möller Graphics Pipeline Hardware Modelling Transform Visibility Illumination + Shading Perception, Interaction Color Texture/ Realism

More information

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

CGT520 Lighting. Lighting. T-vertices. Normal vector. Color of an object can be specified 1) Explicitly as a color buffer CGT520 Lighting Lighting Color of an object can be specified 1) Explicitly as a color buffer Bedrich Benes, Ph.D. Purdue University Department of Computer Graphics 2) Implicitly from the illumination model.

More information

Illumination & Shading

Illumination & Shading Illumination & Shading Goals Introduce the types of light-material interactions Build a simple reflection model---the Phong model--- that can be used with real time graphics hardware Why we need Illumination

More information

A Two-Step Approach for Interactive Pre-Integrated Volume Rendering of Unstructured Grids

A Two-Step Approach for Interactive Pre-Integrated Volume Rendering of Unstructured Grids A Two-Step Approach for Interactive Pre-Integrated Voume Rendering of Unstructured Grids Stefan Roettger and Thomas Ert Visuaization and Interactive Systems Group University of Stuttgart Abstract In the

More information

Virtual Reality for Human Computer Interaction

Virtual Reality for Human Computer Interaction Virtual Reality for Human Computer Interaction Appearance: Lighting Representation of Light and Color Representation of Light and Color Do we need to represent all I! to represent a color C(I)? Representation

More information

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

CSE 167: Introduction to Computer Graphics Lecture #6: Colors. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013 CSE 167: Introduction to Computer Graphics Lecture #6: Colors Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013 Announcements Homework project #3 due this Friday, October 18

More information

Color and Light. CSCI 4229/5229 Computer Graphics Summer 2008

Color and Light. CSCI 4229/5229 Computer Graphics Summer 2008 Color and Light CSCI 4229/5229 Computer Graphics Summer 2008 Solar Spectrum Human Trichromatic Color Perception Are A and B the same? Color perception is relative Transmission,Absorption&Reflection Light

More information

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

Objectives. Introduce Phong model Introduce modified Phong model Consider computation of required vectors Discuss polygonal shading. Shading II 1 Objectives Introduce Phong model Introduce modified Phong model Consider computation of required vectors Discuss polygonal shading Flat Smooth Gouraud 2 Phong Lighting Model A simple model

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

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

CS130 : Computer Graphics Lecture 8: Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside CS130 : Computer Graphics Lecture 8: Lighting and Shading Tamar Shinar Computer Science & Engineering UC Riverside Why we need shading Suppose we build a model of a sphere using many polygons and color

More information

TDA361/DIT220 Computer Graphics, January 15 th 2016

TDA361/DIT220 Computer Graphics, January 15 th 2016 TDA361/DIT220 Computer Graphics, January 15 th 2016 EXAM (Same exam for both CTH- and GU students) Friday January 15 th, 2016, 8.30 12.30 Examiner Ulf Assarsson, tel. 0701-738535 Permitted Technical Aids

More information

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading)

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading) Lecture 9 Graphics pipeline (rasterization and shading) Graphics pipeline - part 1 (recap) Perspective projection by matrix multiplication: x pixel y pixel z canonical 1 x = M vpm per M cam y z 1 This

More information

Introduction to Computer Graphics. Farhana Bandukwala, PhD Lecture 14: Light Interacting with Surfaces

Introduction to Computer Graphics. Farhana Bandukwala, PhD Lecture 14: Light Interacting with Surfaces Introduction to Computer Graphics Farhana Bandukwala, PhD Lecture 14: Light Interacting with Surfaces Outline Computational tools Reflection models Polygon shading Computation tools Surface normals Vector

More information

GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people

GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people GLSL Introduction Fu-Chung Huang Thanks for materials from many other people Programmable Shaders //per vertex inputs from main attribute aposition; attribute anormal; //outputs to frag. program varying

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

Light Transport Baoquan Chen 2017

Light Transport Baoquan Chen 2017 Light Transport 1 Physics of Light and Color It s all electromagnetic (EM) radiation Different colors correspond to radiation of different wavelengths Intensity of each wavelength specified by amplitude

More information

How do we draw a picture?

How do we draw a picture? 1 How do we draw a picture? Define geometry. Now what? We can draw the edges of the faces. Wireframe. We can only draw the edges of faces that are visible. We can fill in the faces. Giving each object

More information

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

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015 Orthogonal Projection Matrices 1 Objectives Derive the projection matrices used for standard orthogonal projections Introduce oblique projections Introduce projection normalization 2 Normalization Rather

More information

Shading and Texturing Due: Friday, Feb 17 at 6:00pm

Shading and Texturing Due: Friday, Feb 17 at 6:00pm CMSC 23700 Winter 2012 Introduction to Computer Graphics Project 2 Feb 2 Shading and Texturing Due: Friday, Feb 17 at 6:00pm (v1.0 Feb 2: initial version) 1 Summary You can complete this project in pairs

More information

CS 498 VR. Lecture 19-4/9/18. go.illinois.edu/vrlect19

CS 498 VR. Lecture 19-4/9/18. go.illinois.edu/vrlect19 CS 498 VR Lecture 19-4/9/18 go.illinois.edu/vrlect19 Review from previous lectures Image-order Rendering and Object-order Rendering Image-order Rendering: - Process: Ray Generation, Ray Intersection, Assign

More information

Color and Light CSCI 4229/5229 Computer Graphics Fall 2016

Color and Light CSCI 4229/5229 Computer Graphics Fall 2016 Color and Light CSCI 4229/5229 Computer Graphics Fall 2016 Solar Spectrum Human Trichromatic Color Perception Color Blindness Present to some degree in 8% of males and about 0.5% of females due to mutation

More information

LCD Video Controller. LCD Video Controller. Introduction Safety Precautions Indentifying the Components... 5

LCD Video Controller. LCD Video Controller. Introduction Safety Precautions Indentifying the Components... 5 LCD Video Controer LCD Video Controer Introduction... 3 Safety Precautions... 4 Indentifying the Components... 5 Main Board... 5 Main Board ASIC Features... 6 LVDS Transmitter... 8 Backight Inverter...

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

Surface Reflection Models

Surface Reflection Models Surface Reflection Models Frank Losasso (flosasso@nvidia.com) Introduction One of the fundamental topics in lighting is how the light interacts with the environment. The academic community has researched

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

OpenGL Lighting Computer Graphics Spring Frank Palermo

OpenGL Lighting Computer Graphics Spring Frank Palermo OpenGL Lighting 15-462 Computer Graphics Spring 2009 Frank Palermo OpenGL is just a bunch of hacks. -Adrien Treuille What Adrien Means... What Adrien means is that OpenGL was designed to produce reasonable-looking

More information

Phong Lighting & Materials. Some slides modified from: David Kabala Others from: Andries Van Damm, Brown Univ.

Phong Lighting & Materials. Some slides modified from: David Kabala Others from: Andries Van Damm, Brown Univ. Phong Lighting & Materials Some slides modified from: David Kabala Others from: Andries Van Damm, Brown Univ. Lighting and Shading Lighting, or illumination, is the process of computing the intensity and

More information

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

Topic 9: Lighting & Reflection models 9/10/2016. Spot the differences. Terminology. Two Components of Illumination. Ambient Light Source Topic 9: Lighting & Reflection models Lighting & reflection The Phong reflection model diffuse component ambient component specular component Spot the differences Terminology Illumination The transport

More information