summaryrefslogtreecommitdiff
path: root/keyshade/bin/data
diff options
context:
space:
mode:
Diffstat (limited to 'keyshade/bin/data')
-rw-r--r--keyshade/bin/data/shader.frag38
-rw-r--r--keyshade/bin/data/shader.vert16
2 files changed, 54 insertions, 0 deletions
diff --git a/keyshade/bin/data/shader.frag b/keyshade/bin/data/shader.frag
new file mode 100644
index 0000000..7dbf468
--- /dev/null
+++ b/keyshade/bin/data/shader.frag
@@ -0,0 +1,38 @@
+#version 150
+
+uniform vec4 keyColour;
+uniform float keyMinDist;
+uniform float keyMaxDist;
+
+// these are our textures
+uniform sampler2DRect backgroundTex;
+uniform sampler2DRect foregroundTex;
+
+// this comes from the vertex shader
+in vec2 texCoordVarying;
+
+
+
+// this is the output of the fragment shader
+out vec4 outputColor;
+
+void main()
+{
+ // Get color values from the background and foreground
+ vec4 back = texture(backgroundTex, texCoordVarying);
+ vec4 fore = texture(foregroundTex, texCoordVarying);
+
+ // get alpha from mask
+ float mask = texture(backgroundTex, texCoordVarying).r;
+
+ vec4 delta = back - keyColour;
+ float distance2 = dot( delta, delta );
+ float weight = clamp( (distance2 - keyMinDist) / (keyMaxDist - keyMinDist) ,0.0,1.0);
+
+ //float4 transparent = IN.color;
+ //transparent.w = 0;
+ //OUT.color = lerp( transparent, IN.color, weight );
+
+ //mix colors from background and foreground based on the mask value
+ outputColor = mix(fore , back, weight);
+}
diff --git a/keyshade/bin/data/shader.vert b/keyshade/bin/data/shader.vert
new file mode 100644
index 0000000..0e63995
--- /dev/null
+++ b/keyshade/bin/data/shader.vert
@@ -0,0 +1,16 @@
+#version 150
+
+// these come from the programmable pipeline
+uniform mat4 modelViewProjectionMatrix;
+
+in vec4 position;
+in vec2 texcoord;
+
+// texture coordinates are sent to fragment shader
+out vec2 texCoordVarying;
+
+void main()
+{
+ texCoordVarying = texcoord;
+ gl_Position = modelViewProjectionMatrix * position;
+} \ No newline at end of file