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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//This file is automatically rebuilt by the Cesium build process.
export default "vec3 LINEARtoSRGB(vec3 linearIn) \n\
{\n\
    #ifndef HDR \n\
    return pow(linearIn, vec3(1.0/2.2));\n\
    #else \n\
    return linearIn;\n\
    #endif \n\
}\n\
\n\
#ifdef LIGHTING_PBR\n\
vec3 applyTonemapping(vec3 linearIn) \n\
{\n\
    #ifndef HDR \n\
    return czm_acesTonemapping(linearIn);\n\
    #else \n\
    return linearIn;\n\
    #endif \n\
}\n\
\n\
vec3 computePbrLighting(czm_modelMaterial inputMaterial)\n\
{\n\
    czm_pbrParameters pbrParameters;\n\
    pbrParameters.diffuseColor = inputMaterial.diffuse;\n\
    pbrParameters.f0 = inputMaterial.specular;\n\
    pbrParameters.roughness = inputMaterial.roughness;\n\
    \n\
    vec3 lightColorHdr = czm_lightColorHdr;\n\
\n\
    vec3 color = inputMaterial.diffuse;\n\
    #ifdef HAS_NORMALS\n\
    color = czm_pbrLighting(\n\
        v_positionEC,\n\
        inputMaterial.normalEC,\n\
        czm_lightDirectionEC,\n\
        lightColorHdr,\n\
        pbrParameters\n\
    );\n\
    #endif\n\
\n\
    color *= inputMaterial.occlusion;\n\
    color += inputMaterial.emissive;\n\
\n\
    // Convert high-dynamic range to low-dynamic range in HDR mode\n\
    color = applyTonemapping(color);\n\
    return color;\n\
}\n\
#endif\n\
\n\
void lightingStage(inout czm_modelMaterial material)\n\
{\n\
    // Even though the lighting will only set the diffuse color,\n\
    // pass all other properties so further stages have access to them.\n\
    vec3 color = vec3(0.0);\n\
\n\
    #ifdef LIGHTING_PBR\n\
    color = computePbrLighting(material);\n\
    #else // unlit\n\
    color = material.diffuse;\n\
    #endif\n\
\n\
    color = LINEARtoSRGB(color);\n\
\n\
    material.diffuse = color;\n\
}\n\
";