蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification

Similar documents
CS Computer Graphics: Illumination and Shading I

CS Computer Graphics: Illumination and Shading I

蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification

Ambient reflection. Jacobs University Visualization and Computer Graphics Lab : Graphics and Visualization 407

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

INF3320 Computer Graphics and Discrete Geometry

Illumination and Shading

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

Illumination & Shading I

Shading and Illumination

CS Surface Rendering

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

Lecture 4 Advanced Computer Graphics (CS & SE )

Lighting. CSC 7443: Scientific Information Visualization

Graphics and Visualization

Computer Graphics. Illumination and Shading

Computer Graphics Lighting

Computer Graphics Lighting. Why Do We Care About Lighting?

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

Virtual Reality for Human Computer Interaction

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

CSCI 4620/8626. Computer Graphics Illumination Models and Surface Rendering Methods (Chapter 17)

CEng 477 Introduction to Computer Graphics Fall

Light Transport Baoquan Chen 2017

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

Introduction to Computer Graphics 7. Shading

Illumination and Shading

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

Lighting/Shading III. Week 7, Wed Mar 3

Surface Rendering Methods

Reflection and Shading

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

Lights, Colour and Materials In OpenGL

Why we need shading?

LIGHTING AND SHADING

Illumination and Shading

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

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Illumination and Shading ECE 567

CS5620 Intro to Computer Graphics

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

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

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

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

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

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

Sung-Eui Yoon ( 윤성의 )

CS 4600 Fall Utah School of Computing

Shading I Computer Graphics I, Fall 2008

Lecture 15: Shading-I. CITS3003 Graphics & Animation

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

Virtual Reality for Human Computer Interaction

Light Sources. Spotlight model

UNIT 7 LIGHTING AND SHADING. 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M

Ligh%ng and Shading. Ligh%ng and Shading. q Is this a plate or a ball? q What color should I set for each pixel?

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

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

Chapter 3. Illumination Models and Surface-Rendering Methods. Department of Computer Science and Engineering

Homework #2. Shading, Ray Tracing, and Texture Mapping

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

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

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

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

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

CS 130 Final. Fall 2015

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

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

CS 148, Summer 2012 Introduction to Computer Graphics and Imaging

Deferred Rendering Due: Wednesday November 15 at 10pm

CS452/552; EE465/505. Lighting & Shading

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

API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3

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

Computer Graphics. Illumination and Shading

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

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

Projections and Hardware Rendering. Brian Curless CSE 557 Fall 2014

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

CS452/552; EE465/505. Intro to Lighting

Lighting and Shading. Slides: Tamar Shinar, Victor Zordon

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

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

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

CS 4620 Program 3: Pipeline

Shading. Brian Curless CSE 457 Spring 2015

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

Shading 1: basics Christian Miller CS Fall 2011

Computer Graphics. Illumination Models and Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL

9. Illumination and Shading

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

Color and Light CSCI 4229/5229 Computer Graphics Fall 2016

CPSC 314 LIGHTING AND SHADING

Illumination & Shading: Part 1

Lighting Models. CS116B Chris Pollett Mar 21, 2004.

Visualisatie BMT. Rendering. Arjan Kok

Shaders. Slide credit to Prof. Zwicker

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

Complex Shading Algorithms

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

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

Transcription:

蔡侑庭 (Yu-Ting Tsai) Department of Computer Science National Chiao Tung University, Taiwan Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification OpenGL Programming Guide, Chap. 5

2 http://caig.cs.nctu.edu.tw/course/cg2007/files /week_5.zip void MyInit() {... } void MyDisplay() {... }

3 Vertex Streams Transformations T f ti & Vertex Operations Primitive Operations Rasterization Pixel O Operations Memory

4 P

5 P

6 r h n l v P

7 P

8 OpenGL lighting is based on modified Phong reflection model Lighting is computed at each vertex (not each face or pixel) OpenGL only considers local l illuminationi No shadows, inter-reflection, refraction, transmission,, etc. If lighting is disabled, vertex colors are adopted as lighting colors

9 Modified Phong Model

10 Initialization Enable Lighting (glenable) GL_LIGHTING, GL_LIGHT0,, GL_LIGHTn Object Drawing Set Light Parameters (gllight) Set Material Parameters (glmaterial) Set Vertex Normals (glnormal)

11 Light sources are virtual objects (invisible) Three types of light sources Point lights, directional lights, and spotlights OpenGL supports multiple light sources Each light source has its own parameters Colors, position, spotlight parameters, & attenuation coefficients

12 Set Light Colors Ambient, diffuse, & specular colors GLfloat afdiffuse[] = { 0.5, 0.6, 0.9, 1.0 }; gllightfv( GL_LIGHT0, GL_DIFFUSE, afdiffuse );

13 Set light position (with non-zero w) Set all spotlight parameters to defaults P

14 Set light position (with zero w) Light direction is implicitly set as [-x, -y, -z] Set all spotlight parameters to defaults P

15 Set light position (with non-zero w) Set spotlight direction s and cut-off angle θ Set spotlight exponent e φ s θ P

16 Intensity of light decreases as distance from the light increases No effect on directional lights

17 Three Attenuation Coefficients Constant, linear, and quadratic coefficients d i P

18 Light position and spotlight direction are in object coordinates Automatically transformed by modelview matrix Lighting colors can be computed in either object or eye coordinates Vertex positions and viewpoint should also be in the same coordinates Translations, rotations, & scaling Output colors are clamped to [0, 1]

19 Materials describe how object surface reacts to incident light OpenGL only considers local l reflection and emission Parameters of front and back faces can be set separately GL_FRONT, GL_BACK, & GL_FRONT_AND_BACK

20 Set Ambient, Diffuse, & Specular Colors Ratio of which a color channel is reflected GLfloat afdiffuse[] = { 0.9, 0.3, 0.1, 1.0 }; glmaterialfv( GL_FRONT, GL_DIFFUSE, afdiffuse );

21 Set Emissive Color How much intensity is emitted from an object GLfloat afemission[] = { 0.1, 0.1, 0.2, 1.0 }; glmaterialfv( GL_FRONT, GL_EMISSION, afemission );

22 Set Specular Exponent Control local reflectance distributions Larger more concentrated on the reflected direction more specular

23 r P

24 Change Light & Material Properties Single Light Multiple Lights

25 Texture Mapping Simple Mapping MIP-Mapping

26 Phong Shading Gouraud Phong

27 Bump Mapping Before After

28 Rules Write code for ALL listed requirements on your own Achieve all requirements by OpenGL fixed pipeline or your own code If you really prefer shaders, contact me first for additional requirements Otherwise, no shaders are allowed in this assignment

30 Local & Global Lighting Models OpenGL Light Parameters OpenGL Material Parameters Assignment II

31 OpenGL Texture Mapping OpenGL Texture Stages Recitation of Selected Topics?

32 How to implement Phong shading when OpenGL does not support per-pixel lighting? OpenGL focuses on functionality It does not care what is your input You can DRAW anything! Input OpenGL Black Box Output

33 Prof. Wen-Chieh Lin s CG Slides OpenGL Specifications http://www.opengl.org/documentation/specs/ /d t ti / / OpenGL Programming Guide, Chap. 5 Sudhansu K. Semwal s OpenGL Tutorial http://www.cs.uccs.edu/~semwal/indexgltutorial.html Nate Robin s OpenGL Tutor Program http://www.xmission.com/~nate/tutors.html i / t /t t

34 Thank You! Any Questions?