16 lines
424 B
GLSL

// Copyright (c) 2025 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#define PACKED_U8_PER_UI 4
#define PACKED_U8_PER_UVEC4 PACKED_U8_PER_UI / 4
uint packedGetU8(uint position, uint data) {
return (data >> (position * 8u)) & 0xFFu;
}
int packedGetI8(uint position, uint data) {
int shift = int(position * 8u);
return int(data << (24 - shift)) >> 24;
}