summaryrefslogtreecommitdiffstats
path: root/src/opengl/util/texture_brush.glsl
blob: 93865b8afc5da49caace922cea2e0e19ecb8352a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
uniform sampler2D brush_texture;
uniform vec2 inv_brush_texture_size;
uniform vec3 inv_matrix_m0;
uniform vec3 inv_matrix_m1;
uniform vec3 inv_matrix_m2;

vec4 brush()
{
    mat3 mat;

    mat[0] = inv_matrix_m0;
    mat[1] = inv_matrix_m1;
    mat[2] = inv_matrix_m2;

    vec3 hcoords = mat * vec3(gl_FragCoord.xy, 1);
    vec2 coords = hcoords.xy / hcoords.z;

    coords *= inv_brush_texture_size;

    coords.y = -coords.y;

    return texture2D(brush_texture, coords);
}