Archive for Code

Stopping WordPress spammer registrations

I used to get 10+ spam user registrations every day on this blog. Not a total flood, but very annoying nonetheless. Today I get none! All thanks to a few lines of code I hacked into wp-login.php. Wanna know how? Read on. Read the rest of this entry »

Comments (5)

Optimizing a sphere-triangle intersection test

It’s been quite a while since I posted on the blog (a) at all, and (b) about a topic remotely related to the name of my domain and subsequently my book. Thanks to a gentle nudge from my friend and colleague Pål-Kristian Engstad I’ll try to rectify the situation with this post about how one could go about optimizing a sphere-triangle intersection test, suitable for a SIMD-implementation (such as on the PS3 SPUs). Read the rest of this entry »

Comments (8)

Step and pulse functions (for alpha channels)

Artists get a lot of mileage out of animating the alpha reference value for the alpha test. Lets call the alpha reference value t. Then, for example, by having alpha come from a 0..1 alpha “contour” or “depth” map, artists can make things gradually appear or disappear by animating t. Read the rest of this entry »


Branchless selections

Some CPU instructions sets offer a way of selecting bits from either of two registers based on the bits of a third register. For example, the SPUs of the CELL in the PS3 have the selb instruction:

selb rt,ra,rb,rc

The result of selb is placed in rt and each bit of rt is either the corresponding bit from ra (if the bit in rc is 0) or from rb (if the bit in rc is 1). Read the rest of this entry »

Comments (18)

Floating-point tolerances revisited

For several years now I’ve participated in the physics tutorial session at GDC (along with Jim Van Verth, Gino van den Bergen, Erin Catto, Brian ‘Squirrel’ Eiserloh, and Marq Singer). One section I’ve covered in some detail is robustness and within this area I’ve stressed (amongst other things) the importance of distinguishing between absolute and relative tolerances when performing comparisons of floating-point numbers.

I won’t go into details about why you would want to care about how your floating-point numbers are compared. (Detailed information can be found in part in my GDC presentation slides and in much more depth in my book.) Here I will assume you already know why you care, and I will just note that absolute and relative tolerances are tested as Read the rest of this entry »

Comments (5)

Order your graphics draw calls around!

A while ago a local developer (hi Rick) asked about what I thought was the best way of ordering draw calls for sending to the graphics chip. As the topic came up again in a discussion at work recently, I thought I’d share my thoughts about what I think is the best approach these days. Read the rest of this entry »

Comments (29)

Memory-efficient pathfinding

Third time’s a charm they say, and as I’ve talked about pathfinding twice before (in Don’t follow the shortest path! and Aiding pathfinding with cellular automata) I thought I’d charm everyone with a third pathfinding article. This time I’ll talk about how we can reduce the memory consumption on a commonly used pathfinding algorithm by about a magnitude! Read the rest of this entry »

Comments (11)

Be more functional

Since I’ve dissed patterns and OOP recently (and rightly so) I thought I’d be a little positive and recycle an email I sent a friend a while ago. This someone was curious about functional languages after I had mentioned them over dinner as he had no experience with them. I absolutely think that if all you have ever used is an imperative language (exemplified by C++, Java, C# and other similar crap) I highly recommend spending (at least) several days learning a functional language. You’ll be a better programmer for it. (And why not learn some logic programming too, while you’re at it.) Read the rest of this entry »

Comments (41)

Posts and links you should have read

I thought I’d post another summary of some (mostly) recent blog posts and links that are worthy of a read, in case you didn’t read them already. Here goes… Read the rest of this entry »

Comments (5)

Advanced bit manipulation-fu

There are lots of things I think a good programmer should understand, and understand well. One, of course, is that OOP amounts to BSE for programmers. Another, and the topic of today, is that good programmers should know how to manipulate bits in their sleep. (No, not those bits!) Read the rest of this entry »

Comments (21)

« Previous entries Next Page » Next Page »