aboutsummaryrefslogtreecommitdiffstats
path: root/src/runtimerender/res/effectlib/funcsampleLightVars.glsllib
blob: 0fd8f62406f65b0953e5a8ecde262c53e94e1439 (plain)
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
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

// RHI version, note the explicit binding (1)

#if QSSG_REDUCE_MAX_NUM_LIGHTS
#define MAX_NUM_LIGHTS 5
#else
#define MAX_NUM_LIGHTS 15
#endif

#define MAX_NUM_SHADOWS 8

struct LightSource
{
    vec4  position;
    vec4  direction;              // Specifies the light direction in world coordinates.
    vec4  diffuse;
    vec4  specular;
    float coneAngle;              // Specifies the intensity distribution of the light.
    float innerConeAngle;         // Specifies the maximum spread angle of the light.
    float constantAttenuation;    // Specifies the constant light attenuation factor.
    float linearAttenuation;      // Specifies the linear light attenuation factor.
    float quadraticAttenuation;   // Specifies the quadratic light attenuation factor.
};

struct ShadowData {
    mat4 matrices[4];
    vec4 dimensionsInverted[4]; // (x, y, z, 0)
    vec4 csmSplits;
    vec4 csmActive;

    float bias;
    float factor;
    float isYUp; // 1.0 = true, 0.0 = false
    float clipNear; // Used for Point light + Spot light

    float shadowMapFar; // Used for Point light + Spot light
    int layerIndex;
    int csmNumSplits;
    float csmBlendRatio;

    float pcfFactor;
};

layout (std140, binding = 1) uniform cbLights
{
    int uNumLights;
    LightSource lights[MAX_NUM_LIGHTS];
} ubLights;

layout (std140, binding = 2) uniform cbShadows
{
    int uNumShadows;
    ShadowData shadowData[MAX_NUM_SHADOWS];
} ubShadows;