Android Support <VisualEffectGraph>

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.

1 Like

It actually looks like this issue doesnt occur on 2020.3.15f2. So there might be something going on in the new versions

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.

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 \Library\PackageCache\com.unity.shadergraph@12.1.0
  2. paste it into \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.