jes notes Index Gallery . Signed Distance Functions Shaft passers Snap issues

2025-03-14

Last modified: 2025-03-15 08:09:04

< 2025-03-13 2025-03-15 >

PolarPattern domain repetition

I am having some trouble getting either my or Cursor's head around the mathematics.

I think we need to firstly rotate into "axis space" (so that our pattern rotates around Z), and rotate back at the end. That's fine.

And then with our pattern rotating around Z, we need to work out the angle to instance 0 and make sure our pattern segments are centered around the centre of instance 0.

And then work out what pattern segment the point is in.

And then rotate the point around Z so that it is in the first segment.

OK, finally got it.

Now just need fillet/chamfer.

Woo, check this out:

That is a PolarPattern of 40 cubes, with fillets on the joins. Domain repetition with 7 overlaps in each direction.

Using Vec3s

Currently lots of code does ad-hoc vector handling, even though I have a Vec3 class.

Firstly I should make .cursorrules tell it to use the Vec3 class, and secondly I should make it change everything to use Vec3s.

Where we have GLSL code like:

vec3 axis = vec3(${normalizedAxis.x.toFixed(16)}, ${normalizedAxis.y.toFixed(16)}, ${normalizedAxis.z.toFixed(16)});

We should maybe make Vec3 have a toFixed() function and then:

vec3 axis = vec3(${normalizedAxis.toFixed(16)});

Or maybe just glsl():

vec3 axis = ${normalizedAxis.glsl()};

Which gives you a string like "vec3(0.0, 0.0, 0.0)" but 16 decimal places or whatever.

Developing SDFs

I think the way to develop SDFs is in 2d in shadertoy. This is so blatantly obvious that I don't know why I didn't work it out before.

Instead of writing JavaScript code to make 3d SDFs, and then loading the app up in Firefox and manipulating the document tree to put objects where I want them, and then trying to work out if the SDF is broken by applying roughness/thickness/etc., I should just make a 2d version in shadertoy and show the actual distance field.

(And, further, I should add a "field cross section" mode to Isoform that will plot a cross section of the scene as a 2d field).

Here is a field cross section view:

You can see that the chamfer causes a warped interior SDF, which then causes a broken "thickness".

Todo

< 2025-03-13 2025-03-15 >