mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-04 02:41:19 +00:00
29 lines
1.3 KiB
GLSL
29 lines
1.3 KiB
GLSL
#define SHADOWS @shadows_enabled
|
|
|
|
#if SHADOWS
|
|
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
|
uniform int shadowTextureUnit@shadow_texture_unit_index;
|
|
varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
|
|
|
|
#if @perspectiveShadowMaps
|
|
uniform mat4 validRegionMatrix@shadow_texture_unit_index;
|
|
varying vec4 shadowRegionCoords@shadow_texture_unit_index;
|
|
#endif
|
|
@endforeach
|
|
#endif // SHADOWS
|
|
|
|
void setupShadowCoords(vec4 viewPos)
|
|
{
|
|
#if SHADOWS
|
|
// This matrix has the opposite handedness to the others used here, so multiplication must have the vector to the left. Alternatively it could be transposed after construction, but that's extra work for the GPU just to make the code look a tiny bit cleaner.
|
|
mat4 eyePlaneMat;
|
|
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
|
eyePlaneMat = mat4(gl_EyePlaneS[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneT[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneR[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneQ[shadowTextureUnit@shadow_texture_unit_index]);
|
|
shadowSpaceCoords@shadow_texture_unit_index = viewPos * eyePlaneMat;
|
|
|
|
#if @perspectiveShadowMaps
|
|
shadowRegionCoords@shadow_texture_unit_index = validRegionMatrix@shadow_texture_unit_index * viewPos;
|
|
#endif
|
|
@endforeach
|
|
#endif // SHADOWS
|
|
} |