|
rivon
|
 |
« Reply #150 on: May 04, 2012, 05:37:39 AM » |
|
Don't square the millions? I'm sure it's possible.
|
|
|
|
|
Logged
|
|
|
|
|
J-Snake
|
 |
« Reply #151 on: May 04, 2012, 07:07:21 AM » |
|
Lol, what if your computation actually requires a square to compute distance/forces... etc.? Some millions is a comparingly small number because you want to have an acceptable resolution. Not squaring big numbers means squaring small numbers but that leads to a sort of fixed point math. If you have an acceptable concept for that let me know.
|
|
|
|
« Last Edit: May 04, 2012, 07:14:40 AM by J-Snake »
|
Logged
|
Independent game developer with an elaborate focus on interesting gameplay, rewarding depth of play and technical quality. TrapThem
|
|
|
|
rivon
|
 |
« Reply #152 on: May 04, 2012, 07:10:36 AM » |
|
Use smaller scale? Or just use floats and stop complaining about their un-precision. I never really bumped into their limit...
|
|
|
|
|
Logged
|
|
|
|
|
J-Snake
|
 |
« Reply #153 on: May 04, 2012, 07:23:41 AM » |
|
The main problem with floats is not its precision, it is inaccuracy. The actual iee-standard is not suited to most situations in games. The most dominant thing affecting gameplay in games is translation of objects and similar geometric transforms. This is what has to be more accurate since the same intended translation in a different place is not exactly the same. I am just pointing that out.
The problems with ints is computation, I cannot reduce the scale if I want to keep certain resolution.
|
|
|
|
|
Logged
|
Independent game developer with an elaborate focus on interesting gameplay, rewarding depth of play and technical quality. TrapThem
|
|
|
|
nospoon
|
 |
« Reply #154 on: May 04, 2012, 07:55:38 AM » |
|
use doubles / long float's or whatever
or maybe consider splitting the ingame space to a grid, and then mapping positions in each cell as floats
|
|
|
|
|
Logged
|
|
|
|
|
ham and brie
|
 |
« Reply #155 on: May 04, 2012, 08:21:19 AM » |
|
But the properties of float-representation have some ugly sideeffects for games. It doesn't matter you scale the borders of your game to 1.0f or to 1000000.0f. You will have the same resolution-distribution almost everywhere what is right in front of your feet, only very close things are treated with an extremely higher resolution. So when it comes to games I would prefer to get rid of the negative exponent and spend this bit to give the mantissa double the resolution.
Get rid of negative exponents? That means that values that would have used negative exponents would be subnormal instead and will be less accurate. Such values are really important, e.g. the components of normalised vectors. You'd get lower accuracy from vectors storing directions, dot products of those vectors, etc.
|
|
|
|
|
Logged
|
|
|
|
|
J-Snake
|
 |
« Reply #156 on: May 04, 2012, 09:17:39 AM » |
|
Get rid of negative exponents? That means that values that would have used negative exponents would be subnormal instead and will be less accurate. Such values are really important, e.g. the components of normalised vectors. You'd get lower accuracy from vectors storing directions, dot products of those vectors, etc.
It is a good trade off for games, I think. If you look at it you will have the same consistent density of digits from 0-1 (over 16 million values) like you have with the current standard from 0.25-0.5. It is pretty sufficient for games. For every computation in your world exceeding the small value of 0.5, like practically every position and translation in front of your feet will be treated with double the precision and more accuracy in relation to very near postions smaller than 1.0 (since the density would be equally distributed from 0-1). It is just that the exponents can cut one or two bits and give it to the mantissa. They just go needlessly low and high for games.
|
|
|
|
« Last Edit: May 04, 2012, 09:35:54 AM by J-Snake »
|
Logged
|
Independent game developer with an elaborate focus on interesting gameplay, rewarding depth of play and technical quality. TrapThem
|
|
|
|
Fallsburg
|
 |
« Reply #157 on: May 04, 2012, 10:29:18 AM » |
|
Also in scientific computations you are interested in the relative error which is fine. But in games it is also about the absolute values, like position and not only the distance. The distance of two equally shifted positions is not always equal.
Yeah, because scientific computation is less concerned with accuracy than games.  It's a game. Just pick something and deal with it. If you ever bump up to inaccuracy issues in your game due to floating point problems then you are doing it wrong.
|
|
|
|
|
Logged
|
|
|
|
|
ham and brie
|
 |
« Reply #158 on: May 04, 2012, 10:36:30 AM » |
|
It is just that the exponents can cut one or two bits and give it to the mantissa. They just go needlessly low and high for games.
I think you're probably confused about what you'd actually gain in practice by having an extra bit or two for the mantissa and are underestimating how important small numbers are and the consequences of making everything under 1 be subnormal.
|
|
|
|
|
Logged
|
|
|
|
|
rivon
|
 |
« Reply #159 on: May 04, 2012, 10:47:32 AM » |
|
Yeah, because scientific computation is less concerned with accuracy than games.  It's a game. Just pick something and deal with it. If you ever bump up to inaccuracy issues in your game due to floating point problems then you are doing it wrong. This. Really, have you ever tried using floats for your ingame positions and speeds and stuff? And if yes, have you had any problems with their precision/accuracy? Are you sure that you aren't just imagining a problem somewhere where there isn't any?
|
|
|
|
|
Logged
|
|
|
|
|
J-Snake
|
 |
« Reply #160 on: May 04, 2012, 11:13:45 AM » |
|
Yeah, because scientific computation is less concerned with accuracy than games.  You understand me wrong, games are less concerned with precision. Scientific computations are concerned with precision, but what counts for them is the relative error, not the absolute error. In games however it is often about the absolut errors. That is a fundamental difference. I understand the properties of float-representation exactly, I know how to make good use of it. But there are flaws I want to spell out, it is the right thread for it after all. The problem is this: translation: No matter how exactly you can compute the direction of your car. It is insignificant to the rounding errors for the position. Direction vectors change all the time (except you want to shoot something to the moon) but position-updates accumulate over and over. And so do errors according to the distribution of the resolution. Just imagine in a racing game when two cars are like 2miles away but receiving the exact same input on the exact same duplicated track. If you let them drive over a certain time the difference in distance and displacement can be mesuared. It is not equal. Another example, imagine two opposed forces pulling on something with the exactly same force. You expect the object to rest but you cannot guarantee it. And if you just change the position of this setup you will end up having different results in general. That is why accuracy would be ideal, but since we cannot have perfect accuracy we can at least increase the precision of our space-resolution. This is only possible by increasing the mantissa, not the exponent. You can spend your exponent 100bits, most of your world will still have the same resolution, only the very tight space around zero will be affected by it. That is why it is a waste of ressources for games.
|
|
|
|
|
Logged
|
Independent game developer with an elaborate focus on interesting gameplay, rewarding depth of play and technical quality. TrapThem
|
|
|
|
Fallsburg
|
 |
« Reply #161 on: May 04, 2012, 11:35:29 AM » |
|
Dude, my main job is scientific computing. I know what we care about. And sometimes we care about relative error and sometimes we care about absolute error. The same is true for games.
And you are confusing potential problems with actual problems. This shit is so far down in the noise for games that it isn't worth caring about, unless you are doing it wrong. If you are doing something wrong, then there is the possibility that there will be a problem (and honestly, most of these problems are idiots doing things like (doubleVal == 1.35) ). But otherwise, there are going to be so much larger effects that this will all get drowned out.
So until you stop coming up with hypothetical problems where you have a racing game with a racer on Mars and a racer on Earth or whatever it takes for there to be an issue, and actually have an actual problem that actually needs to be looked at, stop worrying about this shit.
|
|
|
|
|
Logged
|
|
|
|
|
J-Snake
|
 |
« Reply #162 on: May 04, 2012, 11:51:07 AM » |
|
It can make sense to think about it though. There are practical situations which matter because there are chaotic/instable situations which can turn one or the other route (butterfly-effect)
Just like I mentioned:
If you have distance-dependend forces pulling on something and you choose an initial configuration where they are supposed to face a symmetric object in the same opposite distance (the start of my sports-game) then you can indeed place them so that the object remains unaffected. You can do it by placing the origin in the middle of the gamefield since negative numbers have the exactly same representation. A small trick but the situation gets more fair. And in sports milimeters do count.
|
|
|
|
|
Logged
|
Independent game developer with an elaborate focus on interesting gameplay, rewarding depth of play and technical quality. TrapThem
|
|
|
|
rivon
|
 |
« Reply #163 on: May 04, 2012, 12:05:18 PM » |
|
if (abs(force1 - force2) < 0.000001) finalForce = 0;
It's exactly the thing Fallsburg was talking about - if (doubleVal == 1.35)... If you have any real problem with this, you're doing it wrong.
|
|
|
|
|
Logged
|
|
|
|
|
J-Snake
|
 |
« Reply #164 on: May 04, 2012, 12:19:38 PM » |
|
No, it is not how to properly do certain things either.
Also the car doesn't have to be on mars. It can be only 2 miles. The property that always remains is that the second(more distant)half of your space, no matter how you choose it only gets 2^23 / 2(float) (approx 4million values). Now imagine one drives around the origin and the other just 1 mile away. It quickly accumulates to an uneven situation if you naivly don't do anything about it (or if you don't care about fair and competitive qualities of your game).
|
|
|
|
« Last Edit: May 04, 2012, 12:52:14 PM by J-Snake »
|
Logged
|
Independent game developer with an elaborate focus on interesting gameplay, rewarding depth of play and technical quality. TrapThem
|
|
|
|