assign-material-color.glsl 1.7 KB

1234567891011121314151617181920212223242526272829303132
  1. #if defined(dColorType_uniform)
  2. vec4 material = vec4(uColor, uAlpha);
  3. #elif defined(dColorType_attribute) || defined(dColorType_instance) || defined(dColorType_group) || defined(dColorType_groupInstance)
  4. vec4 material = vec4(vColor.rgb, uAlpha);
  5. #elif defined(dColorType_objectPicking) || defined(dColorType_instancePicking) || defined(dColorType_groupPicking)
  6. vec4 material = uPickable == 1 ? vColor : vec4(0.0, 0.0, 0.0, 1.0); // set to empty picking id
  7. #endif
  8. // mix material with overpaint
  9. #if defined(dOverpaint) && (defined(dColorType_uniform) || defined(dColorType_attribute) || defined(dColorType_instance) || defined(dColorType_group) || defined(dColorType_groupInstance))
  10. material.rgb = mix(material.rgb, vOverpaint.rgb, vOverpaint.a);
  11. #endif
  12. // apply screendoor transparency
  13. #if defined(dTransparency) && (defined(dColorType_uniform) || defined(dColorType_attribute) || defined(dColorType_instance) || defined(dColorType_group) || defined(dColorType_groupInstance))
  14. float ta = 1.0 - vTransparency;
  15. float at = 0.0;
  16. #if defined(dTransparencyVariant_single)
  17. const mat4 thresholdMatrix = mat4(
  18. 1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0,
  19. 13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0,
  20. 4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0,
  21. 16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0
  22. );
  23. at = thresholdMatrix[int(intMod(gl_FragCoord.x, 4.0))][int(intMod(gl_FragCoord.y, 4.0))];
  24. #elif defined(dTransparencyVariant_multi)
  25. at = fract(dot(vec3(gl_FragCoord.xy, vGroup + 0.5), vec3(2.0, 7.0, 23.0) / 17.0f));
  26. #endif
  27. if (ta < 0.99 && (ta < 0.01 || ta < at)) discard;
  28. #endif