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

Similar documents
OpenGL Lighting Computer Graphics Spring Frank Palermo

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

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

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Illumination Models & Shading

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

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

Illumination and Shading

Comp 410/510 Computer Graphics. Spring Shading

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

Pipeline Operations. CS 4620 Lecture 14

CPSC 314 LIGHTING AND SHADING

Computer Graphics. Illumination and Shading

The Rasterization Pipeline

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Illumination and Shading

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

CS 325 Computer Graphics

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

Color and Light CSCI 4229/5229 Computer Graphics Fall 2016

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

CS5620 Intro to Computer Graphics

surface: reflectance transparency, opacity, translucency orientation illumination: location intensity wavelength point-source, diffuse source

Illumination and Shading

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

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

University of Victoria CSC 305 Shading. Brian Wyvill 2016

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

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

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

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

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

Shading 1: basics Christian Miller CS Fall 2011

Computer Graphics MTAT Raimond Tunnel

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

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

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

Shading II. CITS3003 Graphics & Animation

Illumination & Shading

CPSC / Illumination and Shading

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

Shading. Brian Curless CSE 457 Spring 2017

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

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

Introduction to Computer Graphics 7. Shading

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

CS 4600 Fall Utah School of Computing

Shading I Computer Graphics I, Fall 2008

w Foley, Section16.1 Reading

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

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

Illumination & Shading I

CS 130 Final. Fall 2015

CS770/870 Spring 2017 Color and Shading

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

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

Pipeline Operations. CS 4620 Lecture 10

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

Computer Graphics Coursework 1

Simple Lighting/Illumination Models

Chapter 10. Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL

CEng 477 Introduction to Computer Graphics Fall

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

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

Virtual Reality for Human Computer Interaction

Interactive Real-Time Raycasting

Computer Graphics. Illumination and Shading

From Graphics to Visualization

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

7: Rendering (1) COMP Computer Graphics and Image Processing. Local illumination model. Global illumination model. Direct Direct.

Lab 9 - Metal and Glass

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

Illumination & Shading: Part 1

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

Graphics for VEs. Ruth Aylett

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

INF3320 Computer Graphics and Discrete Geometry

Objectives. Shading II. Distance Terms. The Phong Reflection Model

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

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

Complex Shading Algorithms

Illumination in Computer Graphics

Introduction to Visualization and Computer Graphics

CS452/552; EE465/505. Intro to Lighting

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

Homework 3: Programmable Shaders

Deferred Rendering Due: Wednesday November 15 at 10pm

Visualisatie BMT. Rendering. Arjan Kok

Shading. Brian Curless CSE 557 Autumn 2017

Reflection and Shading

Computer Graphics I Lecture 11

Illumination. The slides combine material from Andy van Dam, Spike Hughes, Travis Webb and Lyn Fong

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

Lighting and Materials

Raytracing CS148 AS3. Due :59pm PDT

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

Graphics for VEs. Ruth Aylett

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

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

Models and Architectures

Transcription:

-=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? A per-vertex unit vector Interpolated to per-fragment If all per-vertex normals on triangle face the same way Flat face shading If each per-vertex normal is average of surrounding faces Smoothed face shading Usually calculated for a face Flat shading Smooth shading

Literature Bui Tuong Phong's PhD thesis Illumination for computer generated pictures, 1973 U.Utah Also describes a per-pixel shading method Phong Shading James Blinn Models of light reflection for computer synthesized pictures proc. CGIT, 1977 Blinn-Phong was the built-in default lighting method in older GL and D3D

Background Realistic lighting models based on Optics (physics of light) Radiosity consider energy absorption by surfaces Light rays that reflect/refract on multiple surfaces Hence global illumination Expensive to calculate

Background Real-time rendering favours quick approximations Local illumination techniques (only consider one surface) Diminishing colour with distance from view (Doom) Manually pre-setting colour of world areas (DN3D) We still do this with pre-rendered light maps Mixture of light maps and dynamic lighting (Quake) Introduce some GI techniques?

Shading Models Per-Facet Gouraud (per-vertex and then interpolated) Henri Gouraud "Continuous shading of curved surfaces" (1971), Phong (per-pixel or per-fragment) Q. Where would we code each of these? demos

Ambient Lighting Approximate accumulation of general background light reflections by a single number Too hard everything gets +(0.1,0.1,0.1)

Ambient Reflection i_a = l_a * k_a vec3 l_a = vec3 (0.2, 0.2, 0.2); vec3 k_a = vec3 (1.0, 0.0, 0.0); Light's ambient colour Reflection / material colour

Diffuse Reflection (Lambertian Reflectance) Approximate light hitting surface and scattering in all directions Optics model Johann Heinrich Lambert, Photometria, 1760. As surface is perpendicular to light = most reflective Parallel to light = not reflective at all Q. How can we calculate this angle/factor idea? Incident light diffuse (scattered) Note: perfect (equal) diffusion is assumed

The Vector Dot-Product Gives cosine of angle between 2 vectors Perpendicular = 0 n light_dir Parallel, same direction = 1 Parallel, opposing directions = -1 No notion of left/right side Q. Angle between light and surface? Normalise vectors first!

Diffuse Reflection i_d = l_d * k_d * dot (-light_dir, n) vec3 l_d = vec3 (0.8, 0.8, 0.8); vec3 k_d = vec3 (1.0, 0.0, 0.0); Make sure d.prod >= 0.0

Specular Reflection Model Approximate light that hits surface and entirely reflects in one direction, around the normal (like a billiard ball) Smoother surfaces = shinier = more specular reflection Intensity is 1.0 when reflecting directly into eye Intensity is 0.0 when reflection is perpendicular to eye

Specular Reflection i_s = l_s * k_s * pow (dot (r, v), spec_exp) vec3 l_s = vec3 (1.0, 1.0, 1.0); vec3 k_s = vec3 (1.0, 1.0, 1.0);

Specular Reflection incident light, light_dir reflected light, r n vector to viewer, v Work out r and v, dot product of them to get factor When reflected light points right into eye = full specular There is also an exponent which we can adjust

Specular Highlights Exponent = 100 Exponent = 10

Phong Lighting is the Sum i = i_a + i_d + i_s

Blinn-Phong Lose a small amount of accuracy in specular equation Little bit cheaper to calculate Replace reflect() with a half-way vector: vec3 h = normalize (v - light_dir); vec3 I_s = l_s * k_s * pow (dot (h, n), spec_exp); incident light, light_dir n h reflected light, r vector to viewer, v

Blinn-Phong Reduces specular power by about half > double the exponent

[Somewhat rhetorical] Questions Q. How can we model a non-shiny surface? Q. Is any real surface completely matte? Q. What is physically inaccurate about Phong lighting? Q. Do any real surfaces have a non-white specular colour? Q. What is missing from this lighting model to make it convincing?

Pause If this is the last slide: Do a Phong tutorial Read any of the textbook chaps. Phong lighting Shading models More advanced / general lighting Global versus local illumination

Materials and Textures Q. How can we combine textures with Phong lighting?

Warning: Corrupted Normals Q. Why should we never apply a un-equal scaling to a normal? Q. How can we avoid this? Create a separate model matrix with just the rotations normal matrix or Take inverse (transpose (model_matrix) instead or Don't do lighting on things with uneven scaling or Don't ever do uneven scaling

Warning: Negative dot products Sometimes a dot-product produces a negative number Q. When does this happen? Q. What unwanted visual effect would a negative dot-product give us? To avoid this: float result = max (0.0, dot (a, b));

Point / Directional / Spot Lights Were built-in Spotlight (Webb?)

Gamma Correction Colours and voltages Don't correct textures srgb colour palette

Gamma Correction colour = pow (colour, vec3 (2.2, 2.2, 2.2)); Gives you the full range of colour intensities on your display

Questions Q. More than one light? How? Q. Problems with that?

Further Reading Do a Phong lighting tutorial first Challenge: Can you figure out how to roll-off the light with distance? Deferred lighting and deferred shading, G-buffers BDRF Radiosity