summaryrefslogtreecommitdiffhomepage
path: root/shaders
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2022-04-19 06:32:01 -0400
committerrealtradam <[email protected]>2022-04-19 06:32:01 -0400
commite7d16317b939452e2c378baa5b65c355edf498d2 (patch)
tree072f6b1d6649b76de4b187aa1fc9c6aab8295fba /shaders
parentaa865376f6737393a7f089dda8e1254520af30ba (diff)
downloadzig-chip-8-e7d16317b939452e2c378baa5b65c355edf498d2.tar.gz
zig-chip-8-e7d16317b939452e2c378baa5b65c355edf498d2.zip
added colour split shader
Diffstat (limited to 'shaders')
-rw-r--r--shaders/colour_splitter.fs45
1 files changed, 45 insertions, 0 deletions
diff --git a/shaders/colour_splitter.fs b/shaders/colour_splitter.fs
new file mode 100644
index 0000000..1b20175
--- /dev/null
+++ b/shaders/colour_splitter.fs
@@ -0,0 +1,45 @@
+#version 330
+
+#define PI 3.1415926538
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform vec4 colDiffuse;
+
+// Output fragment color
+out vec4 finalColor;
+
+// Imported variables from code
+uniform float renderWidth;
+uniform float renderHeight;
+
+// Variable set up
+vec2 flipped = vec2(fragTexCoord.x, 1 - fragTexCoord.y); // flipping
+vec2 textureResolution = vec2(renderWidth, renderHeight);
+vec2 onePixel = vec2(1.0, 1.0) / textureResolution; // distance of a single pixel in texels
+vec2 pixelCoor = flipped * textureResolution;
+
+float gridify(float coordinate, float colour) {
+ return floor((cos( (coordinate * 2.0 * PI) + (colour * ((2.0 / 3.0) * PI)) + (0.4 * PI) ) / 2.0) + 0.75);
+}
+
+vec3 is_pixel(vec2 coordinate) {
+ return vec3(gridify(coordinate.x, 1.0), gridify(coordinate.x, 2.0), gridify(coordinate.x, 3.0));
+}
+
+void main()
+{
+ //float is_pixel = gridify(pixelCoor.x, 1.0) * gridify(pixelCoor.y, 1.0);
+ vec4 texelColor = texture(texture0, flipped);
+ texelColor.rgb *= is_pixel(pixelCoor).rgb;
+ //texelColor.r *= 0;
+ //texelColor.g *= 0;
+ //texelColor.b *= 0;
+
+ // NOTE: Implement here your fragment shader code
+ finalColor = texelColor*colDiffuse;
+}