I want to check if a Point is out-of-bounds; greater than (1, 1, 1), less than (-1, -1, -1). If it is out-of-bounds, I want to set its position to a new coordinates (0.5, 0.5. 0.5)
The logic for the above is in the ‘update_outofbounds’ mathmix operator where I compare the x value (P0) with maxBounds(0) and minBounds(0) and update the ‘outOfBounds’. This does not work. The ‘outOfBounds’ value does not get updated even when P0 > maxBounds(0) or P0 < minBounds(0).
I have also tried comparison at vector level (P > maxBounds && P < minBounds), this also does not work. I am missing something here. Please help. POPs-Operation-Question.toe (7.1 KB)
I am attaching the patch with this message. Thank you.
Hey here is one possible answer using GLSL, i can’t really help using node as of now i haven’t been using POPs for long but a bit more of GLSL, I definitely recommend reading a bit of the GLSL POPs documentation (Experimental:Write GLSL POPs - Derivative) , it allows for a lot a more to be done in only one node and to me it have been always more understandable than a series of nodes.
To resume what i have done, I first set the output attribute that will be read and possibly updated by the shader :
vec3 pos = TDInPoint_P();
vec3 vel = TDInPoint_velocity();
Then check if out of bounds (you can see the line right after in the code)
Then if out of bounds i not only reset the position but also the velocity and the oldP attribute otherwise because you compute velocity from oldP, when the position is reset the velocity is very high and the point will continue accelerating and going out of bounds, so i recompute a new random offset and add it to the reset position to generate a new velocity
It looks like the issue might be in your comparison logic. When you check P > maxBounds && P < minBounds, that condition can never be true because no vector can be simultaneously greater than maxBounds and less than minBounds. You might want to rewrite the check per component, like:
Sincere thank you for replying to my question. I really appreciate your the time and effort
@huitresix: GLSL is a little ways away for me. Will definitely check your patch out as inspiration as I move ahead.
@josefpelz: The operation sequence you provide works; very interesting use of operations :-). This will help me move forward. Thank you.
@Dino_J; thx for pointing this out, I did think about this. My understanding is; since I check P against maxBounds and minBounds in independent MathMix blocks AND each of these blocks update ‘outOfBounds’; I must be able to get the correct value for outOfBounds.