diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index cdf4ed16a4..aa5240618a 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -210,7 +210,7 @@ namespace MWRender settings->setReceivesShadowTraversalMask(~0u); //settings->setShadowMapProjectionHint(osgShadow::ShadowSettings::PERSPECTIVE_SHADOW_MAP); - settings->setBaseShadowTextureUnit(1); + settings->setBaseShadowTextureUnit(7); //settings->setMinimumShadowMapNearFarRatio(0); //settings->setNumShadowMapsPerLight(1); //settings->setShadowMapProjectionHint(osgShadow::ShadowSettings::ORTHOGRAPHIC_SHADOW_MAP); diff --git a/files/shaders/objects_vertex.glsl b/files/shaders/objects_vertex.glsl index 42949dccbb..4046386dd6 100644 --- a/files/shaders/objects_vertex.glsl +++ b/files/shaders/objects_vertex.glsl @@ -46,6 +46,7 @@ varying vec4 passColor; varying vec3 passViewPos; varying vec3 passNormal; +uniform int shadowTextureUnit0; varying vec4 shadowSpaceCoords; #include "lighting.glsl" @@ -104,6 +105,6 @@ void main(void) passNormal = gl_Normal.xyz; // 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 = mat4(gl_EyePlaneS[1], gl_EyePlaneT[1], gl_EyePlaneR[1], gl_EyePlaneQ[1]); + mat4 eyePlaneMat = mat4(gl_EyePlaneS[shadowTextureUnit0], gl_EyePlaneT[shadowTextureUnit0], gl_EyePlaneR[shadowTextureUnit0], gl_EyePlaneQ[shadowTextureUnit0]); shadowSpaceCoords = viewPos * eyePlaneMat; } diff --git a/files/shaders/terrain_vertex.glsl b/files/shaders/terrain_vertex.glsl index 89a2307a1e..17a9c436ea 100644 --- a/files/shaders/terrain_vertex.glsl +++ b/files/shaders/terrain_vertex.glsl @@ -14,6 +14,7 @@ varying vec4 passColor; varying vec3 passViewPos; varying vec3 passNormal; +uniform int shadowTextureUnit0; varying vec4 shadowSpaceCoords; #include "lighting.glsl" @@ -38,6 +39,6 @@ void main(void) uv = gl_MultiTexCoord0.xy; // 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 = mat4(gl_EyePlaneS[1], gl_EyePlaneT[1], gl_EyePlaneR[1], gl_EyePlaneQ[1]); + mat4 eyePlaneMat = mat4(gl_EyePlaneS[shadowTextureUnit0], gl_EyePlaneT[shadowTextureUnit0], gl_EyePlaneR[shadowTextureUnit0], gl_EyePlaneQ[shadowTextureUnit0]); shadowSpaceCoords = viewPos * eyePlaneMat; } diff --git a/files/shaders/water_vertex.glsl b/files/shaders/water_vertex.glsl index 513edc730c..6aaa0537c9 100644 --- a/files/shaders/water_vertex.glsl +++ b/files/shaders/water_vertex.glsl @@ -4,6 +4,7 @@ varying vec3 screenCoordsPassthrough; varying vec4 position; varying float depthPassthrough; +uniform int shadowTextureUnit0; varying vec4 shadowSpaceCoords; void main(void) @@ -23,6 +24,6 @@ void main(void) depthPassthrough = gl_Position.z; // 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 = mat4(gl_EyePlaneS[1], gl_EyePlaneT[1], gl_EyePlaneR[1], gl_EyePlaneQ[1]); + mat4 eyePlaneMat = mat4(gl_EyePlaneS[shadowTextureUnit0], gl_EyePlaneT[shadowTextureUnit0], gl_EyePlaneR[shadowTextureUnit0], gl_EyePlaneQ[shadowTextureUnit0]); shadowSpaceCoords = (gl_ModelViewMatrix * gl_Vertex) * eyePlaneMat; }