Debian Codegraph @

shaders/src/main.fs

raw
1 layout(location = 0) out vec4 fragColor;
2
3 #if defined(MATERIAL_HAS_POST_LIGHTING_COLOR)
4 void blendPostLightingColor(const MaterialInputs material, inout vec4 color) {
5 #if defined(POST_LIGHTING_BLEND_MODE_OPAQUE)
6 color = material.postLightingColor;
7 #elif defined(POST_LIGHTING_BLEND_MODE_TRANSPARENT)
8 color = material.postLightingColor + color * (1.0 - material.postLightingColor.a);
9 #elif defined(POST_LIGHTING_BLEND_MODE_ADD)
10 color += material.postLightingColor;
11 #elif defined(POST_LIGHTING_BLEND_MODE_MULTIPLY)
12 color *= material.postLightingColor;
13 #elif defined(POST_LIGHTING_BLEND_MODE_SCREEN)
14 color += material.postLightingColor * (1.0 - color);
15 #endif
16 }
17 #endif
18
19 void main() {
20 // See shading_parameters.fs
21 // Computes global variables we need to evaluate material and lighting
22 computeShadingParams();
23
24 // Initialize the inputs to sensible default values, see material_inputs.fs
25 MaterialInputs inputs;
26 initMaterial(inputs);
27
28 // Invoke user code
29 material(inputs);
30
31 fragColor = evaluateMaterial(inputs);
32
33 #if defined(HAS_DIRECTIONAL_LIGHTING) && defined(HAS_SHADOWING)
34 bool visualizeCascades = bool(frameUniforms.cascades & 0x10u);
35 if (visualizeCascades) {
36 fragColor.rgb *= uintToColorDebug(getShadowCascade());
37 }
38 #endif
39
40 #if defined(HAS_FOG)
41 vec3 view = getWorldPosition() - getWorldCameraPosition();
42 fragColor = fog(fragColor, view);
43 #endif
44
45 #if defined(MATERIAL_HAS_POST_LIGHTING_COLOR)
46 blendPostLightingColor(inputs, fragColor);
47 #endif
48 }