General Information. Studentrepresentanternas ansvar. Overview of the Pipeline and OpenGL. Ulf Assarsson

Similar documents
Graphics Pipeline in a Nutshell

Image Processing and Computer Graphics. Rendering Pipeline. Matthias Teschner. Computer Science Department University of Freiburg

Interaction. Triangles (Clarification) Choice of Programming Language. Display Lists. The CPU-GPU bus. CSCI 480 Computer Graphics Lecture 3

OpenGL & Delphi. Max Kleiner. 1/22

Computer Graphics Labs

Monash University Clayton s School of Information Technology CSE3313 Computer Graphics Sample Exam Questions 2007

INTRODUCTION TO RENDERING TECHNIQUES

Computer Graphics Labs

Computer Graphics (Basic OpenGL, Input and Interaction)

Introduction to MS Visual Studio 6.0

CMSC 427 Computer Graphics 1

4BA6 - Topic 4 Dr. Steven Collins. Chap. 5 3D Viewing and Projections

CSE 564: Visualization. GPU Programming (First Steps) GPU Generations. Klaus Mueller. Computer Science Department Stony Brook University

Graphics Input Primitives. 5. Input Devices Introduction to OpenGL. String Choice/Selection Valuator

Computer Graphics. Anders Hast

Android and OpenGL. Android Smartphone Programming. Matthias Keil. University of Freiburg

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

Introduction to Computer Graphics

Shader Model 3.0. Ashu Rege. NVIDIA Developer Technology Group

A Short Introduction to Computer Graphics

CMSC 427 Computer Graphics 1

Realtime 3D Computer Graphics Virtual Reality

Lecture 3: Coordinate Systems and Transformations

Methodology for Lecture. Review of Last Demo

An Introduction to. Graphics Programming

How To Teach Computer Graphics

3D Graphics and Cameras

Scan-Line Fill. Scan-Line Algorithm. Sort by scan line Fill each span vertex order generated by vertex list

Silverlight for Windows Embedded Graphics and Rendering Pipeline 1

Lecture Notes, CEng 477

GUI GRAPHICS AND USER INTERFACES. Welcome to GUI! Mechanics. Mihail Gaianu 26/02/2014 1

Chapter 1 Introduction to OpenGL

Transformations in the pipeline

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine

Lezione 4: Grafica 3D*(II)

OpenGL Performance Tuning

L20: GPU Architecture and Models

Chapter 2 - Graphics Programming with JOGL

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

CS 4204 Computer Graphics

The mouse callback. Positioning. Working with Callbacks. Obtaining the window size. Objectives

Aston University. School of Engineering & Applied Science

Computer Graphics Hardware An Overview

3D Math Overview and 3D Graphics Foundations

Advanced Visual Effects with Direct3D

COMP175: Computer Graphics. Lecture 1 Introduction and Display Technologies

Beginning Android 4. Games Development. Mario Zechner. Robert Green

Optimizing AAA Games for Mobile Platforms

DATA VISUALIZATION OF THE GRAPHICS PIPELINE: TRACKING STATE WITH THE STATEVIEWER

GPUs Under the Hood. Prof. Aaron Lanterman School of Electrical and Computer Engineering Georgia Institute of Technology

Advanced Graphics and Animations for ios Apps

Comp 410/510. Computer Graphics Spring Introduction to Graphics Systems

Recent Advances and Future Trends in Graphics Hardware. Michael Doggett Architect November 23, 2005

Introduction to GPGPU. Tiziano Diamanti

Performance Optimization and Debug Tools for mobile games with PlayCanvas

An introduction to Global Illumination. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Introduction to Game Programming. Steven Osman

Computer Graphics on Mobile Devices VL SS ECTS

Touchstone -A Fresh Approach to Multimedia for the PC

SketchUp Instructions

CS 4204 Computer Graphics

Writing Applications for the GPU Using the RapidMind Development Platform

Hardware design for ray tracing

Examples. Pac-Man, Frogger, Tempest, Joust,

Color correction in 3D environments Nicholas Blackhawk

Interactive Computer Graphics

The Future Of Animation Is Games

A Crash Course on Programmable Graphics Hardware

Masters of Science in Software & Information Systems

CS 325 Computer Graphics

GPU(Graphics Processing Unit) with a Focus on Nvidia GeForce 6 Series. By: Binesh Tuladhar Clay Smith

Programming 3D Applications with HTML5 and WebGL

Introduction to Computer Graphics. Reading: Angel ch.1 or Hill Ch1.

Real-Time Realistic Rendering. Michael Doggett Docent Department of Computer Science Lund university

Introduction to Computer Graphics

Lecture Notes. Fundamentals of Computer Graphics. Prof. Michael Langer School of Computer Science McGill University

Using Photorealistic RenderMan for High-Quality Direct Volume Rendering

Lecture 15: Hardware Rendering

Course Overview. CSCI 480 Computer Graphics Lecture 1. Administrative Issues Modeling Animation Rendering OpenGL Programming [Angel Ch.

GPU Shading and Rendering: Introduction & Graphics Hardware

The Car Tutorial Part 1 Creating a Racing Game for Unity

CUBE-MAP DATA STRUCTURE FOR INTERACTIVE GLOBAL ILLUMINATION COMPUTATION IN DYNAMIC DIFFUSE ENVIRONMENTS

Input and Interaction

How To Learn To Program In Csc 406 Computer Graphics

GPGPU Computing. Yong Cao

IT 386: 3D Modeling and Animation. Review Sheet. Notes from Professor Nersesian s IT 386: 3D Modeling and Animation course

Optimizing Unity Games for Mobile Platforms. Angelo Theodorou Software Engineer Unite 2013, 28 th -30 th August

Graphical displays are generally of two types: vector displays and raster displays. Vector displays

The Evolution of Computer Graphics. SVP, Content & Technology, NVIDIA

CREATE A 3D MOVIE IN DIRECTOR

GPU Architecture. Michael Doggett ATI

Nicolas P. Rougier PyConFr Conference 2014 Lyon, October 24 25

Computer Graphics. Introduction. Computer graphics. What is computer graphics? Yung-Yu Chuang

Practical Data Visualization and Virtual Reality. Virtual Reality VR Software and Programming. Karljohan Lundin Palmerius

QCD as a Video Game?

Adding Animation With Cinema 4D XL

PCL - SURFACE RECONSTRUCTION

Instructor. Goals. Image Synthesis Examples. Applications. Computer Graphics. Why Study 3D Computer Graphics?

Tutorial for Tracker and Supporting Software By David Chandler

Vertex and fragment programs

Transcription:

1. I am located in room 4115 in EDIT-huset 2. Email: 3. Phone: 031-772 1775 (office) 4. Course assistant: Ulf Assarsson Chalmers University of Technology Tomas Akenine-Mőller 2002 General Information No Project Tutorials in room 4220/4225 or wherever is suitable for you Entrance Cards (inpasseringskort) automatically activated for all of you that are course registered and have a CTH/GU-entrance card (inpasseringskort) Recommended to do the tutorials in groups (Labgrupper) of 2 and 2 Home Page Studentrepresentanternas ansvar Informerar sig om sina kurskamraters synpunkter på kursen. Vidarebefordrar dessa samt deltar i övrigt i diskussionen vid mötena med egna synpunkter. Kan föreslå kursspecifika frågor i kursenkäten. Informerar sina kurskamrater om diskussioner och rekommendationer från mötena. Ersättning utgår i form av presentkort på 200 kr på Cremona. Kursutvärderingar vid Chalmers Overview of the Pipeline and OpenGL Ulf Assarsson 1

The screen consists of many pixels 3D-Rendering Objects are often made of triangles x,y,z- coordinate for each vertex Y Z X State-of-the-Art Real-Time Rendering 2001 Z Y State-of-the-Art Real-Time Rendering X 2001 Textures One application of texturing is to glue images onto geometrical object Texturing: Glue images onto geometrical objects Purpose: more realism, and this is a cheap way to do it + = + = 2

Lighting computation per triangle vertex light blue Rasterizer Geometry red green The Graphics Rendering Pipeline You say that you render a 3D scene, but what is it? First, of all to take a picture, it takes a camera a virtual one. Decides what should end up in the final image A 3D scene is: Geometry (triangles, lines, points, and more) Light sources Material properties of geometry Textures (images to glue onto the geometry) A triangle consists of 3 vertices A vertex is 3D position, and may include normals and more. input Lecture 1: Real-time Rendering The Graphics Rendering Pipeline The pipeline is the engine that creates images from 3D scenes Three conceptual stages of the pipeline: Application (executed on the CPU) Geometry Rasterizer 3D scene Image output The APPLICATION stage Executed on the CPU Means that the programmer decides what happens here Examples: Collision detection Speed-up techniques Animation Most important task: send rendering primitives (e.g. triangles) to the graphics hardware The GEOMETRY stage Task: geometrical operations on the input data (e.g. triangles) Allows: Move objects (matrix multiplication) Move the camera (matrix multiplication) Compute lighting at vertices of triangle Project onto screen (3D to 2D) Clipping (avoid triangles outside screen) Map to window 3

The RASTERIZER stage Main task: take output from GEOMETRY and turn into visible pixels on screen Also, add textures and various other per-pixel operations And visibility is resolved here: sorts the primitives in the z-direction Rewind! Let s take a closer look The programmer sends down primtives to be rendered through the pipeline (using API calls) The geometry stage does per-vertex operations The rasterizer stage does per-pixel operations Next, scrutinize geometry and rasterizer Virtual Camera Defined by position, direction vector, up vector, field of view, near and far plane. point dir fov (angle) near Create image of geometry inside gray region Used by OpenGL, DirectX, ray tracing, etc. far GEOMETRY - The view transform You can move the camera in the same manner as objects But apply inverse transform to objects, so that camera looks down negative z-axis z x 4

GEOMETRY - Lighting Compute lighting at vertices Example light blue Rasterizer Geometry red green Try to mimic how light in nature behaves Hard so uses empirical models, hacks, and some real theory Much more about this in later lecture GEOMETRY - Projection Two major ways to do it Orthogonal (useful in few applications) Perspective (most often used) Mimics how humans perceive the world, i.e., objects apparent size decreases with distance GEOMETRY - Projection Also done with a matrix multiplication! Pinhole camera (left), analog used in CG (right) 5

GEOMETRY Clipping and Screen Mapping Square (cube) after Clip primitives to square Screen mapping, scales and translates square so that it ends up in a rendering window These screen space coordinates together with Z (depth) are sent to the rasterizer stage The RASTERIZER in more detail Scan-conversion Find out which pixels are inside the primitive Texturing + = Put images on triangles blue Interpolation over triangle Z-buffering red green Make sure that what is visible from the camera really is displayed Double buffering And more The RASTERIZER Z-buffering The graphics hardware is pretty stupid It just draws triangles However, a triangle that is covered by a more closely located triangle should not be visible Assume two equally large tris at different depths incorrect Triangle 1 Triangle 2 Draw 1 then 2 correct Draw 2 then 1 The RASTERIZER Z-buffering Would be nice to avoid sorting The Z-buffer (aka depth buffer) solves this Idea: Store z (depth) at each pixel When rasterizing a triangle, compute z at each pixel on triangle Compare triangle s z to Z-buffer z-value If triangle s z is smaller, then replace Z-buffer and color buffer Else do nothing Can render in any order The RASTERIZER double-buffering The monitor displays one image at a time Top of screen new image Bottom old image No control of split position And even worse, we often clear the screen before generating a new image A better solution is double buffering (Could instead keep track of rasterpos and vblank). 6

The RASTERIZER double-buffering Use two buffers: one front and one back The front buffer is displayed The back buffer is rendered to When new image has been created in back buffer, swap front and back And, lately Programmable shading has become a hot topic Vertex shaders Pixel shaders Adds more control and much more possibilities for the programmer HARDWARE Vertex shader program Pixel shader program OpenGL function format The Pipeline and OpenGL function name glvertex3f(x,y,z) dimensions belongs to GL library x,y,z are floats glvertex3fv(p) p is a pointer to an array Example type of object location of vertex A Simple Program Generate a triangle on a solid background glbegin(gl_polygon) glvertex3f(0.0, 0.0, 0.0); glvertex3f(0.0, 1.0, 0.0); glvertex3f(0.0, 0.0, 1.0); glend( ); end of object definition 7

#ifdef WIN32 #include <windows.h> #endif Simple Application... #include <GL/glut.h> // This also includes gl.h static void drawscene(void) { glcolor3f(1,1,1); glbegin(gl_polygon); glvertex3f( 4.0, 0, 4.0); glvertex3f( 4.0, 0,-4.0); glvertex3f(-4.0, 0,-4.0); glend(); } Usually this and next 2 slides are put in the same file main.cpp void display(void) { glclearcolor(0.2, 0.2, 0.8, 1.0); // Set clear color glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); // Clears the color buffer and the z-buffer int w = glutget((glenum)glut_window_width); int h = glutget((glenum)glut_window_height); glviewport(0, 0, w, h); // Set viewport } Simple Application glmatrixmode(gl_projection); // Set matrix glloadidentity(); gluperspective(45.0,w/h, 0.2, 10000.0); // FOV, aspect ratio, near, far glmatrixmode(gl_modelview); // Set modelview matrix glloadidentity(); glulookat(10, 10, 10, // look from 0, 0, 0, // look at 0, 0, 1); // up vector drawscene(); glutswapbuffers(); // swap front and back buffer. This frame will now been displayed. int main(int argc, char *argv[]) { glutinit(&argc, argv); } Simple Application... /* open window of size 512x512 with double buffering, RGB colors, and Z- buffering */ glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutinitwindowsize(512,512); glutcreatewindow("test App"); /* the display function is called once when the glumainloop is called, * but also each time the window has to be redrawn due to window * changes (overlap, resize, etc). */ glutdisplayfunc(display); // Set the main redraw function glutmainloop(); /* start the program main loop */ return 0; Changing Color per Vertex static void drawscene(void) { // glcolor3f(1,1,1); glbegin(gl_polygon); glcolor3f(1,0,0); glvertex3f( 4.0, 0, 4.0); } glcolor3f(0,1,0); glvertex3f( 4.0, 0,-4.0); glcolor3f(0,0,1); glvertex3f(-4.0, 0,-4.0); glend(); Cooler application Starts looking good! Ulf Assarsson 2008 8

Ray Tracing and Geometric Optics One way to form an image is to follow rays of light from a point source finding which rays enter the lens of the camera. However, each ray of light may have multiple interactions with objects before being absorbed or going to infinity. Physical Approaches Ray tracing: follow rays of light from center of until they either are absorbed by objects or go off to infinity Can handle global effects Multiple reflections Translucent objects Slow Must have whole data base available at all times Radiosity: Energy based approach Very slow 9