OctahedralProjectionAtlasFS.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "varying vec2 v_textureCoordinates;\n\
  3. uniform float originalSize;\n\
  4. uniform sampler2D texture0;\n\
  5. uniform sampler2D texture1;\n\
  6. uniform sampler2D texture2;\n\
  7. uniform sampler2D texture3;\n\
  8. uniform sampler2D texture4;\n\
  9. uniform sampler2D texture5;\n\
  10. const float yMipLevel1 = 1.0 - (1.0 / pow(2.0, 1.0));\n\
  11. const float yMipLevel2 = 1.0 - (1.0 / pow(2.0, 2.0));\n\
  12. const float yMipLevel3 = 1.0 - (1.0 / pow(2.0, 3.0));\n\
  13. const float yMipLevel4 = 1.0 - (1.0 / pow(2.0, 4.0));\n\
  14. void main()\n\
  15. {\n\
  16. vec2 uv = v_textureCoordinates;\n\
  17. vec2 textureSize = vec2(originalSize * 1.5 + 2.0, originalSize);\n\
  18. vec2 pixel = 1.0 / textureSize;\n\
  19. float mipLevel = 0.0;\n\
  20. if (uv.x - pixel.x > (textureSize.y / textureSize.x))\n\
  21. {\n\
  22. mipLevel = 1.0;\n\
  23. if (uv.y - pixel.y > yMipLevel1)\n\
  24. {\n\
  25. mipLevel = 2.0;\n\
  26. if (uv.y - pixel.y * 3.0 > yMipLevel2)\n\
  27. {\n\
  28. mipLevel = 3.0;\n\
  29. if (uv.y - pixel.y * 5.0 > yMipLevel3)\n\
  30. {\n\
  31. mipLevel = 4.0;\n\
  32. if (uv.y - pixel.y * 7.0 > yMipLevel4)\n\
  33. {\n\
  34. mipLevel = 5.0;\n\
  35. }\n\
  36. }\n\
  37. }\n\
  38. }\n\
  39. }\n\
  40. if (mipLevel > 0.0)\n\
  41. {\n\
  42. float scale = pow(2.0, mipLevel);\n\
  43. uv.y -= (pixel.y * (mipLevel - 1.0) * 2.0);\n\
  44. uv.x *= ((textureSize.x - 2.0) / textureSize.y);\n\
  45. uv.x -= 1.0 + pixel.x;\n\
  46. uv.y -= (1.0 - (1.0 / pow(2.0, mipLevel - 1.0)));\n\
  47. uv *= scale;\n\
  48. }\n\
  49. else\n\
  50. {\n\
  51. uv.x *= (textureSize.x / textureSize.y);\n\
  52. }\n\
  53. if(mipLevel == 0.0)\n\
  54. {\n\
  55. gl_FragColor = texture2D(texture0, uv);\n\
  56. }\n\
  57. else if(mipLevel == 1.0)\n\
  58. {\n\
  59. gl_FragColor = texture2D(texture1, uv);\n\
  60. }\n\
  61. else if(mipLevel == 2.0)\n\
  62. {\n\
  63. gl_FragColor = texture2D(texture2, uv);\n\
  64. }\n\
  65. else if(mipLevel == 3.0)\n\
  66. {\n\
  67. gl_FragColor = texture2D(texture3, uv);\n\
  68. }\n\
  69. else if(mipLevel == 4.0)\n\
  70. {\n\
  71. gl_FragColor = texture2D(texture4, uv);\n\
  72. }\n\
  73. else if(mipLevel == 5.0)\n\
  74. {\n\
  75. gl_FragColor = texture2D(texture5, uv);\n\
  76. }\n\
  77. else\n\
  78. {\n\
  79. gl_FragColor = vec4(0.0);\n\
  80. }\n\
  81. }\n\
  82. ";