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

#ifndef SSAO_CUSTOM_MATERIAL_GLSLLIB
#define SSAO_CUSTOM_MATERIAL_GLSLLIB

#ifdef QQ3D_SHADER_META
/*{
    "uniforms": [
        { "type": "sampler2D", "name": "qt_aoTexture" , "condition": "QSSG_ENABLE_SSAO", "multiview_dependent": true }
    ]
}*/
#endif // QQ3D_SHADER_META

#if QSSG_ENABLE_SSAO

float qt_screenSpaceAmbientOcclusionFactor()
{
#if QSHADER_VIEW_COUNT >= 2
    ivec2 iSize = textureSize(qt_aoTextureArray, 0).xy;
    vec2 smpUV = (gl_FragCoord.xy) / vec2(iSize);
    return texture(qt_aoTextureArray, vec3(smpUV, qt_viewIndex)).x;
#else
    ivec2 iSize = textureSize(qt_aoTexture, 0);
    vec2 smpUV = (gl_FragCoord.xy) / vec2(iSize);
    return texture(qt_aoTexture, smpUV).x;
#endif
}

#else

float qt_screenSpaceAmbientOcclusionFactor()
{
    return 1.0;
}

#endif

#endif