gpu: pack 2D transforms in vec4 values

Instead of separate 2d scale and transform, pack them into a single
4d value.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-02-27 17:38:06 +01:00
parent 1f117d8de0
commit c34c350a52
7 changed files with 73 additions and 109 deletions
+6 -9
View File
@@ -7,13 +7,10 @@ precision highp float;
#include <common.inc>
layout(binding = 0) uniform Block {
vec4 transform;
vec4 uvCoverTransform;
vec4 uvTransform;
float z;
vec2 scale;
vec2 offset;
vec2 uvCoverScale;
vec2 uvCoverOffset;
vec2 uvScale;
vec2 uvOffset;
};
layout(location = 0) in vec2 pos;
@@ -24,9 +21,9 @@ layout(location = 1) in vec2 uv;
layout(location = 1) out vec2 vUV;
void main() {
gl_Position = vec4(pos*scale + offset, z, 1);
vUV = uv*uvScale + uvOffset;
gl_Position = vec4(pos*transform.xy + transform.zw, z, 1);
vUV = uv*uvTransform.xy + uvTransform.zw;
vec3[2] fboTrans = fboTextureTransform();
vec3 uv3 = transform3x2(fboTrans, vec3(uv, 1.0));
vCoverUV = (uv3*vec3(uvCoverScale, 1.0)+vec3(uvCoverOffset, 0.0)).xy;
vCoverUV = (uv3*vec3(uvCoverTransform.xy, 1.0)+vec3(uvCoverTransform.zw, 0.0)).xy;
}