diff --git a/files/shaders/compatibility/bs/default.frag b/files/shaders/compatibility/bs/default.frag index 5068c01d80..3d2ad07d1d 100644 --- a/files/shaders/compatibility/bs/default.frag +++ b/files/shaders/compatibility/bs/default.frag @@ -26,8 +26,6 @@ uniform sampler2D normalMap; varying vec2 normalMapUV; #endif -uniform sampler2D opaqueDepthTex; - varying float euclideanDepth; varying float linearDepth; @@ -59,7 +57,7 @@ void main() #if defined(DISTORTION) && DISTORTION vec2 screenCoords = gl_FragCoord.xy / (screenRes * @distorionRTRatio); gl_FragData[0].a *= getDiffuseColor().a; - gl_FragData[0] = applyDistortion(gl_FragData[0], distortionStrength, gl_FragCoord.z, texture2D(opaqueDepthTex, screenCoords).x); + gl_FragData[0] = applyDistortion(gl_FragData[0], distortionStrength, gl_FragCoord.z, sampleOpaqueDepthTex(screenCoords).x); return; #endif diff --git a/files/shaders/compatibility/bs/nolighting.frag b/files/shaders/compatibility/bs/nolighting.frag index c9e3ca4e13..da267d7858 100644 --- a/files/shaders/compatibility/bs/nolighting.frag +++ b/files/shaders/compatibility/bs/nolighting.frag @@ -35,7 +35,6 @@ uniform float alphaRef; #if @softParticles #include "lib/particle/soft.glsl" -uniform sampler2D opaqueDepthTex; uniform float particleSize; uniform bool particleFade; uniform float softFalloffDepth; @@ -70,7 +69,7 @@ void main() viewNormal, near, far, - texture2D(opaqueDepthTex, screenCoords).x, + sampleOpaqueDepthTex(screenCoords).x, particleSize, particleFade, softFalloffDepth diff --git a/files/shaders/compatibility/objects.frag b/files/shaders/compatibility/objects.frag index 8bd9664b41..999079a31d 100644 --- a/files/shaders/compatibility/objects.frag +++ b/files/shaders/compatibility/objects.frag @@ -113,8 +113,6 @@ uniform sampler2D orthoDepthMap; varying vec3 orthoDepthMapCoord; #endif -uniform sampler2D opaqueDepthTex; - void main() { #if @particleOcclusion @@ -143,7 +141,7 @@ vec2 screenCoords = gl_FragCoord.xy / screenRes; #if defined(DISTORTION) && DISTORTION gl_FragData[0].a *= getDiffuseColor().a; - gl_FragData[0] = applyDistortion(gl_FragData[0], distortionStrength, gl_FragCoord.z, texture2D(opaqueDepthTex, screenCoords / @distorionRTRatio).x); + gl_FragData[0] = applyDistortion(gl_FragData[0], distortionStrength, gl_FragCoord.z, sampleOpaqueDepthTex(screenCoords / @distorionRTRatio).x); return; #endif @@ -258,7 +256,7 @@ vec2 screenCoords = gl_FragCoord.xy / screenRes; viewNormal, near, far, - texture2D(opaqueDepthTex, screenCoords).x, + sampleOpaqueDepthTex(screenCoords).x, particleSize, particleFade, softFalloffDepth diff --git a/files/shaders/lib/core/fragment.glsl b/files/shaders/lib/core/fragment.glsl index 9b983148cb..d58e17feaf 100644 --- a/files/shaders/lib/core/fragment.glsl +++ b/files/shaders/lib/core/fragment.glsl @@ -40,3 +40,10 @@ vec3 sampleSkyColor(vec2 uv) return texture2D(sky, uv).xyz; } #endif + +uniform sampler2D opaqueDepthTex; + +vec4 sampleOpaqueDepthTex(vec2 uv) +{ + return texture2D(opaqueDepthTex, uv); +} diff --git a/files/shaders/lib/core/fragment.h.glsl b/files/shaders/lib/core/fragment.h.glsl index b8c3f9a32b..9b7ef768e6 100644 --- a/files/shaders/lib/core/fragment.h.glsl +++ b/files/shaders/lib/core/fragment.h.glsl @@ -17,4 +17,6 @@ vec4 samplerLastShader(vec2 uv); vec3 sampleSkyColor(vec2 uv); #endif +vec4 sampleOpaqueDepthTex(vec2 uv); + #endif // OPENMW_FRAGMENT_H_GLSL diff --git a/files/shaders/lib/core/fragment_multiview.glsl b/files/shaders/lib/core/fragment_multiview.glsl index 2880087104..767a3e04bd 100644 --- a/files/shaders/lib/core/fragment_multiview.glsl +++ b/files/shaders/lib/core/fragment_multiview.glsl @@ -2,6 +2,7 @@ #extension GL_OVR_multiview : require #extension GL_OVR_multiview2 : require +#extension GL_EXT_texture_array : require #include "lib/core/fragment.h.glsl" @@ -44,3 +45,10 @@ vec3 sampleSkyColor(vec2 uv) return texture(sky, vec3((uv), gl_ViewID_OVR)).xyz; } #endif + +uniform sampler2DArray opaqueDepthTex; + +vec4 sampleOpaqueDepthTex(vec2 uv) +{ + return texture2DArray(opaqueDepthTex, vec3((uv), gl_ViewID_OVR)); +}