|
|
@ -15,23 +15,31 @@ layout (constant_id = 0) const int TEXTURE_TRANSFORM = 0;
|
|
|
|
#define TEXTURE_TRANSFORM_IDENTITY 0
|
|
|
|
#define TEXTURE_TRANSFORM_IDENTITY 0
|
|
|
|
#define TEXTURE_TRANSFORM_SRGB 1
|
|
|
|
#define TEXTURE_TRANSFORM_SRGB 1
|
|
|
|
|
|
|
|
|
|
|
|
float srgb_to_linear(float x) {
|
|
|
|
float srgb_channel_to_linear(float x) {
|
|
|
|
return max(x / 12.92, pow((x + 0.055) / 1.055, 2.4));
|
|
|
|
return max(x / 12.92, pow((x + 0.055) / 1.055, 2.4));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vec4 srgb_color_to_linear(vec4 color) {
|
|
|
|
|
|
|
|
if (color.a == 0) {
|
|
|
|
|
|
|
|
return vec4(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
color.rgb /= color.a;
|
|
|
|
|
|
|
|
color.rgb = vec3(
|
|
|
|
|
|
|
|
srgb_channel_to_linear(color.r),
|
|
|
|
|
|
|
|
srgb_channel_to_linear(color.g),
|
|
|
|
|
|
|
|
srgb_channel_to_linear(color.b)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
color.rgb *= color.a;
|
|
|
|
|
|
|
|
return color;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
void main() {
|
|
|
|
vec4 val = textureLod(tex, uv, 0);
|
|
|
|
vec4 val = textureLod(tex, uv, 0);
|
|
|
|
if (TEXTURE_TRANSFORM == TEXTURE_TRANSFORM_SRGB) {
|
|
|
|
if (TEXTURE_TRANSFORM == TEXTURE_TRANSFORM_SRGB) {
|
|
|
|
out_color = vec4(
|
|
|
|
out_color = srgb_color_to_linear(val);
|
|
|
|
srgb_to_linear(val.r),
|
|
|
|
|
|
|
|
srgb_to_linear(val.g),
|
|
|
|
|
|
|
|
srgb_to_linear(val.b),
|
|
|
|
|
|
|
|
val.a
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} else { // TEXTURE_TRANSFORM_IDENTITY
|
|
|
|
} else { // TEXTURE_TRANSFORM_IDENTITY
|
|
|
|
out_color = val;
|
|
|
|
out_color = val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
out_color *= data.alpha;
|
|
|
|
out_color *= data.alpha;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|