mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Fix multiview use in techniques
This commit is contained in:
parent
6071de9d1d
commit
a2f5e1c075
5 changed files with 22 additions and 9 deletions
|
@ -81,6 +81,7 @@ namespace fx
|
||||||
#define omw_Position @position
|
#define omw_Position @position
|
||||||
#define omw_Texture1D @texture1D
|
#define omw_Texture1D @texture1D
|
||||||
#define omw_Texture2D @texture2D
|
#define omw_Texture2D @texture2D
|
||||||
|
#define omw_Texture2DArray @texture2DArray
|
||||||
#define omw_Texture3D @texture3D
|
#define omw_Texture3D @texture3D
|
||||||
#define omw_Vertex @vertex
|
#define omw_Vertex @vertex
|
||||||
#define omw_FragColor @fragColor
|
#define omw_FragColor @fragColor
|
||||||
|
@ -154,7 +155,7 @@ mat4 omw_InvProjectionMatrix()
|
||||||
float omw_GetDepth(vec2 uv)
|
float omw_GetDepth(vec2 uv)
|
||||||
{
|
{
|
||||||
#if OMW_MULTIVIEW
|
#if OMW_MULTIVIEW
|
||||||
float depth = omw_Texture2D(omw_SamplerDepth, vec3(uv, gl_ViewID_OVR)).r;
|
float depth = omw_Texture2DArray(omw_SamplerDepth, vec3(uv, gl_ViewID_OVR)).r;
|
||||||
#else
|
#else
|
||||||
float depth = omw_Texture2D(omw_SamplerDepth, uv).r;
|
float depth = omw_Texture2D(omw_SamplerDepth, uv).r;
|
||||||
#endif
|
#endif
|
||||||
|
@ -165,10 +166,19 @@ mat4 omw_InvProjectionMatrix()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vec4 omw_GetDistortion(vec2 uv)
|
||||||
|
{
|
||||||
|
#if OMW_MULTIVIEW
|
||||||
|
return omw_Texture2DArray(omw_SamplerDistortion, vec3(uv, gl_ViewID_OVR));
|
||||||
|
#else
|
||||||
|
return omw_Texture2D(omw_SamplerDistortion, uv);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
vec4 omw_GetLastShader(vec2 uv)
|
vec4 omw_GetLastShader(vec2 uv)
|
||||||
{
|
{
|
||||||
#if OMW_MULTIVIEW
|
#if OMW_MULTIVIEW
|
||||||
return omw_Texture2D(omw_SamplerLastShader, vec3(uv, gl_ViewID_OVR));
|
return omw_Texture2DArray(omw_SamplerLastShader, vec3(uv, gl_ViewID_OVR));
|
||||||
#else
|
#else
|
||||||
return omw_Texture2D(omw_SamplerLastShader, uv);
|
return omw_Texture2D(omw_SamplerLastShader, uv);
|
||||||
#endif
|
#endif
|
||||||
|
@ -177,7 +187,7 @@ mat4 omw_InvProjectionMatrix()
|
||||||
vec4 omw_GetLastPass(vec2 uv)
|
vec4 omw_GetLastPass(vec2 uv)
|
||||||
{
|
{
|
||||||
#if OMW_MULTIVIEW
|
#if OMW_MULTIVIEW
|
||||||
return omw_Texture2D(omw_SamplerLastPass, vec3(uv, gl_ViewID_OVR));
|
return omw_Texture2DArray(omw_SamplerLastPass, vec3(uv, gl_ViewID_OVR));
|
||||||
#else
|
#else
|
||||||
return omw_Texture2D(omw_SamplerLastPass, uv);
|
return omw_Texture2D(omw_SamplerLastPass, uv);
|
||||||
#endif
|
#endif
|
||||||
|
@ -186,7 +196,7 @@ mat4 omw_InvProjectionMatrix()
|
||||||
vec3 omw_GetNormals(vec2 uv)
|
vec3 omw_GetNormals(vec2 uv)
|
||||||
{
|
{
|
||||||
#if OMW_MULTIVIEW
|
#if OMW_MULTIVIEW
|
||||||
return omw_Texture2D(omw_SamplerNormals, vec3(uv, gl_ViewID_OVR)).rgb * 2.0 - 1.0;
|
return omw_Texture2DArray(omw_SamplerNormals, vec3(uv, gl_ViewID_OVR)).rgb * 2.0 - 1.0;
|
||||||
#else
|
#else
|
||||||
return omw_Texture2D(omw_SamplerNormals, uv).rgb * 2.0 - 1.0;
|
return omw_Texture2D(omw_SamplerNormals, uv).rgb * 2.0 - 1.0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -275,6 +285,9 @@ float omw_EstimateFogCoverageFromUV(vec2 uv)
|
||||||
{ "@hdr", technique.getHDR() ? "1" : "0" }, { "@in", mLegacyGLSL ? "varying" : "in" },
|
{ "@hdr", technique.getHDR() ? "1" : "0" }, { "@in", mLegacyGLSL ? "varying" : "in" },
|
||||||
{ "@out", mLegacyGLSL ? "varying" : "out" }, { "@position", "gl_Position" },
|
{ "@out", mLegacyGLSL ? "varying" : "out" }, { "@position", "gl_Position" },
|
||||||
{ "@texture1D", mLegacyGLSL ? "texture1D" : "texture" },
|
{ "@texture1D", mLegacyGLSL ? "texture1D" : "texture" },
|
||||||
|
// Note, @texture2DArray must be defined before @texture2D since @texture2D is a perfect prefix of
|
||||||
|
// texture2DArray
|
||||||
|
{ "@texture2DArray", mLegacyGLSL ? "texture2DArray" : "texture" },
|
||||||
{ "@texture2D", mLegacyGLSL ? "texture2D" : "texture" },
|
{ "@texture2D", mLegacyGLSL ? "texture2D" : "texture" },
|
||||||
{ "@texture3D", mLegacyGLSL ? "texture3D" : "texture" },
|
{ "@texture3D", mLegacyGLSL ? "texture3D" : "texture" },
|
||||||
{ "@vertex", mLegacyGLSL ? "gl_Vertex" : "_omw_Vertex" },
|
{ "@vertex", mLegacyGLSL ? "gl_Vertex" : "_omw_Vertex" },
|
||||||
|
|
|
@ -85,7 +85,7 @@ namespace fx
|
||||||
mDescription = {};
|
mDescription = {};
|
||||||
mVersion = {};
|
mVersion = {};
|
||||||
mGLSLExtensions.clear();
|
mGLSLExtensions.clear();
|
||||||
mGLSLVersion = mUBO ? 330 : 120;
|
mGLSLVersion = (mUBO || Stereo::getMultiview()) ? 330 : 120;
|
||||||
mGLSLProfile.clear();
|
mGLSLProfile.clear();
|
||||||
mDynamic = false;
|
mDynamic = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,11 @@ fragment main {
|
||||||
{
|
{
|
||||||
const float multiplier = 0.14;
|
const float multiplier = 0.14;
|
||||||
|
|
||||||
vec2 offset = omw_Texture2D(omw_SamplerDistortion, omw_TexCoord).rg;
|
vec2 offset = omw_GetDistortion(omw_TexCoord).rg;
|
||||||
offset *= multiplier;
|
offset *= multiplier;
|
||||||
offset = clamp(offset, vec2(-1.0), vec2(1.0));
|
offset = clamp(offset, vec2(-1.0), vec2(1.0));
|
||||||
|
|
||||||
float occlusionFactor = omw_Texture2D(omw_SamplerDistortion, omw_TexCoord+offset).b;
|
float occlusionFactor = omw_GetDistortion(omw_TexCoord+offset).b;
|
||||||
|
|
||||||
omw_FragColor = mix(omw_GetLastShader(omw_TexCoord + offset), omw_GetLastShader(omw_TexCoord), occlusionFactor);
|
omw_FragColor = mix(omw_GetLastShader(omw_TexCoord + offset), omw_GetLastShader(omw_TexCoord), occlusionFactor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#version 120
|
#version 330
|
||||||
#extension GL_EXT_texture_array : require
|
#extension GL_EXT_texture_array : require
|
||||||
|
|
||||||
varying vec2 uv;
|
varying vec2 uv;
|
||||||
|
|
|
@ -50,5 +50,5 @@ uniform sampler2DArray opaqueDepthTex;
|
||||||
|
|
||||||
vec4 sampleOpaqueDepthTex(vec2 uv)
|
vec4 sampleOpaqueDepthTex(vec2 uv)
|
||||||
{
|
{
|
||||||
return texture2DArray(opaqueDepthTex, vec3((uv), gl_ViewID_OVR));
|
return texture(opaqueDepthTex, vec3((uv), gl_ViewID_OVR));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue