Members - Reputation: 125
Posted 16 April 2012 - 05:18 PM
i want to create some 3D on an 8-bit cpu (but with ~4kb memory). basicly i want to be able to specify some shapes, with polygons that have orientation and position (probably with matrices).
i thought about implementing 8-bit minifloats (bits: 1 sign, 4 exponent, 3 fraction/mantissa) for my computations, this would allow me to make small changes to smaller values. but not smaller changes to greater values. which would not be a problem with what is being viewed but it would be a problem in logic, such as calculating the distances between shapes. if i would try to store the positions of polygons relative to eachother within the same shape, then the values of the minifloats might not be so high. but the world would still have to have distances between shapes. also shapes that have linear speed would be hard to track the position of because miniflaots don't increment linearly. also designing a world with where shapes have these kinds of coordinates could be a problem.
- should i try to implement a 16-bit integer format to solve the incrementation of speed?
- should i drop the minifloat idea and do everything with 16-bit integers?
- what do you normally do when you're world doesn't fit into floating points? (are there any special techniques?)
- should i accept the 8-bit integers of the cpu and use that? (i doubt 127 values in each direction is big enough for all coordinates but it might be for what is on screen)
any advice would be appreciated,
GDNet+ - Reputation: 12253
Posted 16 April 2012 - 06:17 PM
In general this sort of work requires you to know where the significant bits of your calculation is currently at, and to exploit that to maintain accuracy at all stages. The fewer bits you're working with, the more attention you will have to pay to these issues.
I worked on a small ray-caster (like Wolfenstien 3D) using 16bit math, and lost interest before taking it very far, but the limitations of fixed point in 16bit was apparent even in relatively straight-forward math.
Benryves was workiing on a raycaster for the TI-83+ awhile back, using 16bit fixed-point, IIRC.
Here are a few links to his stuff:
Journal: 8-bit Raycasting Quake Skies and Animated Textures
Journal: A primitive 3D engine for the TI-83+
throw table_exception("(ノ ゜Д゜)ノ ︵ ┻━┻");
Crossbones+ - Reputation: 2349
Posted 18 April 2012 - 11:49 PM
Also: 8-bit integers may be enough to specify the shape of a given mesh. You won't be able to make very detailed meshes anyways if you pretend to have any sort of speed, not to mention memory usage =P If you can get away with 8-bit integers you're going to make your life a lot easier when it comes to performance.
Another thing is what kind of transformations you plan to do. Translation is easy. Scaling needs multiplications... Rotation is going to be madness the usual way. If you plan to do rotation you may want to use polar coordinates, because then to rotate you just need to add a value to the angle, and then you can convert it to X/Y/Z coordinates using a look-up table or something, reducing or even avoiding the multiplcations needed.
Clipping is going to be madness. I hope you have a plan for this one, especially for the near-Z plane (for the X/Y planes you could attempt to clip while rendering the triangles, for the far-Z plane just remove polygons after a certain distance, like pop-up for early 3D games used to work).
Also: cheat as much as you can. Seriously, if there's something that could be rendered with something that isn't standard polygons but rather a more restricted shape that could be done with a more specific algorithm, by all means try to do that. You can use this to reduce model complexity a lot and gain extra speed.
I'm pretty sure there's a lot more to be said, but that's what comes to my mind right now. It'd be useful to know how much memory do you actually have (if the code has to go in those 4KB or it's separate).
Crossbones+ - Reputation: 2385
Posted 20 April 2012 - 10:43 AM