CheckerboardMaterial.js 1.2 KB

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