Search Unity

Android default VFX Graph vertical lines issue

Discussion in 'Visual Effect Graph' started by VedmedenkoOleg, Apr 28, 2020.

  1. VedmedenkoOleg

    VedmedenkoOleg

    Joined:
    Jul 8, 2014
    Posts:
    2
    I have this weird vertical lines on my Xiaomi MI Max (Android 7.0) with default VFX Graph (which you get by simply doing "Create" -> "Visual Effects" -> "Visual Effects Graph", no modifications at all). What could be the issue? URP project, image attached. In editor everything is working fine.
    Unity: 2019.3.9f1
    Visual Effects Graph: 7.3.1
    photo_2020-04-28_02-47-25.jpg
     
  2. PaulDemeulenaere

    PaulDemeulenaere

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    68
    Hello,
    Indeed, this is a really annoying known issue with GLES 3.1 on Android devices, we have temporarily closed the case but we are still working on mobile & URP integration of the Visual Effect Graph.
    You can also take a look at this thread.
     
    Last edited: Oct 30, 2020
  3. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    297
    Ah... I was just coming around to post about this too! Seems that on Oculus Quest, Output Particle Quads get stretched infinitely on the positive vertical axis.

    I just submitted a bug report, but I guess this issue is more or less well known. Any chance I would have better luck trying it with 2020.1?
     
  4. PaulDemeulenaere

    PaulDemeulenaere

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    68
    As far as I know, this bug hasn't been fixed in 2020.1 yet. It's an issue only on GLES 3.1, if you are using an Oculus Quest, you can potentially switch to Vulkan.
     
    Last edited: Oct 30, 2020
  5. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    297
    At the moment, Vulkan seems to come with its own set of problems :/. Any idea how long it may be before we see a fix for this?
     
  6. fredfu

    fredfu

    Joined:
    Jul 25, 2019
    Posts:
    2
    We came across this problem when we tried VFX on Android.
    Here is the solution we found just in case anyone else may suffer from the same thing.

    We found that [OutputParticleMesh] works fine and [OutputParticleQuad] has some vertical issue on OpenGL ES 3.X.
    Then we used RenderDoc and captured some frames and noticed some expressions in shader was translated into something that GLES does not support.
    In files Path: ~/com.unity.visualeffectgraph/Shaders/ParticlePlanarPrimitives/PassGS.template & PassVS.template, the expression
    o.VFX_VARYING_UV.y = float((id & 2) >> 1); has been translated to u_xlatu0.z = bitfieldExtract(uint(gl_VertexID), 1, 1); in GLSL, while bitfieldExtract is not supported by OpenGL ES 3.0. See links below.
    https://forum.unity.com/threads/bitfieldextract-on-gles3-0.788480/#post-5247716

    So we simply replaced these expressions in templates and everything works fine ~~~
     
    Last edited: Oct 30, 2020
    PaulDemeulenaere likes this.
  7. PaulDemeulenaere

    PaulDemeulenaere

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    68
    Hello @fredfu,

    It's an efficient debug, you correctly have spotted the root cause of these vertical lines.

    The behavior of bitfieldExtract is indeed the root cause but the VisualEffect are relying on compute shader support, thus, we should already run these vertex shader using GLES 3.1. Apparently, bitfieldExtract doesn't behave as expected on all devices. Your change will fix planar (e.g. Quad) primitive output, there are actually several places where this instruction can be used or even generated from the graph compilation.

    We have temporarily closed this case to avoid anyone waiting for this specific fix but we are still working on the correct integration of mobile devices. We already have identified some unexpected driver/hardware behaviors and we are working on these issues.

    For now, the package manager UI does not offer the granularity of specifying preview status per SRP for the VFX package : the VFX Graph is fully supported with HDRP-only (and HDRP supported platform) at the moment. See this thread.

    Thanks for your report !
     
    Last edited: Oct 30, 2020
    fredfu likes this.
  8. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    87
    @fredfu Not quite clear what you replaced that expression with to get around the issue. Would you mind sharing?
     
  9. fredfu

    fredfu

    Joined:
    Jul 25, 2019
    Posts:
    2
    Hi, Barliesque
    Replace these lines in the files mentioned above:
    o.VFX_VARYING_UV.x = float(id & 1);
    o.VFX_VARYING_UV.y = float((id & 2) >> 1);

    to
    o.VFX_VARYING_UV.x = float(id & 1);
    o.VFX_VARYING_UV.y = float(id & 2);
    o.VFX_VARYING_UV.y = o.VFX_VARYING_UV.y / 2f;

    or some expression that get the second bit of value id.

    But this replacements do work on Android OpenGL platform only with the simplest VFX example, just as PaulDemeulenaere said , there exists other places use this expression too. So maybe we could have some patience and confidence on Unity's VFX team, or limit graphic settings to Vulkan as we currently do.
     
  10. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    87
    Ahhh, I see. I'd tried replacing the shift right with a division, but that had no effect. So the trick is to break the operation into two lines to keep the compiler from detecting something it can convert to using bitfieldExtract.

    And indeed, that is working. Thank you!

    The project I'm working on is actually for Quest 2, so Vulkan is not an option. So, given this project would never be released publicly, and particularly since it's targeting one specific piece of hardware, I'm thinking I might be able to get away with using VFX Graph for some fancy particle effects I couldn't pull off with Shuriken. Does that sound crazy?
     
    Last edited: Nov 18, 2020
    Desoxi likes this.
  11. Desoxi

    Desoxi

    Joined:
    Apr 12, 2015
    Posts:
    191
    Wow these few lines not only fixed my infinite stretch issue but also greatly increased the performance on the Quest 1. While previously I've had weird fps drops below 40 when looking down at the origin now it works smoothly at stable 72 fps. I really hope unity fixes this soon at least for VR devices.

    Thanks for the fix @fredfu !
     
  12. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    87
    @PaulDemeulenaere @fredfu @Desoxi
    Not sure what's happened, but the Package Manager is now aggressively overwriting my changes to those template files. Is there any way to stop that from happening? Was there a behind-the-scenes update to the Package Manager to ensure packages aren't modified?
     
  13. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    464
    Is your package in the Library/PackageCache folder of your project? If so, I believe you might need to move it to your Packages folder (at the same level with Assets and Library) to modify it.
     
  14. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    87
    @VladVNeykov
    Ah ha! Yes, that solved it. I hadn't realized you could move packages from the cache into that folder. Strange I was able to get away with changes to the cache version for so long!

    Thanks for the fix Vlad!
     
    Last edited: Dec 4, 2020
    VladVNeykov likes this.
  15. Rich-Ter

    Rich-Ter

    Joined:
    Jan 26, 2018
    Posts:
    1
    Tried the @fredfu solution, didn't work for me, in the player settings we set to Vulkan first and second to OpenGLES3
    My Android (Oneplus7Pro) works fine
    My Partner old Android LG-V20 has lines
    SAMSUNG A71 works fine
    Tried to replace the order when OpenGL is first and Vulkan is second, it made it appear on my android as well.
    Using Unity 2019.3.14f URP
    We saw that Google is supporting Android API 27 which is higher then the old versions that not support the Vulkan, so we in the clear, but still wanted to make sure if we are going to encounter problems from clients.
     
  16. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    87
    Since Vulkan support isn't ready for Quest I've removed it from the list entirely; I'm using minimum Android API level 24. I had success applying fredfu's solution to Visual Effect Graph v.8.2.0
    Given you're having mixed results on different Android devices, my guess would be removing Vulkan might work for you.
     
  17. Voronoi

    Voronoi

    Joined:
    Jul 2, 2012
    Posts:
    396
    I can't find the discussion where this was brought up, but the fix is to use a Mesh emitter, instead of Quads, or in my case a Cube emmitter. The thread seemed to say nothing works except for a Mesh emitter right now. I just selected a Cube in the Mesh emitter and this went away.
     
    Barliesque likes this.
  18. amelia136

    amelia136

    Joined:
    Jun 30, 2021
    Posts:
    1
    This same issue happened with me also, then I tried all the solutions mentioned in this post to fix Vertical Lines. It really worked for me. Thanks a lot!
     
unityunity