Use texture to draw points with WebGL

This commit is contained in:
Éric Lemoine
2014-10-24 16:57:21 +02:00
parent 2ecd2eadf7
commit bbea205a9c
5 changed files with 174 additions and 93 deletions
+8 -2
View File
@@ -3,20 +3,26 @@
//! COMMON
varying vec2 v_texCoord;
//! VERTEX
attribute vec2 a_position;
attribute vec2 a_texCoord;
attribute vec2 a_offsets;
uniform mat4 u_projectionMatrix;
uniform mat2 u_sizeMatrix;
void main(void) {
gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.) + vec4(a_offsets, 0., 0.);
vec2 offsets = u_sizeMatrix * a_offsets;
gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.) + vec4(offsets, 0., 0.);
v_texCoord = a_texCoord;
}
//! FRAGMENT
uniform sampler2D u_image;
void main(void) {
gl_FragColor = vec4(1.0, 1.0, 0.0, 1);
gl_FragColor = texture2D(u_image, v_texCoord);
}