Search Unity

Sample Bezier operator - Improvements

Discussion in 'Visual Effect Graph' started by IllogikaXBoxOne, Feb 21, 2020.

  1. IllogikaXBoxOne

    IllogikaXBoxOne

    Joined:
    Feb 1, 2017
    Posts:
    3
    Hi there!
    I wanted to make particles to follow a spline, and the only thing I found is the operator "Sample Bezier".
    It works like it should, but it's very limited in what you can do with it. I had more than 4 points in the spline (capsule shape) and I had to use some tricks with 4 different bezier samples to achieve my goal.

    bezier_Sample.png

    Where a way to just simply add points on one operator would have been great. The ideal would have been to input an array of Vector3, but that was not necessary in my case. It's just crazy how complex it turns with such a simple goal. Hopefully things will become easier in the future :)

    (My result)
    particles_capsule.png

    Cheers!
     
  2. ThomasVFX

    ThomasVFX

    Joined:
    Jan 14, 2016
    Posts:
    45
    Hello!
    Indeed, the built-in Sample Bezier is just a low-level bezier segment sample and only using it for your specific case is makes the task rather complex.

    Right now, we don't support built-in arrays natively, however, you can use textures to store an array of positions. You can take a look at the VFX Sample Additions (installable via the package manager, from the VFX Graph page).

    upload_2020-2-25_8-28-19.png

    In these additions, I have added an utility subgraph asset that enables sampling a multi-segment bezier (with automatic tangent calculation though, which is probably exactly what you want). The setup involves using a chain of points in the scene. (I'm enclosing the asset and the prefab in a unitypackage so you can try it out)

    upload_2020-2-25_8-37-56.png

    Regarding what you need, you could make a copy of the Sample Multiple Position Map subgraph and remove the automatic tangent computation and instead read the tangent points directly from the position map. The setup is a bit different as you will probably need to ensure to have a correct number of points (NumSegements*3 + 1).

    A final word, if you want this array to be self contained and not rely on points in scene, would be to bake this array into a point cache asset, and use it directly inside the graph using a point cache operator. Right now you can bake point caches from mesh or textures directly in unity (Window/Visual Effects/Utilities/Point Cache Bake Tool) or use the Houdini exporter from our VFXToolbox package.

    upload_2020-2-25_8-51-30.png

    Hope that helps!
     

    Attached Files:

    andybak and alex-sanni like this.
  3. hl2118

    hl2118

    Joined:
    Feb 15, 2018
    Posts:
    3
    Hello! thanks for the explanation, that is potentially the tool I need to solve my problem.
    Just one question though, if I want to move particles along the beizer curve, what should I do?

    thanks for your help!
     
    quan_nguyen_2503 likes this.
  4. Dave_W

    Dave_W

    Joined:
    Feb 12, 2019
    Posts:
    4
    Did you figure this out?
     
  5. quan_nguyen_2503

    quan_nguyen_2503

    Joined:
    Nov 6, 2020
    Posts:
    1
    It may be a little late but I was solving the same problem and found a solution by linking Sample Multiple Position Map's bezier output to a Set Position node inside Update Particle. Good luck!