RFE: Minimum Neighbor Distance in Neighbor POP

So I’ve been on a bit of a kick lately to try and recreate these path tracing shaders from: Maze Worms by Fabrice Neyeret using POPs

The shaders are very clever and use a 1 pixel width border to store information about the particles. So essentially these would be better performant as compute shaders and hence I thought they would be perfect to recreate using POPs. Below attached is my reconstruction:
PathTracer.toe (6.1 KB)

So to start I am a novice when it comes to GLSL. Currently I have not tackled the path changing when a collision is detected as I am still trying to wrap my head around how the Ray POP works (If I’m not wrong that would be how to achieve that). Mostly my questions are about the Neighbor POP and detecting collisions.

A screenshot to show you the output of the file shared above:

So the main challenge I encountered with detecting collision was that a particle would detect its own spiral trail as the closest point which would kill the particle preventing it from drawing any further. This can be checked if you change the Max Neighbor Distance to 0.1 instead of 0.09. I overcame this by deleting a certain amount of the trail based on age and lots of time to figure out the optimum value for Max Neighbor Distance and the Age range of the trail to be deleted.

Mostly I’m curious to understand if there is a better methodology to accomplish collision detection in this scenario and a RFE to include a Minimum Neighbor Distance parameter similar to how its is present in the Proximity POP.

Edit:This was created in Alpha 6 on Windows 11. Just saw the update to Alpha 6.1 and I haven’t updated to it on my system at the time of posting this.

1 Like

Oooo this is really cool. For the direction changing are you just trying to compute some reflection vector ?
I have some POPs glsl for that I can share here.

For the removing your own trails from the collision detection could you add an extra attribute to the trails that specifies origin point ID? I’m not sure if this is possible but if you could then you could check against that when you loop on the nearest points

Currently I haven’t gotten to the point where I’ve looked into changing the direction. Before I get there I wanted to rework the logic for the movement and collision so I can randomise it a bit more.

Should have also added other approaches I tried that I was not successful with. They were:

  • Using the Neighbor POP to output the PartID of the Neighbor and if they were different I would kill the particle. This was not as straight forward as I thought it would be because NerbPartID would be 0 when it didn’t find a neighbor. In the end I couldn’t get it to work because the closest Neighbor would always be its own trail. I was only outputing a single Neighbor because I’m not quite sure about how to do operations on arrays.
  • Used a Lookup Texture POP using the render to kill the particle. Not precise enough because the trail it was colliding would sometimes fall between two points so even though there was a collision it wouldn’t kill the particle.
  • Tried using Ray POP but I haven’t quite figured out how it works and to be fair I didn’t spend a lot of time attempting to understand it as well.

@davispolito feel free to have a play around with the file and attempt the direction change if you would like.

I think something like this is what you’re looking for to solve collisions using neighbor pop. you also probably want to calculate collisions one Frame ahead of the actual collision such that it turns around before drawing.
nebrarraypathtracer.toe (6.7 KB)

it still seems to collide with itself, but the PartID attribute does seem to get assigned to the whole trail so im unsure why that is the case

Hello,

I still have to take a proper look at the setups you shared, but otherwise we can definitely add a minimum distance parameter to the neighbor POP, I’ll log it internally.

Vincent

1 Like

+1 for minimum distance idea

1 Like

Hello again,

Finally took a minute to look at this, cool setup, @davispolito you were very close, the issue was the neighbor IDs the neighbor POP is giving you are for the second input, so you also need to check against second input IDs in the GLSL POP. With that the Delete POP by age can be bypassed, see attached.

nebrarraypathtracer_fixed.toe (6.5 KB)

Otherwise a note on using the ray POP for collision, unfortunately the ray POP is meant for triangles / surfaces, not lines / curves so it won’t work in that case.

However since with the neighbor POP you already know which point you’re colliding with, if you add the tangent to the point as an attribute (with line metrics POP after trail POP) you could calculate a reflected velocity with reflect(). Something like that.

Hope that helps!

1 Like

ahh I see yes, the neighbor pop is only outputting the head particles and the trail particles don’t come out of the neighbor pop!

Indeed, the two inputs don’t get merged.