Skip to content

Commit

Permalink
uniform scaling and scale cleanup in magnet
Browse files Browse the repository at this point in the history
  • Loading branch information
t3kt committed Apr 8, 2024
1 parent 9744153 commit 966cce4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
26 changes: 20 additions & 6 deletions src/operators/filter/magnet.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,28 @@ ReturnT thismap(CoordT p, ContextT ctx) {
CoordT translate = THIS_asCoordT(THIS_Translate) * d;
p -= translate;

CoordT scale = mix(CoordT(1.), THIS_asCoordT(THIS_Scale), d);
p /= scale;
float adjust = 1.;
switch (int(THIS_Scaletype)) {
case THISTYPE_Scaletype_uniform:
{
float scale = mix(1., THIS_Uniformscale, d);
p /= scale;
adjust = scale;
}
break;
case THISTYPE_Scaletype_separate:
{
vec3 scale = mix(vec3(1.), THIS_Scale, d);
p /= THIS_asCoordT(scale);
adjust = vmin(scale);
}
break;
}

p += center;
ReturnT res = inputOp1(p, ctx);
#ifdef THIS_RETURN_TYPE_float
res /= length(scale);
#else
res.x /= length(scale);
#ifdef THIS_RETURN_TYPE_Sdf
res = withAdjustedScale(res, adjust);
#endif
return res;
}
Binary file modified src/operators/filter/magnet.tox
Binary file not shown.
2 changes: 1 addition & 1 deletion src/operators/filter/magnet.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
!rop
meta: !meta
opType: raytk.operators.filter.magnet
opVersion: '14'
opVersion: '15'
opStatus: default
opDef: !def
enable: !expr
Expand Down
3 changes: 2 additions & 1 deletion src/operators/filter/magnet_params.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
names source handling readOnlyHandling conversion enable
Center[xyz] Translate[xyz] Scale[xyz] Amount Radius Fade param runtime macro 1
Center[xyz] Translate[xyz] Scale[xyz] Uniformscale Amount Radius Fade param runtime macro 1
Rotate[xyz] param runtime macro angle 1
Scaletype param constant 1
Binary file modified tests/testCases/operators/filter/magnet_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testCases/operators/filter/magnet_test.tox
Binary file not shown.

0 comments on commit 966cce4

Please sign in to comment.