HomeWork 2 Rasterization

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

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

CS 130 Final. Fall 2015

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

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

CS4620/5620: Lecture 14 Pipeline

Pipeline Operations. CS 4620 Lecture 14

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

Pipeline Operations. CS 4620 Lecture 10

Homework 3: Programmable Shaders

X. GPU Programming. Jacobs University Visualization and Computer Graphics Lab : Advanced Graphics - Chapter X 1

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

Advanced Shading I: Shadow Rasterization Techniques

The Traditional Graphics Pipeline

Chapter 7 - Light, Materials, Appearance

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

CS 4620 Program 3: Pipeline

Introduction to Visualization and Computer Graphics

The Traditional Graphics Pipeline

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

4: Polygons and pixels

CS451Real-time Rendering Pipeline

Computer Science 175. Introduction to Computer Graphics lib175 time: m/w 2:30-4:00 pm place:md g125 section times: tba

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

Rasterization and Graphics Hardware. Not just about fancy 3D! Rendering/Rasterization. The simplest case: Points. When do we care?

I expect to interact in class with the students, so I expect students to be engaged. (no laptops, smartphones,...) (fig)

The Traditional Graphics Pipeline


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

PowerVR Hardware. Architecture Overview for Developers

Many rendering scenarios, such as battle scenes or urban environments, require rendering of large numbers of autonomous characters.

Advanced Lighting Techniques Due: Monday November 2 at 10pm

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing

Game Architecture. 2/19/16: Rasterization

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

Drawing Fast The Graphics Pipeline

Resolve your Resolves Jon Story Holger Gruen AMD Graphics Products Group

Graphics and Interaction Rendering pipeline & object modelling

CS 130 Exam I. Fall 2015

RSX Best Practices. Mark Cerny, Cerny Games David Simpson, Naughty Dog Jon Olick, Naughty Dog

Deferred Rendering Due: Wednesday November 15 at 10pm

Drawing Fast The Graphics Pipeline

Interpolation using scanline algorithm

Institutionen för systemteknik

Rasterization Overview

Line Drawing. Foundations of Computer Graphics Torsten Möller

Hidden surface removal. Computer Graphics

Real-Time Shadows. André Offringa Timo Laman

Real - Time Rendering. Graphics pipeline. Michal Červeňanský Juraj Starinský

3D GRAPHICS. design. animate. render

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

QUESTION BANK 10CS65 : COMPUTER GRAPHICS AND VISUALIZATION

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

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

CS 428: Fall Introduction to. Polygon rendering: additional topics. Andrew Nealen, Rutgers, /14/2009 1

Module 13C: Using The 3D Graphics APIs OpenGL ES

OPENGL RENDERING PIPELINE

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

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL

Chapter IV Fragment Processing and Output Merging. 3D Graphics for Game Programming

- Rasterization. Geometry. Scan Conversion. Rasterization

Drawing Fast The Graphics Pipeline

Rasterization. COMP 575/770 Spring 2013

CHAPTER 1 Graphics Systems and Models 3

The Rendering Pipeline (1)

Models and Architectures

Direct Rendering of Trimmed NURBS Surfaces

CS 464 Review. Review of Computer Graphics for Final Exam

The Rasterization Pipeline

Shading Techniques Denbigh Starkey

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

Graphics Pipeline 2D Geometric Transformations

Painter s HSR Algorithm

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

2: Introducing image synthesis. Some orientation how did we get here? Graphics system architecture Overview of OpenGL / GLU / GLUT

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

CMT315 - Computer Graphics & Visual Computing

The Rasterization Pipeline

Mobile HW and Bandwidth

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

TSBK03 Screen-Space Ambient Occlusion

Rasterization. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 16

Computer Graphics Fundamentals. Jon Macey

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

RASTERISED RENDERING

Standard Graphics Pipeline

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

SFU CMPT 361 Computer Graphics Fall 2017 Assignment 2. Assignment due Thursday, October 19, 11:59pm

Computer Graphics. Shadows

Lecture 13: Reyes Architecture and Implementation. Kayvon Fatahalian CMU : Graphics and Imaging Architectures (Fall 2011)

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

1.2.3 The Graphics Hardware Pipeline

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

The Graphics Pipeline

Lecture 6 of 41. Scan Conversion 1 of 2: Midpoint Algorithm for Lines and Ellipses

Lecture 6 of 41. Scan Conversion 1 of 2: Midpoint Algorithm for Lines and Ellipses

CS 130 Exam I. Fall 2015

Ray Tracing. CPSC 453 Fall 2018 Sonny Chan

Rasterization. CS4620 Lecture 13

Transcription:

HomeWork 2 Rasterization Fall 2012 Submitted By - Nitin Agrahara Ravikumar 73714398

The First Part: Rasterization As required by the homework, the display function of the smooth program is hijacked and a custom display method id used. In our case the method is called Rasterization (). The steps involved in the custom display process are as follow. Obtain the vertices of each of the triangles one by one. Obtain the coordinates of the triangle by using the Bresenhams line algorithm. Update the line buffer with these values. (Line buffer is the size of the screen) Now, scan each pixel column and rows wise. For each row, start the scan from both ends so as to determine the start and end points of the scan in the triangle. Once obtained, fill all the pixels between those pixels to an arbitrary color. Do this for all triangles in the scene. End results are shown in the snapshot. The Second Part: Z Buffer and Shading When we use gluproject to obtain the real world coordinates of the three vertices of a triangle, we also get the apparent depth values of the vertices. What we do for the z buffer calculation is that once we know that a pixel lies within a triangle (from the Rasterization part) we calculate is apparent i.e. Z` values using Barycentric interpolation. We store the values in alpha, beta and gamma. Now, for each pixel that is to be colored, we check the calculated depth value with that of the existing z' stored for that location in the Z buffer (it is also the size of the window.) If the current depth is less than that of the existing value in the z buffer, we overwrite it and replace the color for that pixel with the new way. This way we ensure we are showing only that which is in the front. The result of the same can be viewed in the snapshots. For the flat shading, we assume that the camera and light source are constant. Thus the bisector value remains constant as well. We use this bisector value, plus the normal to the surface of the current triangle. This is because the normal to every point on a triangle is same. Thus we get the normal per triangle, and calculate the shading of the triangle once. And whenever a pixel in a triangle is to be colored, we add the pre calculated shading value to it. And thus obtain flat shading. The result can be viewed in the snapshots.

The Third Part: Bonus - Gouroud Shading. Since we calculated and stored the Barycentric values foe each of the triangles, according to the Gouroud shading technique, all we have to do is calculate the shading of each of the vertices of a triangle, and use the alpha, beta and gamma values to get the shading of the current pixel. We can obtain the normals of the vertices by accessing the data structure provided with the program. Use the same shading functions described earlier and interpolate the color and the check the z buffer as described before. The results are shown in the snapshots. Observations Issues encountered: Improper pixel calculation in Bresenhams algorithm Improper start and end point of a triangle in a scan line. Fixes: Handling all cases while drawing a line (+ve / -ve slopes) With the initial coding techniques employed, the Rasterization was extremely slow especially for meshes with large number of triangles. Adding the flat shading and later Gouroud shading just worsened the situation. Several corrective measures were employed. Which are described as follows: Removing unnecessary for loop and replacing with memset Per triangle flat shading calculations instead of per pixel Integrating the bounding box strategy (the biggest improvement) Still, even with these improvements, the pipeline coded is far less efficient than the once implemented by opengl. This is because of one simple fact. Open GL uses techniques programmed into the hardware. So essentially opengl is doing an operation in one cycle, which we are doing in several lines of code, which has to be interpreted and then executed. The problem of color peaking at the edges in Gouroud is clearly seen as shown in the snapshots.

Snapshots Only the triangles being rendered Snapshots of images rendered without using z buffer or shading

Multiple examples of Flat and Gouroud Shading

Abnormal behavior: As shown in the images below, the pipeline employed by the opengl does not render one of the petals of the rose whereas the implemented by our Rasterization () function does. This petal is indicated below.

About the Submission The code is kept in C and the filename remain unaltered. A makefile has been provided which creates the binary smooth Two extra modes have been added: y To switch between original rendering and the rendering we have implemented. f To switch between Flat and Gouroud shading. Acknowledgements The homework is an extension of the original program smooth written by Nate Robbins and all the code used for reading the object files and corresponding data (vertices/normal/colors) is attributed to him. http://user.xmission.com/~nate/smooth.html