Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Vertex shader source code:
- #version 150
- in vec2 xy;
- in vec3 stw;
- out vec3 atlas;
- void main(void) {
- gl_Position = vec4(xy, 0, 1);
- atlas = stw;
- }
- Geometry shader source code:
- #version 150
- layout (points) in;
- layout (triangle_strip, max_vertices = 4) out;
- in vec3 atlas[1];
- out vec2 texCoord;
- uniform mat4 matrix;
- uniform float lineHeight;
- void main(void) {
- gl_Position = matrix * vec4(gl_in[0].gl_Position.x + atlas[0].z, gl_in[0].gl_Position.y, 0, 1);
- texCoord = vec2(atlas[0].x+atlas[0].z, atlas[0].y + lineHeight);
- EmitVertex();
- gl_Position = matrix * vec4(gl_in[0].gl_Position.x + atlas[0].z, gl_in[0].gl_Position.y + lineHeight, 0, 1);
- texCoord = vec2(atlas[0].x+atlas[0].z, atlas[0].y);
- EmitVertex();
- gl_Position = matrix * vec4(gl_in[0].gl_Position.x, gl_in[0].gl_Position.y, 0, 1);
- texCoord = vec2(atlas[0].x, atlas[0].y + lineHeight);
- EmitVertex();
- gl_Position = matrix * vec4(gl_in[0].gl_Position.x, gl_in[0].gl_Position.y + lineHeight, 0, 1);
- texCoord = vec2(atlas[0].x, atlas[0].y);
- EmitVertex();
- EndPrimitive();
- }
- Fragment shader source code:
- #version 150
- in vec2 texCoord;
- uniform sampler2D tex;
- uniform float opacity;
- out vec4 fragColor;
- void main(void) {
- float alpha = opacity * texelFetch(tex, ivec2(texCoord), 0).r;
- fragColor = vec4(0,0,0,alpha);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement