An OpenMW mod that lets you play the whole Elder Scrolls III: Morrowind as a top-down isometric game — with full online co-op or MMO modes.
C++
Isowind 114bfcf: Android: the port's final GL4ES shaders merged onto Isowind's, applied before its other patches
Isowindd424115e22a3
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 71c74d8..9a22336 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -85,7 +85,8 @@ set(OPENMW_VERSION_RELEASE 0)set(OPENMW_LUA_API_REVISION 129)set(OPENMW_POSTPROCESSING_API_REVISION 5)-# Isowind: builds from an exported source tree (no .git, e.g. Android) pass its git tree hash as ISOWIND_SOURCE_HASH+# Isowind: builds from an exported source tree (no .git, e.g. Android) pass the engine source hash as ISOWIND_SOURCE_HASH+# (see cmake/GitVersion.cmake)set(OPENMW_VERSION_COMMITHASH "${ISOWIND_SOURCE_HASH}")set(OPENMW_VERSION_TAGHASH "")set(OPENMW_VERSION_COMMITDATE "")diff --git a/android/app/build.gradle b/android/app/build.gradleindex 402e8da..3c6839b 100644--- a/android/app/build.gradle+++ b/android/app/build.gradle@@ -767,6 +767,17 @@ android {jvmTarget = '17'}+ // Isowind: every build signed with the same debug key (app/isowind-debug.keystore), so a new APK installs over+ // the last one and keeps the player's data; the key Gradle makes on each fresh CI runner would need an uninstall+ signingConfigs {+ debug {+ storeFile file('isowind-debug.keystore')+ storePassword 'android'+ keyAlias 'androiddebugkey'+ keyPassword 'android'+ }+ }+buildTypes {release {minifyEnabled falsediff --git a/android/app/isowind-debug.keystore b/android/app/isowind-debug.keystorenew file mode 100644index 0000000..c20c0e1Binary files /dev/null and b/android/app/isowind-debug.keystore differdiff --git a/android/buildscripts/CMakeLists.txt b/android/buildscripts/CMakeLists.txtindex e274cba..3915817 100644--- a/android/buildscripts/CMakeLists.txt+++ b/android/buildscripts/CMakeLists.txt@@ -600,7 +600,10 @@ set(OPENMW_COMMON-DSDL2_DIR=${prefix}/lib/cmake/SDL2)+# Isowind: first, the Android port's final shaders (its GL4ES fog, normal and shadow fixes, from its 0.51.0-11+# release) merged onto Isowind's: the scripts below then find their shader markers present and leave them alone.set(OPENMW_PATCH+ patch -d <SOURCE_DIR>/files/shaders -p1 -t -N < ${CMAKE_SOURCE_DIR}/patches/isowind/android-shaders.patch &&patch -d <SOURCE_DIR> -p1 -t -N < ${CMAKE_SOURCE_DIR}/patches/openmw051-final/0001-ndk-r26-stringstream-compat.patch &&patch -d <SOURCE_DIR> -p1 -t -N < ${CMAKE_SOURCE_DIR}/patches/openmw051-final/0002-static-osg-link.patch &&python3 ${CMAKE_SOURCE_DIR}/patches/openmw051-final/apply-ndk-r26-format.py <SOURCE_DIR> &&@@ -633,9 +636,12 @@ set(CRABNET_SOURCE_DIR ${SOURCE_DIR})set(CRABNET_BINARY_DIR ${BINARY_DIR})# Isowind: the engine is this repository (two levels up), exported clean so the build folder isn't copied into itself,-# with its git tree hash as the version (multiplayer only lets the same version play together)-execute_process(COMMAND git -C ${CMAKE_SOURCE_DIR}/../.. rev-parse HEAD^{tree}- OUTPUT_VARIABLE ISOWIND_SOURCE_HASH OUTPUT_STRIP_TRAILING_WHITESPACE)+# with the engine source's hash as the version, as cmake/GitVersion.cmake computes it (multiplayer only lets the same+# version play together)+execute_process(COMMAND git -C ${CMAKE_SOURCE_DIR}/../.. rev-parse HEAD:apps HEAD:components HEAD:files HEAD:extern+ HEAD:cmake HEAD:CMakeLists.txt+ OUTPUT_VARIABLE ISOWIND_ENGINE_TREES OUTPUT_STRIP_TRAILING_WHITESPACE)+string(SHA1 ISOWIND_SOURCE_HASH "${ISOWIND_ENGINE_TREES}")ExternalProject_Add(openmwDEPENDS boost openal osg mygui ffmpeg sdl2 bullet lz4 luajit libicu crabnetdiff --git a/android/buildscripts/patches/isowind/android-shaders.patch b/android/buildscripts/patches/isowind/android-shaders.patchnew file mode 100644index 0000000..6ad9a3f--- /dev/null+++ b/android/buildscripts/patches/isowind/android-shaders.patch@@ -0,0 +1,681 @@+--- a/compatibility/bs/default.frag++++ b/compatibility/bs/default.frag+@@ -72,7 +72,6 @@+ if (!useTreeAnim)+ gl_FragData[0].a *= diffuseColor.a;+ gl_FragData[0].a = alphaTest(gl_FragData[0].a, alphaRef);+-+ vec3 specularColor = getSpecularColor().xyz;+ #if @normalMap+ vec4 normalTex = texture2D(normalMap, normalMapUV);+@@ -83,7 +82,7 @@+ vec3 viewNormal = normalToView(normal);+ specularColor *= normalTex.a;+ #else+- vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);++ vec3 viewNormal = normalToView(normalize(passNormal));+ #endif++ float shadowing = unshadowedLightRatio(linearDepth);+--- a/compatibility/bs/default.vert++++ b/compatibility/bs/default.vert+@@ -69,7 +69,7 @@+++ #if @shadows_enabled+- vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);++ vec3 viewNormal = normalToView(passNormal);+ setupShadowCoords(viewPos, viewNormal);+ #endif+ }+--- a/compatibility/bs/nolighting.frag++++ b/compatibility/bs/nolighting.frag+@@ -56,7 +56,6 @@+ gl_FragData[0].a *= passFalloff;++ gl_FragData[0].a = alphaTest(gl_FragData[0].a, alphaRef);+-+ gl_FragData[0] = applyFogAtDist(gl_FragData[0], euclideanDepth, linearDepth, far);++ #if !defined(FORCE_OPAQUE) && @softParticles+--- a/compatibility/bs/nolighting.vert++++ b/compatibility/bs/nolighting.vert+@@ -63,7 +63,7 @@+ }++ #if @shadows_enabled+- vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);++ vec3 viewNormal = normalize((gl_NormalMatrix * gl_Normal).xyz);+ setupShadowCoords(viewPos, viewNormal);+ #endif+ }+--- a/compatibility/debug.frag++++ b/compatibility/debug.frag+@@ -4,7 +4,7 @@++ varying vec3 vertexNormal;++-uniform bool useAdvancedShader = false;++uniform bool useAdvancedShader;++ void main()+ {+--- a/compatibility/debug.vert++++ b/compatibility/debug.vert+@@ -6,7 +6,7 @@+ uniform vec3 trans;+ uniform vec3 scale;+ uniform bool useNormalAsColor;+-uniform bool useAdvancedShader = false;++uniform bool useAdvancedShader;++ centroid varying vec4 passColor;+ varying vec3 vertexNormal;+--- a/compatibility/fog.glsl++++ b/compatibility/fog.glsl+@@ -1,3 +1,19 @@++// OPENMW_ANDROID_051_GL4ES_EXPLICIT_OBJECT_FOG++#ifdef OPENMW_ANDROID_051_GL4ES_EXPLICIT_OBJECT_FOG++uniform vec4 omwFogColor;++uniform float omwFogStart;++uniform float omwFogEnd;++#define OPENMW_FOG_START omwFogStart++#define OPENMW_FOG_END omwFogEnd++#define OPENMW_FOG_SCALE (1.0 / max(omwFogEnd - omwFogStart, 0.0001))++#define OPENMW_FOG_COLOR omwFogColor++#else++#define OPENMW_FOG_START gl_Fog.start++#define OPENMW_FOG_END gl_Fog.end++#define OPENMW_FOG_SCALE gl_Fog.scale++#define OPENMW_FOG_COLOR gl_Fog.color++#endif+++ #if @skyBlending+ #include "lib/core/fragment.h.glsl"++@@ -12,14 +28,14 @@+ float dist = abs(linearDist);+ #endif+ #if @exponentialFog+- float fogValue = 1.0 - exp(-2.0 * max(0.0, dist - gl_Fog.start/2.0) / (gl_Fog.end - gl_Fog.start/2.0));++ float fogValue = 1.0 - exp(-2.0 * max(0.0, dist - OPENMW_FOG_START/2.0) / (OPENMW_FOG_END - OPENMW_FOG_START/2.0));+ #else+- float fogValue = clamp((dist - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);++ float fogValue = clamp((dist - OPENMW_FOG_START) * OPENMW_FOG_SCALE, 0.0, 1.0);+ #endif+ #ifdef ADDITIVE_BLENDING+ color.xyz *= 1.0 - fogValue;+ #else+- color.xyz = mix(color.xyz, gl_Fog.color.xyz, fogValue);++ color.xyz = mix(color.xyz, OPENMW_FOG_COLOR.xyz, fogValue);+ #endif++ #if @skyBlending+--- a/compatibility/fullscreen_tri.vert++++ b/compatibility/fullscreen_tri.vert+@@ -1,6 +1,6 @@+ #version 120++-uniform vec2 scaling = vec2(1.0, 1.0);++uniform vec2 scaling;++ varying vec2 uv;++--- a/compatibility/groundcover.frag++++ b/compatibility/groundcover.frag+@@ -57,7 +57,6 @@+ gl_FragData[0].a *= 1.0-smoothstep(@groundcoverFadeStart, @groundcoverFadeEnd, euclideanDepth);++ gl_FragData[0].a = alphaTest(gl_FragData[0].a, alphaRef);+-+ #if @normalMap+ vec4 normalTex = texture2D(normalMap, normalMapUV);+ vec3 normal = normalTex.xyz * 2.0 - 1.0;+--- a/compatibility/groundcover.vert++++ b/compatibility/groundcover.vert+@@ -156,7 +156,7 @@+ #endif++ #if (!PER_PIXEL_LIGHTING || @shadows_enabled)+- vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);++ vec3 viewNormal = normalToView(passNormal);+ #endif++ #if @diffuseMap+--- a/compatibility/objects.frag++++ b/compatibility/objects.frag+@@ -85,9 +85,11 @@+ varying vec4 passTangent;+ #endif++-#if @additiveBlending+-#define ADDITIVE_BLENDING+-#endif++// OPENMW_ANDROID_051_GL4ES_DISABLE_ADDITIVE_FOG++// Android/GL4ES compatibility: OpenMW's additive fog branch fades RGB toward++// black instead of the scene fog colour. The stable 0.50 Android GL4ES patch++// deliberately did not define ADDITIVE_BLENDING for compatibility/objects.frag.++// Keep the same compatibility behaviour while diagnosing 0.51 forced shaders.++ #include "lib/core/fragment.h.glsl"+ #include "lib/light/lighting.glsl"+@@ -96,6 +98,9 @@+ #include "lib/util/distortion.glsl"+ #include "lib/util/cutaway.glsl"+++// Android/GL4ES Patch 7: use authoritative OpenMW fog uniforms instead of++// compatibility gl_Fog built-ins for ordinary NIF/object shaders only.++#define OPENMW_ANDROID_051_GL4ES_EXPLICIT_OBJECT_FOG+ #include "fog.glsl"+ #include "vertexcolors.glsl"+ #include "shadows_fragment.glsl"+@@ -164,7 +169,6 @@+ #endif++ gl_FragData[0].a = alphaTest(gl_FragData[0].a, alphaRef);+-+ #if @normalMap+ vec4 normalTex = texture2D(normalMap, normalMapUV + offset);+ vec3 normal = normalTex.xyz * 2.0 - 1.0;+@@ -173,7 +177,7 @@+ #endif+ vec3 viewNormal = normalToView(normal);+ #else+- vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);++ vec3 viewNormal = normalToView(normalize(passNormal));+ #endif++ vec3 viewVec = normalize(passViewPos);+@@ -248,7 +252,14 @@+ gl_FragData[0].xyz += texture2D(emissiveMap, emissiveMapUV).xyz;+ #endif++- gl_FragData[0] = applyFogAtPos(gl_FragData[0], passViewPos, far);++ // OPENMW_ANDROID_051_LOCALMAP_OBJECT_FOG_BYPASS_V1++ // LocalMapRenderToTexture sets screenRes=(1,1) and disables fog through++ // its own osg/gl_Fog state. The Android/GL4ES ordinary-object path uses++ // explicit omwFog* world-camera uniforms instead, so applying that fog to++ // the orthographic LocalMap RTT washes Object/Static textures into the++ // current world fog colour. Keep explicit fog everywhere except LocalMap.++ if (screenRes.x > 1.5 || screenRes.y > 1.5)++ gl_FragData[0] = applyFogAtPos(gl_FragData[0], passViewPos, far);+ gl_FragData[0].xyz = applyCutawaySilhouette(gl_FragData[0].xyz, cutawaySilhouette);+ // Faded by the top-down cutaway: OcclusionFader blends such objects+ gl_FragData[0].a *= cutawayAlpha;+--- a/compatibility/objects.vert++++ b/compatibility/objects.vert+@@ -101,7 +101,7 @@+ #endif++ #if @envMap || !PER_PIXEL_LIGHTING || @shadows_enabled+- vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);++ vec3 viewNormal = normalToView(passNormal);+ #endif++ #if @envMap+--- a/compatibility/shadowcasting.vert++++ b/compatibility/shadowcasting.vert+@@ -6,13 +6,19 @@++ uniform int colorMode;+ uniform bool useTreeAnim;+-uniform bool useDiffuseMapForShadowAlpha = true;+-uniform bool alphaTestShadows = true;++uniform bool useDiffuseMapForShadowAlpha;++uniform bool alphaTestShadows;++ void main(void)+ {+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;+++ // OPENMW_ANDROID_051_GLES2_NATIVE_SHADOW_CLIPPING++ // GL_DEPTH_CLAMP/ARB_clip_control are unavailable through the GLES2 backend.++ // Deliberately use normal GLES2 near/far clipping here. Per-vertex Z++ // clamping can collapse off-volume caster vertices onto a clip plane and++ // produce large view-dependent triangular shadow projections.+++ vec4 viewPos = (gl_ModelViewMatrix * gl_Vertex);+ gl_ClipVertex = viewPos;++--- a/compatibility/shadows_fragment.glsl++++ b/compatibility/shadows_fragment.glsl+@@ -1,11 +1,31 @@+ #define SHADOWS @shadows_enabled+++// OPENMW_ANDROID_051_GRAZING_SHADOW_FIX_V3++// OPENMW_ANDROID_051_GRAZING_SHADOW_FIX_V6++// V3 remains the primary plane. Geometry supplies a conditioned, one-sided++// correction measured at each sampled texel, with a bounded depth budget.++//++// OPENMW_ANDROID_051_GLES2_MANUAL_SHADOW_COMPARE++// GLES2/GL4ES: sample OES depth textures through sampler2D and perform++// the LEQUAL test explicitly; EXT_shadow_samplers is not available.++//++// OPENMW_ANDROID_051_GLES2_QUALITY_PCF++// The launcher specializes these two compile-time constants before each game++// start. Keeping the kernel compile-time avoids dynamic loops/branches on GLES2.++// Level 0 = legacy 1 tap, level 1 = 2x2 / 4 taps (Low),++// level 2 = 3x3 / 9 taps (Medium), level 3 = 4x4 / 16 taps (High).++// Level 4 = continuously weighted cubic 4x4 / 16 taps (Very High).++#define OPENMW_ANDROID_SHADOW_PCF_LEVEL 2++#define OPENMW_ANDROID_SHADOW_MAP_RESOLUTION 4096.0+++ #if SHADOWS+ uniform float maximumShadowMapDistance;+ uniform float shadowFadeStart;+ @foreach shadow_texture_unit_index @shadow_texture_unit_list+- uniform sampler2DShadow shadowTexture@shadow_texture_unit_index;++ uniform sampler2D shadowTexture@shadow_texture_unit_index;+ varying vec4 shadowSpaceCoords@shadow_texture_unit_index;++ // OPENMW_ANDROID_051_GRAZING_SHADOW_FIX_V1++ varying vec2 shadowReceiverPlaneSlope@shadow_texture_unit_index;++ #if @perspectiveShadowMaps+ varying vec4 shadowRegionCoords@shadow_texture_unit_index;+@@ -13,10 +33,75 @@+ @endforeach+ #endif // SHADOWS+++float openmwAndroidReceiverDepthForOffset(float centerDepth, vec2 receiverPlaneSlope, vec2 texelSize, vec2 texelOffset)++{++ // OPENMW_ANDROID_051_GRAZING_SHADOW_FIX_V1++ // Receiver-plane depth bias (RPDB): neighbouring PCF taps must compare++ // against the depth of the same geometric plane at the neighbouring UV,++ // not against the centre fragment depth. This is the key fix for long++ // shadow-acne bands and terrain-triangle artifacts at grazing sun angles.++ return clamp(centerDepth + dot(receiverPlaneSlope, texelSize * texelOffset), 0.0, 1.0);++}++++vec2 openmwAndroidGeometricReceiverPlaneSlopeV6(vec3 shadowXYZ, vec2 stableSlope)++{++ // Evaluate before distance/cascade branches. Normalize each derivative by++ // its largest UV component before solving: an absolute determinant cutoff++ // wrongly rejects valid small triangles and distant receivers.++ vec3 dx = dFdx(shadowXYZ);++ vec3 dy = dFdy(shadowXYZ);++ float scaleX = max(abs(dx.x), abs(dx.y));++ float scaleY = max(abs(dy.x), abs(dy.y));++ dx /= max(scaleX, 1e-20);++ dy /= max(scaleY, 1e-20);++ float determinant = dx.x * dy.y - dy.x * dx.y;++ float conditioning = abs(determinant) / max(length(dx.xy) * length(dy.xy), 1e-10);++ if (scaleX < 1e-20 || scaleY < 1e-20 || conditioning <= 0.0001)++ return stableSlope;++++ vec2 slope = vec2(dx.z * dy.y - dy.z * dx.y,++ dy.z * dx.x - dx.z * dy.x) / determinant;++ // Ease back to the interpolated plane near a singular light projection,++ // instead of switching abruptly between unrelated slopes at the horizon.++ float reliability = smoothstep(0.0001, 0.01, conditioning);++ return mix(stableSlope, clamp(slope, vec2(-128.0), vec2(128.0)), reliability);++}++++float openmwAndroidConservativeReceiverDepthV6(++ float centerDepth,++ vec2 stableSlope,++ vec2 geometricSlope,++ vec2 texelSize,++ vec2 totalTexelOffset)++{++ // Smoothed rock normals are not the rasterized triangle plane. The V5++ // fixed 0.00010 relief left a depth error at grazing angles, particularly++ // at the outer PCF taps. Correct the actual signed error at this texel.++ // Never raise the V3 comparison depth (the dark-facet regression in V4).++ float stableDepth = openmwAndroidReceiverDepthForOffset(++ centerDepth, stableSlope, texelSize, totalTexelOffset);++ float geometricDepth = openmwAndroidReceiverDepthForOffset(++ centerDepth, geometricSlope, texelSize, totalTexelOffset);++ // Same maximum normalized-depth scale as the existing slope bias. The++ // correction is zero when the planes agree; it is not a global offset or++ // a sun-angle fade of real cast shadows. Singular projections use V3.++ float oneSidedRelief = clamp(stableDepth - geometricDepth, 0.0, 0.0030);++ return max(stableDepth - oneSidedRelief, 0.0);++}+++ float unshadowedLightRatio(float distance)+ {+ float shadowing = 1.0;+ #if SHADOWS++ // All derivative evaluations precede even the fade early-return and the++ // cascade-selection branch, so neighbouring fragments share control flow.++ @foreach shadow_texture_unit_index @shadow_texture_unit_list++ float receiverW@shadow_texture_unit_index = shadowSpaceCoords@shadow_texture_unit_index.w;++ vec3 receiverXYZ@shadow_texture_unit_index = shadowSpaceCoords@shadow_texture_unit_index.xyz /++ (abs(receiverW@shadow_texture_unit_index) > 1e-6 ? receiverW@shadow_texture_unit_index : 1e-6);++ vec2 receiverGeometry@shadow_texture_unit_index = openmwAndroidGeometricReceiverPlaneSlopeV6(++ receiverXYZ@shadow_texture_unit_index, shadowReceiverPlaneSlope@shadow_texture_unit_index);++ @endforeach+ #if @limitShadowMapDistance+ float fade = clamp((distance - shadowFadeStart) / (maximumShadowMapDistance - shadowFadeStart), 0.0, 1.0);+ if (fade == 1.0)+@@ -26,13 +111,164 @@+ @foreach shadow_texture_unit_index @shadow_texture_unit_list+ if (!doneShadows)+ {+- vec3 shadowXYZ = shadowSpaceCoords@shadow_texture_unit_index.xyz / shadowSpaceCoords@shadow_texture_unit_index.w;++ vec3 shadowXYZ = receiverXYZ@shadow_texture_unit_index;++ vec2 stableReceiverPlaneSlope = shadowReceiverPlaneSlope@shadow_texture_unit_index;++ vec2 geometricReceiverPlaneSlope = receiverGeometry@shadow_texture_unit_index;+ #if @perspectiveShadowMaps+ vec3 shadowRegionXYZ = shadowRegionCoords@shadow_texture_unit_index.xyz / shadowRegionCoords@shadow_texture_unit_index.w;+ #endif+ if (all(lessThan(shadowXYZ.xy, vec2(1.0, 1.0))) && all(greaterThan(shadowXYZ.xy, vec2(0.0, 0.0))))+ {+- shadowing = min(shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r, shadowing);++ // OPENMW_ANDROID_051_GLES2_SHADOW_COORD_BOUNDS++ // Raw GLES2 depth sampling must never compare receivers outside++ // the valid projected shadow depth volume. Otherwise z > 1 can++ // become a view-dependent full-shadow patch with CLAMP_TO_EDGE.++ if (shadowSpaceCoords@shadow_texture_unit_index.w > 0.0 && shadowXYZ.z > 0.0 && shadowXYZ.z < 1.0)++ {++ vec2 shadowTexel = vec2(1.0 / OPENMW_ANDROID_SHADOW_MAP_RESOLUTION);++ // OPENMW_ANDROID_051_GLES2_RECEIVER_DEPTH_BIAS++ // Retain the proven tiny fixed safety bias, then add only a++ // tightly capped slope-scaled residual for the centre sample.++ // Most grazing-angle correction happens per PCF tap through++ // receiver-plane depth reconstruction below, so this does not++ // require the large global offsets that cause Peter Panning.++ float receiverDepth = max(shadowXYZ.z - 0.00005, 0.0);++ vec2 receiverPlaneSlope = stableReceiverPlaneSlope;++ // OPENMW_ANDROID_051_GRAZING_SHADOW_FIX_V3++ // OPENMW_ANDROID_051_GRAZING_SHADOW_FIX_V6++ // Bounded residual after exact texel-centre reconstruction.++ float receiverSlopeFootprint =++ (abs(receiverPlaneSlope.x) + abs(receiverPlaneSlope.y)) * shadowTexel.x;++ float receiverSlopeBias = min(receiverSlopeFootprint * 0.35, 0.0030);++ receiverDepth = max(receiverDepth - receiverSlopeBias, 0.0);++#if OPENMW_ANDROID_SHADOW_PCF_LEVEL == 0++ // OPENMW_ANDROID_051_GRAZING_SHADOW_FIX_V3++ vec2 shadowUv = (floor(shadowXYZ.xy * OPENMW_ANDROID_SHADOW_MAP_RESOLUTION) + vec2(0.5)) * shadowTexel;++ shadowUv = clamp(shadowUv, shadowTexel, vec2(1.0) - shadowTexel);++ vec2 anchorOffset = (shadowUv - shadowXYZ.xy) / shadowTexel;++ float anchorReceiverDepth = openmwAndroidConservativeReceiverDepthV6(++ receiverDepth,++ receiverPlaneSlope,++ geometricReceiverPlaneSlope,++ shadowTexel,++ anchorOffset);++ shadowing = min(step(anchorReceiverDepth, texture2D(shadowTexture@shadow_texture_unit_index, shadowUv).r), shadowing);++#elif OPENMW_ANDROID_SHADOW_PCF_LEVEL == 1++ // Low: anchor half-texel taps on a real texel boundary so++ // all four lookups land at actual texel centres.++ vec2 shadowUv = floor(++ shadowXYZ.xy * OPENMW_ANDROID_SHADOW_MAP_RESOLUTION + vec2(0.5)) * shadowTexel;++ shadowUv = clamp(shadowUv, shadowTexel, vec2(1.0) - shadowTexel);++ vec2 anchorOffset = (shadowUv - shadowXYZ.xy) / shadowTexel;++ float anchorReceiverDepth = openmwAndroidConservativeReceiverDepthV6(++ receiverDepth,++ receiverPlaneSlope,++ geometricReceiverPlaneSlope,++ shadowTexel,++ anchorOffset);++ float pcfShadow = 0.0;++ pcfShadow += step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-0.5, -0.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-0.5, -0.5)).r);++ pcfShadow += step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2( 0.5, -0.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2( 0.5, -0.5)).r);++ pcfShadow += step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-0.5, 0.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-0.5, 0.5)).r);++ pcfShadow += step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2( 0.5, 0.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2( 0.5, 0.5)).r);++ shadowing = min(pcfShadow * 0.25, shadowing);++#elif OPENMW_ANDROID_SHADOW_PCF_LEVEL == 2++ // Medium: snap the integer 3x3 kernel to the containing++ // shadow texel centre and reconstruct depth from the original UV.++ vec2 shadowUv = (floor(shadowXYZ.xy * OPENMW_ANDROID_SHADOW_MAP_RESOLUTION) + vec2(0.5)) * shadowTexel;++ shadowUv = clamp(shadowUv, shadowTexel, vec2(1.0) - shadowTexel);++ vec2 anchorOffset = (shadowUv - shadowXYZ.xy) / shadowTexel;++ float anchorReceiverDepth = openmwAndroidConservativeReceiverDepthV6(++ receiverDepth,++ receiverPlaneSlope,++ geometricReceiverPlaneSlope,++ shadowTexel,++ anchorOffset);++ float pcfShadow = 0.0;++ pcfShadow += step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-1.0, -1.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-1.0, -1.0)).r);++ pcfShadow += step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2( 0.0, -1.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2( 0.0, -1.0)).r);++ pcfShadow += step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2( 1.0, -1.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2( 1.0, -1.0)).r);++ pcfShadow += step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-1.0, 0.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-1.0, 0.0)).r);++ pcfShadow += step(anchorReceiverDepth, texture2D(shadowTexture@shadow_texture_unit_index, shadowUv).r);++ pcfShadow += step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2( 1.0, 0.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2( 1.0, 0.0)).r);++ pcfShadow += step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-1.0, 1.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-1.0, 1.0)).r);++ pcfShadow += step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2( 0.0, 1.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2( 0.0, 1.0)).r);++ pcfShadow += step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2( 1.0, 1.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2( 1.0, 1.0)).r);++ shadowing = min(pcfShadow * (1.0 / 9.0), shadowing);++#elif OPENMW_ANDROID_SHADOW_PCF_LEVEL == 3++ // High: weighted 4x4 tent PCF at 4096.++ // OPENMW_ANDROID_051_GLES2_TENT_PCF++ // OPENMW_ANDROID_051_GRAZING_SHADOW_FIX_V3++ // Anchor +/-0.5 and +/-1.5 samples on the nearest real++ // texel boundary; all sixteen taps then hit distinct centres.++ vec2 shadowMargin = shadowTexel * 2.0;++ vec2 shadowUv = floor(++ shadowXYZ.xy * OPENMW_ANDROID_SHADOW_MAP_RESOLUTION + vec2(0.5)) * shadowTexel;++ shadowUv = clamp(shadowUv, shadowMargin, vec2(1.0) - shadowMargin);++ vec2 anchorOffset = (shadowUv - shadowXYZ.xy) / shadowTexel;++ float anchorReceiverDepth = openmwAndroidConservativeReceiverDepthV6(++ receiverDepth,++ receiverPlaneSlope,++ geometricReceiverPlaneSlope,++ shadowTexel,++ anchorOffset);++ float pcfShadow = 0.0;++ pcfShadow += 1.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-1.5, -1.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-1.5, -1.5)).r);++ pcfShadow += 3.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-0.5, -1.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-0.5, -1.5)).r);++ pcfShadow += 3.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2( 0.5, -1.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2( 0.5, -1.5)).r);++ pcfShadow += 1.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2( 1.5, -1.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2( 1.5, -1.5)).r);++ pcfShadow += 3.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-1.5, -0.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-1.5, -0.5)).r);++ pcfShadow += 9.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-0.5, -0.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-0.5, -0.5)).r);++ pcfShadow += 9.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2( 0.5, -0.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2( 0.5, -0.5)).r);++ pcfShadow += 3.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2( 1.5, -0.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2( 1.5, -0.5)).r);++ pcfShadow += 3.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-1.5, 0.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-1.5, 0.5)).r);++ pcfShadow += 9.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-0.5, 0.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-0.5, 0.5)).r);++ pcfShadow += 9.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2( 0.5, 0.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2( 0.5, 0.5)).r);++ pcfShadow += 3.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2( 1.5, 0.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2( 1.5, 0.5)).r);++ pcfShadow += 1.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-1.5, 1.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-1.5, 1.5)).r);++ pcfShadow += 3.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-0.5, 1.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-0.5, 1.5)).r);++ pcfShadow += 3.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2( 0.5, 1.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2( 0.5, 1.5)).r);++ pcfShadow += 1.0 * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2( 1.5, 1.5)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2( 1.5, 1.5)).r);++ shadowing = min(pcfShadow * (1.0 / 64.0), shadowing);++#else++ // OPENMW_ANDROID_051_CONTINUOUS_TENT_PCF_V1++ // OPENMW_ANDROID_051_CUBIC_PCF_16_V3++ // Cubic B-spline reconstruction has continuous coverage++ // AND continuous first derivatives across texel boundaries.++ // 16 samples, like High; no 36-tap outer skirt or contrast++ // sharpening. Keep each axis normalized to 9 for the++ // existing runtime validation contract (2D divisor 81).++ vec2 grid = clamp(shadowXYZ.xy * OPENMW_ANDROID_SHADOW_MAP_RESOLUTION - vec2(0.5),++ vec2(1.0), vec2(OPENMW_ANDROID_SHADOW_MAP_RESOLUTION - 3.0));++ vec2 cell = floor(grid);++ vec2 f = grid - cell;++ vec2 g = vec2(1.0) - f;++ vec2 w0 = g * g * g * 1.5;++ vec2 w1 = (3.0 * f * f * f - 6.0 * f * f + vec2(4.0)) * 1.5;++ vec2 w2 = (-3.0 * f * f * f + 3.0 * f * f + 3.0 * f + vec2(1.0)) * 1.5;++ vec2 w3 = f * f * f * 1.5;++ vec2 shadowUv = (cell + vec2(0.5)) * shadowTexel;++ vec2 anchorOffset = (shadowUv - shadowXYZ.xy) / shadowTexel;++ float pcfShadow = 0.0;++ pcfShadow += w0.x * w0.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-1.0, -1.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-1.0, -1.0)).r);++ pcfShadow += w1.x * w0.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(0.0, -1.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(0.0, -1.0)).r);++ pcfShadow += w2.x * w0.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(1.0, -1.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(1.0, -1.0)).r);++ pcfShadow += w3.x * w0.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(2.0, -1.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(2.0, -1.0)).r);++ pcfShadow += w0.x * w1.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-1.0, 0.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-1.0, 0.0)).r);++ pcfShadow += w1.x * w1.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(0.0, 0.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(0.0, 0.0)).r);++ pcfShadow += w2.x * w1.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(1.0, 0.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(1.0, 0.0)).r);++ pcfShadow += w3.x * w1.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(2.0, 0.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(2.0, 0.0)).r);++ pcfShadow += w0.x * w2.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-1.0, 1.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-1.0, 1.0)).r);++ pcfShadow += w1.x * w2.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(0.0, 1.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(0.0, 1.0)).r);++ pcfShadow += w2.x * w2.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(1.0, 1.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(1.0, 1.0)).r);++ pcfShadow += w3.x * w2.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(2.0, 1.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(2.0, 1.0)).r);++ pcfShadow += w0.x * w3.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(-1.0, 2.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(-1.0, 2.0)).r);++ pcfShadow += w1.x * w3.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(0.0, 2.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(0.0, 2.0)).r);++ pcfShadow += w2.x * w3.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(1.0, 2.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(1.0, 2.0)).r);++ pcfShadow += w3.x * w3.y * step(openmwAndroidConservativeReceiverDepthV6(receiverDepth, receiverPlaneSlope, geometricReceiverPlaneSlope, shadowTexel, anchorOffset + vec2(2.0, 2.0)), texture2D(shadowTexture@shadow_texture_unit_index, shadowUv + shadowTexel * vec2(2.0, 2.0)).r);++ shadowing = min(pcfShadow * (1.0 / 81.0), shadowing);++#endif++ }++ doneShadows = all(lessThan(shadowXYZ, vec3(0.95, 0.95, 1.0))) && all(greaterThan(shadowXYZ, vec3(0.05, 0.05, 0.0)));+ #if @perspectiveShadowMaps+--- a/compatibility/shadows_vertex.glsl++++ b/compatibility/shadows_vertex.glsl+@@ -4,6 +4,13 @@+ @foreach shadow_texture_unit_index @shadow_texture_unit_list+ uniform mat4 shadowSpaceMatrix@shadow_texture_unit_index;+ varying vec4 shadowSpaceCoords@shadow_texture_unit_index;++ // OPENMW_ANDROID_051_GRAZING_SHADOW_FIX_V1++ // OPENMW_ANDROID_051_GRAZING_SHADOW_FIX_V3++ // Local receiver-plane depth slope in normalized shadow UV coordinates.++ // The fragment shader uses this to move each PCF comparison onto the++ // expected depth of the same receiver plane instead of comparing every++ // neighbour against the centre depth.++ varying vec2 shadowReceiverPlaneSlope@shadow_texture_unit_index;++ #if @perspectiveShadowMaps+ uniform mat4 validRegionMatrix@shadow_texture_unit_index;+@@ -15,6 +22,55 @@+ const bool onlyNormalOffsetUV = false;+ #endif // SHADOWS+++#if SHADOWS++vec2 openmwAndroidReceiverPlaneSlope(mat4 shadowMatrix, vec4 shadowCoord, vec3 viewNormal)++{++ // OPENMW_ANDROID_051_GRAZING_SHADOW_FIX_V1++ // Derivative-free receiver-plane depth bias for GLES2/GL4ES.++ // Build two tangents on the receiver plane, project them into shadow++ // coordinates and solve dz/du,dz/dv. This remains valid for the Android++ // orthographic sun map and also handles homogeneous W conservatively.++ float normalLength2 = dot(viewNormal, viewNormal);++ if (normalLength2 < 1e-10 || abs(shadowCoord.w) < 1e-6)++ return vec2(0.0);++++ vec3 n = viewNormal * inversesqrt(normalLength2);++ vec3 helperAxis = abs(n.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(0.0, 1.0, 0.0);++ vec3 tangentA = normalize(cross(helperAxis, n));++ vec3 tangentB = cross(n, tangentA);++++ vec4 projectedA = shadowMatrix * vec4(tangentA, 0.0);++ vec4 projectedB = shadowMatrix * vec4(tangentB, 0.0);++++ float invW = 1.0 / shadowCoord.w;++ float invW2 = invW * invW;++ vec3 deltaA = projectedA.xyz * invW - shadowCoord.xyz * projectedA.w * invW2;++ vec3 deltaB = projectedB.xyz * invW - shadowCoord.xyz * projectedB.w * invW2;++++ float determinant = deltaA.x * deltaB.y - deltaB.x * deltaA.y;++++ // OPENMW_ANDROID_051_GRAZING_SHADOW_FIX_V3++ // Use a scale-independent conditioning test. With the Android orthographic++ // shadow range, valid UV basis determinants are naturally around 1e-8, so++ // the previous absolute 1e-8 cutoff discarded ordinary terrain slopes.++ float determinantScale = length(deltaA.xy) * length(deltaB.xy);++ if (determinantScale < 1e-16)++ return vec2(0.0);++++ float minimumDeterminant = determinantScale * 1e-5;++ if (abs(determinant) < minimumDeterminant)++ determinant = determinant < 0.0 ? -minimumDeterminant : minimumDeterminant;++++ vec2 receiverSlope = vec2(++ (deltaA.z * deltaB.y - deltaB.z * deltaA.y) / determinant,++ (deltaB.z * deltaA.x - deltaA.z * deltaB.x) / determinant++ );++++ // Keep only the mathematically singular horizon case finite.++ return clamp(receiverSlope, vec2(-128.0), vec2(128.0));++}++#endif+++ void setupShadowCoords(vec4 viewPos, vec3 viewNormal)+ {+ #if SHADOWS+@@ -42,6 +98,12 @@+ shadowSpaceCoords@shadow_texture_unit_index = shadowSpaceMatrix@shadow_texture_unit_index * offsetViewPosition;+ }+ #endif++++ shadowReceiverPlaneSlope@shadow_texture_unit_index = openmwAndroidReceiverPlaneSlope(++ shadowSpaceMatrix@shadow_texture_unit_index,++ shadowSpaceCoords@shadow_texture_unit_index,++ viewNormal++ );+ @endforeach+ #endif // SHADOWS+ }+--- a/compatibility/terrain.frag++++ b/compatibility/terrain.frag+@@ -74,7 +74,7 @@+ #endif+ vec3 viewNormal = normalToView(normal);+ #else+- vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);++ vec3 viewNormal = normalToView(normalize(passNormal));+ #endif++ float shadowing = unshadowedLightRatio(linearDepth);+--- a/compatibility/terrain.vert++++ b/compatibility/terrain.vert+@@ -52,7 +52,7 @@+ #endif++ #if !PER_PIXEL_LIGHTING || @shadows_enabled+- vec3 viewNormal = normalize(gl_NormalMatrix * passNormal);++ vec3 viewNormal = normalToView(passNormal);+ #endif++ #if !PER_PIXEL_LIGHTING+--- a/compatibility/water.frag++++ b/compatibility/water.frag+@@ -71,6 +71,7 @@++ varying vec4 position;+ varying float linearDepth;++varying vec4 screenPosition; // OPENMW_ANDROID_051_WATER_PROJECTIVE_SCREEN_COORDS++ uniform sampler2D normalMap;++@@ -98,7 +99,12 @@++ float shadow = unshadowedLightRatio(linearDepth);++- vec2 screenCoords = gl_FragCoord.xy / screenRes;++ // OPENMW_ANDROID_051_WATER_PROJECTIVE_SCREEN_COORDS++ // On Android custom resolutions, the shared screenRes uniform can briefly retain++ // the host/native display size during startup. Derive normalized screen UV from++ // the water vertex clip position instead, so reflection/refraction sampling is++ // resolution-independent from the very first rendered frame.++ vec2 screenCoords = (screenPosition.xy / screenPosition.w) * 0.5 + 0.5;++ #define waterTimer osg_SimulationTime++@@ -213,7 +219,14 @@+ #endif++ gl_FragData[0].rgb = mix(refraction, reflection, fresnel);++#if @wetWorldWaterMask++ // OPENMW_ANDROID_051_WETWORLD_WATER_MASK++ // Alpha is reserved as an exact post-processing water marker on Android.++ // RGB shading and native rain-ripple lighting remain unchanged.++ gl_FragData[0].a = 0.0;++#else+ gl_FragData[0].a = 1.0;++#endif+ // no alpha here, so make sure raindrop ripple specularity gets properly subdued+ rainSpecular *= waterTransparency;+ #else+--- a/compatibility/water.vert++++ b/compatibility/water.vert+@@ -4,6 +4,7 @@++ varying vec4 position;+ varying float linearDepth;++varying vec4 screenPosition; // OPENMW_ANDROID_051_WATER_PROJECTIVE_SCREEN_COORDS++ #include "shadows_vertex.glsl"+ #include "lib/view/depth.glsl"+@@ -17,6 +18,7 @@+ void main(void)+ {+ gl_Position = modelToClip(gl_Vertex);++ screenPosition = gl_Position;++ position = gl_Vertex;+diff --git a/cmake/GitVersion.cmake b/cmake/GitVersion.cmakeindex 87584b0..dd6c2d2 100644--- a/cmake/GitVersion.cmake+++ b/cmake/GitVersion.cmake@@ -6,15 +6,18 @@ execute_process (OUTPUT_STRIP_TRAILING_WHITESPACEERROR_QUIET)-# Isowind: the hash of the source tree rather than of the commit. Multiplayer only lets the same version play-# together (the hash is part of the connection password), and the tree is the same wherever that source is built:-# here, and from the snapshot commits pushed to GitHub for the Linux and Android builds.+# Isowind: a hash of the engine's source rather than of the commit. Multiplayer only lets the same version play+# together (the hash is part of the connection password), and this is the same wherever that source is built: here,+# from the snapshot commits pushed to GitHub, and from the Android build's export (android/buildscripts/CMakeLists.txt+# computes it the same way). Only the engine's folders count, so changes to the Android app, CI or Isowind's data+# files don't split players.execute_process (- COMMAND ${GIT_EXECUTABLE} rev-parse HEAD^{tree}+ COMMAND ${GIT_EXECUTABLE} rev-parse HEAD:apps HEAD:components HEAD:files HEAD:extern HEAD:cmake HEAD:CMakeLists.txtWORKING_DIRECTORY ${OpenMW_SOURCE_DIR}RESULT_VARIABLE EXITCODE2- OUTPUT_VARIABLE COMMITHASH+ OUTPUT_VARIABLE ENGINE_TREESOUTPUT_STRIP_TRAILING_WHITESPACE)+string(SHA1 COMMITHASH "${ENGINE_TREES}")string (COMPARE EQUAL "${EXITCODE1}:${EXITCODE2}" "0:0" FULL_SUCCESS)string (COMPARE EQUAL "${EXITCODE2}" "0" COMMIT_SUCCESS)