fire.vertex.fx 1.6 KB

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