From 3D World to 2D Screen. Hendrik Speleers

Similar documents
Set the Viewport. Set the Viewport Clipping. Set the Viewport. Set the Viewport. Set the Viewport. Resizing the Viewport W = H

Set the Viewport Clipping. Computer Graphics CSC470 1

Graphics Systems and Models

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

Chapter 8: Implementation- Clipping and Rasterization

Computer Graphics (CS 543) Lecture 9 (Part 2): Clipping. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

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

Last class. A vertex (w x, w y, w z, w) - clipping is in the - windowing and viewport normalized view volume if: - scan conversion/ rasterization

R asterisation. Part I: Simple Lines. Affine transformation. Transform Render. Rasterisation Line Rasterisation 2/16

Clipping. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Realtime 3D Computer Graphics Virtual Reality

Overview. Pipeline implementation I. Overview. Required Tasks. Preliminaries Clipping. Hidden Surface removal

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

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

3D Rendering Pipeline (for direct illumination)

UNIT -8 IMPLEMENTATION

CS602 Midterm Subjective Solved with Reference By WELL WISHER (Aqua Leo)

Clipping and Scan Conversion

1 Attempt any three of the following: 1 5 a. What is Computer Graphics? How image is to be display on Video Display Device?

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Computer Graphics and GPGPU Programming

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines. Emmanuel Agu

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Computer Graphics

COMP371 COMPUTER GRAPHICS

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

CS Rasterization. Junqiao Zhao 赵君峤

From Vertices To Fragments-1

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

Topic #1: Rasterization (Scan Conversion)

0. Introduction: What is Computer Graphics? 1. Basics of scan conversion (line drawing) 2. Representing 2D curves

Topics. From vertices to fragments

Chapter - 2: Geometry and Line Generations

Computer Graphics. Chapter 1 (Related to Introduction to Computer Graphics Using Java 2D and 3D)

Painter s HSR Algorithm

MET71 COMPUTER AIDED DESIGN

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Line Drawing. Foundations of Computer Graphics Torsten Möller

The Traditional Graphics Pipeline

Rendering approaches. 1.image-oriented. 2.object-oriented. foreach pixel... 3D rendering pipeline. foreach object...

Rendering. A simple X program to illustrate rendering

Rasterization Overview

2D Image Synthesis. 2D image synthesis. Raster graphics systems. Modeling transformation. Vectorization. u x u y 0. o x o y 1

The Traditional Graphics Pipeline

Computer Graphics: Line Drawing Algorithms

CS130 : Computer Graphics Lecture 2: Graphics Pipeline. Tamar Shinar Computer Science & Engineering UC Riverside

Graphics Hardware and Display Devices

Scan Conversion. CMP 477 Computer Graphics S. A. Arekete

EF432. Introduction to spagetti and meatballs

Rendering. A simple X program to illustrate rendering

Tópicos de Computação Gráfica Topics in Computer Graphics 10509: Doutoramento em Engenharia Informática. Chap. 2 Rasterization.

VISIBILITY & CULLING. Don t draw what you can t see. Thomas Larsson, Afshin Ameri DVA338, Spring 2018, MDH

CS488 2D Graphics. Luc RENAMBOT

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

Institutionen för systemteknik

From Ver(ces to Fragments: Rasteriza(on

Graphics System. Processor. Output Display. Input Devices. Frame Buffer. Memory. Array of pixels. Resolution: # of pixels Depth: # of bits/pixel

Computer Graphics - Chapter 1 Graphics Systems and Models

RASTERIZING POLYGONS IN IMAGE SPACE

The Traditional Graphics Pipeline

Display Technologies: CRTs Raster Displays

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY

CS475m - Computer Graphics. Lecture 1 : Rasterization Basics

Fall CSCI 420: Computer Graphics. 7.1 Rasterization. Hao Li.

Overview of Computer Graphics

Computer Graphics and Visualization. Graphics Systems and Models

Werner Purgathofer

CHAPTER 1 Graphics Systems and Models 3

CS 4620 Program 3: Pipeline

Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller

CSCI 420 Computer Graphics Lecture 14. Rasterization. Scan Conversion Antialiasing [Angel Ch. 6] Jernej Barbic University of Southern California

3D graphics, raster and colors CS312 Fall 2010

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4620/8626 Computer Graphics Spring 2014 Homework Set 1 Suggested Answers

Surface shading: lights and rasterization. Computer Graphics CSE 167 Lecture 6

Rasterization. Rasterization (scan conversion) Digital Differential Analyzer (DDA) Rasterizing a line. Digital Differential Analyzer (DDA)

3D Graphics Pipeline II Clipping. Instructor Stephen J. Guy

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Clipping. Concepts, Algorithms for line clipping. 1 of 16. Andries van Dam. Clipping - 10/12/17

Volume Shadows Tutorial Nuclear / the Lab

Drawing in 3D (viewing, projection, and the rest of the pipeline)

VTU QUESTION PAPER SOLUTION UNIT -1 INTRODUCTION

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

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

KRISTU JYOTI COLLEGE OF MANAGEMENT & TECHNOLOGY QUESTION BANK BCA SEMESTER III Computer graphics Part A (2 marks questions)

SAZ4C COMPUTER GRAPHICS. Unit : 1-5. SAZ4C Computer Graphics

521493S Computer Graphics Exercise 1 (Chapters 1-3)

Ray Tracing Basics I. Computer Graphics as Virtual Photography. camera (captures light) real scene. photo. Photographic print. Photography: processing

Z- Buffer Store the depth for each pixel on the screen and compare stored value with depth of new pixel being drawn.

1 Introduction to Graphics

Computer Graphics: Graphics Output Primitives Line Drawing Algorithms

Hidden Surfaces II. Week 9, Mon Mar 15

Pipeline Operations. CS 4620 Lecture 14

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY CS2401 COMPUTER GRAPHICS QUESTION BANK

Image Formation. Introduction to Computer Graphics. Machiraju/Zhang/Möller/Klaffenböck

3D Rasterization II COS 426

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

Output Primitives Lecture: 3. Lecture 3. Output Primitives. Assuming we have a raster display, a picture is completely specified by:

Einführung in Visual Computing

CEng 477 Introduction to Computer Graphics Fall 2007

CS 543: Computer Graphics. Rasterization

Transcription:

Hendrik Speleers

Overview Synthetic camera Rendering pipeline World window versus viewport Clipping Cohen-Sutherland algorithm Rasterizing Bresenham algorithm

Three different actors in a scene Objects: exist in space, independent of viewer Viewer: camera, human, Lights: shading, shadows,...

Viewer Pinhole camera (camera obscura) Projection plane behind projection center: an inverted image Easy mathematical description y y camera object z z Synthetic camera Projection plane in front of projection center: no inversion

Viewer We don t want to see everything Clipping Looking through a 2D window Two clipping models 2D clipper: First project, and then cut everything outside window 3D clipper: Cut everything outside view pyramid, and then project

3D graphics libraries OpenGL, Direct3D, Java3D, Provide routines for modeling and rendering Communicate with graphics hardware Synthetic camera is the basis Keyboard // Mouse Display Application program Graphics library Graphics hardware

Rendering pipeline 3D Transformer Projector Rasterizer 2D Conversion from 3D world vertices to 2D screen pixels Transform to camera coordinate system (camera in origin) Project 3D coordinates to 2D coordinates + Clip away everything we don t see in window Transform to pixels in the frame buffer

World window versus viewport World window: specifies which part of the world should be drawn Viewport: rectangle in screen window in which we want to draw Window Screen window World window Viewport

World window versus viewport Mapping (x,y) (s,t) is linear x s W l W r V l V r s=ax+b, A= V r V l W r W l, B=V l AW l Preserving aspect ratio (width/height) of world window Maximizing and centering in viewport

2D Clipping Lines outside world window are not to be drawn Algorithm clipsegment(...) If line is within window then return true (accept) If line is outside window then return false (reject) Otherwise clip and return true

2D Clipping Cohen-Sutherland region outcodes Divide space into 9 regions 4 bits per region Left? Above? Right? Below? Trivial accept: Both endpoints are FFFF TTFF FTFF FTTF TFFF FFFF FFTF TFFT FFFT FFTT Trivial reject: Both endpoints have T in the same position

2D Clipping Cohen-Sutherland chopping If line is neither trivial accept nor reject Then clip against edges of window repeatedly chop chop accept

2D Clipping Cohen-Sutherland line clipper boolean clipsegment(point p1, Point p2) { do { if (trivial accept) return true; if (trivial reject) return false; if (p1 is outside) { if (p1 is left) chop left; if (p1 is above) chop above;... } if (p2 is outside) {... } } while (true) }

Rasterizing Viewport on raster display Cathode ray tube (CRT) monitor Liquid crystal display (LCD) monitor Image is discrete Framebuffer Raster image is stored in memory as a matrix of pixels (= picture elements) The color of each pixel specifies the beam intensity Video hardware scans framebuffer at 60Hz Changes in framebuffer visible on screen > double buffering Switch buffers when one buffer is finished

Rasterizing Raster display Graphics software Video controller Rasterizer Framebuffer How to convert lines/polygons to pixels? Continuous to discrete: scan conversion

Rasterizing Scan converting lines (x 2, y 2 ) Find the pixels closest to the ideal line (y y 1 )=m( x x 1 ), m= Dy Dx = y 2 y 1 x 2 x 1 (x 1, y 1 ) Dy Naive algorithm Dx If slope m 1 : illuminate one pixel per column; work incrementally If slope m > 1 : illuminate one pixel per row; work incrementally (just x y)

Rasterizing Scan converting lines: slope m 1 y = y1; for (i = x1; i <= x2; i++) { plotpixel(i, Math.round(y)); y += m; } Inefficient: Computation of round(y) for each integer x And floating point addition

Rasterizing Scan converting lines: Bresenham algorithm Only integer arithmetic What is the next pixel? Assuming slope 0 m 1, two possibilities Decision variable: d = a b If (d > 0) Else j+ 3 2 j+ 1 2 y = m x + h a b Alternative: d = Dx (a b) Only interested in sign, so this gives the same result Incremental computation i+ 1 2 i+ 3 2

Rasterizing Scan converting lines: Bresenham algorithm d k = d k 1 2 Dy or d k = d k 1 2 (Dy Dx) a k m b k a k m b k

Rasterizing Scan converting lines: Bresenham algorithm dk = Dx (a k b k ) = Dx ((a k 1 m) (b k 1 + m)) = Dx (a k 1 b k 1 ) 2 Dx m = d k 1 2 Dy dk = Dx (a k b k ) = Dx ((2 m b k 1 ) (m a k 1 )) = Dx (a k 1 b k 1 ) 2 Dx (m 1) = d k 1 2 (Dy Dx) Exercise: Write the entire algorithm