blob: 882b2cf59f1327352f2f22bbf0d57ad36a9f66e0 (
plain)
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
|
out vec4 FragColor;
uniform sampler2D strokeColor;
uniform sampler2D strokeDepth;
uniform float amplitude;
uniform float period;
uniform float phase;
uniform int orientation;
uniform vec2 wsize;
#define M_PI 3.1415926535897932384626433832795
#define HORIZONTAL 0
#define VERTICAL 1
void main()
{
vec4 outcolor;
ivec2 uv = ivec2(gl_FragCoord.xy);
float stroke_depth;
float value;
if (orientation == HORIZONTAL) {
float pval = (uv.x * M_PI) / wsize[0];
value = amplitude * sin((period * pval) + phase);
outcolor = texelFetch(strokeColor, ivec2(uv.x, uv.y + value), 0);
stroke_depth = texelFetch(strokeDepth, ivec2(uv.x, uv.y + value), 0).r;
}
else {
float pval = (uv.y * M_PI) / wsize[1];
value = amplitude * sin((period * pval) + phase);
outcolor = texelFetch(strokeColor, ivec2(uv.x + value, uv.y), 0);
stroke_depth = texelFetch(strokeDepth, ivec2(uv.x + value, uv.y), 0).r;
}
FragColor = outcolor;
gl_FragDepth = stroke_depth;
}
|