OctahedralProjectionAtlasFS.js 2.4 KB

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