53599592e0
Comes with backends for Vulkan, Metal, Direct3D 11.1, and OpenGL (ES). All APIs are private for now. Shader conditioning (i.e. generating a QRhiShader in memory or on disk from some shader source code) is done via the tools and APIs provided by qt-labs/qtshadertools. The OpenGL support follows the cross-platform tradition of requiring ES 2.0 only, while optionally using some (ES) 3.x features. It can operate in core profile contexts as well. Task-number: QTBUG-70287 Change-Id: I246f2e36d562e404012c05db2aa72487108aa7cc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
31 lines
805 B
GLSL
31 lines
805 B
GLSL
#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;
|
|
}
|