diff options
author | pryazha <pryadeiniv@mail.ru> | 2025-02-19 22:26:48 +0500 |
---|---|---|
committer | pryazha <pryadeiniv@mail.ru> | 2025-02-19 22:26:48 +0500 |
commit | f9ad6fa902c1167d7622ee7af2617d14b62bee21 (patch) | |
tree | 9d78792cf360ed871616a9ea66c4237018292aa7 /advanced_opengl/8.geometry_shader/shaders/explosion.geom | |
parent | 926cbd0d49890772f911e6a6bedb7835605ced89 (diff) |
quite a lot of changes that I, of course, are not going to describe;)
Diffstat (limited to 'advanced_opengl/8.geometry_shader/shaders/explosion.geom')
-rw-r--r-- | advanced_opengl/8.geometry_shader/shaders/explosion.geom | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/advanced_opengl/8.geometry_shader/shaders/explosion.geom b/advanced_opengl/8.geometry_shader/shaders/explosion.geom new file mode 100644 index 0000000..e708591 --- /dev/null +++ b/advanced_opengl/8.geometry_shader/shaders/explosion.geom @@ -0,0 +1,41 @@ +#version 330 core +layout(triangles) in; +layout(triangle_strip, max_vertices = 3) out; + +in VS_OUT { + vec2 gtex_coords; +} gs_in[]; + +out vec2 ftex_coords; + +uniform float time; + +vec3 get_normal(void) +{ + vec3 a = vec3(gl_in[0].gl_Position)-vec3(gl_in[1].gl_Position); + vec3 b = vec3(gl_in[2].gl_Position)-vec3(gl_in[1].gl_Position); + return(normalize(cross(a, b))); +} + +vec4 explode(vec4 position, vec3 normal) +{ + float magnitude = 0.2; + vec3 direction = normal*magnitude*((sin(time)+1.0)/2.0); + vec4 result = position+vec4(direction, 0.0); + return(result); +} + +void main(void) +{ + vec3 normal = get_normal(); + gl_Position = explode(gl_in[0].gl_Position, normal); + ftex_coords = gs_in[0].gtex_coords; + EmitVertex(); + gl_Position = explode(gl_in[1].gl_Position, normal); + ftex_coords = gs_in[1].gtex_coords; + EmitVertex(); + gl_Position = explode(gl_in[2].gl_Position, normal); + ftex_coords = gs_in[2].gtex_coords; + EmitVertex(); + EndPrimitive(); +} |