🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

ok, gonna seem like a weird one...lol

Started by
2 comments, last by medievil 3 years, 1 month ago

Trying to convert old style bumpmap L6V5U5 to X8L8V8U8 so I can retain the signed texture (this is in dx9) and having a heck of a time…
using this code to turn 5/6 to 8 bits (from an r6g5b5 converter):
uint8_t u = src_r6g5b5[0] & 0x1f;

uint8_t v = ((src_r6g5b5[1] & 0x03) << 3) |(src_r6g5b5[0] >> 5 );

uint8_t l = src_r6g5b5[1] >> 2;

dst_argb[0] = (l << 2) | (l >> 4);

dst_argb[1] = (v << 3) | (v >> 1) & 0x07);

dst_argb[2] = ((u << 3) | (u >> 1) & 0x07); this and above to retain sign bit

dst_argb[3] = 255u;

anyone know why this doesn't seem to work at all?

Advertisement

dst_argb[1] = (v << 3) | (v >> 1) & 0x07);

Odd number of parentheses.

Otherwise, I'd suggest to run a few tests to verify correctness of all the bit shuffles that you perform.

I fail to understand how you scale things, (x / 63) * 255 isn't a nice power-of-two computation: (63 / 64) * 256 = 252.0 ≠ 255

You may want to start with the simpler slower but trivially correct division + multiplication at first until you get things right, then see about speeding it up.

besides the obvious cut and past error, this code DOES work converting to argb (or well abgr actually), but you lose sign since argb is unsigned only, it doesn't seem to work converting to xlvu
The texture output ends up left half texture data, right half solid color on all 3 main channels (l, v and u)

This topic is closed to new replies.

Advertisement