Color in OpenGL Polygonal Shading Light Source in OpenGL Material Properties Normal Vectors Phong model

Similar documents
Computer Graphics. Jeng-Sheng Yeh 葉正聖 Ming Chuan University (modified from Bing-Yu Chen s slides)

Scan Conversion & Shading

Scan Conversion & Shading

Lighting. Dr. Scott Schaefer

Surface Mapping One. CS7GV3 Real-time Rendering

R s s f. m y s. SPH3UW Unit 7.3 Spherical Concave Mirrors Page 1 of 12. Notes

5.2 Shading in OpenGL

Shading in OpenGL. Outline. Defining and Maintaining Normals. Normalization. Enabling Lighting and Lights. Outline

Computer Animation and Visualisation. Lecture 4. Rigging / Skinning

Discussion. History and Outline. Smoothness of Indirect Lighting. Irradiance Caching. Irradiance Calculation. Advanced Computer Graphics (Fall 2009)

Real-time. Shading of Folded Surfaces

Range images. Range image registration. Examples of sampling patterns. Range images and range surfaces

Illumination Models. To calculate the color of an illuminated position on the

Diffuse and specular interreflections with classical, deterministic ray tracing

Discussion. History and Outline. Smoothness of Indirect Lighting. Irradiance Calculation. Irradiance Caching. Advanced Computer Graphics (Fall 2009)

Physics 132 4/24/17. April 24, 2017 Physics 132 Prof. E. F. Redish. Outline

REFRACTION. a. To study the refraction of light from plane surfaces. b. To determine the index of refraction for Acrylic and Water.

Global Illumination and Radiosity

Global Illumination and Radiosity

Shading , Fall 2004 Nancy Pollard Mark Tomczak

Barycentric Coordinates. From: Mean Value Coordinates for Closed Triangular Meshes by Ju et al.

COMP250: Computer Graphics

AP PHYSICS B 2008 SCORING GUIDELINES

Global Illumination: Radiosity

Our objects so far have mostly looked as if they plan to stay home and watch

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

Why we need shading?

Electrical analysis of light-weight, triangular weave reflector antennas

Monte Carlo Rendering

Consistent Illumination within Optical See-Through Augmented Environments

PHYS 219 Spring semester Lecture 20: Reflection of Electromagnetic Radiation: Mirrors and Images Formed by Mirrors

Some Tutorial about the Project. Computer Graphics

Illumination and Shading

Interactive Rendering of Translucent Objects

Global Illumination and Radiosity

SLAM Summer School 2006 Practical 2: SLAM using Monocular Vision

DIFFRACTION SHADING MODELS FOR IRIDESCENT SURFACES

Introduction to Radiosity

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

UNIT 2 : INEQUALITIES AND CONVEX SETS

Global Illumination. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/26/07 1

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Finding Intrinsic and Extrinsic Viewing Parameters from a Single Realist Painting

Surface Rendering Methods

Structure from Motion

Shading Intro. Shading & Lighting. Light and Matter. Light and Matter

2.2 Photometric Image Formation

Illumination and Shading ECE 567

Slide 1 SPH3UW: OPTICS I. Slide 2. Slide 3. Introduction to Mirrors. Light incident on an object

Computer graphics III Light reflection, BRDF. Jaroslav Křivánek, MFF UK

Illumination & Shading: Part 1

Inverse Kinematics (part 2) CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Spring 2016

Shading and Illumination

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

Sung-Eui Yoon ( 윤성의 )

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

ESTIMATION OF INTERIOR ORIENTATION AND ECCENTRICITY PARAMETERS OF A HYBRID IMAGING AND LASER SCANNING SENSOR

S1 Note. Basis functions.

Simulation and Animation of Fire

Harmonic Coordinates for Character Articulation PIXAR

Monte Carlo Integration

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

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

Dependence of the Color Rendering Index on the Luminance of Light Sources and Munsell Samples

6.837 Introduction to Computer Graphics Assignment 5: OpenGL and Solid Textures Due Wednesday October 22, 2003 at 11:59pm

CS 325 Computer Graphics

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

Calibrating a single camera. Odilon Redon, Cyclops, 1914

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Lecture #15 Lecture Notes

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

Fast, Arbitrary BRDF Shading for Low-Frequency Lighting Using Spherical Harmonics

Analysis of Continuous Beams in General

Computer Graphics. Illumination and Shading

Topics and things to know about them:

Freeform Shading and Lighting Systems from Planar Quads

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

FEATURE EXTRACTION. Dr. K.Vijayarekha. Associate Dean School of Electrical and Electronics Engineering SASTRA University, Thanjavur

PBRT core. Announcements. pbrt. pbrt plug-ins

Module 6: FEM for Plates and Shells Lecture 6: Finite Element Analysis of Shell

Illumination Model. The governing principles for computing the. Apply the lighting model at a set of points across the entire surface.

Virtual Reality for Human Computer Interaction

CEng 477 Introduction to Computer Graphics Fall

ROBOT KINEMATICS. ME Robotics ME Robotics

Fitting & Matching. Lecture 4 Prof. Bregler. Slides from: S. Lazebnik, S. Seitz, M. Pollefeys, A. Effros.

Accounting for the Use of Different Length Scale Factors in x, y and z Directions

Display Reflectance Model Based on the BRDF

Illumination & Shading

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

TEST-05 TOPIC: OPTICS COMPLETE

Reading. 14. Subdivision curves. Recommended:

Illumination and Shading

Parallel Computation of the Functions Constructed with

Object Recognition Based on Photometric Alignment Using Random Sample Consensus

Shading I Computer Graphics I, Fall 2008

Shape Representation Robust to the Sketching Order Using Distance Map and Direction Histogram

Mach band effect. The Mach band effect increases the visual unpleasant representation of curved surface using flat shading.

VISUAL SELECTION OF SURFACE FEATURES DURING THEIR GEOMETRIC SIMULATION WITH THE HELP OF COMPUTER TECHNOLOGIES

2x x l. Module 3: Element Properties Lecture 4: Lagrange and Serendipity Elements

Transcription:

Color n OpenGL Polygonal Shadng Lght Source n OpenGL Materal Propertes Normal Vectors Phong model 2

We know how to rasterze - Gven a 3D trangle and a 3D vewpont, we know whch pxels represent the trangle But what color should those pxels be? 3

Adds realsm to our objects Suppose we create a model of a sphere usng many polygons and color t wth glcolor. But our objectve s 4

n ths verson of OpenGL, the sphere s drawn from the front to the back. So f the depth test s cancelled, what we wll see s the back of the sphere. n another verson of OpenGL the results can be dfferent. 5

Lght-materal nteractons affect vertces appearance Due to ths nteracton, each vertex would have dfferent color and shade Need to consder - Lght sources - Materal propertes - Locaton of vewer - Surface orentaton 6

Color n OpenGL Polygonal Shadng Lght Source n OpenGL Materal Propertes Normal Vectors Phong model 7

glcolor3f(red, green, blue) glcolor4f(red, green, blue, alpha) 8

s OpenGL lghtng enabled? NO YES Color determned by glcolor3f( ) gnorng: normals lghts materal propertes Color determned by shades Usng: normals lghts materal propertes 9

Color n OpenGL Polygonal Shadng Lght Source n OpenGL Materal Propertes Normal Vectors Phong model 10

Shadng s defned as a smooth transton from one color to another Curved surfaces are approxmated by polygons Types of shadng are: - Flat shadng - Smooth Shadng 11

Enabled wth glshademodel(gl_flat) Shadng s constant across polygon Color of last vertex determnes nteror color Only sutable for very small polygons v2 v0 v1 12

Enable wth glshademodel(gl_smooth) nterpolate color n nteror Computed durng rasterzaton Much better than flat shadng More expensve to calculate v2 v0 v1 13

Color n OpenGL Polygonal Shadng Lght Source n OpenGL Materal Propertes Normal Vectors Phong model 14

Lghtng n general must be enabled glenable(gl_lghtng) Each ndvdual lght must be enabled glenable(gl_lght0) OpenGL supports at least 8 lght sources There are 3 types of effects of lght source: Ambent Dffuse Specular 15

Ambent lght : Drectonless Objects are evenly lt on all surfaces n all drectons Objects are evenly shaded regardless of ther vewng angle Dffuse lght: Comes from a partcular drecton Reflected evenly off a surface Specular lght: Comes from a partcular drecton Reflected sharply and n a partcular drecton To make objects specular, both lght source and object must have specular property set 16

17

Use vectors (r, g, b, a) for lght propertes Beware: lght postons wll be transformed by the modelvew matrx GLfloat lght_ambent[] = {0.2, 0.2, 0.2, 1.0}; GLfloat lght_dffuse[] = {1.0, 1.0, 1.0, 1.0}; GLfloat lght_specular[] = {1.0, 1.0, 1.0, 1.0}; GLfloat lght_poston[] = {-1.0, 1.0, -1.0, 0.0}; gllghtfv(gl_lght0, GL_AMBENT, lght_ambent); gllghtfv(gl_lght0, GL_DFFUSE, lght_dffuse); gllghtfv(gl_lght0, GL_SPECULAR, lght_specular); gllghtfv(gl_lght0, GL_POSTON, lght_poston); 18

Drectonal lght gven by poston vector (parallel rays) GLfloat lght_poston[] = {-1.0, 1.0, -1.0, 0.0}; gllghtfv(gl_lght0, GL_POSTON, lght_poston); Pont source gven by poston pont (spotlght) GLfloat lght_poston[] = {-1.0, 1.0, -1.0, 1.0}; gllghtfv(gl_lght0, GL_POSTON, lght_poston); 19

A lght source whch located nsde the scene. Lght spreads n a cone shape Can be drected CUTOFF angle s between 0 to 90 unless t s 180. (ths s the defualt value) GLfloat lght_drecton[]={1,-1,-1,1}; gllghtfv(gl_lght0, GL_SPOT_DRECTON, lght_drecton); gllghtf(gl_lght0, GL_SPOT_CUTOFF, 45); 20

Lght sources are geometrc objects whose postons or drectons are affected by OpenGL matrces t s possble to: Move the lght source(s) wth the object(s) Move the lght source(s) and object(s) ndependently Fx the object(s) and move the lght source(s) Fx the lght source(s) and move the object(s) 21

Color n OpenGL Polygonal Shadng Lght Source n OpenGL Materal Propertes Normal Vectors Phong model 22

Materal have certan reflectve color propertes Put a blue ball n a dark room wth only yellow lght, how would t looks lke? Materal propertes stay n effect untl changed GLfloat mat_a[] = {0.1, 0.5, 0.8, 1.0}; GLfloat mat_d[] = {0.1, 0.5, 0.8, 1.0}; GLfloat mat_s[] = {1.0, 1.0, 1.0, 1.0}; GLfloat low_sh[] = {5.0}; glmateralfv(gl_front, GL_AMBENT, mat_a); glmateralfv(gl_front, GL_DFFUSE, mat_d); glmateralfv(gl_front, GL_SPECULAR, mat_s); glmateralfv(gl_front, GL_SHNNESS, low_sh); glenable(gl_color_materal); 23

Color n OpenGL Polygonal Shadng Lght Source n OpenGL Materal Propertes Normal Vectors Phong model 24

Defne unt normal before each vertex glnormal3f(nx, ny, nz); glvertex3f(x1, y1, z1); glvertex3f(x2, y2, z2); glvertex3f(x3, y3, z3); same normal for all vertces glnormal3f(nx1, ny1, nz1); glvertex3f(x1, y1, z1); glnormal3f(nx2, ny2, nz2); glvertex3f(x2, y2, z2); glnormal3f(nx3, ny3, nz3); glvertex3f(x3, y3, z3); dfferent normals 25

Length of normals changes under some modelvew transformatons (but not under translatons and rotatons) Ask OpenGL to automatcally re-normalze glenable(gl_normalze); 26

Color n OpenGL Polygonal Shadng Lght Source n OpenGL Materal Propertes Normal Vectors Phong model 27

cosne law (dot product) N L N L cos Nˆ Lˆ cos K ( Nˆ Lˆ) D D L N q L Surface

Phong Model Vˆ Rˆ cos(a) n max(0, Vˆ ˆ) R Phong exponent: apparent smoothness of the surface Vewer R a q N q L V K ( Vˆ Rˆ ) S S n L

Sngle lght source: Vewer R a q N q L V E K A A K D ( N L) K ( V L S R) n L

Multple lght sources: Vewer L 1 N L 2 V E K A A ( K D ( N L ) K S ( V R ) n )

Vsual llustraton of the Phong equaton: here the lght s whte, the ambent and dffuse colors are both blue, and the specular color s whte, reflectng a small part of the lght httng the surface. The ntensty of the dffuse component vares wth the drecton of the surface.

Shadow terms tell whch lght sources are blocked Cast ray towards each lght source L S = 0 f ray s blocked, S = 1 otherwse n S D A A E S R V K L N K K ) ) ( ) ( ( Shadow Term

R R n S D A A E K S R V K L N K K ) ) ( ) ( ( Also trace secondary rays from ht surfaces Global llumnaton from mrror reflecton and transparency

Trace secondary ray n drecton of mrror reflecton Evaluate radance along secondary ray and nclude t nto llumnaton model R R n S D A A E K S R V K L N K K ) ) ( ) ( ( Radance for mrror reflecton ray

E Materal Emsson A Global ambent Lght Source ntensty R Reflecton ntensty K A Materal Ambent K D Materal Dffuse K S Materal Specular K R Materal Reflecton S Lght Shadowed? n Materal Shnness Normalzed vectors: L ntersecton to lght N ntersecton normal V ntersecton to Eye R ntersecton to reflected lght n E K A A ( K D ( N L ) K S ( V R ) ) S K R R