INFOGR Computer Graphics

Similar documents
INFOGR Computer Graphics. Jacco Bikker - April-July Lecture 3: Ray Tracing (Introduction) Welcome!

INFOGR Computer Graphics

Practical 2: Ray Tracing

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Ground Truth. Welcome!

Ray Tracing Part 1. CSC418/2504 Introduction to Computer Graphics. TA: Muhammed Anwar & Kevin Gibson

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

INFOGR Computer Graphics

Topics and things to know about them:

INFOGR Computer Graphics. Jacco Bikker - April-July Lecture 14: Grand Recap. Welcome!

Computer Graphics and Image Processing Ray Tracing I

INFOGR Computer Graphics. J. Bikker - April-July Lecture 11: Visibility. Welcome!

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

INFOGR Computer Graphics

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

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

Homework #2. Hidden Surfaces, Projections, Shading and Texture, Ray Tracing, and Parametric Curves

INFOMAGR Advanced Graphics. Jacco Bikker - February April Welcome!

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007

CS451Real-time Rendering Pipeline

INFOGR Computer Graphics. J. Bikker - April-July Lecture 11: Acceleration. Welcome!

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

Lecture 4 - Real-time Ray Tracing

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

CS 4620 Midterm, March 21, 2017

lecture 18 - ray tracing - environment mapping - refraction

Ray Tracer Due date: April 27, 2011

Ray Tracing. CPSC 453 Fall 2018 Sonny Chan

Computer Graphics and Visualization. What is computer graphics?

Photorealistic 3D Rendering for VW in Mobile Devices

CIS 581 Interactive Computer Graphics

Raytracing CS148 AS3. Due :59pm PDT

Lecture 1. Computer Graphics and Systems. Tuesday, January 15, 13

COMP 175 COMPUTER GRAPHICS. Ray Casting. COMP 175: Computer Graphics April 26, Erik Anderson 09 Ray Casting

TSBK03 Screen-Space Ambient Occlusion

Intro to Ray-Tracing & Ray-Surface Acceleration

U.C. Berkeley, EECS, Computer Science TAKE HOME EXAM. Your Class Computer Account: Your student ID #:

Today. Rendering algorithms. Rendering algorithms. Images. Images. Rendering Algorithms. Course overview Organization Introduction to ray tracing

Graphics (INFOGR ): Example Exam

CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

The Rasterization Pipeline

Real Time Rendering of Complex Height Maps Walking an infinite realistic landscape By: Jeffrey Riaboy Written 9/7/03

Lecture 11. More Ray Casting/Tracing

Programming projects. Assignment 1: Basic ray tracer. Assignment 1: Basic ray tracer. Assignment 1: Basic ray tracer. Assignment 1: Basic ray tracer

Spring 2009 Prof. Hyesoon Kim

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

Photorealism: Ray Tracing

Luxo Jr. (Pixar, 1986) Last Time. Real Cameras and Ray Tracing. Standard Rasterization. Lights, Cameras, Surfaces. Now Playing:

CS 354R: Computer Game Technology

Graphics Hardware and Display Devices

Representing and Computing Polarized Light in a Ray Tracer

Ray Tracing. CS334 Fall Daniel G. Aliaga Department of Computer Science Purdue University

DH2323 DGI13. Lab 2 Raytracing

Computer Graphics Fundamentals. Jon Macey

Ray Tracer I: Ray Casting Due date: 12:00pm December 3, 2001

Computer Graphics. - Ray Tracing I - Marcus Magnor Philipp Slusallek. Computer Graphics WS05/06 Ray Tracing I

Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

Advanced Lighting Techniques Due: Monday November 2 at 10pm

Effects needed for Realism. Computer Graphics (Fall 2008) Ray Tracing. Ray Tracing: History. Outline

Overview: Ray Tracing & The Perspective Projection Pipeline

Assignment 6: Ray Tracing

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

CS 4620 Program 4: Ray II

Animation & Rendering

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

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Spring 2012)

Ray Tracing. Outline. Ray Tracing: History

Lecture 8 Ray tracing Part 1: Basic concept Yong-Jin Liu.

Today. Rendering algorithms. Rendering algorithms. Images. Images. Rendering Algorithms. Course overview Organization Introduction to ray tracing

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1

A Quick Introduction to POV-Ray

Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping

CS 464 Review. Review of Computer Graphics for Final Exam

6.837 Introduction to Computer Graphics Quiz 2 Thursday November 20, :40-4pm One hand-written sheet of notes allowed

Lecture 2 - Acceleration Structures

Movie: Geri s Game. Announcements. Ray Casting 2. Programming 2 Recap. Programming 3 Info Test data for part 1 (Lines) is available

CS 4620 Program 3: Pipeline

Lahore University of Management Sciences. CS 452 Computer Graphics

Computer Graphics (CS 543) Lecture 13b Ray Tracing (Part 1) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics. Lecture 02 Graphics Pipeline. Edirlei Soares de Lima.

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

Ray tracing. Methods of Programming DV2. Introduction to ray tracing and XML. Forward ray tracing. The image plane. Backward ray tracing

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

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

6.837 Introduction to Computer Graphics Final Exam Tuesday, December 20, :05-12pm Two hand-written sheet of notes (4 pages) allowed 1 SSD [ /17]

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Lahore University of Management Sciences. CS 452 Computer Graphics

Spring 2011 Prof. Hyesoon Kim

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

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

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

Game Programming. Bing-Yu Chen National Taiwan University

Computer Graphics Lecture 2

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

Graphics Systems and Models

CS 431/636 Advanced Rendering Techniques

The University of Calgary

CS 381 Computer Graphics, Fall 2012 Midterm Exam Solutions. The Midterm Exam was given in class on Tuesday, October 16, 2012.

Motivation. Sampling and Reconstruction of Visual Appearance. Effects needed for Realism. Ray Tracing. Outline

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

Transcription:

INFOGR Computer Graphics Jacco Bikker & Debabrata Panja - April-July 2018 Lecture 4: Graphics Fundamentals Welcome!

Today s Agenda: Rasters Colors Ray Tracing Assignment P2

INFOGR Lecture 4 Graphics Fundamentals 3 Raster Displays Discretization

INFOGR Lecture 4 Graphics Fundamentals 4 Raster Displays Discretization Rasterization: Converting a vector image into a raster image for output on a video display or printer or storage in a bitmap file format. (Wikipedia)

INFOGR Lecture 4 Graphics Fundamentals 5 Raster Displays Rasterization Improving rasterization: 1. Increase resolution;

INFOGR Lecture 4 Graphics Fundamentals 6 Raster Displays Rasterization Improving rasterization: 1. Increase resolution; 2. Anti-aliasing; 3. Animation.

INFOGR Lecture 4 Graphics Fundamentals 10 Raster Displays Discretization π=4 a 2 +b 2 =c 2 a 1 +b 1 =c 1

INFOGR Lecture 4 Graphics Fundamentals 11 Raster Displays CRT Cathode Ray Tube Physical implementation origins Electron beam zig-zagging over a fluorescent screen.

INFOGR Lecture 4 Graphics Fundamentals 12 Raster Displays CRT Cathode Ray Tube 0,0 y=1 x Physical implementation consequences Origin in the top-left corner of the screen Axis system directly related to pixel count x=-1 0,0 x=1 Not the coordinate system we expected y y=-1

INFOGR Lecture 4 Graphics Fundamentals 13 Raster Displays CRT Cathode Ray Tube 0,0 y=1 x Proper screen coordinates x=-1 0,0 x=1 Pixel coordinates are only relevant for the final step: plotting pixels Decouple the 2D screen coordinates in your game / app from the physical mapping. y y=-1

INFOGR Lecture 4 Graphics Fundamentals 14 Raster Displays Frame rate PAL: 25fps NTSC: 30fps (actually: 29.97) Typical laptop screen: 60Hz High-end monitors: 120-240Hz Cartoons: 12-15fps Human eye: Frame-less Not a raster. How many fps / megapixels is enough?

INFOGR Lecture 4 Graphics Fundamentals 15 Raster Displays Frame rate 0 ms 20 ms 40 ms 60 ms Frame 1 Frame 2 Frame 3 Sim 1 Sim 2 Sim 3 Input 1 Input 2 Input 3 Even 100 frames per second may result in a noticeable delay of 30ms. A very high frame rate minimizes the response time of the simulation.

INFOGR Lecture 4 Graphics Fundamentals 16 Raster Displays Generating images Rendering: The process of generating an image from a 2D or 3D model by means of a computer program. (Wikipedia) Two main methods: on a raster 1. Ray tracing: for each pixel: what color do we assign to it? 2. Rasterization: for each triangle, which pixels does it affect?

Today s Agenda: Rasters Colors Ray Tracing Assignment P2

INFOGR Lecture 4 Graphics Fundamentals 18 Colors Color representation Computer screens emit light in three colors: red, green and blue. By additively mixing these, we can produce most colors: from black (red, green and blue turned off) to white (red, green and blue at full brightness). In computer graphics, colors are stored in discrete form. This has implications for: Color resolution (i.e., number of unique values per component); Maximum brightness (i.e., range of component values).

INFOGR Lecture 4 Graphics Fundamentals 19 Colors Color representation The most common color representation is 32-bit ARGB, which stores red, green and blue as 8 bit values (0..255). Alternatively, we can use 16 bit for one pixel (RGB 565), or a color palette. In that case, one byte is used per pixel, but only 256 unique colors can be used for the image.

INFOGR Lecture 4 Graphics Fundamentals 20 Colors Color representation

INFOGR Lecture 4 Graphics Fundamentals 21 Colors Color representation

INFOGR Lecture 4 Graphics Fundamentals 22 Colors Color representation

INFOGR Lecture 4 Graphics Fundamentals 23 Colors Color representation Textures can typically safely be stored as palletized images. Using a smaller palette will result in smaller compressed files.

INFOGR Lecture 4 Graphics Fundamentals 24 Colors Color representation Using a fixed range (0:0:0 255:255:255) places a cap on the maximum brightness that can be represented: A white sheet of paper: (255,255,255) A bright sky: (255,255,255) The difference becomes apparent when we look at the sky and the sheet of paper through sunglasses. (or, when the sky is reflected in murky water)

INFOGR Lecture 4 Graphics Fundamentals 25 Colors Color representation For realistic rendering, it is important to use an internal color representation with a much greater range than 0..255 per color component. HDR: High Dynamic Range; We store one float value per color component. Including alpha, this requires 128bit per pixel.

INFOGR Lecture 4 Graphics Fundamentals 26 Colors Color representation Like pixel coordinates, pixel colors on the physical screen are only useful for final pixel plotting: Do not use integer colors clamped to [0..255] internally, unless you have a good reason for this.

Today s Agenda: Rasters Colors Ray Tracing Assignment P2

INFOGR Lecture 4 Graphics Fundamentals 28 Ray Tracing PART 1: Introduction & shading (today, Tuesday) PART 2: Reflections, refraction, absorption (next week Thursday) PART 3: Path Tracing (later)

INFOGR Lecture 4 Graphics Fundamentals 29 Ray Tracing Ray Tracing: World space Geometry Eye Screen plane Screen pixels Primary rays Intersections Point light Shadow rays Light transport Extension rays Light transport

INFOGR Lecture 4 Graphics Fundamentals 30 Ray Tracing Ray Tracing: World space Geometry Eye Screen plane Screen pixels Primary rays Intersections Point light Shadow rays Light transport Extension rays Light transport

INFOGR Lecture 8 Ray Tracing Ray Tracing

INFOGR Lecture 4 Graphics Fundamentals 32 Ray Tracing Ray Tracing: World space Geometry Eye Screen plane Screen pixels Primary rays Intersections Point light Shadow rays Light transport Extension rays Light transport Note: We are calculating light transport backwards.

INFOGR Lecture 8 Ray Tracing Ray Tracing

INFOGR Lecture 4 Graphics Fundamentals 34 Ray Tracing

INFOGR Lecture 4 Graphics Fundamentals 35 Ray Tracing

INFOGR Lecture 4 Graphics Fundamentals 36 Ray Tracing Physical basis Ray tracing uses ray optics to simulate the behavior of light in a virtual environment. It does so by finding light transport paths: From the eye Through a pixel Via scene surfaces To one or more light sources. At each surface, the light is modulated. The final value is deposited at the pixel (simulating reception by a sensor). T. Whitted, An Improved Illumination Model for Shaded Display, ACM, 1980.

INFOGR Lecture 4 Graphics Fundamentals 37 Intersections Ray definition A ray is an infinite line with a start point: p(t) = O + td, where t > 0. struct Ray { float3 O; float3 D; float t; }; // ray origin // ray direction // distance The ray direction is generally normalized.

INFOGR Lecture 4 Graphics Fundamentals 38 Intersect Ray setup A ray is initially shot through a pixel on the screen plane. The screen plane is defined in world space: Only if V = (0,0,1) of course. Camera position: E = (0,0,0) View direction: V Screen center: C = E + dv Screen corners: p 0 = C + 1, 1,0, p 1 = C + 1, 1,0, p 2 = C + ( 1,1,0) From here: Change FOV by altering d; Transform camera by multiplying E, p 0, p 1, p 2 with the camera matrix.

INFOGR Lecture 4 Graphics Fundamentals 39 Intersect Ray setup Point on the screen: p u, v = p 0 + u p 1 p 0 + v(p 2 p 0 ), u, v [0,1) p 1 p 0 Ray direction (before normalization): D = p u, v E Ray origin: O = E E p 2 p 2 p 0

INFOGR Lecture 4 Graphics Fundamentals 40 Intersect Ray intersection Given a ray p(t) = O + td, we determine the smallest intersection distance t by intersecting the ray with each of the primitives in the scene. p 1 p 0 Ray / plane intersection: E Plane: p N + d = 0 Ray: p(t) = O + td Substituting for p(t), we get p 2 O + td N + d = 0 t = (O N + d)/(d N) P = O + td

INFOGR Lecture 4 Graphics Fundamentals 41 Intersect Ray intersection Ray / sphere intersection: p 0 Sphere: p C p C r 2 = 0 Ray: p(t) = O + td p 1 Substituting for p(t), we get E O + td C O + td C r 2 = 0 D D t 2 + 2D O C t + (O C) 2 r 2 = 0 ax 2 + bx + c = 0 x = b ± a = D D b = 2D (O C) c = O C O C r 2 b2 4ac 2a Negative: no intersections p 2

INFOGR Lecture 4 Graphics Fundamentals 42 Intersect Ray Intersection D Efficient ray / sphere intersection: void Sphere::IntersectSphere( Ray ray ) { vec3 c = this.pos - ray.o; float t = dot( c, ray.d ); vec3 q = c - t * ray.d; float p 2 = dot( q, q ); if (p 2 > sphere.r 2 ) return; t -= sqrt( sphere.r 2 p 2 ); if ((t < ray.t) && (t > 0)) ray.t = t; // or: ray.t = min( ray.t, max( 0, t ) ); } Note: This only works for rays that start outside the sphere. Ԧc Ԧq p 2 t O

Today s Agenda: Rasters Colors Ray Tracing Assignment P2

INFOGR Lecture 4 Graphics Fundamentals 44 Checkpoint Math Basics vector!= point planes, normals spheres dot product, cross product Assignment P1 template rgb colors in 32-bit coordinate systems in practice OpenGL in C# vertex buffers & shaders Checkpoint 1: MIDTERM on May 22 nd Checkpoint 2: P2 on May 29 th

INFOGR Lecture 4 Graphics Fundamentals 45 Assignment 2 Assignment 2: Write a basic ray tracer. Using the template In a 1024x512 window Two views, each 512x512 Left view: 3D Right view: 2D slice

INFOGR Lecture 4 Graphics Fundamentals 46 Assignment 2 Assignment 2: Write a basic ray tracer. Steps: 1. Create a Camera class; default: position (0,0,0), looking at (0,0,-1). 2. Create a Ray class 3. Create a Primitive class and derive from it a Sphere and a Plane class 4. Add code to the Camera class to create a primary ray for each pixel 5. Implement Intersect methods for the primitives 6. Per pixel, find the nearest intersection and plot a pixel 7. Add controls to move and rotate the camera 8. Add a checkerboard pattern to the floor plane. For y = 0, visualize every 10 th ray Visualize the intersection points 9. Add reflections and shadow rays (next lecture).

INFOGR Lecture 4 Graphics Fundamentals 47 Assignment 2 Extra points: Add additional primitives, e.g.: Triangle, quad, box Torus, cylinder Fractal Add textures to all primitives Add a sky dome Add refraction and absorption (next lecture) One extra point for the fastest ray tracer One extra point for the smallest ray tracer meeting the minimum requirements.

INFOGR Lecture 4 Graphics Fundamentals 48 Assignment 2 Official: Full details in the official assignment 2 document, available today from the website. Deadline: May 29 th, 23:59. Small exhibition of noteworthy entries in a subsequent lecture and on the website.

Today s Agenda: Rasters Colors Ray Tracing Assignment P2

INFOGR Computer Graphics Jacco Bikker & Debabrata Panja - April-July 2018 END OF lecture 4: Graphics Fundamentals Next lecture: More on Ray Tracing