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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Android Support <VisualEffectGraph>

Discussion in 'Editor & General Support' started by Arcalise, Aug 1, 2021.

  1. Arcalise

    Arcalise

    Joined:
    Sep 27, 2019
    Posts:
    20
    Hey all. I had a quick question about the visual effects graph on URP. It seems like based on my searches visual effect graph does work on mobile. There are some limitations it seems but it works. However, Upon creating a brand new URP project, switching it to android and adding a visual effect graph(selecting all defaults for everything) I get a bunch of errors. Although it seems like the graph works fine in the editor, the shades will throw errors if you hit compile on the VFX graph/ or you try to build the project.

    Shader error in '[New VFX] [System] Initialize Particle': syntax error: unexpected token '#' at kernel CSMain at Project/Library/PackageCache/com.unity.visualeffectgraph@12.0.0/Shaders/VFXCommon.hlsl(123) (on gles3)


    I tested this both on 2021.2.0b4 and 2021.2.0b5.

    I'm downloading an LTS build to try. If I've looked over something simple as to why it doesn't work please feel free to correct me. If visual effects graph needs further setup, it seems like it should default to a working template when on an android build mode.
     
    Last edited: Aug 1, 2021
    Kogar likes this.
  2. Arcalise

    Arcalise

    Joined:
    Sep 27, 2019
    Posts:
    20
    It actually looks like this issue doesnt occur on 2020.3.15f2. So there might be something going on in the new versions
     
  3. Kogar

    Kogar

    Joined:
    Jun 27, 2013
    Posts:
    80
    Same problem on 2021.2.0f1 . URP, Android and VFX do not seem to work together. On Windows build it is working fine.

    Just creating a default VFX Graph i am getting the same error on the android build.

    Initialize Particle': syntax error: unexpected token '#' at kernel CSMain at /Library/PackageCache/com.unity.visualeffectgraph@12.1.0/Shaders/VFXCommon.hlsl(136) (on gles3)

    Didn't happen on 2021.1.21f1 too.
     
  4. Fingerbob

    Fingerbob

    Joined:
    Sep 6, 2014
    Posts:
    24
    I've bugged this :
    Case 1377463

    The problem appears to be in two places:
    Packages\com.unity.visualeffectgraph@12.1.0\Shaders\VFXCommon.hlsl
    two functions cause the issue.
    line 134 ish : float4 SampleTexture(VFXSamplerCubeArray s, float3 coords, float slice)
    and line 161 ish : float4 SampleTexture(VFXSamplerCubeArray s, float3 coords, float slice, float level)

    both use macros the first uses SAMPLE_TEXTURE_CUBE_ARRAY and the second uses SAMPLE_TEXTURE_CUBE_ARRAY_LOD

    in the URP core code, these macros get translated into ERROR_UNSUPPORTED_FUNCTION macro, which is defined in Packages\com.unity.render-pipelines.core@12.1.0\ShaderLibrary\API\GLES3.hlsl
    as
    #define ERROR_ON_UNSUPPORTED_FUNCTION(funcName) #error #funcName is not supported on GLES 3.0

    however, you can't just slap "#error" after a "return" in the code, so it just doesn't work.

    a fix I've tested is:
    1. copy the VFX package completely from <PROJECT>\Library\PackageCache\com.unity.shadergraph@12.1.0
    2. paste it into <PROJECT>\Assets\Packages\...

    you can then modify the source.
    around line 136, replace the line that calls SAMPLE_TEXTURE_CUBE_ARRAY with
    return float4(0,0,0,0);

    and the same around line 163.

    this will obviously fail on effect graphs that use 3D textures, but it should at least allow your graphs to compile.