Josh Posted July 19, 2015 Share Posted July 19, 2015 I didn't end up using this, but here's an interesting bit of code that can be used to compress an RGB color into two components. Does not work with blending: vec2 toRGB565(in vec3 c) { ivec2 outcInt = ivec2(c.rb * 31.0); int green = int(c.g*63.0); ivec2 LOHI = ivec2(green & 7,green >> 3); LOHI <<= ivec2(5); return (vec2(outcInt | LOHI) / 255.0); } vec3 fromRGB565(in vec2 c) { vec3 outc; ivec2 cInt = ivec2(c*255.0); ivec2 cIntMod = cInt & 31; outc.rb = vec2(cIntMod) / 31.0; ivec2 gComps = cInt>>5; outc.g = float(gComps.x | (gComps.y<<3)) / 63.0; return outc; } 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
drarem Posted July 27, 2015 Share Posted July 27, 2015 I love this type of stuff. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.