Clipping Solids (SDF functions)

Hi community!

Here is a picture:

And there is a working example:

This topic is an evolving of the previous one

Just had a thought, what if there’s a shorter way to check, if a point is inside of a solid body.
And I’ve remembered about the distance functions from some good articles of Inigo Quilez.
So, why not give those functions a try?
The result, as you can see, looks promising. You can set primitives by formulas, then translate, rotate or distort them, thus you set the area of visibility. The more flexibilty, the more funny stuff you can do :slight_smile:

Update #1

Update #2
Another approach

Update #3
Approach #2 coloured by indices

Update #4
Set colours of solids by the result of function

Update #5
Coloured solids + symmetry

Update #6
Instancing + colours


This is fantastic!

Have you found a way to determine whether the points are inside any arbitrary geometry? Or does it have to be defined by a mathematical equation, like the twisted cube? I was working on an identical “volumetric display” project to show models through particles, but haven’t been able to figure out how to calculate when the particle is inside the geometry :frowning_face:. The best I’ve been able to do so far is to find the geometry faces via depthMap render.

Check it out: Volumetric Display

1 Like

Yes, the box is defined in the shader:

float udBox( vec3 p, vec3 b )
  return length(max(abs(p)-b,0.0));

Unfortunately, I have no idea of how to do that stuff with arbitrary geometries.

The only way I can imagine is that you can model complex solids by combining the primitives described with the distance functions. But the more complex the model, the more complex shaders you get :thinking:

Just have a look at the source code of the raymarching shader, there you can find all the functions for primitives:

Very cool idea! :+1:

1 Like

Not sure if someone needs this technique at all :thinking: , but I’ve made some additional examples and put them as updates in the main post.

Several updates in the main post :slight_smile:

Have a look at this showcase. That’s what I had in mind. Hell of modelling :slight_smile:

1 Like

Haha! Neat! That’s a good way to do it!

1 Like