Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

66 рядки
1.4 KiB

  1. [vert.glsl]
  2. #version 120
  3. attribute vec3 in_vertex;
  4. attribute vec4 in_color;
  5. attribute vec4 in_texcoord;
  6. uniform mat4 in_model_view;
  7. uniform mat3 in_normal_mat;
  8. uniform mat4 in_proj;
  9. uniform float in_sprite_orientation;
  10. varying vec4 pass_texcoord;
  11. varying vec4 pass_color;
  12. void main(void)
  13. {
  14. vec4 vertex = in_model_view * vec4(in_vertex - vec3(0.0,0.5,0.0), 1.0);
  15. vec3 v_offset = vec3(1.0 * in_texcoord.z, -1.0 * in_texcoord.w, 0.0);
  16. float sinX = sin(in_sprite_orientation);
  17. float cosX = cos(in_sprite_orientation);
  18. float sinY = sinX;
  19. mat2 rotationMatrix = mat2(cosX, -sinX, sinY, cosX);
  20. v_offset.xy = rotationMatrix * v_offset.xy;
  21. //Billboard calculations
  22. vertex.xyz += v_offset;
  23. //pass datas
  24. pass_texcoord = in_texcoord;
  25. pass_color = in_color;
  26. gl_Position = in_proj * vertex;
  27. }
  28. [frag.glsl]
  29. #version 120
  30. #if defined GL_ES
  31. precision highp float;
  32. #endif
  33. uniform sampler2D in_texture;
  34. uniform float in_sprite_flip;
  35. varying vec4 pass_texcoord;
  36. varying vec4 pass_color;
  37. const float cos_45 = 0.70710678118;
  38. const float PI = 3.14159265358979323846264;
  39. void main(void)
  40. {
  41. vec4 color = texture2D(in_texture, pass_texcoord.xy -
  42. vec2(pass_texcoord.z * in_sprite_flip, 0.0)) *
  43. pass_color;
  44. if (color.a < 0.01)
  45. discard;
  46. gl_FragColor = color * pass_color;
  47. }