Further games and graphics concepts COSE50581 Introduction to Module and Recap Bob Hobbs Faculty of Computing, Engineering and Technology Staffordshire.

Slides:



Advertisements
Similar presentations
Prof. Muhammad Saeed. Procedure-Driven Programming Event-Driven Programming Events Messages Event Handlers GUI Windows and Multitasking Queues ( System.
Advertisements

Real-Time Rendering 靜宜大學資工研究所 蔡奇偉副教授 2010©.
COMPUTER GRAPHICS SOFTWARE.
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Graphics Pipeline.
Introduction to Windows Programming. First Windows Program This program simply displays a blank window. The following code is the minimum necessary to.
CS 4363/6353 INTRODUCTION TO COMPUTER GRAPHICS. WHAT YOU’LL SEE Interactive 3D computer graphics Real-time 2D, but mostly 3D OpenGL C/C++ (if you don’t.
CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS.
IN-LAB # 1 - GETTING STARTED - BUT FIRST: 1.Project ideas - watch the scope!!! 2.Check accounts 3. Either myself or the TA need to check you off BEFORE.
Further Programming for 3D applications CE Introduction to Further Programming for 3D application Bob Hobbs Faculty of Computing, Engineering and.
Graphics Systems I-Chen Lin’s CG slides, Doug James’s CG slides Angel, Interactive Computer Graphics, Chap 1 Introduction to Graphics Pipeline.
The Graphics Pipeline CS2150 Anthony Jones. Introduction What is this lecture about? – The graphics pipeline as a whole – With examples from the video.
Sep 30, I3I3DG&VR CE00539-m Interactive 3D Graphics and Virtual Reality Bob Hobbs Faculty of Computing, Engineering and Technology Staffordshire.
Game Engine Design ITCS 4010/5010 Spring 2006 Kalpathi Subramanian Department of Computer Science UNC Charlotte.
First Windows Program Hello Windows. 2 HELLOWIN.C #include LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; int WINAPI WinMain (HINSTANCE hInstance,
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) CS 426 Intro to 3D Computer Graphics © 2003, 2004, 2005 Jason Leigh Electronic.
CS 480/680 Computer Graphics Course Overview Dr. Frederick C Harris, Jr. Fall 2012.
Further Programming for 3D applications CE Introduction to Further Programming for 3D application Bob Hobbs Faculty of Computing, Engineering and.
Advanced Computer Graphics March 06, Grading Programming assignments Paper study and reports (flipped classroom) Final project No written exams.
Chris Kerkhoff Matthew Sullivan 10/16/2009.  Shaders are simple programs that describe the traits of either a vertex or a pixel.  Shaders replace a.
COMP 261 Lecture 16 3D Rendering. input: set of polygons viewing direction direction of light source(s) size of window. output: an image Actions rotate.
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
Overview of Previous Lesson(s) Over View  Visual C++ provides us with 3 basic ways of creating an interactive Windows application  Using the Windows.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
Chapter 1: Hello, MFC Windows Programming Model Department of Digital Contents Sang Il Park.
Chapter 1: Hello, MFC Your first MFC Application Department of Digital Contents Sang Il Park.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
1 Introduction to Computer Graphics SEN Introduction to OpenGL Graphics Applications.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 CS4610/7610: Introduction to Computer Graphics.
BZUPAGES.COM Visual Programming Lecture – 2 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
Direct3D Workshop November 17, 2005 Workshop by Geoff Cagle Presented by Players 2 Professionals.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
COMPUTER GRAPHICS CSCI 375. What do I need to know?  Familiarity with  Trigonometry  Analytic geometry  Linear algebra  Data structures  OOP.
Lecture 11: Exam Revision 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271  Coursework.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Programming 3D Applications CE Displaying Computer Graphics Week 3 Lecture 5 Bob Hobbs Faculty of Computing, Engineering and Technology Staffordshire.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
GUI-Based Programming ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Dialog boxes Modal and modeless dialog boxes Displaying about dialog box: case WM_COMMAND : switch (LOWORD (wParam)) { case IDM_APP_ABOUT : DialogBox (hInstance,
Subject Name: Computer Graphics Subject Code: Textbook: “Computer Graphics”, C Version By Hearn and Baker Credits: 6 1.
The WM_NCHITTEST Message  This is an internal message used by Windows for generating all the other mouse messages.  Though it almost never needs to be.
Introduction to OpenGL
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Lecture 8: Discussion of papers OpenGL programming Lecturer: Simon Winberg Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
Introduction to Computer Graphics
Spring 2006 G5BAGR – Advanced Computer Graphics
- Introduction - Graphics Pipeline
Windows Programming Lecture 09.
Window.
Windows Programming Model
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
Models and Architectures
Introduction to Computer Graphics with WebGL
The program in traditional OS
Graphics Processing Unit
Windows Programming Lecture 13
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
Lecture 13 Clipping & Scan Conversion
Computer Graphics Introduction to Shaders
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Presentation transcript:

Further games and graphics concepts COSE50581 Introduction to Module and Recap Bob Hobbs Faculty of Computing, Engineering and Technology Staffordshire University

Outline Module Details Module Details What is 3D programming? What is 3D programming? Physics & AI Physics & AI Typical Processing Steps Typical Processing Steps Modelling and Rendering Modelling and Rendering Windows and Direct X Windows and Direct X Programmable Pipeline Programmable Pipeline Summary Summary

Module Details Teaching Team Teaching Team –Bob –Steve Foster –Carl Mitchell Semester 1 & 230 cats Semester 1 & 230 cats 3 Hours per week 3 Hours per week –Weeks (2hrs Lecture + 1hr Tutorial) –Weeks 7 – 12 (1hr Lecture + 2hrs Tutorial) –Timetable Timetable

Module Details Course Handbook & Lecture Notes Specification Specification Specification Blackboard (not yet live) Blackboard (not yet live) Assignment Details 70% assignment work 70% assignment work –Phased submission with reflective report components 30% two hour exam at end of year 30% two hour exam at end of year

Program of Study – Semester 1 Week 01 Introduction to Module and DirectX11, Maths Week 01 Introduction to Module and DirectX11, Maths Week 02 Geometry, Transformations, Colour using the programmable pipeline Week 02 Geometry, Transformations, Colour using the programmable pipeline Week 03 Depth, Stencil Buffer, Simple Lighting Week 03 Depth, Stencil Buffer, Simple Lighting Week 04Camera, Transformations Week 04Camera, Transformations Week 05Data structures for graphics engines Week 05Data structures for graphics engines Week 06 Advanced Lighting and Shading Week 06 Advanced Lighting and Shading Week 07Textures & Texture Mapping, Render States Week 07Textures & Texture Mapping, Render States Week 08Cube, Normal and Bump mapping Week 08Cube, Normal and Bump mapping Week 09Meshing and Instancing Week 09Meshing and Instancing Week 10 Culling, Clipping, Depth and Line Drawing Week 10 Culling, Clipping, Depth and Line Drawing Week 11Tessellation and Terrain Week 11Tessellation and Terrain Week 12Review and Assessment Week 12Review and Assessment

Program of Study – Semester 2 Week 01 Animation and Timing Week 01 Animation and Timing Week 02 Newtonian Physics (velocity, motion, forces) Week 02 Newtonian Physics (velocity, motion, forces) Week 03 Gravity and friction Week 03 Gravity and friction Week 04Particles and Ballistics Week 04Particles and Ballistics Week 05Rotational Physics Week 05Rotational Physics Week 06 Collision Detection and Response Week 06 Collision Detection and Response Week 07Principles of AI, Behaviours Week 07Principles of AI, Behaviours Week 08Pathfinding and searching, Autonomous motion Week 08Pathfinding and searching, Autonomous motion Week 09Ai for scene optimisation Week 09Ai for scene optimisation Week 10 State management Week 10 State management Week 11Decisions and cognition Week 11Decisions and cognition Week 12Review and Assessment Week 12Review and Assessment

What is 3D rendering? Object Viewer Generally deals with graphical display of 3D objects as seen by viewer Synthetic image will vary according to: viewing direction, viewer position, illumination, object properties,... Projection onto 2D surface

What is 3D Computer Graphics? 3D graphics: generation of graphical display (rendering) of 3D object(s) from specification (model(s)) 3D graphics: generation of graphical display (rendering) of 3D object(s) from specification (model(s)) Specification Modelling Graphical display Rendering such as

Wireframe polygonal modelSolid object Vertices Viewpoint Typical Processing Steps Facets Transformation Hidden surface removal Light source Shading

Object model(s) Illumination model Viewing and projection specification Graphics engine Graphical display Rendering: operations that produce view of scene projected onto view surface Modelling: numerical description of scene objects, illumination, and viewer Typical Processing Steps

23-Oct D picture Light source Surface material Typical Processing Steps xmxm zmzm ymym xmxm zmzm ymym 3D world coordinates 3D modelling coordinates 2D device coordinates 3D viewing coordinates & Culling xwxw zwzw ywyw xvxv zvzv yvyv Graphics pipeline: generation of picture involves sequence of coordinate transformations, hidden surface removal, shading/texturing and etc...

23-Oct-1512 Typical graphics pipeline Typical Processing Steps Pos., orient. of display area Geometry models Shapes World pos., orient., sizes Viewpoint Pos., orient. Field of view Projection type Viewport Object & back-face culling View mapping onto display device Generation / configuration of world Mesh operations Geometry processing: shape, world geometry, viewpoint 2D picture Lights & materials Shading, texturing,... Light pos., orient. Optical char. Pixel operations Material processing: colour, texture, transparency/occlusion, … Hidden surface removal Viewpoint

23-Oct-1513 Typical Processing Steps Loading or generation of object (shape, surface properties) model Loading or generation of object (shape, surface properties) model Model coordinate transformation: translation, rotation, projection,... Model coordinate transformation: translation, rotation, projection,... Hidden surface removal Hidden surface removal Shading Shading Display Display

23-Oct-1514 Viewport transformation 3D Models Modelling transformation 2D Display Back-face culling & Vertex lighting Viewing transformation Object culling Clipping could also be performed before viewing transformation, or during rasterisation Polygon clipping Typical Processing Steps Projection Scan conv. HSR, Texturing, & Shading Typical graphics pipeline

Modelling Human Head Model 1438 facets

Modelling Human Head Model 7258 facets

Modelling Teacher and Board Model 2074 facets

Rendering Shaded Human Head 1438 facets

Rendering Shaded Human Head 7258 facets

Rendering Shaded Teacher and Board

23-Oct-1521 Triangle scan conversion Rendering requires scan conversion Rendering requires scan conversion Scan conversion of graphics primitive: Scan conversion of graphics primitive: – point-by- point traversal of primitive along (horizontal) scan lines along (horizontal) scan lines coherence often exploited (e.g. incremental computation) coherence often exploited (e.g. incremental computation) å reduces computational cost Rendering

23-Oct-1522 x y Rasterisation of filled triangle Point grid (raster) Scan line Point / Pixel External pointRendering b Common approach: polygon interior filled line by line, one point at a time (rasterisation) linear interpolation (i.e. line equation) often used for colour shade, depth and other calculations at each pixellinear interpolation (i.e. line equation) often used for colour shade, depth and other calculations at each pixel

23-Oct-1523 General procedure for filled triangles: find intersections of scan line with polygon edge find intersections of scan line with polygon edge – use equation of line joining two vertices: interpolation edge coherence, hence use incremental computation edge coherence, hence use incremental computation fill / shade / texture interior points between intersection pairs along scan line fill / shade / texture interior points between intersection pairs along scan line Rendering

23-Oct-1524 General procedure for filled triangles: find intersections of scan line with polygon edge find intersections of scan line with polygon edge – use equation of line joining two vertices: interpolation edge coherence, hence use incremental computation edge coherence, hence use incremental computation fill / shade / texture interior points between intersection pairs along scan line fill / shade / texture interior points between intersection pairs along scan line Rendering

Windows Programming Rendering takes place in a window Rendering takes place in a window Application must generate window in which to render graphics Application must generate window in which to render graphics IP3DA used C and GLUT to handle windows. OpenGL can run in GLUT or other windowing framework including MS windows IP3DA used C and GLUT to handle windows. OpenGL can run in GLUT or other windowing framework including MS windows DirectX is integrated into windows programming API DirectX is integrated into windows programming API

What is a “window?” The most obvious windows are the application windows on your desktop. The most obvious windows are the application windows on your desktop. The term “window” also refers to any child window or control (such as a button) within a window. The term “window” also refers to any child window or control (such as a button) within a window. Windows are organized in a hierarchy. Windows are organized in a hierarchy.

Example - Calculator

Event Driven Programming Windows programming is event driven. Windows programming is event driven. An event driven program sits and waits for an event to process. An event driven program sits and waits for an event to process. Events include moving or sizing a window, clicking the mouse button over a window, or typing keys on the keyboard. Events include moving or sizing a window, clicking the mouse button over a window, or typing keys on the keyboard. Windows programs are notified of events by messages sent from the OS. Windows programs are notified of events by messages sent from the OS.

Win32 API We will use the Win32 Platform API to write a windows program. We will use the Win32 Platform API to write a windows program. –Typically more tedious, but we only need to create one window. –Faster and Smaller executable. –Written in C++ Other options include: Other options include: –MFC, Qt, wxWindows, SDL,.NET Forms

WinMain Instead of main, windows programs use WinMain Instead of main, windows programs use WinMain WinMain has different parameters: WinMain has different parameters: – HINSTANCE hInstance – a handle to the program – HINSTANCE hPrevInstance – no longer used. – LPSTR lpCmdLine – unparsed command line. Doesn’t include executable’s filename. – int nCmdShow – Specifies how the window should be initially shown (ie. Minimized, Maximized, Normal) WinMain must have a WINAPI modifier. WinMain must have a WINAPI modifier. – int WINAPI WinMain (…) WinMain still returns an integer like main. WinMain still returns an integer like main.

Headers To use the Win32 API we need to #include windows.h To use the Win32 API we need to #include windows.h If we #define WIN32_LEAN_AND_MEAN before #including windows.h, the compiler will skip compiling the more rarely used windows code. If we #define WIN32_LEAN_AND_MEAN before #including windows.h, the compiler will skip compiling the more rarely used windows code.

Windows Program Outline Create Window Class Create Window Class Create Window Create Window Show the Window Show the Window Enter Message Loop Enter Message Loop

Window Classes A window class acts as a template for window creation. A window class acts as a template for window creation. Window classes are not classes in the C++ sense. Window classes are not classes in the C++ sense. We can set such properties as: We can set such properties as: –Name of the window class – important for identifying it later! –Window style – How it looks and its default behaviors. –Window procedure – a pointer to function that handles messages for a window. –Default cursor, icon, and menu.

Creating a Window Class Fill out a WNDCLASS or WNDCLASSEX structure. Fill out a WNDCLASS or WNDCLASSEX structure. Use the structure to register the class with a call to RegisterClass or RegisterClassEx, respectively. Use the structure to register the class with a call to RegisterClass or RegisterClassEx, respectively.

Create the Window Create a Window with a call to CreateWindow or CreateWindowEx. Create a Window with a call to CreateWindow or CreateWindowEx. Some of the parameters you will need to enter include: Some of the parameters you will need to enter include: –The name of a window class. –The name of the window. –A handle to a parent window. ( NULL if no parent) –Initial size and position of the window. CreateWindow and CreateWindowEx will return a window handle ( HWND ) if successful or NULL if failed. CreateWindow and CreateWindowEx will return a window handle ( HWND ) if successful or NULL if failed.

Showing the Window When we create a window it starts off hidden. When we create a window it starts off hidden. To show the window you must call ShowWindow (hWnd, nCmdShow) To show the window you must call ShowWindow (hWnd, nCmdShow) – hWnd – returned from CreateWindow / Ex. – nCmdShow – parameter from WinMain. –This will send a message to the window telling it to show. Call UpdateWindow (hWnd) to force the window to process the show message immediately. Call UpdateWindow (hWnd) to force the window to process the show message immediately.

Message Loops A message loop is needed to forward messages to their windows. A message loop is needed to forward messages to their windows. There are different ways to make a message loop but here is the most common one: There are different ways to make a message loop but here is the most common one: MSG msg = {0}; // returns FALSE when message is WM_QUIT while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg); // translate keyboard messages. DispatchMessage (&msg); // send message to its window. }

Message Loop (Cont’d) The loop uses: The loop uses: –A MSG structure – Holds message information. – GetMessage – Retrieves the next message. Waits for a message if the message queue is empty. – TranslateMessage – Translate some keyboard messages. – DispatchMessage – Dispatches the message to the appropriate windows procedure.

Windows Procedure Every window has an associate procedure for handling messages. Every window has an associate procedure for handling messages. Windows procedures have the following format: Windows procedures have the following format: – LRESULT CALLBACK ProcName (HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);

Window Procedure Example Here is an example procedure: Here is an example procedure: LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_DESTROY: PostQuitMessage (0); return 0; } return DefWindowProc (hwnd, msg, wp, lp); }

Window Procedure Parameters The procedure has 4 parameters: The procedure has 4 parameters: – HWND hwnd – handle to the window receiving the message. This is useful when multiple windows share the same procedure. You can think of it sort of like a this pointer. – UINT msg – The message. – WPARAM wp and LPARAM lp – These are parameters to the message and may represent different things.

Window Procedure Return When the procedure completely handles a message, it should return 0. When the procedure completely handles a message, it should return 0. The procedure should let the OS handle all other messages by calling DefWindowProc and then return its result. The procedure should let the OS handle all other messages by calling DefWindowProc and then return its result.

WM_DESTROY and WM_QUIT Initially we only want to handle one message: WM_DESTROY. Initially we only want to handle one message: WM_DESTROY. –This message is called when a window is closed. –Note that just because the window is destroyed, the program will still run. –To end the program we send WM_QUIT by calling PostQuitMessage.

WM_* Other messages you may want to handle include: Other messages you may want to handle include: – WM_CREATE – WM_SIZE – WM_LBUTTONDOWN – WM_LBUTTONUP – WM_MOUSEMOVE – WM_KEYDOWN – WM_KEYUP – WM_PAINT Check MSDN literature for information about these messages: Check MSDN literature for information about these messages:

Direct X The window has to obtain a handle to a Direct 3D and swap chain to render graphics objects in the windows object created. The window has to obtain a handle to a Direct 3D and swap chain to render graphics objects in the windows object created. In DirectX 11 this is based on the Programmable Pipeline. In DirectX 11 this is based on the Programmable Pipeline.

23-Oct-1546 Suggested Reading (Microsoft DirectX Graphics Documentation) (Microsoft DirectX Graphics Documentation) (Cg homepage) (Cg homepage)

23-Oct-1547 Programmable hardware pipeline on GPU Programmable hardware pipeline on GPU – concurrent processing on single chip Shaders offer code development flexibility and processing speed Shaders offer code development flexibility and processing speed Shader: program segment inserted into graphics pipeline and executed on GPU Shader: program segment inserted into graphics pipeline and executed on GPU – replaces section of fixed-function pipeline vertex shader, pixel shader, geometry shader vertex shader, pixel shader, geometry shader Variety of shader languages Variety of shader languages Summary