opaque depth texture must account for multiview

This commit is contained in:
Mads Buvik Sandvei 2025-01-26 14:57:34 +01:00
parent c16064e6f3
commit 2762be9f85
6 changed files with 21 additions and 9 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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);
}

View file

@ -17,4 +17,6 @@ vec4 samplerLastShader(vec2 uv);
vec3 sampleSkyColor(vec2 uv);
#endif
vec4 sampleOpaqueDepthTex(vec2 uv);
#endif // OPENMW_FRAGMENT_H_GLSL

View file

@ -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));
}