SunTextureFS.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "uniform float u_radiusTS;\n\
  3. varying vec2 v_textureCoordinates;\n\
  4. vec2 rotate(vec2 p, vec2 direction)\n\
  5. {\n\
  6. return vec2(p.x * direction.x - p.y * direction.y, p.x * direction.y + p.y * direction.x);\n\
  7. }\n\
  8. vec4 addBurst(vec2 position, vec2 direction, float lengthScalar)\n\
  9. {\n\
  10. vec2 rotatedPosition = rotate(position, direction) * vec2(25.0, 0.75);\n\
  11. float radius = length(rotatedPosition) * lengthScalar;\n\
  12. float burst = 1.0 - smoothstep(0.0, 0.55, radius);\n\
  13. return vec4(burst);\n\
  14. }\n\
  15. void main()\n\
  16. {\n\
  17. float lengthScalar = 2.0 / sqrt(2.0);\n\
  18. vec2 position = v_textureCoordinates - vec2(0.5);\n\
  19. float radius = length(position) * lengthScalar;\n\
  20. float surface = step(radius, u_radiusTS);\n\
  21. vec4 color = vec4(vec2(1.0), surface + 0.2, surface);\n\
  22. float glow = 1.0 - smoothstep(0.0, 0.55, radius);\n\
  23. color.ba += mix(vec2(0.0), vec2(1.0), glow) * 0.75;\n\
  24. vec4 burst = vec4(0.0);\n\
  25. burst += 0.4 * addBurst(position, vec2(0.38942, 0.92106), lengthScalar);\n\
  26. burst += 0.4 * addBurst(position, vec2(0.99235, 0.12348), lengthScalar);\n\
  27. burst += 0.4 * addBurst(position, vec2(0.60327, -0.79754), lengthScalar);\n\
  28. burst += 0.3 * addBurst(position, vec2(0.31457, 0.94924), lengthScalar);\n\
  29. burst += 0.3 * addBurst(position, vec2(0.97931, 0.20239), lengthScalar);\n\
  30. burst += 0.3 * addBurst(position, vec2(0.66507, -0.74678), lengthScalar);\n\
  31. color += clamp(burst, vec4(0.0), vec4(1.0)) * 0.15;\n\
  32. gl_FragColor = clamp(color, vec4(0.0), vec4(1.0));\n\
  33. }\n\
  34. ";