]> git.tdb.fi Git - libs/gl.git/commitdiff
Rearrange postprocessing shaders
authorMikko Rasa <tdb@tdb.fi>
Sat, 24 Apr 2021 11:31:11 +0000 (14:31 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 24 Apr 2021 11:31:11 +0000 (14:31 +0300)
Postprocess.glsl has been renamed to flat_effect.glsl and made more
generic so it can be used in non-postprocessing effects too.

builtin_data/_ambientocclusion.glsl
builtin_data/_ambientocclusion_combine.glsl
builtin_data/_ambientocclusion_occlude.glsl
builtin_data/_bloom.glsl
builtin_data/_bloom_blur.glsl
builtin_data/_bloom_combine.glsl
builtin_data/_colorcurve.glsl
shaderlib/flat_effect.glsl [new file with mode: 0644]
shaderlib/postprocess.glsl [deleted file]

index 89d13357b67404dd5f06c180541d5723f372a34b..dca636bb646092da6cd0a823f5fe3783186c851f 100644 (file)
@@ -2,6 +2,7 @@ const int max_samples = 32;
 
 uniform mat4 projection_matrix;
 
+uniform sampler2D source;
 uniform sampler2D depth;
 uniform sampler2D occlusion;
 uniform sampler2D rotate;
index 616bada9e4b88b5cda6c5b139a363bd1a907d261..88929066b73f7cca9a77cc062223935522ce511a 100644 (file)
@@ -1,7 +1,8 @@
-import postprocess;
+import flat_effect;
 import _ambientocclusion;
 
 #pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
 void main()
 {
        vec3 center = unproject(vec3(vertex.xy, texture(depth, texcoord).r));
index e1900323a6cc9a66432f4d70e29312dcaa5a92c0..260f1efa770a89a04679dfc39c7c5de3277d7cc7 100644 (file)
@@ -1,7 +1,8 @@
-import postprocess;
+import flat_effect;
 import _ambientocclusion;
 
 #pragma MSP stage(fragment)
+layout(location=0) out float frag_out;
 void main()
 {
        vec4 rv = texture(rotate, gl_FragCoord.xy/4.0)*2.0-1.0;
@@ -21,5 +22,5 @@ void main()
                        count += 1.0;
                }
        }
-       frag_color = vec4(1.0-occlusion_sum/count, 0.0, 0.0, 1.0);
+       frag_out = 1.0-occlusion_sum/count;
 }
index 262cb29b4349e102b87b5bc087f7787ddff3c162..fe3dd6e44d7f6b7f43dfe76f869e60bfd42f9b18 100644 (file)
@@ -1,3 +1,4 @@
+uniform sampler2D source;
 uniform sampler2D blurred;
 uniform vec2 delta;
 uniform BloomParams
index ce1cf755bed6c48f8418de0a7f8367d2e4c16e87..0207506df89b9cf14a2597014b0f08401be55e23 100644 (file)
@@ -1,10 +1,11 @@
-import postprocess;
+import flat_effect;
 import _bloom;
 
 #pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
 void main()
 {
-       frag_color = vec4(0.0, 0.0, 0.0, 0.0);
+       frag_color = vec4(0.0);
        for(int i=0; i<=size*2; ++i)
                frag_color += texture(source, texcoord+delta*float(i-size))*factors[i];
 }
index 641459bec38b2379bf06c190632f4cf7fe39e3b0..be561af1eab987d67cf33d6908696a449a6d1106 100644 (file)
@@ -1,7 +1,8 @@
-import postprocess;
+import flat_effect;
 import _bloom;
 
 #pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
 void main()
 {
        frag_color = mix(texture(source, texcoord), texture(blurred, texcoord), strength);
index 23b5577dc4a05d72cfc46083aa714fd006484938..9b6ae3627c38a03c724e101783f543ded7b2fd37 100644 (file)
@@ -1,13 +1,16 @@
-import postprocess;
+import flat_effect;
 
-uniform sampler1D curve;
 uniform ToneMapping
 {
        float exposure;
        vec3 brightness_response;
 };
 
+uniform sampler2D source;
+uniform sampler1D curve;
+
 #pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
 void main()
 {
        vec4 incoming = texture(source, texcoord);
diff --git a/shaderlib/flat_effect.glsl b/shaderlib/flat_effect.glsl
new file mode 100644 (file)
index 0000000..0377b8a
--- /dev/null
@@ -0,0 +1,8 @@
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 vertex;
+void main()
+{
+       gl_Position = vertex;
+       out vec2 texcoord = vertex.xy*0.5+0.5;
+       passthrough;
+}
diff --git a/shaderlib/postprocess.glsl b/shaderlib/postprocess.glsl
deleted file mode 100644 (file)
index c868bd1..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-uniform sampler2D source;
-
-#pragma MSP stage(vertex)
-layout(location=0) in vec4 vertex;
-void main()
-{
-       gl_Position = vertex;
-       out vec2 texcoord = vertex.xy*0.5+0.5;
-       passthrough;
-}
-
-#pragma MSP stage(fragment)
-layout(location=0) out vec4 frag_color;