Archived

This topic is now archived and is closed to further replies.

digitalfreak

fundamental question about using floating point.

Recommended Posts

say in the game world(in contrast to screen world), a point''s coordinates are represented as floating point values,now in order to draw it on screen, you can rasterize the values by truncating and rounding, and the errors will be at most 0.5;then no matter how precise you keep these values in the game world(that is, no matter how many digits are used for the fractional part), they can still lose considerable precision when converted to the screen world.then why people use so many digits for fractional part just to be truncated or rounded at last?

Share this post


Link to post
Share on other sites
If you have an object whose coordinates in the world are retained as floating point, then you can truncate to integer only for rendering, but keep the actual coordinates as float or double. This way, you minimize the error coming from world calculations over time. Error can creep in for instance when moving along a vector, and the more digits of precision you have, the less this error will affect the object''s position in reality. Contrast moving a pair of integer coordinates along an arbitrary vector with moving a pair of floating point coordinates along the same vector, and imagine which scenario will end with the object nearest the desired destination.

The coordinates are truncated for rendering, as rendering is merely an approximation of the current state of the scene, and truncation can be tolerated in that aspect.

Josh
vertexnormal AT linuxmail DOT org


Check out Golem: Lands of Shadow, an isometrically rendered hack-and-slash inspired equally by Nethack and Diablo.

Share this post


Link to post
Share on other sites
It''s like copying a video tape. If make a copy of the the original tape, you''ll lose some quality. If you make a copy of a copy of a copy, then it''ll look a lot worse.

There''s a lot of math that goes on before your object gets rendered(Transforms, collision, lighting, etc). If you wait til the last moment to convert to integers for screen space you''ll lose some quality. If you do it early on, it''ll look a lot worse.

Disregarding all of that, if you don''t leave your stuff as floats you would never have the option of turning on anti-aliasing.

-John

Share this post


Link to post
Share on other sites