pbrSpecularGlossinessMaterial.glsl 1005 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * Compute parameters for physically based rendering using the
  3. * specular/glossy workflow. All inputs are linear; sRGB texture values must
  4. * be decoded beforehand
  5. *
  6. * @name czm_pbrSpecularGlossinessMaterial
  7. * @glslFunction
  8. *
  9. * @param {vec3} diffuse The diffuse color for dielectrics (non-metals)
  10. * @param {vec3} specular The reflectance at normal incidence (f0)
  11. * @param {float} glossiness A number from 0.0 to 1.0 indicating how smooth the surface is.
  12. * @return {czm_pbrParameters} parameters to pass into {@link czm_pbrLighting}
  13. */
  14. czm_pbrParameters czm_pbrSpecularGlossinessMaterial(
  15. vec3 diffuse,
  16. vec3 specular,
  17. float glossiness
  18. )
  19. {
  20. czm_pbrParameters results;
  21. // glossiness is the opposite of roughness, but easier for artists to use.
  22. float roughness = 1.0 - glossiness;
  23. results.roughness = roughness * roughness;
  24. results.diffuseColor = diffuse * (1.0 - max(max(specular.r, specular.g), specular.b));
  25. results.f0 = specular;
  26. return results;
  27. }