File: matrix.vert

package info (click to toggle)
olive-editor 20200620-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 40,228 kB
  • sloc: cpp: 51,932; sh: 56; makefile: 7; xml: 7
file content (37 lines) | stat: -rw-r--r-- 724 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#version 150

uniform mat4 %1;

uniform vec2 %2_resolution;
uniform vec2 ove_resolution;

in vec4 a_position;
in vec2 a_texcoord;

out vec2 ove_texcoord;

mat4 scale_mat4(vec3 scale) {
    return mat4(
        scale.x, 0.0, 0.0, 0.0,
        0.0, scale.y, 0.0, 0.0,
        0.0, 0.0, scale.z, 0.0,
        0.0, 0.0, 0.0, 1.0
    );
}

void main() {
    // Create identity matrix
    mat4 transform = mat4(1.0);

    // Scale to square
    transform *= scale_mat4(vec3(1.0 / ove_resolution, 1.0));

    // Multiply by received matrix
    transform *= %1;

    // Scale back out to footage size
    transform *= scale_mat4(vec3(%2_resolution, 1.0));

    gl_Position = transform * a_position;
    ove_texcoord = a_texcoord;
}