From 10bc3da9b9e355a6ee03bfadabcb1884b6cfb41d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Tue, 20 Apr 2021 08:10:23 +0200 Subject: [PATCH] Improve shader compatibility with GLES (#14489) --- data/shaders/drawline.vert | 8 ++++---- data/shaders/drawrect.vert | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/data/shaders/drawline.vert b/data/shaders/drawline.vert index 2faf19dc2a..dea6af7f47 100644 --- a/data/shaders/drawline.vert +++ b/data/shaders/drawline.vert @@ -16,12 +16,12 @@ flat out uint fColour; void main() { - vec2 pos = clamp(vVertMat * vBounds, vClip.xy, vClip.zw); + vec2 pos = clamp(vVertMat * vec4(vBounds), vec2(vClip.xy), vec2(vClip.zw)); // Transform screen coordinates to viewport coordinates - pos = (pos * (2.0 / uScreenSize)) - 1.0; - pos.y *= -1; - float depth = 1.0 - (vDepth + 1) * DEPTH_INCREMENT; + pos = (pos * (2.0 / vec2(uScreenSize))) - 1.0; + pos.y *= -1.0; + float depth = 1.0 - (float(vDepth) + 1.0) * DEPTH_INCREMENT; fColour = vColour; diff --git a/data/shaders/drawrect.vert b/data/shaders/drawrect.vert index b752f364dc..6c1e0a9be7 100644 --- a/data/shaders/drawrect.vert +++ b/data/shaders/drawrect.vert @@ -30,16 +30,16 @@ flat out vec3 fPalettes; void main() { // Clamp position by vClip, correcting interpolated values for the clipping - vec2 m = clamp(((vVertMat * vClip) - (vVertMat * vBounds))/(vBounds.zw - vBounds.xy) + vVertVec, 0.0, 1.0); - vec2 pos = mix(vBounds.xy, vBounds.zw, m); + vec2 m = clamp(((vVertMat * vec4(vClip)) - (vVertMat * vec4(vBounds)))/vec2(vBounds.zw - vBounds.xy) + vVertVec, 0.0, 1.0); + vec2 pos = mix(vec2(vBounds.xy), vec2(vBounds.zw), m); fTexColour = vec3(mix(vTexColourBounds.xy, vTexColourBounds.zw, m), vTexColourAtlas); fTexMask = vec3(mix(vTexMaskBounds.xy, vTexMaskBounds.zw, m), vTexMaskAtlas); fPosition = pos; // Transform screen coordinates to texture coordinates - float depth = 1.0 - (vDepth + 1) * DEPTH_INCREMENT; - pos = pos / uScreenSize; + float depth = 1.0 - (float(vDepth) + 1.0) * DEPTH_INCREMENT; + pos = pos / vec2(uScreenSize); pos.y = pos.y * -1.0 + 1.0; fPeelPos = vec3(pos, depth * 0.5 + 0.5);