From: Mikko Rasa Date: Sat, 24 Apr 2021 11:31:11 +0000 (+0300) Subject: Rearrange postprocessing shaders X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=d4312ccb1a73acecc57394b2c5230083b1f8b6a1;p=libs%2Fgl.git Rearrange postprocessing shaders Postprocess.glsl has been renamed to flat_effect.glsl and made more generic so it can be used in non-postprocessing effects too. --- diff --git a/builtin_data/_ambientocclusion.glsl b/builtin_data/_ambientocclusion.glsl index 89d13357..dca636bb 100644 --- a/builtin_data/_ambientocclusion.glsl +++ b/builtin_data/_ambientocclusion.glsl @@ -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; diff --git a/builtin_data/_ambientocclusion_combine.glsl b/builtin_data/_ambientocclusion_combine.glsl index 616bada9..88929066 100644 --- a/builtin_data/_ambientocclusion_combine.glsl +++ b/builtin_data/_ambientocclusion_combine.glsl @@ -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)); diff --git a/builtin_data/_ambientocclusion_occlude.glsl b/builtin_data/_ambientocclusion_occlude.glsl index e1900323..260f1efa 100644 --- a/builtin_data/_ambientocclusion_occlude.glsl +++ b/builtin_data/_ambientocclusion_occlude.glsl @@ -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; } diff --git a/builtin_data/_bloom.glsl b/builtin_data/_bloom.glsl index 262cb29b..fe3dd6e4 100644 --- a/builtin_data/_bloom.glsl +++ b/builtin_data/_bloom.glsl @@ -1,3 +1,4 @@ +uniform sampler2D source; uniform sampler2D blurred; uniform vec2 delta; uniform BloomParams diff --git a/builtin_data/_bloom_blur.glsl b/builtin_data/_bloom_blur.glsl index ce1cf755..0207506d 100644 --- a/builtin_data/_bloom_blur.glsl +++ b/builtin_data/_bloom_blur.glsl @@ -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]; } diff --git a/builtin_data/_bloom_combine.glsl b/builtin_data/_bloom_combine.glsl index 641459be..be561af1 100644 --- a/builtin_data/_bloom_combine.glsl +++ b/builtin_data/_bloom_combine.glsl @@ -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); diff --git a/builtin_data/_colorcurve.glsl b/builtin_data/_colorcurve.glsl index 23b5577d..9b6ae362 100644 --- a/builtin_data/_colorcurve.glsl +++ b/builtin_data/_colorcurve.glsl @@ -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 index 00000000..0377b8a6 --- /dev/null +++ b/shaderlib/flat_effect.glsl @@ -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 index c868bd11..00000000 --- a/shaderlib/postprocess.glsl +++ /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;