# Making particlesGPU react to geometry boundries or shapes?

Hi all!!

I’m trying to create my 1st TD project using the particlesGPU palette and I want to make the particles look like they are bouncing off the sides of the frame rather than passing outside side of the boundaries… how would you go about constraining the particles in geometry…? cheers!!

Hey @JimiPower,

on the “Particles” parameter page, you have a set of parameters that can help with this:

• `Pos Limit Plane` - specify the maximum bounding box size
• `Neg Limit Plane` - specify the minimum bounding box size
• `Hit` - specify the behavior of the particle when position is equal or outside the bounding box size. By default this is “Die on Contact” but can be switched to “Bounce on Contact”

There is unfortunately no functionality in the component to derive this of a random geometry directly. You could reference a Box SOP or similar and then enter into the Pos/Neg Limit Plane parameters an expression such as `op('box1').min[0]` or `op('box1').max[0]` returning the minimum and maximum bounds. As the `.min` and `.max` members of the SOP Class return a tdu.Position, access to the x, y and z components is done via the square bracket notation.

Does this help?
cheers
Markus

1 Like

Hi Markus, thanks heaps for replying, yes that helps hugely… I’m only getting back onto this again now, struggling to grasp what the pos/neg limit plane #value represents on 1st glance. I’ll keep playing with it, will let you know how I get on… thanks again!! Jimi

Hi @JimiPower,

you can think of the Limit Planes as minimum and maximum bounds of a geometry. They essentially create a box. The Negative Limit Plane describes the box’s smallest coordinates in xyz space while the Positive Limit Plane describes the box’s largest coordinates in xyz space.
For example having a Neg Limit Plane set to `-1, -1, -1` and the Pos Limit Plane set to `1,1,1` would create a cube with an edge length of `2` centered at the root of the coordinate system.
Similarly a Neg Limit Plane set to `0,0,0` and the Pos Limit Plane set to `1,1,1` would create a cube with the edge length of `1` centered at `0.5,0.5,0.5`.

Hope this helps
Cheers
Markus

Hi Markus, thanks heaps for taking the time to reply again!! After a bit more playing the limit plane values and stuff is all starting gel… I’m now trying to get my head around referencing an SOP with an expression but I haven’t been able to get it to work… this is where I’m at so far:
LazerTunnel.toe (513.9 KB)
I’m trying to contain the particles in a torus or tube shape and want the particles to cling and react inside it. My idea is that the output would just look like a densely populated ring of particles which I want to project into haze for a laser tunnel-like effect… cheers again, Jimi

Hey @JimiPower,

currently the bounds are hardcoded to be a cube like volume. For this to work with a tube, you would have to change some of the glsl code for the particlesGPU component. It’s actually not too hard - currently on `line 164` of the glsl1_pixel DAT it has a if condition which determines if the particle should be reborn or reflected:

`````` if (posLife.x > uLimitPos.x || posLife.y > uLimitPos.y || posLife.z > uLimitPos.z || posLife.x < uLimitNeg.x || posLife.y < uLimitNeg.y || posLife.z < uLimitNeg.z)
``````

where the particles current position, stored in `posLife` is compared to the values of the limit planes stored in `uLimitPos` and uLimitNeg`.
To make this work for a tube that faces down the z axis, you would have to calculate the distance from the center like such:

``````if (length(vec2(posLife.x, posLife.y)) > 2)
``````

where the `2` is basically the radius of the tube. You might also want to limit the particles in z, for that you would add an `or` condition:

``````if (length(vec2(posLife.x, posLife.y)) > 2 || posLife.z > 5 || posLife.z < -5)
``````

Depending on if you are working on a mac or not, you would have to make this change also in `glsl1_pixelMAC`

Let me know if this works
cheers
Markus

Awesome, thanks heaps man… I’ll give it a crack and let you know how I go… cheers, Jimi

1 Like