hw1-2 review hw 3 questions?

Similar documents
INF3320 Computer Graphics and Discrete Geometry

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

Shading and Illumination

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

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

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

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

2001, Denis Zorin. Subdivision Surfaces

LIGHTING AND SHADING

Surface Rendering Methods

dq dt I = Irradiance or Light Intensity is Flux Φ per area A (W/m 2 ) Φ =

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

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

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

Illumination & Shading: Part 1

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Sung-Eui Yoon ( 윤성의 )

Why we need shading?

dq dt I = Irradiance or Light Intensity is Flux Φ per area A (W/m 2 ) Φ =

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

CS5620 Intro to Computer Graphics

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

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

Illumination and Shading

Computer Graphics. Illumination and Shading

Shading I Computer Graphics I, Fall 2008

Graphics and Visualization

Lighting and Materials

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

Color and Light CSCI 4229/5229 Computer Graphics Fall 2016

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Illumination and Shading

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

Illumination and Shading ECE 567

Light Transport Baoquan Chen 2017

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

CS Surface Rendering

Virtual Reality for Human Computer Interaction

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

The Rendering Equation. Computer Graphics CMU /15-662

Illumination and Shading

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

Introduction to Computer Vision. Introduction CMPSCI 591A/691A CMPSCI 570/670. Image Formation

CS 5625 Lec 2: Shading Models

CS-184: Computer Graphics. Today. Lecture 22: Radiometry! James O Brien University of California, Berkeley! V2014-S

CS Computer Graphics: Illumination and Shading I

CS Computer Graphics: Illumination and Shading I

Illumination. Michael Kazhdan ( /657) HB Ch. 14.1, 14.2 FvDFH 16.1, 16.2

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

Lighting. CSC 7443: Scientific Information Visualization

Lighting and Reflectance COS 426

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

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

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

Lecture 4 Advanced Computer Graphics (CS & SE )

Radiance. Radiance properties. Radiance properties. Computer Graphics (Fall 2008)

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

Reflection models and radiometry Advanced Graphics

Virtual Reality for Human Computer Interaction

Light Sources. Spotlight model

CEng 477 Introduction to Computer Graphics Fall

Understanding Variability

Global Illumination. CSCI 420 Computer Graphics Lecture 18. BRDFs Raytracing and Radiosity Subsurface Scattering Photon Mapping [Ch

Global Illumination. Global Illumination. Direct Illumination vs. Global Illumination. Indirect Illumination. Soft Shadows.

Overview. Radiometry and Photometry. Foundations of Computer Graphics (Spring 2012)

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

CSE 681 Illumination and Phong Shading

Illumination Models & Shading

Illumination in Computer Graphics

Shading 1: basics Christian Miller CS Fall 2011

w Foley, Section16.1 Reading

Electromagnetic waves and power spectrum. Rays. Rays. CS348B Lecture 4 Pat Hanrahan, Spring 2002

CS 4600 Fall Utah School of Computing

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

Comp 410/510 Computer Graphics. Spring Shading

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

6. Illumination, Lighting

CS6670: Computer Vision

Global Illumination. Global Illumination. Direct Illumination vs. Global Illumination. Indirect Illumination. Soft Shadows.

Simple Lighting/Illumination Models

Illumination. Courtesy of Adam Finkelstein, Princeton University

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

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

Illumination & Shading

CPSC / Illumination and Shading

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

CPSC 314 LIGHTING AND SHADING

Lighting. Figure 10.1

CS5670: Computer Vision

CS184 LECTURE RADIOMETRY. Kevin Wu November 10, Material HEAVILY adapted from James O'Brien, Brandon Wang, Fu-Chung Huang, and Aayush Dawra

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

Computer Graphics. Illumination and Shading

Illumination & Shading

Radiometry & BRDFs CS295, Spring 2017 Shuang Zhao

The Rendering Equation. Computer Graphics CMU /15-662, Fall 2016

CS6670: Computer Vision

Visualisatie BMT. Rendering. Arjan Kok

Light. Properties of light. What is light? Today What is light? How do we measure it? How does light propagate? How does light interact with matter?

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

Spectral Color and Radiometry

Transcription:

hw1-2 review hw 3 questions?

Lecture 6 Blending Lighting & Materials Notes on hw4

Blending combine the color value of the fragment with that of pixel in frame buffer. without blending - overwrite - opaque with (lower) alpha values - transparency, translucency

Blending Source & Destination 1. Specify how to compute source/destination factors 2. Combine using factors Source Destination Rs,Gs,Bs,As Rd,Gd,Bd,Ad E.T. 06 SR,SG,SB,SA RsSR GsSG BsSB AsSA Final + RdDR, + GdDG, + BdDB, + AdDA DR,DG,DB,DA

Blending glenable(gl_blend); glblendfunc(source_factor, destination_factor); example factors: GL_ZERO, GL_ONE, GL_DST_COLOR, GL_SRC_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA range [0,1] gldisable(gl_blend); glblendfunc(gl_one, GL_ZERO);

Blending E.T. 06 Back-to-Front, Front-to-Back Order Matters! if using z-buffer - if front object translucent overwrites z value of back opaque object - no blending. Solution disable depth buffering and draw in order make it read only when drawing translucent objects gldepthmask(gl_false) : read only gldepthmask(gl_true) : restore original

Lighting

Graphics vs. Physics Color of an object Intensity/Color of light ray Reflection Spectrum: Fraction of light of each frequency that gets reflected Radiance Distribution Intensity/Color of point light source Intensity spectrum of a point light source

Some physics... Radiometry = measuring light Photon : quantum of light with position, direction of propagation and a wavelength λ (assumption - light propogates in straight lines in isotropic medium) speed c that depends on refractive index of medium frequency f = c/λ : invariant to refractive index energy q = hf = hc/λ, h ~1e-34 Plank s constant

Light = Radiant Energy measured in joules Spectral Radiant Energy, Q = i hc λ i sun vs. single-wavelength laser amount of radiant energy per unit wavelength interval at wavelength λ measured in (joules/nm), Radiant flux (Radient power) power = energy per unit time time rate of flow of radient energy Q λ = dq dλ measured in (joules/sec, watts), Φ = dq dt

Radiant Flux Density radiant flux per unit area at a point on a surface measured in (watts/m 2 ) arriving flux - Irradiance leaving flux - Radiant exitance E = dφ in da M = dφ out da!"!!!!"! "#$%&'!()! *&&)+#),-'!!! "#$%&'!(.! /)+#),0!'1#0),-'!

Solid Angles Reminder: A regular angle θ = l R circle has 2π radians solid angle spanned by a cone is measured by the area of intersection of the cone with a sphere:!! $ % % differential solid angle can be assigned a direction. Unit: steradian (full sphere = 4"#

Radiance: Measure of Light Radiance(Luminance): Number of photons(or energy) arriving per time at a small area perpendicular to the ray from a particular direction L(ω) =!!" "! d 2 φφ cos θdadω =!"!"#" $%"&'!(')*+%'+ watt m 2 steradians!! *!" Physical quantity equivalent to psychological concept of brightness as observed by us.!# " "

Constancy of Radiance radiance is constant along a ray: consider the flow of photons in a a thin pencil; the number of photons entering onthe right with the direction inside &",! exit through the other side; equating the expressions for entering and exiting diff. flows we get &!! # #! &"! &'! # # " &" " &' " # &! " but &'! &"! # &' " &" " so #! # # "! 2005 Denis Zorin

Local illumination model Describes interaction of the light and the surface! light can be reflected, absorbed and transmitted! most important: reflection! reflection can be ideal specular, diffuse and and anything between! reflection equation relates the outgoing radiance in some direction to the incoming radiance! 2005 Denis Zorin

Once again, radiance: L(ω, L(ω) θ) = d 2 φφ cos θdadω = watt m 2 steradians and irradiance (flux density incoming energy per area) E = dφ in da E(ω, θ) = L(ω, θ) cos θdω = watt m 2

BRDF Bidirectional Reflectance Distribution Function E.T. 06 ( ) reflected radiance exiting a surface in direction r irradiance incident on the surface from direction i ( ) ians -1! " " " "!!! %& f(ω i, ω r ) = L r(ω r, θ r ) E i (ω i, θ i ) unit : steradians -1

Reflection equation the outgoing radiance in direction r is the sum of the radiances due to radiance from all incoming directions:! "!! " " #! # "!! $ %! " "! $!! $ " $%& " $ &! $ the integral is over the upper hemisphere! " " " "! %&!!! 2005 Denis Zorin

Reflection geometry V: direction to the eye surface N: normal R: reflected diection L: direction to the light source R = 2(N,V)N - V! 2005 Denis Zorin

Snell s law If a surface separates two media with different refraction indices (e.g. air and water) the light rays change direction when they go through. Snell s law: the refracted ray is stays in the plane spanned by the normal and the direction of the original ray. The angles between the normal and the rays are related by!!!"#!! $! "!"#! " where! " and! # are refraction indices. normal!!! 2005 Denis Zorin!"

Refracted ray direction V N!!! $!!! $!!" % T! "!!&"$ #'! " # (!! " &(! &"$ #' " ' #! "! 2005 Denis Zorin

Illumination model Two main components:! light source characteristics! position! intensity for each freq. (color) often, different intensity can be specified for different colors! directional distribution! surface properties! reflectance for each freq. (color)! different reflectance can be specified for diffuse and specular light! 2005 Denis Zorin

And now graphics...

Local lighting model Describes interaction of the light with the surface. Almost never truly based on physics: perception plays a greater role. Visible light: electromagnetic waves, with wavelengths 400nm (violet) - 700nm (red); intensity can vary over many orders of magnitude. Computer model: only three frequencies : RGB, intensity varies over a small range, typically only 255 discrete values/ color.! 2005 Denis Zorin

Perception Perceptual response to light with an arbitrary spectrum = Perceptual response produced by a linear combination of 3 primary wavelengths. (R,G,B)

A simple model In the model commonly used in graphics applications, there are several components! diffuse relection: intensity does not depend on the direction to the viewer! specular: simulates relective surfaces and specular highlights depending on the direction to the viewer! ambient: a crude approximation to the illumination created by the light diffusely reflected from surfaces emissive: simulation of light originating from objects! 2005 Denis Zorin

Diffuse (Lambertian) Component Lambert s Cosine Law : Color intensity is prop. to the cosine of the angle between surface normal and direction to light source l http://escience.anu.edu.au/lecture/cg/illumination/lambertcosinelaw.en.html θ n Ld cos θ Ld (n l) Ld = ld sd (n l) Ld = ld sd max(0,(n l)) (or = ld sd n l ) Does not depend on view direction = scatters the same way in all directions

Diffuse (Lambertian) Component E.T. 06 Light comes from one direction Brighter if perpendicular to surface Once hits surface, scattered equally

Ambient Component La = la sa Scattered light in the environment Seems to come from all directions When ambient light hits a surface, it s scattered in all directions

Specular(Phong) Component Highlights - part of surface where α=0 brightest highlight. There s also brightness when α small. l θ θ n α r e need a function s.t. it s high when r=e and gradually falls off as r gets away from e. lsss(e r) too large area, can be negative r = 2(l n)n-l Ls = lsssmax(0, e r) p

Specular(Phong) Component Light comes from a particular direction Bounces off surface at a preferred direction Shininess Mirror - light from source reaches the eye only if r=e

Specular reflection p = 0 p = 1 p = 2 p = 10 p = 25 p = 100! 2005 Denis Zorin

Metal vs. plasitic Natural look of metallic surfaces is difficult to simulate, but the first approximation is obtained using proper highlight color. For plastic objects, highlights are close in color to the color of the light. For metals, to the color of the surface. Assuming white lights, for plastic set k spec =[c,c,c], where c is a constant, for more metallic look set k spec = k diff! 2005 Denis Zorin plastic look metallic look

Emissive Component simulates light originating from objects (ex: light bulb) is not effected by any other light does not add to light in the scene Le = se

Attenuation In real life: Radiance goes down by 1/r2 Ex: Stars vs. Sun Due to approximations inverse-square law results in very dark images Solution : Let the user choose the attenuation factors (a,b,c) 1/(a + br + cr 2 ) E.T. 06 Default - (1,0,0) - no attenuation

Complete Equation Ld = ld sd max(0,(n l)) La = la sa Ls = ls ss max(0, (e r)) p A = 1/(a + br + cr 2 ) Total Radiance L = A(La + (Ld + Ls))

OpenGL Lighting Model Color of light source depends on amounts of red/green/blue light it emits Ambient Diffuse Specular Emissive

OpenGL Materials Approximate color of material based on percentage of incoming light color it reflects Ex. Red ball - in white light Red ball - in red light Red ball - in green light

RGB Values Lights vs. Materials Materials (R M, GM, BM) reflected percentage Ex. (1,1,0) - reflects all red, all blue, no green Light (R L, GL, BL) percentage of full intensity Ex. (1,1,1) brightest white, (.5,.5,.5 ) gray E.T. 06 The color we see is given by: RL*RM + GL*GM + BL*BM

OpenGL Steps 1. Define normal vectors for each vertex of all objects 2. Create/Select/Position one or more light sources 3. Create/Select a Lighting Model 4. Define material properties for the objects in the scene

Normals Orientation relative to light sources ( = how much light will it get) all normals must be of unit length glenable(gl_normalize) glenable(gl_rescale_normal) (Normal must have been scaled uniformly and must have been unit initially.)

Vertex vs. Face Normals Smooth (Gouraud) vs. Flat Shading There s also Phong Shading

OpenGL Steps 1. Define normal vectors for each vertex of all objects 2. Create/Select/Position one or more light sources 3. Create/Select a Lighting Model 4. Define material properties for the objects in the scene

gllight(light, pname, param) GL_LIGHT0, GL_LIGHT1,... GL_LIGHT8 Note: Default values for lights 1-8 Color: GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR Position: GL_POSITION (Directional/Positional Light) Spotlight Parameters (direction, angle) Attenuation Parameters (constant, linear, quadratic) E.T. 06

OpenGL Steps 1. Define normal vectors for each vertex of all objects 2. Create/Select/Position one or more light sources 3. Create/Select a Lighting Model 4. Define material properties for the objects in the scene

Lighting Model gllightmodel(pname, param) Global Ambient Light Intensity(.2,.2,.2,1.) GL_LIGHT_MODEL_AMBIENT Viewpoint - local to scene or at infinity(*) GL_LIGHT_MODEL_LOCAL_VIEWER Lighting - front(*) and back faces of objects GL_LIGHT_MODEL_TWO_SIDE Specular separate or not(*) GL_LIGHT_MODEL_COLOR_CONTROL (param = GL_SEPARATE_SPECULAR_COLOR for correct texturing)

Enabling Lighting glenable(gl_lighting); After parameter specifications for light: glenable(gl_light0);

OpenGL Steps 1. Define normal vectors for each vertex of all objects 2. Create/Select/Position one or more light sources 3. Create/Select a Lighting Model 4. Define material properties for the objects in the scene

Material Properties glmaterial(face, pname, param) GL_FRONT GL_AMBIENT GL_BACK GL_DIFFUSE GL_FRONT_AND_BACK GL_SPECULAR GL_SHININESS GL_EMISSION call before glbegin()..glend() sequence - just like glcolor A Possibly Faster Method : glenable(gl_color_material); glcolormaterial(face, pname) glcolor(.1,.1,.1,.1)

Final Color Computation Vertex Color = material emission at vertex + global ambient light * material ambient property + attenuated combination of ambient, diffuse and specular contributions from each light source

Final Color Computation Vertex Color = material emission at vertex glmaterial : GL_EMISSION E.T. 06 GL_LIGHT_MODEL_AMBIENT glmaterial : GL_AMBIENT + global ambient light * material ambient property GL_CONSTANT/LINEAR/ QUADRATIC_ATTENUATION + attenuated combination of ambient, diffuse and specular contributions from each light source gllight: GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR

Hw3 help

light positioning tips compute difference in x and y in screen coords. computing motion in world coordinates right/left direction : vector s = up x view up/down direction: vector t = view x s in/out direction : view vector