#version 450 #extension GL_EXT_shader_8bit_storage : require #extension GL_EXT_shader_explicit_arithmetic_types_int8 : require #extension GL_EXT_scalar_block_layout : require //#define GL_EXT_shader_8bit_storage 1 struct ComputeParameters { uint8_t tintMapType; }; layout (binding = 0) uniform ParameterUBO { ComputeParameters params; } ubo; layout(std430, binding = 1) readonly buffer TexelSSBOIn { u8vec4 texelsIn[]; }; layout(std430, binding = 2) buffer TexelSSBOOut { u8vec4 texelsOut[]; }; layout(scalar, binding = 3) readonly buffer ComputeSSBOIn { u8vec3 tintMapIn[]; }; layout (local_size_x = 256, local_size_y = 1, local_size_z = 1) in; void main() { uint idx = gl_GlobalInvocationID.x; u8vec4 texelIn = texelsIn[idx]; // Grayscale code // float gray = dot(vec3(texelIn.rgb), vec3(0.2627, 0.6780, 0.0593)); // texelsOut[idx] = u8vec4(u8vec3(gray), 1.0); // TintMap code uint8_t gray = uint8_t(dot(vec3(texelIn.rgb), vec3(0.2627, 0.6780, 0.0593))); texelsOut[idx] = u8vec4(tintMapIn[ubo.params.tintMapType * 256 + gray], 1.0); // texelsOut[idx] = u8vec4(tintMapIn[191], 1.0); }