fire.vertex.fx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. precision highp float;
  2. // Attributes
  3. attribute vec3 position;
  4. #ifdef UV1
  5. attribute vec2 uv;
  6. #endif
  7. #ifdef UV2
  8. attribute vec2 uv2;
  9. #endif
  10. #ifdef VERTEXCOLOR
  11. attribute vec4 color;
  12. #endif
  13. #include<bonesDeclaration>
  14. // Uniforms
  15. #include<instancesDeclaration>
  16. uniform mat4 view;
  17. uniform mat4 viewProjection;
  18. #ifdef DIFFUSE
  19. varying vec2 vDiffuseUV;
  20. #endif
  21. #ifdef POINTSIZE
  22. uniform float pointSize;
  23. #endif
  24. // Output
  25. varying vec3 vPositionW;
  26. #ifdef VERTEXCOLOR
  27. varying vec4 vColor;
  28. #endif
  29. #include<clipPlaneVertexDeclaration>
  30. #include<fogVertexDeclaration>
  31. #include<shadowsVertexDeclaration>
  32. // Fire
  33. uniform float time;
  34. uniform float speed;
  35. #ifdef DIFFUSE
  36. varying vec2 vDistortionCoords1;
  37. varying vec2 vDistortionCoords2;
  38. varying vec2 vDistortionCoords3;
  39. #endif
  40. void main(void) {
  41. #include<instancesVertex>
  42. #include<bonesVertex>
  43. gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
  44. vec4 worldPos = finalWorld * vec4(position, 1.0);
  45. vPositionW = vec3(worldPos);
  46. // Texture coordinates
  47. #ifdef DIFFUSE
  48. vDiffuseUV = uv;
  49. vDiffuseUV.y -= 0.2;
  50. #endif
  51. // Clip plane
  52. #include<clipPlaneVertex>
  53. // Fog
  54. #include<fogVertex>
  55. // Vertex color
  56. #ifdef VERTEXCOLOR
  57. vColor = color;
  58. #endif
  59. // Point size
  60. #ifdef POINTSIZE
  61. gl_PointSize = pointSize;
  62. #endif
  63. #ifdef DIFFUSE
  64. // Fire
  65. vec3 layerSpeed = vec3(-0.2, -0.52, -0.1) * speed;
  66. vDistortionCoords1.x = uv.x;
  67. vDistortionCoords1.y = uv.y + layerSpeed.x * time / 1000.0;
  68. vDistortionCoords2.x = uv.x;
  69. vDistortionCoords2.y = uv.y + layerSpeed.y * time / 1000.0;
  70. vDistortionCoords3.x = uv.x;
  71. vDistortionCoords3.y = uv.y + layerSpeed.z * time / 1000.0;
  72. #endif
  73. }