File: main.frag

package info (click to toggle)
qtbase-opensource-src-gles 5.15.2%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 346,096 kB
  • sloc: cpp: 2,029,283; ansic: 316,141; xml: 117,558; python: 10,681; java: 7,431; asm: 4,023; perl: 2,044; sh: 1,967; yacc: 1,687; lex: 1,333; javascript: 878; makefile: 307; objc: 70
file content (30 lines) | stat: -rw-r--r-- 805 bytes parent folder | download | duplicates (11)
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
#version 440

layout(location = 0) in vec4 vLCVertPos;

layout(location = 0) out vec4 fragColor;

layout(binding = 1) uniform sampler2DShadow shadowMap;

layout(std140, binding = 0) uniform buf {
    mat4 mvp;
    mat4 lightMvp;
    mat4 shadowBias;
    int useShadow;
} ubuf;

void main()
{
    vec4 adjustedLcVertPos = vLCVertPos;
    adjustedLcVertPos.z -= 0.0001; // bias to avoid acne

    // no textureProj, that seems to end up not doing the perspective divide for z (?)
    vec3 v = adjustedLcVertPos.xyz / adjustedLcVertPos.w;
    float sc = texture(shadowMap, v); // sampler is comparison enabled so compares to z

    float shadowFactor = 0.2;
    if (sc > 0 || ubuf.useShadow == 0)
        shadowFactor = 1.0;

    fragColor = vec4(0.5, 0.3 + ubuf.useShadow * 0.2, 0.7, 1.0) * shadowFactor;
}