Wikipedia: Making of Doom
en.wikipedia.org
en.wikipedia.org
I am sure there are many more such bit twiddling and magic number hacks, but nothing quite as useful to me than this magic to compute the reciprocal of a square root. The only other floating point operations that comes up this frequently in what I do are log and exp.
In my day to day coding (not that I code every day, far from it) I have nothing to do with game engines, yet inverse square root shows up in almost every corner (pun intended) in the vector manipulation code, for example in finding the cosine similarity between two documents.
Does not work for double precision, 64 bit, and nothing I write is so performance critical that it demands the use of this trick, but its still fun
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y;
i = 0x5f3759df - ( i >> 1 );
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) );
return y;
}
Taken from the wikipedia article http://en.wikipedia.org/wiki/Fast_inverse_square_root has the fuller story. x = x xor y
y = x xor y
x = x xor y
It's also possible to use addition and subtraction instead of xor.This is one of the most common questions in 'technical interviews' when big IT companies are recruiting fresh grads.
It's not much good explaining how simple it is to understand the xor-swap - it doesn't change the fact that the majority of engineering students go to the link like the one I posted, compile a list of questions and answers, and rattle off answers before the question is even completed in the interviews.
It's like knowing [any interesting method] can be used to accomplish a task, without knowing why said method works.
edit: I realise all this is OT, but I was downvoted for my earlier post and felt the need to defend it.
http://www.urbandictionary.com/define.php?term=idspispopd
The Smashing Pumpkins for their part continued to the joke by adding a sample from Doom to 'Where Boys Fear to Tread' on 'Mellon Collie and the Infinite Sadness'. The booklet contains the following credit: "Explosion from Doom courtesy of id Software, Inc and bobby prince Music""
Both Carmacks, Romero, Tom Hall, Kevin Cloud, etc in startup mode :D
I used to read their .plan's.... :o
Dunno, I just enjoy keeping track of what I post and seeing what's popular, etc!
File not found
Don't worry about "File not found"
http://www.gdcvault.com/play/1014627/Classic_Game_Postmortem...
If you look around the free section of the GDC site there are a lot videos about other classic games too
It's quite an interesting talk - lots of people have interviewed John Carmack about the history of Doom, and he was certainly a core figure, but I enjoyed hearing a telling from outside the usual "id Software has been continuously successful for decades" frame of reference.
(about the sources for some of the textures)"Among the more unusual sources, one texture was based on Adrian's snakeskin boots, and a bloody texture for the hell levels was created from a photograph of a wound on Cloud's knee"
Awesome. I thought the skin-wall textures in ep.3 were pretty gross. Eww! nerdscabs!
How to burn a NeXTCube
I find this really interesting, Carmack's been using Objective-C long before he started his iPhone work.