mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-29 11:01:23 +00:00
eba0a467d5
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.
25 lines
907 B
Text
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);
|
|
}
|
|
}
|