diff --git a/src/operators/filter/magnet.glsl b/src/operators/filter/magnet.glsl index 8005d8b55..9710b40fd 100644 --- a/src/operators/filter/magnet.glsl +++ b/src/operators/filter/magnet.glsl @@ -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; } diff --git a/src/operators/filter/magnet.tox b/src/operators/filter/magnet.tox index cc1925cf9..f52d475d2 100644 Binary files a/src/operators/filter/magnet.tox and b/src/operators/filter/magnet.tox differ diff --git a/src/operators/filter/magnet.yaml b/src/operators/filter/magnet.yaml index 7c16844bb..6094012df 100644 --- a/src/operators/filter/magnet.yaml +++ b/src/operators/filter/magnet.yaml @@ -1,7 +1,7 @@ !rop meta: !meta opType: raytk.operators.filter.magnet - opVersion: '14' + opVersion: '15' opStatus: default opDef: !def enable: !expr diff --git a/src/operators/filter/magnet_params.txt b/src/operators/filter/magnet_params.txt index 6614fd5d4..20588251e 100644 --- a/src/operators/filter/magnet_params.txt +++ b/src/operators/filter/magnet_params.txt @@ -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 diff --git a/tests/testCases/operators/filter/magnet_test.png b/tests/testCases/operators/filter/magnet_test.png index 753baa9f5..74a64d752 100644 Binary files a/tests/testCases/operators/filter/magnet_test.png and b/tests/testCases/operators/filter/magnet_test.png differ diff --git a/tests/testCases/operators/filter/magnet_test.tox b/tests/testCases/operators/filter/magnet_test.tox index 59ccd459d..886a233fb 100644 Binary files a/tests/testCases/operators/filter/magnet_test.tox and b/tests/testCases/operators/filter/magnet_test.tox differ