This file is indexed.

/usr/src/castle-game-engine-4.1.1/x3d/opengl/glsl/variance_shadow_map_common.fs is in castle-game-engine-src 4.1.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
/* Extract shadow (how light is the point) from variance shadow map.
   This closely follows VSM presentation, slide 16. */

float shadow(sampler2D shadowMap, const vec4 shadowMapCoord, const in float size)
{
  /* Avoid back-projecting shadows. */
  if (shadowMapCoord.z < 0.0) return 0.0;

  /* When coord2 is outside (0, 0) - (1, 1) square,
     it's always in the shadow. Otherwise shadows would be stretched
     over whole scene, due to clamping. */
  vec2 coord2 = shadowMapCoord.st / shadowMapCoord.q;
  if (coord2.s < 0.0 || coord2.s > 1.0 ||
      coord2.t < 0.0 || coord2.t > 1.0)
    return 0.0;

  vec4 moments = texture2D(shadowMap, coord2);
  float distance_to_light = shadowMapCoord.z / shadowMapCoord.q;

  if (distance_to_light <= moments[0])
    return 1.0; else
  {
    float E_x2 = moments[1];
    float Ex_2 = moments[0] * moments[0];
    float variance = E_x2 - Ex_2;
    float m_d = moments[0] - distance_to_light;
    return variance / (variance + m_d * m_d);
  }
}

float shadow_depth(sampler2D shadowMap, const vec4 shadowMapCoord)
{
  /* Avoid back-projecting shadows. */
  if (shadowMapCoord.z < 0.0) return 0.0;

  vec2 coord2 = shadowMapCoord.st / shadowMapCoord.q;

  /* When coord2 is outside (0, 0) - (1, 1) square, set d = 0.
     Otherwise texture would be visible stretched due to clamping. */
  if (coord2.s < 0.0 || coord2.s > 1.0 ||
      coord2.t < 0.0 || coord2.t > 1.0)
    return 0.0; else
    return texture2D(shadowMap, coord2).x;
}