Skip to content

Commit

Permalink
🟦 [Nodes] Added "Star Symmetry"
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesFouchy committed May 25, 2024
1 parent 7115289 commit de55796
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 0 deletions.
46 changes: 46 additions & 0 deletions Nodes/50 2D Modifier/Star Symmetry.clbnode
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// https://www.youtube.com/watch?v=il_Qg9AqQkE

INPUT Point2D 'Center';
INPUT float 'Size';
INPUT Angle 'Angle';
INPUT int 'Iterations';
INPUT float 'Mask';

vec2 u(float angle)
{
return vec2(sin(angle), cos(angle));
}

UV main(UV Image)
{
vec2 out_uv = Image - 'Center';
out_uv /= 'Size';

out_uv.x = abs(out_uv.x);
float fractal_angle = (5. / 6.) * PI;
out_uv.y += tan(fractal_angle) * 0.5;

vec2 u_line = u(fractal_angle);
float d = dot(out_uv - vec2(0.5, 0), u_line);
out_uv -= u_line * max(0., d) * 2.;

u_line = u('Angle');
out_uv.x += 0.5;

float scale = 3.;
for (int i = 0; i < 'Iterations'; i++)
{
out_uv *= scale;
out_uv.x -= scale / 2.;
out_uv.x = abs(out_uv.x);
out_uv.x -= 0.5;
out_uv -= u_line * min(0., dot(out_uv, u_line)) * 2.;
}

d = length(out_uv - vec2(clamp(out_uv.x, -1., 1.), 0.));
out_uv /= (pow(scale, float('Iterations')));
out_uv *= 'Size';
out_uv += 'Center';

return mix(Image, out_uv, 'Mask');
}
99 changes: 99 additions & 0 deletions Nodes/50 2D Modifier/Star Symmetry.clbnode.presets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"Presets": {
"Underlying container": [
{
"first": "42282f76-8c81-410d-a961-63a914727cdd",
"second": {
"Name": "Default",
"Values": [
{
"index": 3,
"data": {
"Name": "Center",
"Value": {
"Point2D": {
"x": 0.0,
"y": 0.0
}
},
"Metadata": {
"Drag speed": 0.00009999999747378752
}
}
},
{
"index": 2,
"data": {
"Name": "Size",
"Value": 1.0,
"Metadata": {
"Bounds": {
"Has min bound": true,
"Min": 0.000009999999747378752,
"Has max bound": false,
"Max": 1.0,
"Drag speed": 0.009999999776482582,
"Use slider": false,
"Is logarithmic": false
}
}
}
},
{
"index": 11,
"data": {
"Name": "Angle",
"Value": {
"Radians": {
"Radians": 0.0
}
},
"Metadata": {
"Number of snaps": 24,
"Snaps offset (in radians)": 0.0,
"Always snap": false
}
}
},
{
"index": 1,
"data": {
"Name": "Iterations",
"Value": 4,
"Metadata": {
"Bounds": {
"Has min bound": true,
"Min": 0,
"Has max bound": true,
"Max": 10,
"Drag speed": 0.0020000000949949028,
"Use slider": false,
"Is logarithmic": false
}
}
}
},
{
"index": 2,
"data": {
"Name": "Mask",
"Value": 1.0,
"Metadata": {
"Bounds": {
"Has min bound": true,
"Min": 0.0,
"Has max bound": true,
"Max": 1.0,
"Drag speed": 0.009999999776482582,
"Use slider": true,
"Is logarithmic": false
}
}
}
}
]
}
}
]
}
}

0 comments on commit de55796

Please sign in to comment.