Improve shader compatibility with GLES (#14489)

This commit is contained in:
Michał Janiszewski 2021-04-20 08:10:23 +02:00 committed by GitHub
parent 7525f5d5da
commit 10bc3da9b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

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

View File

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