soft shadows optimization

This commit is contained in:
2023-02-22 15:48:50 +03:00
parent 91bc31e7db
commit 7455a7341c
6 changed files with 58 additions and 40 deletions

View File

@@ -27,18 +27,21 @@ const float _pe = 2.4e-7;
void main(void) {
if (bitfieldExtract(object_flags, 2, 1) == 0)
discard;
vec4 diffuse = qgl_materialTexture(QGL_MAP_DIFFUSE, qgl_FragTexture.xy, vec4(0));
if(diffuse.a < 0.5)
vec4 diffuse = qgl_materialTexture(QGL_MAP_DIFFUSE, qgl_FragTexture.xy, vec4(0.f));
if(diffuse.a < 0.5f)
discard;
float z = gl_FragCoord.z;
z = z + z - 1;
z = ((_pe - 2.) * z_near) / (z + z + _pe - 2.); // infinite depth
//float z = gl_FragCoord.z;
//z = z + z - 1;
//z = ((_pe - 2.) * z_near) / (z + z + _pe - 2.); // infinite depth
#ifdef OMNI
gl_FragDepth = 1 - 1 / (length(pos.xyz) - z_near + 1);
float z = length(pos.xyz);
#else
gl_FragDepth = 1 - 1 / (pos.z - z_near + 1);
float z = pos.z;
#endif
z = 1.f - 1.f / (z - z_near + 1.f);
gl_FragDepth = z;
qgl_FragData[0].r = z;
//qgl_FragData[0].r = length(vec3(pos.xy, z));//1/gl_FragCoord.w;
}