-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgradientSquareOutline.sca
More file actions
26 lines (26 loc) · 882 Bytes
/
gradientSquareOutline.sca
File metadata and controls
26 lines (26 loc) · 882 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
#import <gradients>
#import <sdf>
using namespace std;
// Entry point of the shader code asset //
// @param[default=#00FFFFFF] colorl
// @param[default=#0000C0FF] color2
// @param[default=5.0,min=4.0,max=9.0] number
// @return color
vec4 main(vec4 colorl, vec4 color2, float center){
// get time and animate on a loop
float time = sin(getTime()/4.);
//get uv coordinates
vec2 uv = fragment(getVertexTexCoord());
// assign colors to uv
vec4 color = mix(colorl, color2, gradientHorizontal(uv));
// create a rectangle
auto sdf = sdfRectangleSharp(vec2(0.5, 0.5), vec2(center, center));
// convert solid to outline
auto sdfA = sdfAnnular(sdf, 0.005);
// assign sdf to uv
float dist = sdfA(uv);
float edge = fwidth(dist);
float alpha = smoothstep(-edge, +edge, dist);
//return
return mix(color, color.rgb0, alpha);
}