render/vulkan: add dummy 3d lookup table to output shader

Later commits will add shader options that use a real 3d
lookup table.
This commit is contained in:
Manuel Stoeckl 2024-01-06 21:04:52 -05:00 committed by Simon Ser
parent 895e3d18b9
commit c64144a39b
4 changed files with 229 additions and 17 deletions

View file

@ -2,9 +2,17 @@
layout (input_attachment_index = 0, binding = 0) uniform subpassInput in_color;
layout(set = 1, binding = 0) uniform sampler3D lut_3d;
layout(location = 0) in vec2 uv;
layout(location = 0) out vec4 out_color;
/* struct wlr_vk_frag_output_pcr_data */
layout(push_constant) uniform UBO {
layout(offset = 80) float lut_3d_offset;
float lut_3d_scale;
} data;
float linear_channel_to_srgb(float x) {
return max(min(x * 12.92, 0.04045), 1.055 * pow(x, 1. / 2.4) - 0.055);
}
@ -25,5 +33,10 @@ vec4 linear_color_to_srgb(vec4 color) {
void main() {
vec4 val = subpassLoad(in_color).rgba;
// temporary code to use the 3d look up table; to be dropped next commit
vec3 pos = data.lut_3d_offset + vec3(0.5,0.5,0.5) * data.lut_3d_scale;
val.rgb *= texture(lut_3d, pos).rgb;
out_color = linear_color_to_srgb(val);
}