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