-
Notifications
You must be signed in to change notification settings - Fork 210
Expand file tree
/
Copy pathCloneFrag.glsl
More file actions
45 lines (39 loc) · 1017 Bytes
/
CloneFrag.glsl
File metadata and controls
45 lines (39 loc) · 1017 Bytes
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
//
// Copyright (C) 2023 Autodesk, Inc. All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
#define FRAGCOLOR gl_FragColor
#define in varying
#endif
#extension GL_ARB_texture_rectangle : require
uniform sampler2DRect texture0; /*texture*/
uniform vec2 cloneOffset;
in vec2 TexCoord0; // paint stroke texcoord [-1, 1]
in vec2 TexCoord1; // paint stroke texcoord w.r.t. frame
void main()
{
vec2 d = fwidth(TexCoord0);
float l = max(d.x, d.y);
float w = 1.0 / l;
float border = 2.0 / w;
vec2 m = TexCoord0 - vec2(0.5, 0.5);
float radius = 0.5;
float dist = radius - length(m);
float t = 0.0;
if (dist > border)
{
t = 1.0;
}
else if (dist > 0.0)
{
t = smoothstep(0.0, 1.0, dist / border);
}
FRAGCOLOR.a = t;
vec2 shifted = TexCoord1 + cloneOffset;
FRAGCOLOR.rgb = texture2DRect(texture0, shifted).rgb;
}