Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Resolved VFX Graph Particle strips Tiling

Discussion in 'Visual Effect Graph' started by Skullhac, May 8, 2021.

  1. Skullhac

    Skullhac

    Joined:
    Dec 5, 2016
    Posts:
    14
    Hello !

    I'm running into this issue again with particle strips in VFX graph (but I think there is a similar issue with the trail renderer and Shuriken's trail module).

    Currently, we have 2 options to tile our texture on our ribbon : Stretch (one texture stretched along the whole ribbon) and Repeat per segment (one texture per particle of the ribbon). But there is no option to choose how many texture we want to tile per segment.

    Which means, if I want to repeat a texture over a ribbon with a spawn over distance of 10, I'll get 10 times my texture per unit travelled. Of course, I want 1/10 of my texture per particle, so one unit = one texture.

    I feel like it could be a very usefull tool to create stylised trail. Stretched trails are dragged around by their head (which is the intended behaviour), which works great for objects constantly moving, but if I want to leave a trail in the path of my projectile, I have to use repeat per segment (so my texture wont "shrink" when the first particle of the ribbon will start disapearing), but I would like to control my tiling so I can play with the overall look of the trail (and also avoid "ugly" ending of a trail).

    Sorry for what I'll show now, but I tried UE4 Cascade's particle, and they have an option, "Tiling distance", that allow you to manage the tiling of a ribbon. What's interesting is that you have to use a second UV Set (UVSet 1) instead of UVSet 0 (which is default) to allow the tiling, otherwise you only get a stretching behaviour.

    Animation.gif

    From left to right : UVSet 1, tiling 0 (normal stretch effect), tiling 100, tiling 50 and the right most is using UVSet 0 (same effect as a 0 tiling).

    As you can see, you can manage how many time you want to repeat your texture along the trail, and also, when the trail disappear, the texture wont shrink, but will smoothly disappear (well, if I added a dissolve effect or alpha fade out it would be better).

    I hope I was clear about my issue, I would like to know if there is a workaround with a shader to get the same result (I tried something with the particleId and a modulo to compute the tiling but it totally ruined my texture, but I'll try again and show some results).

    Also, maybe that has to do with the "Custom" tiling option of the particle strip, but I don't know how to use it.
     
    daneobyrd and Mirkowo like this.
  2. Skullhac

    Skullhac

    Joined:
    Dec 5, 2016
    Posts:
    14
    After some time playing with the Custom UV Mode of the particle strips, I ended up with something close to the behaviour I want (don't mind the fps, it's my gif recorder, it's very smooth otherwise) :
    CustomUV.gif

    And here is the VFX setup :
    Capture.PNG

    "Tiling" has a value of 10 in my example and also control how many particle I spawn per unit. In that case, I try to spawn one full texture per unit, which means I want 1/10th of my texture per particle.

    It almost works, if it wasn't for that last particle that get the full texture reversed and printed on it (you can't see it well on the gif, but the texture is printed right to left).

    So I guess my error comes from my math to compute the TexCoord : I use the particle ID and a modulo to get a value incrementing from 0 to 9, and remap this value to a 0-1 range and feed it to my TexCoord. But I made a mistake in my reasoning somewhere and I can't fix it. It's really frustrating because I'm very close to the effect I want and it could open so much possibilities...
     
    Mirkowo likes this.
  3. Skullhac

    Skullhac

    Joined:
    Dec 5, 2016
    Posts:
    14
    Big thanks to @Alesk who helped me with this issue. They fixed my broken solution with the following vfx + shader combo (picture by them) :
    striptexture.png

    With this, you can leave a static trail behind an object, while still being able to control the tiling of the texture (basically, a controllable Repeat by Segment mode, which should have the tiling option by default in a near future I hope).

    Of course, you can add any effect in the shader or the vfx, like a dissolve effect, an alpha fade out/fade in, a scrolling/panning texture/noise, whatever suits your need.

    The part that uses particle index and particle count in strip is a way to fade in the beginning of the trail while it's still being "revealed", and fade out the end of the trail while it's being "erased", to hide the hard texture edge you would get if simply fading the early and end of the particle lifetime.

    Hope this can help people looking for a way to have tilable and CONTROLABLE particle strip/trail/ribbon.

    Now give us a way to create a shader that combine stretching AND tiling and vfx artists might be happy.

    Thx again @Alesk , I probably would still be struggling with this without them.
     
    Marie_G, shibi2017, fleity and 3 others like this.
  4. Alesk

    Alesk

    Joined:
    Jul 15, 2010
    Posts:
    337
    You're welcome ;)
     
    Mirkowo likes this.
  5. Mirkowo

    Mirkowo

    Joined:
    Sep 8, 2020
    Posts:
    1
    super good post. i feel like i've just found gold :D
     
  6. shibi2017

    shibi2017

    Joined:
    Jan 18, 2018
    Posts:
    150
    thank you, really good trick