Interpolation using scanline algorithm

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

Shading. Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller/Fuhrmann

CS5620 Intro to Computer Graphics

Illumination Models & Shading

Pipeline Operations. CS 4620 Lecture 14

Pipeline Operations. CS 4620 Lecture 10

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

Chapter 7 - Light, Materials, Appearance

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

Computer Graphics 1. Chapter 7 (June 17th, 2010, 2-4pm): Shading and rendering. LMU München Medieninformatik Andreas Butz Computergraphik 1 SS2010

How do we draw a picture?

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

9. Illumination and Shading

Lighting and Shading

CPSC 314 LIGHTING AND SHADING

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

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

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

TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students)

Advanced Shading I: Shadow Rasterization Techniques

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

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

Graphics and Interaction Surface rendering and shading

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

Topics and things to know about them:

Lecture outline Graphics and Interaction Surface rendering and shading. Shading techniques. Introduction. Surface rendering and shading

CPSC GLOBAL ILLUMINATION

Computer Graphics. Shadows

Illumination and Shading

Introduction Ray tracing basics Advanced topics (shading) Advanced topics (geometry) Graphics 2010/2011, 4th quarter. Lecture 11: Ray tracing

Computer Graphics. Illumination and Shading

CS 130 Exam I. Fall 2015

From Graphics to Visualization

CS770/870 Spring 2017 Color and Shading

Light Sources. Spotlight model

Surface Rendering Methods

So far, we have considered only local models of illumination; they only account for incident light coming directly from the light sources.

CS 130 Final. Fall 2015

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

Illumination and Shading

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

COMP environment mapping Mar. 12, r = 2n(n v) v

Computer Graphics. Lecture 14 Bump-mapping, Global Illumination (1)

Spring 2012 Final. CS184 - Foundations of Computer Graphics. University of California at Berkeley

The Traditional Graphics Pipeline

Computer Graphics 10 - Shadows

Introduction to Computer Graphics 7. Shading

Illumination and Shading

Illumination & Shading: Part 1

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

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

CEng 477 Introduction to Computer Graphics Fall 2007

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

CS 4620 Midterm, March 21, 2017

Illumination and Shading

Shading Techniques Denbigh Starkey

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

Complex Shading Algorithms

COMP 4801 Final Year Project. Ray Tracing for Computer Graphics. Final Project Report FYP Runjing Liu. Advised by. Dr. L.Y.

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

Level of Details in Computer Rendering

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

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

Reflection and Shading

Visible-Surface Detection Methods. Chapter? Intro. to Computer Graphics Spring 2008, Y. G. Shin

Shading, Advanced Rendering. Week 7, Wed Feb 28

Real-Time Shadows. André Offringa Timo Laman

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

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

Interactive Computer Graphics A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL

The Traditional Graphics Pipeline

CHAPTER 1 Graphics Systems and Models 3

Shadows. COMP 575/770 Spring 2013

The Traditional Graphics Pipeline

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized

CS 488. More Shading and Illumination. Luc RENAMBOT

CPSC / Illumination and Shading

Rasterizing triangles

Lighting/Shading III. Week 7, Wed Mar 3

- Rasterization. Geometry. Scan Conversion. Rasterization

Photorealism: Ray Tracing

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

Computer Graphics. Illumination and Shading

Topic 11: Texture Mapping 10/21/2015. Photographs. Solid textures. Procedural

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Computer Graphics. Lecture 13. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura

CS452/552; EE465/505. Clipping & Scan Conversion

CS354 Computer Graphics Ray Tracing. Qixing Huang Januray 24th 2017

Graphics for VEs. Ruth Aylett

Computergrafik. Matthias Zwicker. Herbst 2010

Previously... contour or image rendering in 2D

Illumination Modelling

CS 325 Computer Graphics

Comp 410/510 Computer Graphics. Spring Shading

Shading 1: basics Christian Miller CS Fall 2011

Graphics Hardware and Display Devices

Lecture 11: Ray tracing (cont.)

Computer Graphics I Lecture 11

Transcription:

Interpolation using scanline algorithm Idea: Exploit knowledge about already computed color values. Traverse projected triangle top-down using scanline. Compute start and end color value of each pixel row using linear interpolation along the triangle s edges. Fill each pixel row using linear interpolation between the start and end color of that row. 320322: Graphics and Visualization 454

Interpolation using scanline algorithm 320322: Graphics and Visualization 455

Gouraud shading 320322: Graphics and Visualization 456

Shading in OpenGL Setting State glshademodel( GL_SMOOTH GL_FLAT); GL_FLAT: flat shading GL_SMOOTH: Gouraud shading 320322: Graphics and Visualization 457

Gouraud shading Gouraud shading produces smooth transitions of light intensities, but silhouettes remain polygonal. However, typically triangles are small such that this cannot be noticed. 320322: Graphics and Visualization 458

Gouraud shading Using Gouraud shading, illumination is only evaluated at the vertices of the triangles. Specular highlights that do not stretch over vertices of the mesh are missed. specular highlight 320322: Graphics and Visualization 459

Gouraud shading During animation, specular highlights can show some flickering when using Gouraud shading. 320322: Graphics and Visualization 460

6.3 Phong Shading 320322: Graphics and Visualization 461

Phong shading Improve shading by applying the illumination model at each unprojected pixel, i.e., at those points of a triangle that are projected onto a pixel of the screen. 320322: Graphics and Visualization 462

Phong shading algorithm Use a scanline that traverses the triangle top-down in screen space. For each start and end point of a pixel row, linearly interpolate the surface normal along the triangle s edges. For each pixel row, linearly interpolate the surface normal between start and end point of that row. Apply the illumination model at each unprojected pixel value using the interpolated surface normal. 320322: Graphics and Visualization 463

Phong shading algorithm Apply same interpolation formula as in Gouraud shading, but interpolate normals instead of color values. 320322: Graphics and Visualization 464

Phong shading 320322: Graphics and Visualization 465

Phong shading Specular highlights are always correctly and exactly computed. Highlights appear much smoother. No flickering during animations. 320322: Graphics and Visualization 466

Comparison: flat, Gouraud, Phong shading 320322: Graphics and Visualization 467

Phong shading The evaluation of the illumination model at each unprojected screen pixel is expensive. Illumination needs to be applied in object space rather than screen space. The pixel can be easily unprojected when storing depth information (cf. depth buffer). 320322: Graphics and Visualization 468

Phong shading Phong shading is not supported by OpenGL. It is nowadays implemented using pixel or fragment shaders. The normals can be handed to the shader encoded as colors. Gouraud shading using these colors then interpolates the normals. 320322: Graphics and Visualization 469

7. Global Illumination 320322: Graphics and Visualization 470

Global Illumination The Phong, Blinn-Phong, and BRDF models are local illumination models, i.e., they only take into account the local geometry of an object. Global illumination models take into account the entire geometry that is present in the scene. In particular, global illumination considers the interference of objects with each other. For example, when one object occludes the light source with respect to another object, the other object should appear to be in the shadow of the first object. 320322: Graphics and Visualization 471

7.1 Ray Tracing 320322: Graphics and Visualization 472

Ray tracing Ray tracing is a global illuminiation method. It allows for the computation of all shadows in the scene. 320322: Graphics and Visualization 473

Observation In nature, light from a light source gets reflected at a point p. The amount of incoming light that is reflected in direction v to the viewer determines the color of the object at position p. 320322: Graphics and Visualization 474

Ray tracing idea Trace the light ray through the scene. Since many light rays are being sent out from each light source in all directions, this can be computationally very intense. For efficiency purposes, trace in backward direction. Start rays from the viewpoint. Send a ray through each pixel of the screen onto the scene. Trace the ray to the light sources. 320322: Graphics and Visualization 475

Ray tracing idea light 1 light 2 secondary rays viewpoint object 1 primary ray object 2 screen Primary rays are sent from the viewer through the center of each pixel of the screen When the primary rays hit an object, secondary rays are sent from the point of intersection towards each light source. 320322: Graphics and Visualization 476

Ray tracing idea light 1 light 2 secondary rays viewpoint object 1 object 2 primary rays screen If a secondary ray hits an object, that object occludes the light source. The color of the pixel is computed by applying a local ilumination model at the position, where the primary ray hits the object, taking into account all light sources that are not occluded. 320322: Graphics and Visualization 477

Ray-tracing idea 320322: Graphics and Visualization 478

Ray-tracing idea 320322: Graphics and Visualization 479

Ray-triangle intersection Let the objects be given as triangular meshes. To find intersections of (primary or secondary) rays with the objects, one has to find and compute intersection points of rays with triangles. Ifmanytrianglesarepresentin thescene, onemay want to reduce the amount of triangles that are considered by using spatial partitioning. Spatial partitioning stores for each cell only those triangles that lie (completely or partially) in the cell. The ray-triangle intersection can be limited to those cells that are intersected by the ray (in the order in which it intersects). 320322: Graphics and Visualization 480

Ray-triangle intersection 1. Compute intersection of ray with plane. 2. Check whether intersection point lies within the triangle. 320322: Graphics and Visualization 481

Ray-triangle intersection Compute intersection of ray with plane. 320322: Graphics and Visualization 482

Ray-triangle intersection 320322: Graphics and Visualization 483

Ray-triangle intersection 320322: Graphics and Visualization 484

convex polygons Other polygons plane-intersection: like triangles inside test: algebraically concave polygons plane-intersection: like triangles inside test: ray intersection non-planar polygons triangulate 320322: Graphics and Visualization 485