Files
oak-editor/engine/shaders/colordifferencekey.frag
Mike-Solar 28c4426236 build: split the engine into liboakengine.so; worker drops the UI entirely
Physical split: app/{audio,cli,codec,common,config,node,pluginSupport,
render,task,timeline,undo,tool,shaders} plus coreengine, version and
ui/icons+colorcoding move to a new top-level engine/ tree, built as
liboakengine.so (shared). The render backends (oakgl/oakvulkan) move
with it and link the engine library instead of embedding a static
render-core subset (libolive-rendercore is gone).

- oak-render-worker now links liboakengine instead of the whole
  libolive-editor object set: 336MB -> 2.9MB, no Qt Widgets UI
- the editor links liboakengine for the engine and keeps only UI
  objects in libolive-editor
- install/packaging: GNUInstallDirs libdir on Linux, bundle copy on
  macOS, oakengine.dll staged for NSIS, AppImage validation entry
- fix backend lookup for the new layout: DynamicRenderer searched
  ../app but backends now live in engine/; a stale pre-split liboakgl
  in the build tree got dlopened instead, re-initialized and later
  destroyed the interposed engine statics (full-suite segfault at
  DialogSequenceParameterTab, found via gdb watchpoint)
2026-07-20 03:23:28 +08:00

69 lines
1.7 KiB
GLSL

uniform sampler2D tex_in;
uniform sampler2D garbage_in;
uniform sampler2D core_in;
uniform int color_in;
uniform bool garbage_in_enabled;
uniform bool core_in_enabled;
uniform float highlights_in;
uniform float shadows_in;
uniform bool mask_only_in;
in vec2 ove_texcoord;
out vec4 frag_color;
#define SCREEN_COLOR_GREEN 0
#define SCREEN_COLOR_BLUE 1
void main(void) {
vec4 tex_col = texture(tex_in, ove_texcoord);
// Unassociate RGB before calculating values
vec4 unassoc = tex_col;
if (unassoc.a > 0) {
unassoc.rgb /= unassoc.a;
}
// Simple keyer, generates a inverted mask (background is white, foreground black)
float mask;
if (color_in == SCREEN_COLOR_GREEN) {
mask = (unassoc.g - max(unassoc.r, unassoc.b));
} else{ // Assume SCREEN_COLOR_BLUE
mask = (unassoc.b - max(unassoc.r, unassoc.g));
}
mask = clamp(mask, 0.0, 1.0);
if (garbage_in_enabled) {
// Force anything we want to remove to be 1.0
vec4 garbage = texture(garbage_in, ove_texcoord);
// Assumes garbage is achromatic
mask += garbage.r;
mask = clamp(mask, 0.0, 1.0);
}
if (core_in_enabled) {
// Force anything we want to keep to be 0.1
vec3 core = texture(core_in, ove_texcoord).rgb;
vec3 core_invert = 1.0 - core.rgb;
// Assumes core is achromatic
mask *= core_invert.r;
mask = clamp(mask, 0.0, 1.0);
}
// Crush blacks and push whites
mask = highlights_in * (shadows_in * mask - 1.0) + 1.0;
mask = clamp(mask, 0.0, 1.0);
// Invert mask
mask = 1.0 - mask;
// Multiply color by mask
tex_col *= mask;
if (!mask_only_in) {
frag_color = tex_col;
} else {
frag_color = vec4(vec3(mask), 1.0);
}
}