Support sky blending in multiview mode

LTO-timing^2
Petr Mikheev 3 years ago
parent e70d2be1ee
commit b3c8c8eb56

@ -1,7 +1,8 @@
uniform float far; uniform float far;
#if @skyBlending #if @skyBlending
uniform sampler2D sky; #include "openmw_fragment.h.glsl"
uniform float skyBlendingStart; uniform float skyBlendingStart;
#endif #endif
@ -23,14 +24,13 @@ vec4 applyFogAtDist(vec4 color, float euclideanDist, float linearDist)
color.xyz = mix(color.xyz, gl_Fog.color.xyz, fogValue); color.xyz = mix(color.xyz, gl_Fog.color.xyz, fogValue);
#endif #endif
#if @skyBlending && !@useOVR_multiview #if @skyBlending
float fadeValue = clamp((far - dist) / (far - skyBlendingStart), 0.0, 1.0); float fadeValue = clamp((far - dist) / (far - skyBlendingStart), 0.0, 1.0);
fadeValue *= fadeValue; fadeValue *= fadeValue;
#ifdef ADDITIVE_BLENDING #ifdef ADDITIVE_BLENDING
color.xyz *= fadeValue; color.xyz *= fadeValue;
#else #else
vec3 skyColor = texture2D(sky, gl_FragCoord.xy / screenRes).xyz; color.xyz = mix(mw_sampleSkyColor(gl_FragCoord.xy / screenRes), color.xyz, fadeValue);
color.xyz = mix(skyColor, color.xyz, fadeValue);
#endif #endif
#endif #endif

@ -31,3 +31,12 @@ vec4 mw_samplerLastShader(vec2 uv)
{ {
return texture2D(omw_SamplerLastShader, uv); return texture2D(omw_SamplerLastShader, uv);
} }
#if @skyBlending
uniform sampler2D sky;
vec3 mw_sampleSkyColor(vec2 uv)
{
return texture2D(sky, uv).xyz;
}
#endif

@ -1,3 +1,6 @@
#ifndef OPENMW_FRAGMENT_H_GLSL
#define OPENMW_FRAGMENT_H_GLSL
@link "openmw_fragment.glsl" if !@useOVR_multiview @link "openmw_fragment.glsl" if !@useOVR_multiview
@link "openmw_fragment_multiview.glsl" if @useOVR_multiview @link "openmw_fragment_multiview.glsl" if @useOVR_multiview
@ -8,4 +11,10 @@ vec4 mw_sampleRefractionMap(vec2 uv);
float mw_sampleRefractionDepthMap(vec2 uv); float mw_sampleRefractionDepthMap(vec2 uv);
#endif #endif
vec4 mw_samplerLastShader(vec2 uv); vec4 mw_samplerLastShader(vec2 uv);
#if @skyBlending
vec3 mw_sampleSkyColor(vec2 uv);
#endif
#endif // OPENMW_FRAGMENT_H_GLSL

@ -35,4 +35,13 @@ uniform sampler2DArray omw_SamplerLastShader;
vec4 mw_samplerLastShader(vec2 uv) vec4 mw_samplerLastShader(vec2 uv)
{ {
return texture2DArray(omw_SamplerLastShader, vec3((uv), gl_ViewID_OVR)); return texture2DArray(omw_SamplerLastShader, vec3((uv), gl_ViewID_OVR));
} }
#if @skyBlending
uniform sampler2DArray sky;
vec3 mw_sampleSkyColor(vec2 uv)
{
return texture2DArray(sky, vec3((uv), gl_ViewID_OVR)).xyz;
}
#endif

Loading…
Cancel
Save