-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrepeat.glsl
61 lines (41 loc) · 1.1 KB
/
repeat.glsl
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#START_VERTEX
#version 140
/**
-------------- texture coords vertex shader -------------
author: Richman Stewart
simple vertex shader that sets the position
to the specified matrix and position while
passing the vertex colour and tex coords
to the fragment shader
**/
in vec2 a_position;
in vec2 a_tex_coord;
in vec4 a_colour;
uniform mat4 matrix;
out vec4 v_colour;
out vec2 tex_coord;
void main() {
v_colour = a_colour;
tex_coord = a_tex_coord;
gl_Position = matrix * vec4(a_position, 0, 1);
}
#END_VERTEX
#START_FRAGMENT
#version 140
/**
------------ texture repeat fragment shader ------------
author: Richman Stewart
repeats the original texture x, y amount of times
---------------------- use -----------------------------
repeat - the amount of times to repeat
the texture horizontally and vertically
**/
in vec4 v_colour;
in vec2 tex_coords;
out vec4 pixel;
uniform sampler2D t0;
uniform vec2 repeat = vec2(2, 2);
void main() {
pixel = v_colour * texture2D(t0, vec2(mod(tex_coords.x * repeat.x, 1), mod(tex_coords.y * repeat.y, 1)));
}
#END_FRAGMENT