CheckerboardMaterial.js 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "uniform vec4 lightColor;\n\
  3. uniform vec4 darkColor;\n\
  4. uniform vec2 repeat;\n\
  5. \n\
  6. czm_material czm_getMaterial(czm_materialInput materialInput)\n\
  7. {\n\
  8. czm_material material = czm_getDefaultMaterial(materialInput);\n\
  9. \n\
  10. vec2 st = materialInput.st;\n\
  11. \n\
  12. // From Stefan Gustavson's Procedural Textures in GLSL in OpenGL Insights\n\
  13. float b = mod(floor(repeat.s * st.s) + floor(repeat.t * st.t), 2.0); // 0.0 or 1.0\n\
  14. \n\
  15. // Find the distance from the closest separator (region between two colors)\n\
  16. float scaledWidth = fract(repeat.s * st.s);\n\
  17. scaledWidth = abs(scaledWidth - floor(scaledWidth + 0.5));\n\
  18. float scaledHeight = fract(repeat.t * st.t);\n\
  19. scaledHeight = abs(scaledHeight - floor(scaledHeight + 0.5));\n\
  20. float value = min(scaledWidth, scaledHeight);\n\
  21. \n\
  22. vec4 currentColor = mix(lightColor, darkColor, b);\n\
  23. vec4 color = czm_antialias(lightColor, darkColor, currentColor, value, 0.03);\n\
  24. \n\
  25. color = czm_gammaCorrect(color);\n\
  26. material.diffuse = color.rgb;\n\
  27. material.alpha = color.a;\n\
  28. \n\
  29. return material;\n\
  30. }\n\
  31. ";