How to use sdf's as bounding boxes for forces?

Textures To Particles with control2.vl (72.6 KB)

Moved from matrix…
I’m trying to use a bounding box for forces, seems to be a fairly common need, coming from c4d or games I’d think, wind when you leave a building for example. Ideally with fall off. This patch is using textures as vector field as a starting point, but only to emit particles. And I was trying to use an SDF to activate the curl force, but adding examples as @texone has suggested, makes the simulation stage throw errors, of
Could not compile shader. See error messages.[shaders\Shader_2110393184.sdsl(141,47)]: Error: E0227: Unable to find stream variable [PositionWS] in class [Shader_2110393184]
[shaders\Shader_2110393184.sdsl(141,47)]: Warning: W0003: Unable to find type reference for member [streams.PositionWS]
[shaders\Shader_2110393184.sdsl(141,47)]: Error: E0227: Unable to find stream variable [xyz] in class [Shader_2110393184]
[shaders\Shader_2110393184.sdsl(141,47)]: Warning: W0003: Unable to find type reference for member [streams.PositionWS.xyz]

But I’ve also seen

Could not compile shader. See error messages.Error: C:\Program Files\vvvv\vvvv_gamma_5.2-0016-g7a8f596b6a\log\shader_ComputeFXEffect_cea16ae793cff792e2007a6fa92e0be5.hlsl(191,31-85): warning X3203: signed/unsigned mismatch, unsigned assumed
C:\Program Files\vvvv\vvvv_gamma_5.2-0016-g7a8f596b6a\log\shader_ComputeFXEffect_cea16ae793cff792e2007a6fa92e0be5.hlsl(196,39-56): error X3018: invalid subscript ‘PositionWS’

With the other suggestion

I’ve left the simulation stage unattached, so you should see some particles spawn and respawn after 8 seconds. Attach one the group nodes for errors

Textures To Particles with control3.vl (73.2 KB)

So detaching the positionWS node makes the shader work, but then you get no bounding box effect, the if is just true.

image

  1. You need to use the particle position attribute to sample the sdf

  2. PositionWS is a draw shader semantic that in this case is not set

1 Like

Perfect, without the if region and straight into the strength of the curl force works as a softedge too, wonderful thank you!