fire.vertex.fx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. // Fire
  32. uniform float time;
  33. uniform float speed;
  34. #ifdef DIFFUSE
  35. varying vec2 vDistortionCoords1;
  36. varying vec2 vDistortionCoords2;
  37. varying vec2 vDistortionCoords3;
  38. #endif
  39. void main(void) {
  40. #include<instancesVertex>
  41. #include<bonesVertex>
  42. gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
  43. vec4 worldPos = finalWorld * vec4(position, 1.0);
  44. vPositionW = vec3(worldPos);
  45. // Texture coordinates
  46. #ifdef DIFFUSE
  47. vDiffuseUV = uv;
  48. vDiffuseUV.y -= 0.2;
  49. #endif
  50. // Clip plane
  51. #include<clipPlaneVertex>
  52. // Fog
  53. #include<fogVertex>
  54. // Vertex color
  55. #ifdef VERTEXCOLOR
  56. vColor = color;
  57. #endif
  58. // Point size
  59. #ifdef POINTSIZE
  60. gl_PointSize = pointSize;
  61. #endif
  62. #ifdef DIFFUSE
  63. // Fire
  64. vec3 layerSpeed = vec3(-0.2, -0.52, -0.1) * speed;
  65. vDistortionCoords1.x = uv.x;
  66. vDistortionCoords1.y = uv.y + layerSpeed.x * time / 1000.0;
  67. vDistortionCoords2.x = uv.x;
  68. vDistortionCoords2.y = uv.y + layerSpeed.y * time / 1000.0;
  69. vDistortionCoords3.x = uv.x;
  70. vDistortionCoords3.y = uv.y + layerSpeed.z * time / 1000.0;
  71. #endif
  72. }