obs-StreamFX/data/effects/lut-consumer.effect
Michael Fabian 'Xaymar' Dirks eba0a467d5 gfx/lut: Add a simple but efficient LUT producer and consumer
For simple image and video editing, LUTs (Look-Up Tables) are vastly superior to running the entire editing operation on each pixel - especially if all the processing can be done inside a single shader.

Due to the post-processing requirements for our LUTs, we are limited to 8 bits per channel - though clever use of the unused Alpha channel may result in additional space. For our purposes however, this is definitely enough.
2023-03-28 13:11:11 +02:00

25 lines
907 B
Text

#include "shared.effect"
#include "lut.effect"
//------------------------------------------------------------------------------
// Uniforms
//------------------------------------------------------------------------------
uniform texture2d image;
uniform texture2d lut;
uniform int4 lut_params_0; // [size, grid_size, texture_size, 0]
uniform float4 lut_params_1; // [inverse_size, inverse_grid_size, inverse_texture_size, half_texel]
//------------------------------------------------------------------------------
// Functionality
//------------------------------------------------------------------------------
float4 PSConsumeLUT(VertexData vtx) : TARGET {
float4 c = image.Sample(LinearClampSampler, vtx.uv);
return float4(sample_lut2(c.rgb, lut, lut_params_0, lut_params_1), c.a);
};
technique Draw {
pass {
vertex_shader = DefaultVertexShader(vtx);
pixel_shader = PSConsumeLUT(vtx);
}
}