UV map question

Skeletons, animations, shaders, texturing, converting, fixing and anything else related to read game models
verticalD
Posts: 9
Joined: Thu May 18, 2017 10:35 am

UV map question

Post by verticalD »

how many ways are there for storing UV coordinates (both x and y) in only 4 bytes (or even 2 bytes) instead of the usual way of using two floats (8 bytes) ?
verticalD
Posts: 9
Joined: Thu May 18, 2017 10:35 am

Re: UV map question

Post by verticalD »

[this is for people who might come here from google]
My problem got solved. it turns out there were two bytes giving the x and y coords.
so I just did this >

int bytex= reader.ReadByte();
float x = (float)bytex / 255;
int bytey= reader.ReadByte();
float y = (float)bytey / 255;

so basically for any type of uv coords value other than float:

int value= reader.<read the byte(bytes)>
float actualValueInFloat = (float)value/type.Maxvalue) //where type.Maxvalue gives the maximum number allowed in the value type)

Im not saying this would work for every scenario. but you should give it a try
Sir Kane
Posts: 16
Joined: Sun Mar 27, 2016 7:20 pm

Re: UV map question

Post by Sir Kane »

Another option is 16 bit floats.