Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (7th_zorro, Quad, VoroneTZ, 1 invisible), 623 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 4
Page 182 of 191 1 2 180 181 182 183 184 190 191
Re: Fun Thread reloaded [Re: Redeemer] #448238
01/24/15 11:37
01/24/15 11:37
Joined: Sep 2003
Posts: 9,859
F
FBL Offline OP
Senior Expert
FBL  Offline OP
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Originally Posted By: Redeemer
I was talking about the doom engine on a game forum and somebody said something stupid about how the game deals with precision in its numbers, so I had to correct them. Later I was asked for a more detailed explanation and I offered the following explanation of fixed-point math, floating-point math, and why you even need "precision" to begin with:

Click to reveal..
The gist of it is that you need a helluva lot of precision and range in your numbers to generate any kind of recognizable 3D graphics at reasonable scale. Think about it... at 16 bits, even if you defined 1 "map unit" as being equal to 1 millimeter of real world length, you'd end up with less than 66 meters (~200 ft) on each axis to make any of your big mazy levels. Tiny? Yes. So clearly you need a ton of range to make anything reasonably large, and doom fixes this by making 1 map unit equally to something in the range of ~50mm. That gives them plenty of range to make nice big levels.

But why is the precision such a big deal? Well stop and think about that for a moment too. The most basic trig functions, sin and cosine, return FRACTIONS. That's not an accident. But it poses a problem because we need to use these functions frequently as coefficients to make our 3D transformations, and we'll lose precious amounts of information if a large number of the digits resulting from these computations is lost afterwards. So clearly, we don't just need range, we need precision too.

Doom meets this balance of range and precision by using a thing called 16-bit fixed point arithmetic. It is called 16-bit because each part of the numbers it uses have a 16-bit integer part, AND a 16-bit fractional part (binary fractions?! well, yeah, did you think fractions only worked if you counted in tens?). It is called FIXED POINT because the radix point (decimal point in plain english, but binary point more specifically) sits in the middle of the number and never moves (as opposed to a FLOATING POINT, which will put more digits on the left or right side of the number as necessary to increase the range or precision of the number). Lastly, it's called arithmetic because we're adding and stuff. Duh.

So, 16-bit fixed point arithmetic. That means our biggest number can be just shy of 65536, and our smallest number (sans zero) is 1/65536. That's a lot of precision! Is it enough?

Sort of. But if you've played Doom a lot, and you're astute person who picks up easily on visual glitches, you'll notice that even with ALL of this range and precision, you still get occasional visual artifacts such as "straight" walls that distort when you are extremely close to them, or extremely long side-defs that appear to "jump around" as you move the camera.

Can you imagine how bad those artifacts would look with over FOUR THOUSAND TIMES less precision? Walls would be CONSTANTLY jumping around. The bending and warping would be obscene. It'd be like you jumped into Picassoland. Ridiculous.

So that's PART of the reason it would make no sense for Marathon to use precision that small.

The second part is that using such little precision makes absolutely positively no sense from an implementation perspective. Marathon used fixed point math just like Doom. But if they really have FOUR THOUSAND TIMES less precision, that means they are only allocating 4 bits for the fractional parts of their numbers. Were the marathon devs extremely short on memory, forcing them to store and extract the fractional parts of different variables in whole bytes? Were they just masochistic? Or is somebody confused in their explanation? I'll let you decide.

By the way... the visual artifacts I mentioned from Doom have been fixed in many sourceports such as ZDoom, partly by increasing the size (and therefore the resolution) of their variables, and partly by switching to floating-point arithmetic (where the number of bits allocated to range and precision is adjusted as needed).

But even with this extended size, the visual inaccuracies haven't been completely eliminated so much as marginalized into non-existence. Visual inaccuracies, a result of information lost during transformations, is endemic to ALL 3D hardware/software. You just can't see it most of the time anymore thanks to most modern variable sizes, which are quite enormous. 64 bits = 64 binary digits, you know... and that is a lot of digits.

It's quite long, but for those of you who are not programming wizards, you may find it useful to read. But mostly I'm just reposting it here because I don't want it to go to waste on that board grin (there are not too many technical people there...)


Probably a waste putting this to the fun thread... while still not the 100% perfect place it's possibly better dumped in the Gameplay/Game Design forum.

Re: Fun Thread reloaded [Re: FBL] #448239
01/24/15 12:15
01/24/15 12:15
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
why should this be a waste?

the forum is dead anyways and the remaining members have a look at every single post, no matter where it's been posted.


POTATO-MAN saves the day! - Random
Re: Fun Thread reloaded [Re: Kartoffel] #448240
01/24/15 12:45
01/24/15 12:45
Joined: Sep 2003
Posts: 9,859
F
FBL Offline OP
Senior Expert
FBL  Offline OP
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
it will get lost here in random fun spam, and if you later remember there was a write up, you will not search in the fun thread.

Re: Fun Thread reloaded [Re: FBL] #448244
01/25/15 09:52
01/25/15 09:52
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
The mods are free to move it someplace else if they want to.


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: Fun Thread reloaded [Re: Redeemer] #448259
01/26/15 13:29
01/26/15 13:29
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
meh...

Re: Fun Thread reloaded [Re: Hummel] #448409
02/03/15 23:27
02/03/15 23:27
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America


4 retweets, yeah! We are super popular. laugh grin


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: Fun Thread reloaded [Re: Redeemer] #448424
02/04/15 17:43
02/04/15 17:43
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany


POTATO-MAN saves the day! - Random
Re: Fun Thread reloaded [Re: Kartoffel] #448618
02/12/15 19:24
02/12/15 19:24
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252

Re: Fun Thread reloaded [Re: Hummel] #448993
02/27/15 12:23
02/27/15 12:23
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Code:
printf ( "% d", sizeof(int64) );


bittersweet.

Re: Fun Thread reloaded [Re: txesmi] #449445
03/20/15 21:06
03/20/15 21:06
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252

I don't even...

Page 182 of 191 1 2 180 181 182 183 184 190 191

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1