Collision Detection between Dynamic Rigid Objects and Static Displacement Mapped Surfaces in Computer Games

Similar documents
References. Additional lecture notes for 2/18/02.

Collision Detection. These slides are mainly from Ming Lin s course notes at UNC Chapel Hill

A Different Approach for Continuous Physics. Vincent ROBERT Physics Programmer at Ubisoft

Collision and Proximity Queries

Distance and Collision Detection

Introduction to Collision Detection

Geometric Computations for Simulation

CPSC / Sonny Chan - University of Calgary. Collision Detection II

Voronoi Diagram. Xiao-Ming Fu

Collision Detection II. These slides are mainly from Ming Lin s course notes at UNC Chapel Hill

Simulation in Computer Graphics Space Subdivision. Matthias Teschner

Critique for CS 448B: Topics in Modeling The Voronoi-clip Collision Detection Algorithm

Lesson 05. Mid Phase. Collision Detection

Collision Detection based on Spatial Partitioning

Collision detection. Piotr Fulma«ski. 1 grudnia

An iterative, octree-based algorithm for distance computation between polyhedra with complex surfaces 1

Collision detection. Piotr Fulma«ski. 19 pa¹dziernika Wydziaª Matematyki i Informatyki, Uniwersytet Šódzki, Polska

Using Bounding Volume Hierarchies Efficient Collision Detection for Several Hundreds of Objects

Physically-Based Laser Simulation

Overview. Collision Detection. A Simple Collision Detection Algorithm. Collision Detection in a Dynamic Environment. Query Types.

Collision Detection. Jane Li Assistant Professor Mechanical Engineering & Robotics Engineering

Computer Graphics Ray Casting. Matthias Teschner

Simulation (last lecture and this one)

15-494/694: Cognitive Robotics

Computational Geometry

Tracking Minimum Distances between Curved Objects with Parametric Surfaces in Real Time

Collision Detection. Pu Jiantao.

Direct Rendering of Trimmed NURBS Surfaces

Intersection Acceleration

Rigid Body Simulation. Jeremy Ulrich Advised by David Mount Fall 2013

Visualization and Analysis of Inverse Kinematics Algorithms Using Performance Metric Maps

Collision Detection CS434. Daniel G. Aliaga Department of Computer Science Purdue University

CS337 INTRODUCTION TO COMPUTER GRAPHICS. Describing Shapes. Constructing Objects in Computer Graphics. Bin Sheng Representing Shape 9/20/16 1/15

Collision handling: detection and response

Spatial Data Structures

Introduction to Optimization Problems and Methods

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Describing Shapes. Constructing Objects in Computer Graphics 1/15

Spatial Data Structures

Introduction to Optimization

Spatial Data Structures

Numerical Optimization

TSBK03 Screen-Space Ambient Occlusion

13.472J/1.128J/2.158J/16.940J COMPUTATIONAL GEOMETRY

08: CONTACT MODELLING 15/02/2016

1.2 Numerical Solutions of Flow Problems

Homework 1: Implicit Surfaces, Collision Detection, & Volumetric Data Structures. Loop Subdivision. Loop Subdivision. Questions/Comments?

Collision Detection with Bounding Volume Hierarchies

Spatial Data Structures

Collision detection in Chrono

T6: Position-Based Simulation Methods in Computer Graphics. Jan Bender Miles Macklin Matthias Müller

Conjectures concerning the geometry of 2-point Centroidal Voronoi Tessellations

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Collision processing

Free-Form Deformation and Other Deformation Techniques

Cut-and-Paste Editing of Multiresolution Surfaces

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Spatial Data Structures

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

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

Jane Li. Assistant Professor Mechanical Engineering Department, Robotic Engineering Program Worcester Polytechnic Institute

Collision Detection of Triangle Meshes using GPU

Lecture 11: Ray tracing (cont.)

Ray Tracing Acceleration Data Structures

Scene Management. Video Game Technologies 11498: MSc in Computer Science and Engineering 11156: MSc in Game Design and Development

CPSC 340: Machine Learning and Data Mining. Density-Based Clustering Fall 2016

ASIA MAHDI NASER ALZUBAIDI Computer Science Department, College of Science Karbala University Karbala, Iraq MAIS SAAD AL-SAOUD

Anatomy of a Physics Engine. Erwin Coumans

Lesson 1: Creating T- Spline Forms. In Samples section of your Data Panel, browse to: Fusion 101 Training > 03 Sculpt > 03_Sculpting_Introduction.

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

Continuous Collision Detection and Physics

Chapter 4. Clustering Core Atoms by Location

Terrain rendering (part 1) Due: Monday, March 10, 10pm

(Refer Slide Time: 00:02:24 min)

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

What is a Rigid Body?

CMSC427 Final Practice v2 Fall 2017

Overview. Collision detection. Collision detection. Brute force collision detection. Brute force collision detection. Motivation

Computational Geometry

Motivation. Freeform Shape Representations for Efficient Geometry Processing. Operations on Geometric Objects. Functional Representations

From curves to surfaces. Parametric surfaces and solid modeling. Extrusions. Surfaces of revolution. So far have discussed spline curves in 2D

Multi-View Matching & Mesh Generation. Qixing Huang Feb. 13 th 2017

The Traditional Graphics Pipeline

Bounding Volume Hierarchies

Programming Game Engines ITP 485 (4 Units)

Surface Modeling. Polygon Tables. Types: Generating models: Polygon Surfaces. Polygon surfaces Curved surfaces Volumes. Interactive Procedural

Comparison of Interior Point Filter Line Search Strategies for Constrained Optimization by Performance Profiles

The Traditional Graphics Pipeline

Dynamic Collision Detection

Subdivision. Outline. Key Questions. Subdivision Surfaces. Advanced Computer Graphics (Spring 2013) Video: Geri s Game (outside link)

Objects DO overlap. Objects DO NOT overlap. No calculations needed.

Surgical Cutting on a Multimodal Object Representation

Curve Corner Cutting

Evaluating the Quality of Triangle, Quadrilateral, and Hybrid Meshes Before and After Refinement

Mesh-Based Inverse Kinematics

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

CAB: Fast Update of OBB Trees for Collision Detection between Articulated Bodies

Point Cloud Simplification and Processing for Path-Planning. Master s Thesis in Engineering Mathematics and Computational Science DAVID ERIKSSON

improving raytracing speed

Numerical Optimization: Introduction and gradient-based methods

Task Description: Finding Similar Documents. Document Retrieval. Case Study 2: Document Retrieval

Transcription:

between Dynamic Rigid Objects and Static Displacement Mapped Surfaces in Computer Games Author:, KTH Mentor: Joacim Jonsson, Avalanche Studios Supervisor: Prof. Christopher Peters, KTH 26 June, 2015

Overview Introduction Purpose: Improve the performance and robustness of collision detection in Avalanche game engine. Contribution: Fix artifacts in some cases by creating new backward projection methods. Highly reduce the time of collision detection between dynamic objects and the terrain by creating multiresolution method.

Outline Introduction 1 Introduction Displacement Mapped Surface 2 3 Multiresolution in the Game Summary

Outline Introduction Displacement Mapped Surface 1 Introduction Displacement Mapped Surface 2 3 Multiresolution in the Game Summary

Introduction Displacement Mapped Surface Definition Collision detection refers the detection of the intersection of two or more objects. Figure: Collision detection in Street Fighter

Penetration Introduction Displacement Mapped Surface When collision is detected, the penetration follows.

Displacement Mapped Surface Two forms of collision detection: Continuous: very expensive. Simulate solid objects in real life. Discrete: objects will end up with penetrating each other.

Backtracking Introduction Displacement Mapped Surface Like Tom Cruise in Edge of Tomorrow, it turns time backwards and fix the penetration that occurred in the last frame.

Displacement Mapped Surface How to determine the collision between the dynamic objects and the terrain? First, how is the terrain formed? It is formed by base triangle primitives with displacement maps.

Outline Introduction Displacement Mapped Surface 1 Introduction Displacement Mapped Surface 2 3 Multiresolution in the Game Summary

Base Primitive Introduction Displacement Mapped Surface p(u, v) = P 0 + u(p 1 P 0 ) + v(p 2 P 0 ), n(u, v) = N 0 + u(n 1 N 0 ) + v(n 2 N 0 ). (1) Figure: A base primitive.

2D Terrain Surface Introduction Displacement Mapped Surface p (u, v) = p(u, v) + d(u, v)n(u, v). (2) Figure: Base primitives and the projected surface.

Displacement maps Introduction Displacement Mapped Surface The terrain map consists of 64 64 terrain patches. Each terrain patch consists of several non-uniform terrain quads. Figure: Displacement map of a terrain patch.(slide 27,Slide 28)

Introduction Displacement Mapped Surface

Projected Surface Introduction Displacement Mapped Surface A bilinear patch is formed by four non-coplanar points: p 00 ([0, 0, 1]), p 01 ([1, 0, 1]), p 10 ([0, 1, 0.5]), p 11 ([1, 1, 4]). Assume that the patch faces upwards. 4 4 3.5 3.5 3 3 2.5 2.5 2 2 1.5 1.5 1 1 0.5 0 0.2 0.4 0.6 0.8 01 0.5 1 0.5 0 0.2 0.4 0.6 0.8 10 0.5 1 (a) Two triangles can bound the bilinear patch. (b) Two triangles cannot bound the bilinear patch.

Displacement Mapped Surface Figure: Determine triangle type. (Slide 30)

Displacement Mapped Surface How to determine the collision between the dynamic objects and the terrain? Second, how is the collision detection performed? It is performed by two phases: the broad phase and the narrow phase.

Outline Introduction 1 Introduction Displacement Mapped Surface 2 3 Multiresolution in the Game Summary

Introduction The broad phase collision detection helps to filtrate the potentially colliding object sets. The brute-force way is doing collision test for all pairs of objects, and the complexity is O(n 2 ). (a) Sweep and prune. (b) Spatial subdivision.

Tree Structure Introduction Figure: Collision detection between AABBs (Axis Aligned Bounding Box).

Swept Volume Introduction The AABB in the game bounds not the object, but the Swept Volume of the object from one frame to the next.

Early Out Introduction Figure: Early out check using the bounding planes.

Outline Introduction 1 Introduction Displacement Mapped Surface 2 3 Multiresolution in the Game Summary

Introduction Problem The large terrain system contains complex geometry, like tunnels, caves and cliffs. The participating colliding shapes are usually restricted to being convex.

Multiresolution Bounding Volume Multiresolution bounding volume method is created in this thesis for the static terrain collision detection. Figure: A 2D case. The coarsest bounding surface (red line), one level finer bounding surface (blue line) and finest bounding surface (black dot line). (Slide 30)

Bounding Volumes Introduction Figure: There will be a dislocation between bounding volumes between neighbouring quads.

Bounding Surface (2D) Figure: A 16 16 quad with constrained points (grey dots) and bounding points (green dots).(slide 13)

Optimization is done separately for each quad. Location relationship in the displacement maps (slide 13) is not corresponds with that in the world space. Figure: These two quads are detached in the world space. 4 4 (green) quad and 2 2 (red) quad

Inequality-constrained Nonlinear Programming Problem The optimization problem is formed as follows: minimize N i=0 f (x i) subject to Q j (x i ) 0 i = 1,, N, j = 1,, M. (3) where x i R is the variable, which represents the forwards projected length from a bounding point.

To make the bounding surface bound the surface as tightly as possible, the objective function f (x i ) can be derived as follows, i.e. to keep the distances between the bounding surface and the terrain as small as possible (Slide 25, Slide 16): f (x i ) = (x i l i ) 2 (4) where l i is the original displacement length in the bounding point p j. The constrains Q j can be derived as following (to keep the forwards projected points between the bounding planes): Q j = (P 1 P 0 ) (P 2 P 0 ) (P j P 0 ) (5) where P 0, P 1 and P 2 are the forwards projected points of the bounding points p 0, p 1 and p 2. P j is the forwards projected point of a constrained point p j.

Optimization Method Introduction The problem is nonlinear problems with nonlinear inequality constraints. minimize f 0 (x) subject to f i (x) 0, i = 1,, m, x min j x j x max j j = 1,, n. where x = (x 1,, x n ) T R n is the vector of variables, x min j and x max j are the lower and upper bounds of x j. Typically, the objective function f 0 and the constraint functions f 0, f 1,, f m are twice continuously differentiable. (6)

A CCSA (Conservative Convex Separable Approximation) method contains the outer and inner iterations. Within each outer iteration, there will be no or several inner iterations [1]. minimize f 0 (x) + a 0 z + m i=1 (c iy i + 1 2 d iy 2 i ) subject to f i (x) a i z y i 0, i = 1,, m, x min j x j x max j j = 1,, n, z 0 and y i 0, i = 1,, m, (7) where a 0, a i, c i and d i are given real numbers such that a 0 > 0, a i 0, c i 0, d i 0, and c i + d i > 0, a i c i > a 0 for i = 1,, m. The index k represents the outer iteration number and l represents the inner iteration number.

The subproblem takes the form as follows: minimize g (k,l) 0 (x) + a 0 z + m i=1 (c iy i + 1 2 d iy 2 i ) subject to g (k,l) i (x) a i z y i 0, i = 1,, m, x X (k), z 0 and y j 0, (8) The function g (k,l) i (x) in this subproblem is chosen as: g (k,l) i (x) = v i (x, x (k), σ (k) )+ρ (k,l) i ω i (x, x (k), σ (k) ), i = 0, 1,, m. (9) where v i and w i are real value functions.

Given a quad with two primitive triangles inside, and it has 9 9 constrained points. The number of bounding points is assumed to be four (i.e. the bounding size is eight), for simple test. These four bounding points are mainly four vertices of this quad. (a) The projection directions on the constrained points and the bounding points. (b) Surface f (x, y) = x 3 + y 3.

Red dots represent the projected points on the surface and the blue circles represents the four bounding points. It is clearly seen that two triangles bound these projected points. (a) Side view. (b) Isometric view.

Bounding Volumes in the Game (a) Isometric view. (b) Side view. Figure: Upper and lower bounding surfaces with size 8.

Bounding Volumes in the Game (a) Isometric view. (b) Side view. Figure: Upper and lower bounding surfaces with size 4.

Bounding Volumes in the Game (a) Isometric view. (b) Side view. Figure: Upper and lower bounding surfaces with size 2.

Bounding Volumes Introduction (a) (b) (c) (d) Figure: There will be no gap between neighbouring convex bounding volumes.

Convex versus Convex One of the most commonly used algorithm in game engine is GJK (Gilbert-Johnson-Keerthi) algorithm [2]. This algorithm relies on a support function to iteratively get closer simplices to the solution using Minkowski difference. (a) Two shapes collide on one vertex. (b) No collision.

The first simplex is built using what is called a support function. Support function returns one point inside the Minkowski difference given two sets K A and K B. Figure: The first two vertices in the first simplex.

(a) The first iteration. (b) New simplex does not contain the origin. (c) The second iteration. (d) New simplex contains the origin.

Multiresolution

Coarsest Level

One Level Down

Finest Level

Outline Introduction 1 Introduction Displacement Mapped Surface 2 3 Multiresolution in the Game Summary

Introduction Definition Backward projection is the inverse problem of forward projection, by projecting an arbitrary point in space onto the base primitive. Figure: The projection length is smaller than the displacement length, and collision is detected.

Aligned Plane Method The method currently used is constructing a plane which passes through the query point P. This plane is parallel to the base primitive. Figure: Aligned plane method (bad case).

This method works well for most cases in the game. In most cases, the lengths along the projection direction of the base primitives are small compared with the size of the base primitive (as (b) suggests) or the projection direction in one base primitive are close (as (a) suggests). (a) (b)

Introduction Bad Case But bad cases can happen and will result in error when doing collision detection with the terrain surface. (a) (b)

Aligned Projection Direction Method Given a query point P in space and the backwards projected point P on the base primitive. The line PP should have the same direction as the interpolated projection direction on P, i.e. the same direction as n. The objective function is as follows: f = (r g) (r g) where r = u(n 1 N 0 ) + v(n 2 N 0 ) + N 0 g = P u(p 1 P 0 ) v(p 2 P 0 ) P 0 (10) The BFGS (Broyden-Fletcher-Goldfarb-Shanno) algorithm is used to solve this unconstrained nonlinear optimization problem.

Alpha Plane Method Introduction The three forward projected vertices on the alpha plane are denoted as P 0, P 1 and P 2, where P 0 = P 0 + αn 0, P 1 = P 1 + αn 1, P 2 = P 2 + αn 2. (11) To ensure the alpha plane passing through the query point, the objective function will be: f = ((P 1 P 0 ) (P 2 P 0 )) (P P 0 ) (12) Newton s iteration method is used to obtain α.

Alpha Plane Method Introduction Figure: Aligned plane method.

Introduction Bad Case Fixed (a) Alpha Plane Method. (b) Aligned Projection Direction Method.

Outline Introduction Multiresolution in the Game Summary 1 Introduction Displacement Mapped Surface 2 3 Multiresolution in the Game Summary

Test Environment Introduction Multiresolution in the Game Summary The character is teleported to a remote place without too many dynamic objects for test. Irrelevant complex objects, like the ships near the shore, are moved away from the terrain. Complex objects, like warships, are spawned to test the consuming time.

Original Method Introduction Multiresolution in the Game Summary Original method performs backward projection in each vertex of the dynamic object after the broad phase is done (refer to Slide 49). It is quite expensive compared with multiresolution collision detection.

Multiresolution in the Game Summary Improvement using Multiresolution Figure: The time comparison when spawn one warship. Original collision detection (red), Multiresolution collision detection: coarsest bounding volume detection (green), finer bounding volume detection (violet, close to 0), final surface detection (yellow).

Multiresolution in the Game Summary Improvement using Multiresolution

Multiresolution in the Game Summary Figure: A warship contains many sub-objects. The multiresolution collision detection method will only detect the collision between the bottom of the warship and the terrain surface. It is notable that the gray mesh in this figure is not the terrain surface, but the projected primitives.

Multiresolution in the Game Summary Figure: The time comparison on four threads when the warship is moved to some place with high density of primitives. Original collision detection (red), Multiresolution collision detection: coarsest bounding volume detection (green), finer bounding volume detection (violet, close to 0), final surface detection (yellow).

Multiresolution in the Game Summary Figure: Comparison between the two methods in one certain frame when the warship is put in the area with high density of primitives.

Outline Introduction Multiresolution in the Game Summary 1 Introduction Displacement Mapped Surface 2 3 Multiresolution in the Game Summary

Multiresolution in the Game Summary Figure: The flow chart of this thesis.

Appendix Reference Reference Krister Svanberg. A Class of Globally Convergent Optimization Methods Based on Conservative Convex Separable Approximations. SIAM J. Optim. 12(2), p. 555-573, 2002p. E.G. Gilbert, D.W. Johnson, and S.S. Keerthi. A Fast Procedure for Computing the Distance between Complex Objects in Three-Dimensional Space. IEEE Journal of Robotics and Automation, 4(2):193-203, 1988. Java and Physics Engine. http://www.dyn4j.org/2010/04/ gjk-distance-closest-points/.