new shader: phosphor-basic.frag v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 03 Dec 2023 19:22:42 +0100
branchv_0
changeset 18 c4384f43c739
parent 17 f53a040bdc89
child 19 262828ae9682
new shader: phosphor-basic.frag
shaders/default.frag
shaders/phosphor-basic.frag
shaders/scanlines-basic.frag
shaders/soften-borders.frag
--- a/shaders/default.frag	Sun Dec 03 19:22:25 2023 +0100
+++ b/shaders/default.frag	Sun Dec 03 19:22:42 2023 +0100
@@ -10,7 +10,7 @@
 	return vec4(vec3(luminance), original.a);
 }
 
-void main(){
+void main() {
 	fColor = texture(uTexture, vTextureXY).rgba;
 	// fColor = grayscale(fColor);
 	// fColor *= vec4(0.8, 1., 0.2, 1.);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/shaders/phosphor-basic.frag	Sun Dec 03 19:22:42 2023 +0100
@@ -0,0 +1,40 @@
+#version 330 core
+
+uniform  sampler2D  uTexture;
+in       vec2       vTextureXY;
+out      vec4       fColor;
+
+vec4 grayscale(vec4 original) {
+	const vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);
+	float luminance = dot(original.rgb, luminanceWeighting);
+	return vec4(vec3(luminance), original.a);
+}
+
+vec4 invert(vec4 original) {
+	original = clamp(original, 0.0, 1.0);
+	return vec4(vec3(1.) - original.rgb, original.a);
+}
+
+float rand(vec2 co) {
+    return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
+}
+
+void main() {
+	fColor = texture(uTexture, vTextureXY).rgba;
+
+	// fColor = grayscale(fColor);
+	// fColor = invert(fColor);
+	fColor = (fColor-rand(vTextureXY)*0.3) * 1.6;
+
+	float lineCount = 200.;
+	fColor.xyz *= abs(sin(radians(vTextureXY.y * 180. * lineCount)));
+
+	// float columnCount = 320;
+	// fColor.xyz *=
+	//  clamp(abs(sin(radians(vTextureXY.x * 180. * columnCount)))+0.6, 0., 1.);
+
+	// fColor = grayscale(fColor) * vec4(1.00, 0.80, 0.10, 1.00); // amber
+	fColor = grayscale(fColor) * vec4(0.30, 0.80, 0.20, 1.00); // green
+
+	// let us move decades ago, when screens were greener and future brighter
+}
--- a/shaders/scanlines-basic.frag	Sun Dec 03 19:22:25 2023 +0100
+++ b/shaders/scanlines-basic.frag	Sun Dec 03 19:22:42 2023 +0100
@@ -4,9 +4,9 @@
 in       vec2       vTextureXY;
 out      vec4       fColor;
 
-void main(){
+void main() {
 	fColor = texture(uTexture, vTextureXY).rgba;
 
-	float lineCount = 260.;
+	float lineCount = 200.;
 	fColor.xyz *= abs(sin(radians(vTextureXY.y * 180. * lineCount)));
 }
--- a/shaders/soften-borders.frag	Sun Dec 03 19:22:25 2023 +0100
+++ b/shaders/soften-borders.frag	Sun Dec 03 19:22:42 2023 +0100
@@ -4,7 +4,7 @@
 in       vec2       vTextureXY;
 out      vec4       fColor;
 
-void main(){
+void main() {
 	fColor = texture(uTexture, vTextureXY).rgba;
 
 	float width = 0.01;