It occurs to me that while I’ve been plugging this on Twitter, I haven’t mentioned it here: Essential Mathematics for Games and Interactive Applications has just come out with a third edition, kindly published by our friends at AK Peters and CRC Press. The book has been brought up-to-date and certain chapters have been revised to flow better. The most significant change is probably the lighting chapter, which still uses a very simple lighting model but builds it out of a physically-based lighting approach. There are also updates in the discussions of floating point formats, shaders, color formats and random number generators, plus much more! Please take a look, I think you’ll find it worthwhile.
Another piece of big news is that the code with the book has been updated as well. The previous edition used OpenGL 2.0 and D3D 9 — now it uses OpenGL 3.2 Core Profile, and D3D 11. Anything that depended on the old fixed-function pipeline (such as the old OpenGL varyings and uniforms) has been updated. And the book no longer comes with a CD. All the code is freely (both in terms of beer and of speech) available at GitHub. This should be good news for those of you who purchased the electronic edition; other than the platform updates it should be compatible with the second edition.
Finally, I’d like to include a few notes on the demo code. Some of the code was written after the text for the book was largely complete, so some of the minor challenges and decisions in writing a cross-platform renderer aren’t really covered, or aren’t covered in much detail.
I’ve spoken at the East Coast Game Conference in the past, mostly doing a version of our physics tutorial (cut down to 1 hour, if you can believe it). This year I wanted to do something different and talk about something new, in this case the work I did to get stereo up and running in Ratchet & Clank: All 4 One. Attendance was a little lower than I expected, but it was still a good audience. I have to admit perhaps the title of the talk might have scared other people off: Hybrid Stereoscopy in Ratchet & Clank: All 4 One. Maybe the description will be less forboding:
This talk will cover Insomniac’s hybrid 3D stereo technique, using a combination of reprojection for opaque objects and standard stereo rendering for transparent objects. This gives something close to the speed of reprojection with fewer artifacts. The talk will cover the process followed to create the technique, equations used to match the reprojected and standard data, and a list of mistakes to avoid for anyone interested in stereo.
I do cover some math that a lot of other stereo talks brush over — so if you’re interested in stereo please click on the link and check it out.
So it’s been a while since I checked comments — it appears that email forwarding got broken at some point — and I see my last post had a large number of comments regarding errata. I believe the commenter also sent me a tweet about them as well, so no real excuses there. And it probably didn’t help that the site went down for a couple weeks. In any case, I’ll take a look today and address those.
As far as this year’s tutorials, I believe it was a success. There was a lot of interest after each presentation, and while it’s hard to judge based on just that (a bit of selection bias there), most people seemed to like what they heard. I will, this week, be putting up the latest slides for this year, as well as the missing ones from previous years.
One thing I’d like to do, now that I have some free time, is post some more on this blog. My presentation this year was a revamp of an orientation representation/quaternion talk I’ve given in past years, with a new section on 2D rotations. So I’m thinking I might do a series of posts expanding on complex numbers as a method for 2D rotation. I’m thinking it might be possible to store the cosine of the half angle and do some interesting things with that, as the sine of the half angle is always implied (when using half angles, you can stay within the upper semicircle and assume the sine is always positive sqrt(1 – cos^2(theta/2)). We’ll see how that goes.
An alternative is a series on the math behind Robin Green’s talk this year — though to keep off of his toes it might be a series on the math you need to know in order to understand Robin Green’s talk.
A couple weeks ago, Mike Acton, head of Core Technologies at Insomniac (where I’m now working, btw) posted this reaming of some standard C++ math code. I think it’s an excellent read if you’re interested in deeply optimizing your math code, in particular for consoles, and in particular for the PS3.
Of course, posting this at all is a bit uncomfortable from where I’m sitting. I think it’s safe to say that if you were to compare our library code to what he is, er, analyzing, you’d find some significant similarities. However, our libraries were mainly designed to teach mathematical concepts rather than optimization concepts. As such, you end up with classes that represent mathematical entities, e.g. Planes, Spheres, Lines, etc. and simple code that emphasizes clarity. That said — as Mike’s slides aptly demonstrate — if you’re trying to squeeze every cycle out of the machine there are other ways to organize your data and code, and in fairness we didn’t address that much at all. In retrospect this was an unfortunate oversight. I’d say more emphasis on optimization would be a good addition to the Third Edition, but I’m not sure what my family would think of another book…
After months of hard work, we’re finally done with the Second Edition.Â It went to the presses last week, and it will be available May 16th.Â Pre-order it now.
The following drove me crazy for the past few weeks, so I figured I’d better post about it just to get the word out.
For those who don’t know, VS 2005 added the notion of a “manifest” to manage DLLs. Every application must have a valid manifest, or you can’t run. In general, you can use the default settings, but if you’re running on a FAT32 partition (which I am, as I share it through BootCamp), for some reason it just doesn’t always create the manifest correctly. Beats me why since I’d think that sort of thing should be independent of what file system you have, but there you go. The solution is to check the “Use FAT32 work-around” option in the Manifest Tool section of the main project’s properties.
Now I can finally go through and update all of the examples to use our new rendering platform — it took a bit to put together, but we finally have a cross-platform renderer that supports both OpenGL and D3D9.
Sorry about the long delay between updates: things have been very busy here in Chez Jim.
Lars and I have been hard at work on the second edition, and are wrapping up the text this week to be shipped to the publisher. The major changes are:
- Brand new chapter on random numbers
- The three core rendering chapters have been completely rewritten for vertex and fragment shaders
- Direct3D 9 and OpenGL 2 support added
In addition, all the remaining chapters have been revised for clarity, corrections and updated content. Skinning and morphing unfortunately didn’t make it into the main text because of space, but may end up on the CD or may be posted on this site at some point. Availability of this edition will be sometime next year.
A few bits of other news:
- Lars and I are both at NVIDIA Corporation now. Lars is working on mobile technology, and I’m working on OpenGL drivers.
- I should be at GDC in 2008, although that may be up in the air.
That’s about it for now. I’ll update as the process continues to let you know how it’s going.
I’ve had a couple reports of issues with the OS X libraries as shipped with the book. The problem appears to be that the libraries are compiled for Mac OS 10.2, but don’t work so well with 10.3 and particularly 10.4 and up. And the fact that they are compiled for a PowerPC architecture doesn’t help the new Intel machines.
The solution is simple: recompile the libraries. To do so, you’ll need to make sure that all the files are writeable. Open a terminal window and change to the “common” directory and then type:
make clean PLATFORM=OSX
If you still have issues after doing this, let me know and we’ll try to track it down.
Note that this is the same procedure you’ll have to follow for the Linux builds, except that the platform doesn’t need to be specified. While the libraries are compiled under an older version of Mandrake, there is no guarantee that they will work for other Linux builds or versions.
For those who are interested in the process of construction of a math library, or perhaps are interested in other people’s opinions on how such a library would be constructed, or perhaps would like to share your own opinions on such a library… er, I’ll start again.
In the sweng-gamedev mailing list, Noel Llopis started up a thread regarding the creation of a industry-wide standard math library. This has led to a very long discussion of such a library, and the creation of a wiki page. As of yet I don’t have much of an opinion on this other than the discussion is extremely verbose and so I can’t keep up with it all. However, someone out there might, and so I share its existence with you all.
Some of this may meander into the next edition of the book, particularly the management of SIMD operations which is something I’m dealing with in my company’s library. However, I can say for certain that there will not be a separate Point class in the book’s library, because a) it’s simpler to manage and b) I trust people not to do dumb things with Vectors when they’re actually Points. This may be a foolish assumption on my part.
Addendum (05/19/06): there’s also a SourceForge page to deposit potential code for said library.
Just a quick note to say that a second edition for Essential Mathematics for Games… is in the works. If you have items that you would like to see updated, expanded, or just plain included in a new edition, please let me know. Also, if you’re an educator and you’re using this book as part of a course, please drop me a line as well. We may be interested in having you do a detailed review of the first edition.
You can send me email at ‘jim’ at this domain, or use the form on the front page of the site.
Thanks in advance.
I had originally intended on writing up a post about some of the science and math I’ve been seeing on TV lately. However, as I got into it, I realized it was going to end up too long, too verbose and (more importantly) without a point. A boring rant for ranting’s sake, if you will. So… y’all (or youse guys, if you prefer) get this post instead: a series of fun math- and science-related links which provide a nice diversion on slow days.
First of all, my apologies for the lack of posts. Part of it was the demands of my paid work: For some time, I’ve been working on the PS2 version of Rainbow Six: Lockdown, and those of you in the know are aware that the ship date was pushed out from March to September. While most of that was just polish, doing that final 1% takes a fair amount of effort. So only recently have I felt like digging into new engineering challenges and blogging again. The other part was that I didn’t have much to write about, but I have some ideas which I’ll put up in the next few weeks.
The GDC sessions have finally been announced, and I’m pretty excited about the tutorial this year. Instead of doing the usual 2-3 people talking about a variety of subjects, some of which is not their specialty, this year we have 6 people with a broad range of experience. This should allow us to have deeper coverage and present an overall better tutorial.
Here are the speakers, with their current proposed topics:
Jim Van Verth: Physics Engine Overview
Christer Ericson: Numerical Robustness
Squirrel Eiserloh: Relative Motion and Collision
Gino van den Bergen: Narrow (GJK) and Broad (Sweep and Prune) Phase Collision
Erin Catto: Constraints and Solvers
Marq Singer: Dynamic Destruction
The full session description can be found on the GDC 2006 site. Hope to see some of you there!
A bit of a digression here: the notes for the Future of Curved Surfaces roundtable are up in the publications area. Overall, a pretty good discussion. I don’t think anything was really resolved, but I certainly learned quite a bit. Hopefully others did too.
We now return you to your irregularly scheduled reparameterization discussion.
I had a few more topics left over from GDC, but I left my notes at work. And I’ll be on lead engineer duty this week and a bit of next so I’m not optimistic I’ll have time to post anything from there.
So instead I’ll write a bit about some lighting research I’ve been doing. Lately I’ve been interested in doing some improvements to lightmap generation — both making it efficient (in both speed and memory) and improving the quality of the lighting solution.
Due to sickness and unexpected work, I haven’t had a chance to do some of the updates I’d planned. I’m working on a write-up about computing center of mass, since I botched that badly during the presentation. I still need to do a little more research to make sure I got it right, though. The Mirtich and Eberly presentations are mostly formula manipulation, and not intuitive from the geometric standpoint.
Until then, here’s an article by Joe van den Heuvel and
Miles Jackson regarding sphere collision: Pool Hall Lessons. Someone recommended it as an alternative method for dynamic sphere-sphere collision. Looking at it, it appears that it might be faster than the one I came up with; certainly so in the average case, as it culls out obvious misses early. But again, I haven’t had a chance to do an in-depth analysis of it.
The Win32 sample code has been updated to match what was shown at GDC. The ZIP file also includes the old Mac base code because someone (didn’t catch your name, sorry) expressed an interest in porting it. If you’ve downloaded the code previously, it includes three new examples: an integration methods demo which shows the effect of using three different integration techniques with a spring force; a resting contact demo using impulses to resolve the collision; a resting contact demo which uses contact forces to resolve the collision. For the last two, I have commented out the code which slows it down to 10 fps, so it should look fairly smooth in both cases. If you want to uncomment it, it’s in Game::Update().
For those who picked up the book, there are two code demos in the Chapter 11 folder that are also apropos. The first shows the bounding hierarchy for a simple submarine model. The second shows a one-dimensional example of the use of sweep and prune.
I’ve uploaded the latest tutorial slides to the site. I made a few changes, mostly removing demo links (which require specific paths and wouldn’t necessarily work) and replacing some of them with direct web links. I also fixed the positive and negative elements in the collision response slides. In case I missed one or two, basically if the relative velocity along the normal or the relative force along the normal is positive, then the objects will be pushed together. So the correction (either impulse or constraint force) is in the opposite direction of the normal, and needs to be negative.
I’ll be doing a few more updates throughout the week. Tomorrow I’ll upload the latest demo code, at least for Windows. There was also a lot of good conversation during the breaks and after the talk, so I’ll post some comments, corrections and clarifications based on that. So stay tuned.
Just finished rewriting the basic collision response demo to make use of a new dynamic collision model. Originally it determined whether collision is occurring in the current frame, pushed the objects apart, and then reset the velocities for the next frame. Now it determines whether a collision will occur interframe, advances to that timestep and computes the collision response, and then continues movement for the remainder of the frame. Took a bit to deal with the vagaries of floating point, but it appears to work. I’ll write up a bit more detail on this tomorrow; it’s late.
Tomorrow I work on slides and explore the world of resting forces. Also known as “fun with LCP.”
Been a little busy lately trying to get a game out, but I did manage to squeeze in some time to create this new site using WordPress. It has some advantages in that I can display math and code a little easier, as you can see. I’m using MimeTeX for the math display — it’s got some issues with bold fonts, but otherwise I can enter the formulas I need in a LaTeX-like way without anyone needing to install MathML fonts. For the code, I’m using iG: Syntax Hiliter, with some tweaks to the colors.
Hopefully I’ll have some time in the next few weeks to type up some more errata, and what I and my co-lecturers are up to as we prep for GDC 2005.