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.
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)
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:
copy the VFX package completely from \Library\PackageCache\com.unity.shadergraph@12.1.0
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.