From 84bcd409a3743e933d039a9b3e073030fd2630df Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 23 May 2018 19:06:47 +0200 Subject: Implement particle trails using overlaying textures --- src/shader/display_fragment.glsl | 25 ++++++++++++++++++++++--- src/shader/vertex.glsl | 3 ++- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'src/shader') diff --git a/src/shader/display_fragment.glsl b/src/shader/display_fragment.glsl index 8b98ce1..03986a0 100644 --- a/src/shader/display_fragment.glsl +++ b/src/shader/display_fragment.glsl @@ -1,11 +1,30 @@ static const std::string DISPLAY_FRAGMENT_SHADER_CODE = R"( -#version 330 core +#version 460 out vec4 FragColor; in vec2 TexCoords; -uniform sampler2D screen_texture; + +uniform sampler2D screen_texture_0; +uniform sampler2D screen_texture_1; +uniform sampler2D screen_texture_2; +uniform sampler2D screen_texture_3; +uniform sampler2D screen_texture_4; +uniform sampler2D screen_texture_5; +uniform sampler2D screen_texture_6; +uniform sampler2D screen_texture_7; +uniform sampler2D screen_texture_8; +uniform sampler2D screen_texture_9; void main() { - FragColor = texture(screen_texture, TexCoords); + FragColor = texture(screen_texture_0, TexCoords) + + 0.9 * texture(screen_texture_1, TexCoords) + + 0.8 * texture(screen_texture_2, TexCoords) + + 0.7 * texture(screen_texture_3, TexCoords) + + 0.6 * texture(screen_texture_4, TexCoords) + + 0.5 * texture(screen_texture_5, TexCoords) + + 0.4 * texture(screen_texture_6, TexCoords) + + 0.3 * texture(screen_texture_7, TexCoords) + + 0.2 * texture(screen_texture_8, TexCoords) + + 0.1 * texture(screen_texture_9, TexCoords); } )"; diff --git a/src/shader/vertex.glsl b/src/shader/vertex.glsl index 8ab6ccb..2d4009a 100644 --- a/src/shader/vertex.glsl +++ b/src/shader/vertex.glsl @@ -3,6 +3,7 @@ uniform mat4 MVP; void main() { gl_Position = MVP * vec4(gl_Vertex.xy, 0.0, 1.0); - gl_FrontColor = vec4(max(1. - gl_Vertex.z/5., 0.1), 0., 0., 0.); + //gl_FrontColor = vec4(max(1. - gl_Vertex.z/5., 0.1), 0., 0., 0.); + gl_FrontColor = vec4(1., 0., 0., 0.); } )"; -- cgit v1.2.3