Add small example
This commit is contained in:
8
shaders/2d-passthrough-vertex.glsl
Normal file
8
shaders/2d-passthrough-vertex.glsl
Normal file
@@ -0,0 +1,8 @@
|
||||
#version 330 core
|
||||
|
||||
layout (location = 0) in vec2 inputVertex;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(inputVertex.x, inputVertex.y, 0.0, 1.0);
|
||||
}
|
11
shaders/2d-zoom-translate-vertex.glsl
Normal file
11
shaders/2d-zoom-translate-vertex.glsl
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 330 core
|
||||
|
||||
layout (location = 0) in vec2 inputVertex;
|
||||
uniform float zoom;
|
||||
uniform vec2 center_pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 translated = (vec4(inputVertex.x, inputVertex.y, 0.0, 1.0) - vec4(center_pos.x, center_pos.y, 0.0, 0.0));
|
||||
gl_Position = vec4(translated.x, translated.y, translated.z, translated.w) * vec4(zoom, zoom, 1, 1);
|
||||
}
|
8
shaders/fixed-red-fragment.glsl
Normal file
8
shaders/fixed-red-fragment.glsl
Normal file
@@ -0,0 +1,8 @@
|
||||
#version 330 core
|
||||
|
||||
out vec4 fragmentColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
fragmentColor = vec4(1.0, 0.0, 0.0, 0.0);
|
||||
}
|
8
shaders/textured-rectangle-fragment.glsl
Normal file
8
shaders/textured-rectangle-fragment.glsl
Normal file
@@ -0,0 +1,8 @@
|
||||
#version 330 core
|
||||
|
||||
out vec4 fragmentColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
fragmentColor = vec4(1.0, 0.0, 0.0, 0.0);
|
||||
}
|
11
shaders/textured-rectangle-vertex.glsl
Normal file
11
shaders/textured-rectangle-vertex.glsl
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 330 core
|
||||
|
||||
layout (location = 0) in vec2 inputVertex;
|
||||
uniform float zoom;
|
||||
uniform vec2 pos_offset;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 pos2d = (inputVertex - pos_offset) * zoom;
|
||||
gl_Position = vec4(pos2d.x , pos2d.y, 0.0, 1.0);
|
||||
}
|
15
shaders/triangle-gen-geometry.glsl
Normal file
15
shaders/triangle-gen-geometry.glsl
Normal file
@@ -0,0 +1,15 @@
|
||||
#version 330 core
|
||||
|
||||
layout (points) in;
|
||||
layout (triangle_strip, max_vertices=3) out;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = gl_in[0].gl_Position + vec4(-0.1, 0.0, 0.0, 0.0);
|
||||
EmitVertex();
|
||||
gl_Position = gl_in[0].gl_Position + vec4(0.0, 0.1, 0.0, 0.0);
|
||||
EmitVertex();
|
||||
gl_Position = gl_in[0].gl_Position + vec4(0.1, 0.0, 0.0, 0.0);
|
||||
EmitVertex();
|
||||
EndPrimitive();
|
||||
}
|
17
shaders/triangle-gen-zoomed-geometry.glsl
Normal file
17
shaders/triangle-gen-zoomed-geometry.glsl
Normal file
@@ -0,0 +1,17 @@
|
||||
#version 330 core
|
||||
|
||||
layout (points) in;
|
||||
layout (triangle_strip, max_vertices=3) out;
|
||||
|
||||
uniform float zoom;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = gl_in[0].gl_Position + vec4(-0.1, 0.0, 0.0, 0.0) * zoom;
|
||||
EmitVertex();
|
||||
gl_Position = gl_in[0].gl_Position + vec4(0.0, 0.1, 0.0, 0.0) * zoom;
|
||||
EmitVertex();
|
||||
gl_Position = gl_in[0].gl_Position + vec4(0.1, 0.0, 0.0, 0.0) * zoom;
|
||||
EmitVertex();
|
||||
EndPrimitive();
|
||||
}
|
Reference in New Issue
Block a user