|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
bluemage |
I found a similar question that seemed like it was answered for an older version.
If I have a video that has a green screen effect how do I chromakey out the green?
the old post in reference
https://forum.godotengine.org/35619/how-to-key-out-any-color-using-a-shader-in-godot-3
if anyone can help me. I’d greatly appreciate it.
That answer is still valid in Godot 3.1 AFAIK.
Zylann | 2019-05-31 13:01
system
2
|
|
|
|
Reply From: |
TimurKady |
Set “color” to Color(0, 0, 0, 0) for transparency and try pick up the value of “key_distance” (0.2 - 0.4)
shader_type canvas_item;
render_mode blend_mix;
uniform bool use_mult;
uniform float key_distance : hint_range(0, 1);
uniform vec4 chroma_key : hint_color;
uniform vec4 color : hint_color;
void fragment() {
COLOR = texture(TEXTURE, UV);
if (distance(COLOR, chroma_key) < key_distance) {
if (use_mult) {
COLOR = COLOR * color;
}
else {
COLOR = color;
}
}
}