CS 4363/6353 OTHER THINGS YOU SHOULD KNOW. OVERVIEW Matrix Stacks Raytracing and NPR Physics Engines Common File Formats.

Slides:



Advertisements
Similar presentations
Lecture 8 Transparency, Mirroring
Advertisements

Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
The Art and Technology Behind Bioshock’s Special Effects
Introduction To 3D Modeling
3D Graphics Rendering and Terrain Modeling
Translation and Rotation in 2D and 3D David Meredith Aalborg University.
SE 313 – Computer Graphics Lecture 13: Lighting and Materials Practice Lecturer: Gazihan Alankuş 1.
1. What is Lighting? 2 Example 1. Find the cubic polynomial or that passes through the four points and satisfies 1.As a photon Metal Insulator.
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.
Computer Graphics - Class 10
Meshes Dr. Scott Schaefer. 3D Surfaces Vertex Table.
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Object-Order vs. Screen-Order Rendering April 24, 2003.
Global Illumination May 7, Global Effects translucent surface shadow multiple reflection.
7M836 Animation & Rendering
AGD: 5. Game Arch.1 Objective o to discuss some of the main game architecture elements, rendering, and the game loop Animation and Games Development.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Hierarchical Transformations Hierarchical Models Scene Graphs
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
9/20/2001CS 638, Fall 2001 Today Finishing Up Reflections More Multi-Pass Algorithms Shadows.
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) CS 426 Intro to 3D Computer Graphics © 2003, 2004, 2005 Jason Leigh Electronic.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Introducing To 3D Modeling George Atanasov Telerik Corporation
CSE 381 – Advanced Game Programming Basic 3D Graphics
Week 2 - Wednesday CS361.
CS 376 Introduction to Computer Graphics 04 / 11 / 2007 Instructor: Michael Eckmann.
Project Raytracing. Content Goals Idea of Raytracing Ray Casting – Therory – Practice Raytracing – Theory – Light model – Practice Output images Conclusion.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
CS 4363/6353 TEXTURE MAPPING PART II. WHAT WE KNOW We can open image files for reading We can load them into texture buffers We can link that texture.
Course Introduction and Terminology CGDD 4113 – 3D MODELING AND ANIMATION.
Image Synthesis Rabie A. Ramadan, PhD D Images.
Games Games GAMES. About Me:  Ariel Nehmad.  I’m 31 years old.  Live in Buenos Aires, Argentina.  CTO and father of Flare3D, FLSL and Flare3D Phys…
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
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.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Basic Rendering Pipeline and Shading Spring 2012.
CSE 381 – Advanced Game Programming GLSL Lighting.
2008/9/24 Kim, HyungSeok. HyungSeok Kim, Konkuk University Part I: Framework – 1. Windows creation – 2. Renderer – 3. Lights and Objects/Model loading.
Game Programming 06 The Rendering Engine
Modeling with OpenGL Practice with OpenGL transformations.
1 Ray-Tracing ©Anthony Steed Overview n Recursive Ray Tracing n Shadow Feelers n Snell’s Law for Refraction n When to stop!
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
B. RAMAMURTHY Simulating Motion and Implementing Animation.
Mark Nelson 3d projections Fall 2013
Sky Boxes and Vector Math 2 Course Information CVG: Programming 4 My Name: Mark Walsh Website:
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
CS380: Computer Graphics Distributed Ray Tracing TA Course URL:
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
Project 3 Help Session: Ray Tracing. Getting Started Download the starter pack. 1.sample_ray.exe 2.ray-skel directory 3.scenes directory Look at the Road.
APE'07 IV INTERNATIONAL CONFERENCE ON ADVANCES IN PRODUCTION ENGINEERING June 2007 Warsaw, Poland M. Nowakiewicz, J. Porter-Sobieraj Faculty of.
Chapter 5. Lighting Computer Graphics (spring, 2009) School of Computer Science University of Seoul.
Unity 3D Rolfe Bozier 24-Apr-2017
Introduction to Computer Graphics
Games Development Practices 3D Modelling
© University of Wisconsin, CS559 Spring 2004
Photorealistic Rendering vs. Interactive 3D Graphics
Introducing Blender.
Texture Mapping Part II
Assignment 8 Chess Game.
Introducing Blender.
Introducing Blender.
Lighting.
CSE 381 – Advanced Game Programming Terrain
UMBC Graphics for Games
CS5500 Computer Graphics May 29, 2006
Computer Graphics 4Practical Lesson
Computer Graphics Material Colours and Lighting
Presentation transcript:

CS 4363/6353 OTHER THINGS YOU SHOULD KNOW

OVERVIEW Matrix Stacks Raytracing and NPR Physics Engines Common File Formats

MATRIX STACKS Typically, matrices are stored in a stack to avoid this Stacks give us the ability to rotate one body around another Stacks are also how (character) animation is done Let’s say we wanted to fly through the solar system You still have a camera matrix The sun has been translated (but probably not rotated)

MATRIX STACK EXAMPLE Camera matrix

MATRIX STACK EXAMPLE Camera matrix “Push” the camera matrix. Note: everything is rotated by our camera matrix…

MATRIX STACK EXAMPLE Camera matrix “Push” the translation of the sun Sun trans matrix

MATRIX STACK EXAMPLE Camera matrix “Push” the translation of the sun Sun trans matrix Combine everything on the stack into one MV matrix, then draw the sun. Trans first, then camera! mMV Order of operations

MATRIX STACK EXAMPLE Camera matrix Sun trans matrix The Earth is both translated Note: yes, yes… I know it’s not to scale…

MATRIX STACK EXAMPLE Camera matrix Sun trans matrix The Earth is both translated Earth trans matrix

MATRIX STACK EXAMPLE Camera matrix Sun trans matrix The Earth is both translated and rotated (in that order), so we push those on a separate frame… Earth trans matrix Earth rot matrix

MATRIX STACK EXAMPLE Camera matrix Sun trans matrix WRONG! The matrices are multiplied TOP DOWN! Earth trans matrix Earth rot matrix

MATRIX STACK EXAMPLE Camera matrix Sun trans matrix WRONG! The matrices are multiplied TOP DOWN! Earth rot matrix Earth trans matrix

MATRIX STACK EXAMPLE Camera matrix Sun trans matrix Combine everything on the stack into one MV matrix, then draw the Earth! mMV Earth rot matrix Earth trans matrix Order

MATRIX STACK EXAMPLE Camera matrix Sun trans matrix What about the moon? Earth rot matrix Earth trans matrix

MATRIX STACK EXAMPLE Camera matrix Sun trans matrix Well, the moon has a translation… Moon trans matrix Earth rot matrix Earth trans matrix

MATRIX STACK EXAMPLE Camera matrix Sun trans matrix Well, the moon has a translation… as well as a rotation… Moon trans matrix Moon rot matrix Earth rot matrix Earth trans matrix

MATRIX STACK EXAMPLE Camera matrix Sun trans matrix Well, the moon has a translation… as well as a rotation… Moon rot matrix Moon trans matrix Earth rot matrix Earth trans matrix

MATRIX STACK EXAMPLE Camera matrix Sun trans matrix So we combine everything on the stack into one MV matrix, then draw the moon mMV Earth rot matrix Earth trans matrix Moon rot matrix Moon trans matrix Order

MATRIX STACK EXAMPLE Camera matrix Sun trans matrix What if we want to draw a little independent spaceship? Earth rot matrix Earth trans matrix Moon rot matrix Moon trans matrix

MATRIX STACK EXAMPLE Camera matrix Sun trans matrix POP the Moon stuff! Earth rot matrix Earth trans matrix

MATRIX STACK EXAMPLE Camera matrix Sun trans matrix POP the Earth stuff! Earth rot matrix Earth trans matrix

MATRIX STACK EXAMPLE Camera matrix Sun trans matrix POP the Sun stuff!

MATRIX STACK EXAMPLE Camera matrix …Leaving us with just the camera matrix. Then, we can add the spaceship matrices on top of that.

MATRIX STACK EXAMPLE Camera matrix Push the spaceship trans first! Ship trans matrix

MATRIX STACK EXAMPLE Camera matrix Then the rotation! Why? Ship trans matrix Ship rot matrix

MATRIX STACK EXAMPLE Camera matrix Now that you have your MV, draw the ship… Ship trans matrix Ship rot matrix mMV

RAYTRACING Easy to read article at Note: there are independent reflection, refraction and shadow rays

EXAMPLES (AGAIN, FROM WIKIPEDIA.ORG)

RAYTRACING Advantages: Realistic simulation of lighting Natural shadows Simple to implement (but not trivial) Heavily parallelizable Disadvantages Still an approximation not truly photorealistic Must limit depth Recursively adds up light values of rays Ssssssssssssslllllllllllllllloooooooooooooooowwwwwwwwwwwwww

“…holds that when human replicas look and act almost, but not perfectly, like actual human beings, it causes a response of revulsion among human observers” THE UNCANNY VALLEY… Fantasy: The Spirits Within

NPR (NON-PHOTOREALISTIC RENDERING) Stylistic Water color Impressionism Example: Toon Shading Geometry remains the same Shading changes Commonly seen in video games Borderlands

WORKING WITH PHYSICS ENGINES There are several out there: Tokamak (open source, no longer maintained) Bullet (open source – several commercial games and movies like “2012” and “Bolt”) Havok (commercial – Ireland, loads of commercial games) PhysX (commercial – Ageia/NVDIA, CUDA, uses PPU, tons of games as well) Usually provide: Gravity Collision (between static and dynamic bodies) Soft-body physics Ragdoll physics Vehicle dynamics Fluid simulations Cloth simulations

HOW WE USE THEM… Physics engine is a black box We “load” the physics engine Tell it which objects are dynamic Tell it which are static Define parameters, such as gravity, bounce and so on During each frame of animation: Update the physics engine by a delta time Ask the physics engine for: The location of each dynamic object The orientation of each dynamic object

TOKAMAK EXAMPLE Typically have a limited number of basic shapes Cube Capsule Sphere Must declare variables to hold all of the objects in your scene #include neSimulator* gSim = NULL; neRigidBody* gCubes[NUM_CUBES]; neRigidBody* sphere; neAnimatedBody* floor1 = NULL; neT3 t;

void setupPhysicsEngine() { // This will define the size and shape of each cube neGeometry* geom; // length, width and height of the cube neV3 boxSize1; neV3 gravity; neV3 pos; float mass; float fmass = 0.2f; // The number of total objects the simulator has to keep track of... neSimulatorSizeInfo sizeInfo; // Fill in the size info about the environment sizeInfo.rigidBodiesCount = NUM_CUBES+1; sizeInfo.animatedBodiesCount = 1; // total number of objects sizeInfo.geometriesCount = sizeInfo.rigidBodiesCount + sizeInfo.animatedBodiesCount; // total number of collisions possible n*(n-1)/2 sizeInfo.overlappedPairsCount = sizeInfo.geometriesCount*(sizeInfo.geometriesCount-1)/2; sizeInfo.rigidParticleCount = 0; sizeInfo.constraintsCount = 0; sizeInfo.terrainNodesStartCount = 0; gravity.Set(0.0f, -3.0f, 0.0f); gSim = neSimulator::CreateSimulator(sizeInfo, NULL, &gravity); // Setup a box - using loop for (int i = 0; i < NUM_CUBES; i++) { gCubes[i] = gSim->CreateRigidBody(); // Get the geometry object from the cube geom = gCubes[i]->AddGeometry(); boxSize1.Set(1.0f, 1.0f, 1.0f); geom->SetBoxSize(boxSize1[0], boxSize1[1], boxSize1[2]); gCubes[i]->UpdateBoundingInfo(); mass = 1.0f; gCubes[i]->SetInertiaTensor(neBoxInertiaTensor(boxSize1[0], boxSize1[1], boxSize1[2], mass)); gCubes[i]->SetMass(mass); pos.Set(i%10-5, i/10+0.5, -30); gCubes[i]->SetPos(pos); } // Create the sphere sphere = gSim->CreateRigidBody(); geom = sphere->AddGeometry(); geom->SetSphereDiameter(2); sphere->UpdateBoundingInfo(); sphere->SetInertiaTensor(neSphereInertiaTensor(2, fmass)); sphere->SetMass(fmass); pos.Set(0, 1, -4); sphere->SetPos(pos); sphere->SetAngularDamping(0.01f); // Create the floor floor1 = gSim->CreateAnimatedBody(); geom = floor1->AddGeometry(); boxSize1.Set(100, 0.001, 100); geom->SetBoxSize(boxSize1[0], boxSize1[1], boxSize1[2]); floor1->UpdateBoundingInfo(); pos.Set(0, 0, 0); floor1->SetPos(pos); }

void display () { degree += 0.1f; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gSim->Advance(0.015); //Cubes for (int i = 0; i < NUM_CUBES; i++) { t = gCubes[i]->GetTransform(); cube_state[0][0] = t.rot[0][0]; cube_state[1][0] = t.rot[1][0]; cube_state[2][0] = t.rot[2][0]; cube_state[3][0] = t.pos[0]; cube_state[0][1] = t.rot[0][1]; cube_state[1][1] = t.rot[1][1]; cube_state[2][1] = t.rot[2][1]; cube_state[3][1] = t.pos[1]; cube_state[0][2] = t.rot[0][2]; cube_state[1][2] = t.rot[1][2]; cube_state[2][2] = t.rot[2][2]; cube_state[3][2] = t.pos[2]; cube_state[0][3] = 0.0f; cube_state[1][3] = 0.0f; cube_state[2][3] = 0.0f; cube_state[3][3] = 1.0f; drawCube(…); } // Sphere t = sphere->GetTransform(); sphere_state[0][0] = t.rot[0][0]; sphere_state[1][0] = t.rot[1][0]; sphere_state[2][0] = t.rot[2][0]; sphere_state[3][0] = t.pos[0]; sphere_state[0][1] = t.rot[0][1]; sphere_state[1][1] = t.rot[1][1]; sphere_state[2][1] = t.rot[2][1]; sphere_state[3][1] = t.pos[1]; sphere_state[0][2] = t.rot[0][2]; sphere_state[1][2] = t.rot[1][2]; sphere_state[2][2] = t.rot[2][2]; sphere_state[3][2] = t.pos[2]; sphere_state[0][3] = 0.0f; sphere_state[1][3] = 0.0f; sphere_state[2][3] = 0.0f; sphere_state[3][3] = 1.0f; drawSphere(…); glutSwapBuffers(); glutPostRedisplay(); }

COMMON FILE FORMATS.3ds – AutoDesk 3DS Max (legacy).blend - Blender.c4d – Cinema 4D.dae – COLLADA (xml).fbx – AutoDesk.lwo – LightWave Object.ma/.mb – AutoDesk Maya.max – AutoDesk 3DS Max.md2/.md3 – Quake 2/Quake 3.pov – POV ray file.skp – Google Sketchup.sldasm – SolidWorlds Assembly.smd – Valve’s format.u3D – Universal 3D (3D Industry Consortium - xml)

THE.OBJ FILE FORMAT Also called WaveFront OBJ Text-based Easy to work with and widely accepted File specifies: Position of each vertex UVs of each vertex Normals of each vertex List of faces (triangles)

EXAMPLE ( # List of Vertices, with (x,y,z[,w]) coordinates, w is optional. v v # Texture coordinates, in (u,v[,w]) coordinates, w is optional. vt [0.234] vt # Normals in (x,y,z) form; normals might not be unit. vn vn # Face Definitions (see below) f 1 2 3# Vertices only f 3/1 4/2 5/3# Vertices/Texture coords f 6/4/1 3/5/3 7/6/5# Vertices/Textures/Normals f......

OTHER OPTIONS Smooth shading s 1 – smoothing is true s off – no smoothing Materials may be put into a separate.mtl file newmtl myMat Ka #ambient white Kd #diffuse white Ks #specular off Ns # size of spec (s from our lighting equation) Tr 0.9#transparency