Making a surface that uses Byte instead of float

BlitzMax Forums/MiniB3D Module/Making a surface that uses Byte instead of float

AnniXa(Posted 2010) [#1]
Hey, i think about making a new specified Tsurface type that uses :byte for the vert_coords values, because my surfaces are not so big, verticles never got negative coords and i dont need so exacly vertexPositions.
Also i would like to remove alot stuff from the surf that i dont need, (bones thingys and some other stuff) because i have very big meshes for a scenery thing, and the Memory usage only for surfaces can raise up to > 600MB while my framerate is sticky on 60 and fine, i think its because of the mass floatīs.

so before i maybe start wasting my time with this i just wanted to ask if you maybe know some stuff about that, would it be possible to make a new tsurface like that?

Last edited 2010


ima747(Posted 2010) [#2]
should be possible for memory conservation however you might get a significant performance hit as the bytes will likely have to be converted to floats on the fly to work with everything else... you might be able to counteract that a bit by using ints instead of bytes since they're the fastest primitive in bmax due to it's 32 bit nature, however there will still be conversion and it wouldn't save as much space...

to reduce the performance impact you may need to create a whole new rendering path around bytes, i.e. modify TMesh and TCamera into byte based variants as well so you could create a ByteMesh which contains ByteSurface's and is rendered through a ByteCamera... but you still may be affected because of the object layouts from the world root for creating the render queue for each camera...

if your usage is rising that high you're probably better off looking into some way to segment and manage the meshes/surfaces etc. It's likely to both improve memory usage as well as frame rates (can never be too high...) and you might find your solution ends up being applicable to other things as well for more performance etc.


SLotman(Posted 2010) [#3]
Won't make a difference AFAIK - every card internally store vertex and tex coordinates as floats - so even if you manage to make everything as bytes in miniB3D or even on plain OpenGL. it will have an overhead to convert it to float.

But... how are you measuring this surface memory usage? A float is 4 bytes, * 9 (x,y,z,u,v,w,nx,ny,nz) = 36 bytes per vertex. If you're using more than 600mb on just surfaces, this means you have more than 17 million vertex loaded?


AnniXa(Posted 2010) [#4]
well thank you for that hinds,

i just made a countvertex function that cycles through all relevant surfs and geht te vertcount.
when the ram usage is on ~600MB the vertx Count is on aprox 700000 connected with 300000 tris.
when i turn off the creation for the surfaces the memory usage is on ~100mb just for other stuff.
so around 500mb just for the surfaces :(