-
Notifications
You must be signed in to change notification settings - Fork 210
Expand file tree
/
Copy pathSoftCloneFrag.glsl
More file actions
35 lines (29 loc) · 901 Bytes
/
SoftCloneFrag.glsl
File metadata and controls
35 lines (29 loc) · 901 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
//
// 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 m = TexCoord0 - vec2(0.5, 0.5);
float mag = sqrt(m.x * m.x + m.y * m.y);
float radius = 0.5;
float bot = 0.01831563888; /* exp(-4.0) */
float ratio = mag * 2.0 / radius;
if (ratio <= 2.0) FRAGCOLOR.a = exp(-ratio*ratio)-bot*ratio*0.5;
else FRAGCOLOR.a = 0.0;
vec2 shifted = TexCoord1 + cloneOffset;
FRAGCOLOR.rgb = texture2DRect(texture0, shifted).rgb;
}