|
-
- [vert.glsl]
- #version 120
-
- attribute vec3 in_vertex;
- attribute vec4 in_color;
- attribute vec4 in_texcoord;
-
- uniform mat4 in_model_view;
- uniform mat3 in_normal_mat;
- uniform mat4 in_proj;
- uniform float in_sprite_orientation;
-
- varying vec4 pass_texcoord;
- varying vec4 pass_color;
-
- void main(void)
- {
- vec4 vertex = in_model_view * vec4(in_vertex - vec3(0.0,0.5,0.0), 1.0);
-
- vec3 v_offset = vec3(1.0 * in_texcoord.z, -1.0 * in_texcoord.w, 0.0);
-
- float sinX = sin(in_sprite_orientation);
- float cosX = cos(in_sprite_orientation);
- float sinY = sinX;
- mat2 rotationMatrix = mat2(cosX, -sinX, sinY, cosX);
-
- v_offset.xy = rotationMatrix * v_offset.xy;
-
- //Billboard calculations
- vertex.xyz += v_offset;
-
- //pass datas
- pass_texcoord = in_texcoord;
- pass_color = in_color;
-
- gl_Position = in_proj * vertex;
- }
-
- [frag.glsl]
- #version 120
-
- #if defined GL_ES
- precision highp float;
- #endif
-
- uniform sampler2D in_texture;
- uniform float in_sprite_flip;
-
- varying vec4 pass_texcoord;
- varying vec4 pass_color;
-
- const float cos_45 = 0.70710678118;
- const float PI = 3.14159265358979323846264;
-
- void main(void)
- {
- vec4 color = texture2D(in_texture, pass_texcoord.xy -
- vec2(pass_texcoord.z * in_sprite_flip, 0.0)) *
- pass_color;
- if (color.a < 0.01)
- discard;
- gl_FragColor = color * pass_color;
- }
|