Illumination Models & Shading

Total Page:16

File Type:pdf, Size:1020Kb

Illumination Models & Shading CS5620 Illumination Models Intro to Computer Graphics and Shading Illumination Models So Far … and Shading wireframe hidden surfaces Next step… 1 2 What’s Missing ? Lighting vs. Shading • Light ! • Lighting – Interaction between materials and light sources • Need to understand: – Physics – How lighting works Zbuffer(Scene) • Types of lights • Shading … • Types of surfaces – Determining the color of a pixel putColor(x,y,col(P)) – Computer graphics … end – How shading works • • Shading usually determined by Shading algorithms lighting 3 4 The Physics Local vs. Global Illumination Model Basic Illumination Model Light rays are emitted from light sources and • Local bounce (reflect) in the scene until they reach the – only direct and local interaction eye of objects with light • Global – all interactions and exchange of light – Can model more effects • Reflection, refraction, soft shadows 5 6 Copyright C. Gotsman, G. Elber, M. Ben-Chen Page 1 Computer Science Dept., Technion CS5620 Illumination Models Intro to Computer Graphics and Shading Local vs. Global A Single Interaction What determines pixel color? Type of light Object color Object surface material Object geometry 7 8 Light Sources Material Properties • Point: All light originates at a point – Rays hit planar surface at different incidence • Specular angles – Smooth surface • Directional: All light rays are parallel – Rays hit a planar surface at identical – Reflects light at well-defined angle incidence angles – May be modeled as point source at infinity – Also called parallel source • • Area: Light originates at finite area in space Diffuse – In between the point and parallel sources – Rough surface – Also called distributed source – Reflects light equally in all directions • Ambient: Background light – Comes equally from all directions 9 10 Light/Reflection Types Phong Reflection Model • Local illumination model • Looking for a value I(p) per point on the surface • Represents the total contribution of all lights in the scene • Takes into consideration – Position of the viewer – Position of the lights – Color of the lights – … 11 12 Copyright C. Gotsman, G. Elber, M. Ben-Chen Page 2 Computer Science Dept., Technion CS5620 Illumination Models Intro to Computer Graphics and Shading Some Notation Ambient Reflection • I – direction to light source • Assume non-directional light in the environment • n – normal direction • Object illuminated with same light everywhere – Looks like a silhouette • v – direction to COP (eye, camera) 퐼푎 = 푘푎퐿푎 푘푎 : fraction of ambient light reflected from surface • r – direction of reflected ray 퐿푎: ambient light intensity • Defines object’s color 13 14 Diffuse Reflection Diffuse Reflection • Dull surfaces such as solid matte plastic reflects • How does the light direction affect the illumination? incoming light uniformly in all directions • Larger angle with normal less illumination density • Called diffuse or Lambertian reflection Fully Partially illuminated illuminated 15 16 Diffuse Reflection Specular Reflection • Shiny objects (e.g. metallic) reflect light in 푘푑 : fraction of diffuse light preferred direction 푟 determined by surface reflected from surface 퐼푑 = 푘푑(푙 ⋅ 푛)퐿푑 normal 푛. 퐿푑: diffuse light intensity 푙 ⋅ 푛 = cos 휃 17 18 Copyright C. Gotsman, G. Elber, M. Ben-Chen Page 3 Computer Science Dept., Technion CS5620 Illumination Models Intro to Computer Graphics and Shading Specular Reflection Specular Reflection • Most objects are not ideal mirrors – also 퐼 = 푘 푟 ⋅ 푣 훼퐿 reflect in the immediate vicinity of 푟 푘푠 : fraction of specular light 푠 푠 푠 reflected from surface 퐿푠 • Approximate attenuation 퐿 : diffuse light intensity by cos훼 푠 (no real physical basis) 퐿푠 푟 ⋅ 푣 = cos 훼 : shininess coefficient 19 20 Specular Reflection Total Illumination • Exponent 훼 of cosine controls decay factor • 퐼 = 퐼푎 + 퐼푑 + 퐼푠 • Sum over all light sources • No physical basis, • May use different coefficients for RGB components but looks good • Beware of overflows 21 22 Triangle Shading Algorithms Flat Shading • Applied to piecewise linear • Given the lights and materials in the scene, polygonal models • Simple surface lighting how do we compute the color at a given point approximated over polygons on a triangle ? • Illumination value depends only on polygon normal each polygon is colored with a uniform intensity • Three main types • Looks non-smooth (worsened by – Flat shading (per polygon) Mach band effect) – Gouraud shading (per vertex) – Phong shading (per pixel) 23 24 Copyright C. Gotsman, G. Elber, M. Ben-Chen Page 4 Computer Science Dept., Technion CS5620 Illumination Models Intro to Computer Graphics and Shading Normal per Vertex Gouraud Shading • Compute illumination intensity at vertices using normals • Linearly interpolate intensity over polygon interior If a polyhedron is an approximation of smooth surface: • Assign to each vertex the normal of original surface at that point • If surface is not available use estimated normal (e.g. average of neighboring faces). 25 26 Gouraud Shading Phong Shading Linearly interpolate lighting intensities at the vertices over • Interpolate (at the vertices in image space) normal vectors interior pixels of the polygon, in the image plane instead of illumination intensities • Apply the illumination equation for each interior pixel with its c1 c12 t 12 c 1 (1 t 12 ) c 2 c13 t 13 c 1 (1 t 13 ) c 3 own (interpolated) normal n scanline Y=y 1 n12 t 12 n 1 (1 t 12 ) n 2 n13 t 13 n 1 (1 t 13 ) n 3 (,)xy scanline Y=y c 3 c2 n3 c( x , y ) t123 c 12 (1 t 123 ) c 13 n2 Question: Can Gouraud shading support specular lighting? n(,) x y t123 n 12 (1 t 123 ) n 13 ;(,) c x y Illum ((,)) n x y 27 28 Comparison Comparison phong flat gourard flat gourard phong 29 30 Copyright C. Gotsman, G. Elber, M. Ben-Chen Page 5 Computer Science Dept., Technion CS5620 Illumination Models Intro to Computer Graphics and Shading Gourard 31 Copyright C. Gotsman, G. Elber, M. Ben-Chen Page 6 Computer Science Dept., Technion .
Recommended publications
  • Opengl 4.0 Shading Language Cookbook
    OpenGL 4.0 Shading Language Cookbook Over 60 highly focused, practical recipes to maximize your use of the OpenGL Shading Language David Wolff BIRMINGHAM - MUMBAI OpenGL 4.0 Shading Language Cookbook Copyright © 2011 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: July 2011 Production Reference: 1180711 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-849514-76-7 www.packtpub.com Cover Image by Fillipo ([email protected]) Credits Author Project Coordinator David Wolff Srimoyee Ghoshal Reviewers Proofreader Martin Christen Bernadette Watkins Nicolas Delalondre Indexer Markus Pabst Hemangini Bari Brandon Whitley Graphics Acquisition Editor Nilesh Mohite Usha Iyer Valentina J. D’silva Development Editor Production Coordinators Chris Rodrigues Kruthika Bangera Technical Editors Adline Swetha Jesuthas Kavita Iyer Cover Work Azharuddin Sheikh Kruthika Bangera Copy Editor Neha Shetty About the Author David Wolff is an associate professor in the Computer Science and Computer Engineering Department at Pacific Lutheran University (PLU).
    [Show full text]
  • Phong Shading
    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 dimension. • Need to portray planar, curved, textured, translucent, etc. surfaces. • Model light and shadow. Depth Cues Eliminate hidden parts (lines or surfaces) Front? “Wire-frame” Back? Convex? “Opaque Object” Concave? Why we need shading • Suppose we build a model of a sphere using many polygons and color it with glColor. We get something like • But we want Shading implies Curvature Shading Motivation • Originated in trying to give polygonal models the appearance of smooth curvature. • Numerous shading models – Quick and dirty – Physics-based – Specific techniques for particular effects – Non-photorealistic techniques (pen and ink, brushes, etching) Shading • Why does the image of a real sphere look like • Light-material interactions cause each point to have a different color or shade • Need to consider – Light sources – Material properties – Location of viewer – Surface orientation Wireframe: Color, no Substance Substance but no Surfaces Why the Surface Normal is Important Scattering • Light strikes A – Some scattered – Some absorbed • Some of scattered light strikes B – Some scattered – Some absorbed • Some of this scattered light strikes A and so on Rendering Equation • The infinite scattering and absorption of light can be described by the rendering equation – Cannot be solved in general – Ray tracing is a special case for
    [Show full text]
  • CS488/688 Glossary
    CS488/688 Glossary University of Waterloo Department of Computer Science Computer Graphics Lab August 31, 2017 This glossary defines terms in the context which they will be used throughout CS488/688. 1 A 1.1 affine combination: Let P1 and P2 be two points in an affine space. The point Q = tP1 + (1 − t)P2 with t real is an affine combination of P1 and P2. In general, given n points fPig and n real values fλig such that P P i λi = 1, then R = i λiPi is an affine combination of the Pi. 1.2 affine space: A geometric space composed of points and vectors along with all transformations that preserve affine combinations. 1.3 aliasing: If a signal is sampled at a rate less than twice its highest frequency (in the Fourier transform sense) then aliasing, the mapping of high frequencies to lower frequencies, can occur. This can cause objectionable visual artifacts to appear in the image. 1.4 alpha blending: See compositing. 1.5 ambient reflection: A constant term in the Phong lighting model to account for light which has been scattered so many times that its directionality can not be determined. This is a rather poor approximation to the complex issue of global lighting. 1 1.6CS488/688 antialiasing: Glossary Introduction to Computer Graphics 2 Aliasing artifacts can be alleviated if the signal is filtered before sampling. Antialiasing involves evaluating a possibly weighted integral of the (geometric) image over the area surrounding each pixel. This can be done either numerically (based on multiple point samples) or analytically.
    [Show full text]
  • FAKE PHONG SHADING by Daniel Vlasic Submitted to the Department
    FAKE PHONG SHADING by Daniel Vlasic Submitted to the Department of Electrical Engineering and Computer Science in Partial Fulfillment of the Requirements for the Degrees of Bachelor of Science in Computer Science and Engineering and Master of Engineering in Electrical Engineering and Computer Science at the Massachusetts Institute of Technology May 17, 2002 Copyright 2002 M.I.T. All Rights Reserved. Author ________________________________________________________ Department of Electrical Engineering and Computer Science May 17, 2002 Approved by ___________________________________________________ Leonard McMillan Thesis Supervisor Accepted by ____________________________________________________ Arthur C. Smith Chairman, Department Committee on Graduate Theses FAKE PHONG SHADING by Daniel Vlasic Submitted to the Department of Electrical Engineering and Computer Science May 17, 2002 In Partial Fulfillment of the Requirements for the Degrees of Bachelor of Science in Computer Science and Engineering And Master of Engineering in Electrical Engineering and Computer Science ABSTRACT In the real-time 3D graphics pipeline framework, rendering quality greatly depends on illumination and shading models. The highest-quality shading method in this framework is Phong shading. However, due to the computational complexity of Phong shading, current graphics hardware implementations use a simpler Gouraud shading. Today, programmable hardware shaders are becoming available, and, although real-time Phong shading is still not possible, there is no reason not to improve on Gouraud shading. This thesis analyzes four different methods for approximating Phong shading: quadratic shading, environment map, Blinn map, and quadratic Blinn map. Quadratic shading uses quadratic interpolation of color. Environment and Blinn maps use texture mapping. Finally, quadratic Blinn map combines both approaches, and quadratically interpolates texture coordinates. All four methods adequately render higher-resolution methods.
    [Show full text]
  • Interactive Refractive Rendering for Gemstones
    Interactive Refractive Rendering for Gemstones LEE Hoi Chi Angie A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Master of Philosophy in Automation and Computer-Aided Engineering ©The Chinese University of Hong Kong Jan, 2004 The Chinese University of Hong Kong holds the copyright of this thesis. Any person(s) intending to use a part of whole of the materials in the thesis in a proposed publication must seek copyright release from the Dean of the Graduate School. 统系绍¥圖\& 卿 15 )ij UNIVERSITY —肩j N^Xlibrary SYSTEM/-^ Abstract Customization plays an important role in today's jewelry design industry. There is a demand on the interactive gemstone rendering which is essential for illustrating design layout to the designer and customer interactively. Although traditional rendering techniques can be used for generating photorealistic image, they require long processing time for image generation so that interactivity cannot be attained. The technique proposed in this thesis is to render gemstone interactively using refractive rendering technique. As realism always conflicts with interactivity in the context of rendering, the refractive rendering algorithm need to strike a balance between them. In the proposed technique, the refractive rendering algorithm is performed in two stages, namely the pre-computation stage and the shading stage. In the pre-computation stage, ray-traced information, such as directions and positions of rays, are generated by ray tracing and stored in a database. During the shading stage, the corresponding data are retrieved from the database for the run-time shading calculation of gemstone. In the system, photorealistic image of gemstone with various cutting, properties, lighting and background can be rendered interactively.
    [Show full text]
  • Flat Shading
    Shading Reading: Angel Ch.6 What is “Shading”? So far we have built 3D models with polygons and rendered them so that each polygon has a uniform colour: - results in a ‘flat’ 2D appearance rather than 3D - implicitly assumed that the surface is lit such that to the viewer it appears uniform ‘Shading’ gives the surface its 3D appearance - under natural illumination surfaces give a variation in colour ‘shading’ across the surface - the amount of reflected light varies depends on: • the angle between the surface and the viewer • angle between the illumination source and surface • surface material properties (colour/roughness…) Shading is essential to generate realistic images of 3D scenes Realistic Shading The goal is to render scenes that appear as realistic as photographs of real scenes This requires simulation of the physical processes of image formation - accurate modeling of physics results in highly realistic images - accurate modeling is computationally expensive (not real-time) - to achieve a real-time graphics pipeline performance we must compromise between physical accuracy and computational cost To model shading requires: (1) Model of light source (2) Model of surface reflection Physically accurate modelling of shading requires a global analysis of the scene and illumination to account for surface reflection between surfaces/shadowing/ transparency etc. Fast shading calculation considers only local analysis based on: - material properties/surface geometry/light source position & properties Physics of Image Formation Consider the
    [Show full text]
  • An Importance Sampling Method for Arbitrary Brdfs Used in Global Illumination Applications
    UNIVERSITY OF GRANADA Postgraduate Programme in Software Systems Development Departament of Lenguajes y Sistemas Inform´aticos An Importance Sampling Method for arbitrary BRDFs used in Global Illumination Applications Ph.D. Thesis Dissertation (for european mention) presented by Rosana Montes Soldado Advisor Carlos Ure na˜ Almagro Granada. June, 2008 Editor: Editorial de la Universidad de Granada Autor: Rosana Montes Soldado Nº REGISTRO: 11/45216 ISBN: 978-84-694-3302-7 To my parents Antonio and Maria Abstract Nowadays there are many applications in the real world for Global Illumination algorithms. From modern movies’ special effects to the design of interior lighting, and even amazing video games. The scattering of light in an environment create an interesting effect on a surface: a distinctive quality of many materials. In this sense the BRDF function captures the behaviour of light when it arrives on a surface and reflects in several directions. Our main objective of this work involves obtaining visually realistic images from computers, that accomplish a simulation of the propagation of light with numerical calculations [Mil84, WRC88, GSCH93, GTGB84, CWH93] using programs. The use of these algorithms allow us to obtain images with a more natural aspect, similar to the photographs. It is possible to simulate these characteristics with a computer using Global Illumination algorithms [Whi80, CPC84, Kaj86, WH92], that are based on following a ray path applying Monte Carlo’s method. Often these calculations present high run times, therefor we tried to implement efficient techniques suitable for them. In addition, Monte Carlo’s algorithms carry an intrinsic error in the estimator, that it is corrected using many more random samples.
    [Show full text]
  • Ray Casting Architectures for Volume Visualization
    MITSUBISHI ELECTRIC RESEARCH LABORATORIES http://www.merl.com Ray Casting Architectures for Volume Visualization Harvey Ray, Hanspeter Pfister, Deborah Silver, Todd A. Cook TR99-17 April 1999 Abstract Real-time visualization of large volume datasets demands high performance computation, push- ing the storage, processing, and data communication requirements to the limits of current tech- nology. General purpose parallel processors have been used to visualize moderate size datasets at interactive frame rates; however, the cost and size of these supercomputers inhibits the widespread use for real-time visualization. This paper surveys several special purpose architectures that seek to render volumes at interactive rates. These specialized visualization accelerators have cost, per- formance, and size advantages over parallel processors. All architectures implement ray casting using parallel and pipelined hardware. We introduce a new metric that normalizes performance to compare these architectures. The architectures included in this survey are VOGUE, VIRIM, Array Based Ray Casting, EM-Cube, and VIZARD II. We also discuss future applications of special purpose accelerators. IEEE Transactions on Visualization and Computer Graphics This work may not be copied or reproduced in whole or in part for any commercial purpose. Permission to copy in whole or in part without payment of fee is granted for nonprofit educational and research purposes provided that all such whole or partial copies include the following: a notice that such copying is by permission of Mitsubishi Electric Research Laboratories, Inc.; an acknowledgment of the authors and individual contributions to the work; and all applicable portions of the copyright notice. Copying, reproduction, or republishing for any other purpose shall require a license with payment of fee to Mitsubishi Electric Research Laboratories, Inc.
    [Show full text]
  • Shading and Rendering
    Chapter 7 - Shading and Rendering • Local Illumination Models: Shading • Global Illumination: Ray Tracing • Global Illumination: Radiosity • Non-Photorealistic Rendering Literature: H.-J. Bungartz, M. Griebel, C. Zenger: Einführung in die Computergraphik, 2. Auflage, Vieweg 2002 LMU München – Medieninformatik – Andreas Butz – Computergrafik 1 – SS2015 – Kapitel 7 1 ! The 3D rendering pipeline (our version for this class) 3D models in 3D models in world 2D Polygons in Pixels in image model coordinates coordinates camera coordinates coordinates Scene graph Camera Rasterization Animation, Lights Interaction LMU München – Medieninformatik – Andreas Butz – Computergrafik 1 – SS2015 – Kapitel 7 2 ! Local Illumination: Shading • Local illumination: – Light calculations are done locally without the global scene – No cast shadows (since those would be from other objects, hence global) – Object shadows are OK, only depend on the surface normal ! • Simple idea: Loop over all polygons • For each polygon: – Determine the pixels it occupies on the screen and their color – Draw using e.g., Z-buffer algorithm to get occlusion right ! • Each polygon only considered once • Some pixels considered multiple times • More efficient: Scan-line algorithms LMU München – Medieninformatik – Andreas Butz – Computergrafik 1 – SS2015 – Kapitel 7 3 ! Scan-Line Algorithms in More Detail • Polygon Table (PT): – List of all polygons with plane equation parameters, color information and inside/outside flag (see rasterizaton) ! • Edge Table (ET): – List of all non-horizontal
    [Show full text]
  • Appendix: Graphics Software Took
    Appendix: Graphics Software Took Appendix Objectives: • Provide a comprehensive list of graphics software tools. • Categorize graphics tools according to their applications. Many tools come with multiple functions. We put a primary category name behind a tool name in the alphabetic index, and put a tool name into multiple categories in the categorized index according to its functions. A.I. Graphics Tools Listed by Categories We have no intention of rating any of the tools. Many tools in the same category are not necessarily of the same quality or at the same capacity level. For example, a software tool may be just a simple function of another powerful package, but it may be free. Low4evel Graphics Libraries 1. DirectX/DirectSD - - 248 2. GKS-3D - - - 278 3. Mesa 342 4. Microsystem 3D Graphic Tools 346 5. OpenGL 370 6. OpenGL For Java (GL4Java; Maps OpenGL and GLU APIs to Java) 281 7. PHIGS 383 8. QuickDraw3D 398 9. XGL - 497 138 Appendix: Graphics Software Toois Visualization Tools 1. 3D Grapher (Illustrates and solves mathematical equations in 2D and 3D) 160 2. 3D Studio VIZ (Architectural and industrial designs and concepts) 167 3. 3DField (Elevation data visualization) 171 4. 3DVIEWNIX (Image, volume, soft tissue display, kinematic analysis) 173 5. Amira (Medicine, biology, chemistry, physics, or engineering data) 193 6. Analyze (MRI, CT, PET, and SPECT) 197 7. AVS (Comprehensive suite of data visualization and analysis) 211 8. Blueberry (Virtual landscape and terrain from real map data) 221 9. Dice (Data organization, runtime visualization, and graphical user interface tools) 247 10. Enliten (Views, analyzes, and manipulates complex visualization scenarios) 260 11.
    [Show full text]
  • Computação Gráfica Computer Graphics Engenharia Informática (11569) – 3º Ano, 2º Semestre
    Computação Gráfica Computer Graphics Engenharia Informática (11569) – 3º ano, 2º semestre Chap. 9 – Shading http://di.ubi.pt/~agomes/cg/09-shading.pdf T09 Shading Outline Based on https://www.cs.unc.edu/~dm/UNC/COMP236/LECTURES/LightingAndShading.ppt …: – Light-dependent illumination models: a refresher – Shading: motivation – Types of shading: flat, Gouraud, and Phong – Flat shading algorithm – Gouraud shading algorithm – Phong shading algorithm – Shading issues – Flat, Gouraud, and Phong shaders in GLSL – OpenGL/GLSL examples. T09 Shading Light-dependent models: a refresher stills.htm / raygallery / raytracer Direct (or local) illumination: /~johns/ – Simple interaction between light and objects jedi.ks.uiuc.edu – Real-time process supported by OpenGL http:// l – Example: Phong’s illumination model. Indirect (or global) illumination: – Multiple interactions between light and objects (e.g., inter-object reflections, refraction, and shadows) – It is a real-time process for small scenes, but not for complex scenes – Examples: raytracing, radiosity, photon mapping … T09 Shading Shading: motivation We now have a direct lighting model for a simple point on the surface. Assuming that our surface is defined as a mesh of polygonal faces, what points should we use? – Computing the color for all points is expensive – The normals may not be explicitly defined for all points It should be noted that: – Lighting involves a rather cumbersome calculation process if it is applied to all points on the surface of an object – There are several possible
    [Show full text]
  • Lighting CS425: Computer Graphics I
    Lighting CS425: Computer Graphics I Fabio Miranda https://fmiranda.me Fabio Miranda | CS425: Computer Graphics I Overview • Light and shading • Rendering equation • Light-material interaction • Reflection models: • Phong, • Blinn-Phong • Shading models: • Flat • Gouraud • Phong Fabio Miranda | CS425: Computer Graphics I 2 Lighting and shading • Light is emitted by a light source. • Light interacts with objects in the scene: • Part is absorbed, part is scattered in new directions. • Finally, light is absorbed by a sensor (e.g., human eye, film). Fabio Miranda | CS425: Computer Graphics I 3 Lighting and shading • Shading objects so their images appear three-dimensional. • How can we model light-material interactions? • We will see how to build a simple reflection model (Phong model) that can be used with real-time graphics hardware. Fabio Miranda | CS425: Computer Graphics I 4 Why we need shading? • Appearance of surfaces, taking into account: • Surface material • Lighting conditions MC Escher Fabio Miranda | CS425: Computer Graphics I 5 Why we need shading? Full Sun Morning Sun Setting Sun Grey Weather Rouen Cathedral (Monet series) Fabio Miranda | CS425: Computer Graphics I 6 Light and shading 1. Light source emits photons 3. Some are captured 2. Photons interact by eye / camera with the environment: absorption, reflection Fabio Miranda | CS425: Computer Graphics I 7 Lighting and shading • Light-material interactions cause each point to have a different color or shade. • We need to consider: • Light sources. • Material properties. • Location
    [Show full text]