readd and improve greenscreen/color key effect

This commit is contained in:
Xonk
2026-04-19 00:08:56 -04:00
parent eceea8c003
commit ebdcf56ccd
4 changed files with 64 additions and 2 deletions
+38
View File
@@ -76,6 +76,8 @@ float convertHandDepth_2(in float depth, bool hand) {
#include "/lib/util.glsl"
#include "/lib/projections.glsl"
#include "/lib/macro_lod_mod.glsl"
#include "/lib/DistantHorizons_projections.glsl"
#include "/lib/gameplay_effects.glsl"
@@ -164,6 +166,38 @@ void doCameraGridLines(inout vec3 color, in vec2 texcoord){
color = mix(color, vec3(1.0), gridLines);
}
void doColorKeying(inout vec3 color){
// get distance from the camera in meters
#ifdef USING_LOD_MOD
float linearDistance = length(mat3(gbufferModelViewInverse)*toScreenSpace_DH(gl_FragCoord.xy*texelSize, texelFetch(depthtex0,ivec2(gl_FragCoord.xy),0).r, texelFetch(LOD_DEPTHTEX0,ivec2(gl_FragCoord.xy),0).r));
#else
float linearDistance = length(mat3(gbufferModelViewInverse)*toScreenSpace(vec3(gl_FragCoord.xy*texelSize, texelFetch(depthtex0,ivec2(gl_FragCoord.xy),0).r)));
#endif
// set range(s)
linearDistance = linearDistance - COLOR_KEY_RANGE;
// configure width n shiz
#if COLOR_KEY_WIDTH > 0
linearDistance /= COLOR_KEY_WIDTH*0.5;
#ifdef COLOR_KEY_INVERT
linearDistance = -1.0 + abs(linearDistance);
#else
linearDistance = 1.0 - abs(linearDistance);
#endif
linearDistance *= COLOR_KEY_WIDTH*0.5;
#else
#ifdef COLOR_KEY_INVERT
linearDistance = 1.0 - linearDistance;
#else
linearDistance = -1.0 + linearDistance;
#endif
#endif
// composite
if(linearDistance > 0.0) color = vec3(COLOR_KEY_R,COLOR_KEY_G,COLOR_KEY_B);
}
void main() {
float noise = interleaved_gradientNoise();
@@ -233,5 +267,9 @@ void main() {
COLOR = vec3(ld(texture(depthtex1, texcoord*RENDER_SCALE).r));
#endif
#ifdef COLOR_KEYING
doColorKeying(COLOR);
#endif
gl_FragColor.rgb = COLOR;
}
+12
View File
@@ -580,6 +580,18 @@ screen.Camera_Settings = Camera Settings
option.CINEMATIC_BORDER_COVERAGE_HORIZONTAL = Cinematic Border §bⓘ Horizontal
suffix.CINEMATIC_BORDER_COVERAGE_HORIZONTAL = % Screen Coverage
value.CINEMATIC_BORDER_COVERAGE_HORIZONTAL.0 = §cOFF
screen.COLOR_KEYING_SETTINGS = Color Key / Green-Screen
option.COLOR_KEYING = Color Key / Green-Screen
option.COLOR_KEY_R = Red Amount
option.COLOR_KEY_G = Green Amount
option.COLOR_KEY_B = Blue Amount
option.COLOR_KEY_INVERT = Invert Colored Area
option.COLOR_KEY_RANGE = Distance From Camera
suffix.COLOR_KEY_RANGE=m
option.COLOR_KEY_WIDTH = Width of Colored Area
value.COLOR_KEY_WIDTH.0 = §bⓘ Start At Set Distance
suffix.COLOR_KEY_WIDTH=m
###################################################### ↑↑↑ THIS SUBMENU'S DESCRIPTIONS
+9
View File
@@ -255,6 +255,15 @@
#define FILM_GRAIN_AMOUNT 0 // [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100]
#define CINEMATIC_BORDER_COVERAGE_VERTICAL 0 // [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100]
#define CINEMATIC_BORDER_COVERAGE_HORIZONTAL 0 // [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100]
// #define COLOR_KEYING
#ifdef COLOR_KEYING
// #define COLOR_KEY_INVERT
#define COLOR_KEY_RANGE 16 // [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 125 150 175 200 225 250 275 325 350 375 400 525 550 575 600 625 650 675 700 825 850 875 900 925 950 975 1000 1025 1050 1075 1000 1100 1125 1150 1175 1200 1225 1250 1275 1300 1325 1350 1375 1400 1425 1450 1475 1500 1525 1550 1575 1600 1625 1650 1675 1700 1725 1750 1775 1800 1825 1850 1875 1900 1925 1950 1975 2000 2100 2125 2150 2175 2200 2225 2250 2275 2300 2325 2350 2375 2400 2425 2450 2475 2500 2525 2550 2575 2600 2625 2650 2675 2700 2725 2750 2775 2800 2825 2850 2875 2900 2925 2950 2975 3000 3100 3125 3150 3175 3200 3225 3250 3275 3300 3325 3350 3375 3400 3425 3450 3475 3500 3525 3550 3575 3600 3625 3650 3675 3700 3725 3750 3775 3800 3825 3850 3875 3900 3925 3950 3975 3000 3100 3125 3150 3175 3200 3225 3250 3275 3300 3325 3350 3375 3400 3425 3450 3475 3500 3525 3550 3575 3600 3625 3650 3675 3700 3725 3750 3775 3800 3825 3850 3875 3900 3925 3950 3975 4000 4100 4125 4150 4175 4200 4225 4250 4275 4300 4325 4350 4375 4400 4425 4450 4475 4500 4525 4550 4575 4600 4625 4650 4675 4700 4725 4750 4775 4800 4825 4850 4875 4900 4925 4950 4975 5000 6000 7000 8000 9000 10000]
#define COLOR_KEY_WIDTH 0 // [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 125 150 175 200 225 250 275 325 350 375 400 525 550 575 600 625 650 675 700 825 850 875 900 925 950 975 1000 1025 1050 1075 1000 1100 1125 1150 1175 1200 1225 1250 1275 1300 1325 1350 1375 1400 1425 1450 1475 1500 1525 1550 1575 1600 1625 1650 1675 1700 1725 1750 1775 1800 1825 1850 1875 1900 1925 1950 1975 2000 2100 2125 2150 2175 2200 2225 2250 2275 2300 2325 2350 2375 2400 2425 2450 2475 2500 2525 2550 2575 2600 2625 2650 2675 2700 2725 2750 2775 2800 2825 2850 2875 2900 2925 2950 2975 3000 3100 3125 3150 3175 3200 3225 3250 3275 3300 3325 3350 3375 3400 3425 3450 3475 3500 3525 3550 3575 3600 3625 3650 3675 3700 3725 3750 3775 3800 3825 3850 3875 3900 3925 3950 3975 3000 3100 3125 3150 3175 3200 3225 3250 3275 3300 3325 3350 3375 3400 3425 3450 3475 3500 3525 3550 3575 3600 3625 3650 3675 3700 3725 3750 3775 3800 3825 3850 3875 3900 3925 3950 3975 4000 4100 4125 4150 4175 4200 4225 4250 4275 4300 4325 4350 4375 4400 4425 4450 4475 4500 4525 4550 4575 4600 4625 4650 4675 4700 4725 4750 4775 4800 4825 4850 4875 4900 4925 4950 4975 5000 6000 7000 8000 9000 10000]
#define COLOR_KEY_R 0.0 // [0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
#define COLOR_KEY_G 1.0 // [0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
#define COLOR_KEY_B 0.0 // [0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
#endif
#endif
#if defined DEPTH_OF_FIELD_RELATED_SETTINGS
File diff suppressed because one or more lines are too long