I have a problem with Unity’s SSAO shader. I get the following warnings:
Shader warning in ‘Hidden/SSAO’: GLSL vertex shader: 335: ERROR: ‘]’ : syntax error parse error at line 60
Shader warning in ‘Hidden/SSAO’: GLSL vertex shader: 335: ERROR: ‘]’ : syntax error parse error at line 89
Shader warning in ‘Hidden/SSAO’: GLSL vertex shader: 335: ERROR: ‘]’ : syntax error parse error at line 124
Shader warning in ‘Hidden/SSAO’: GLSL vertex shader: 335: ERROR: ‘]’ : syntax error parse error at line 170
Shader warning in ‘Hidden/SSAO’: GLSL vertex shader: 335: ERROR: ‘]’ : syntax error parse error at line 243
These warnings appear whenever I have a camera with the SSAO image effect attached and create/edit another shader. What could be the problem, and how to solve it?
Not sure if this is the best solution but it works well for me. If you look towards the top of SSAOShader.shader, you will see:
#ifdef UNITY_COMPILER_HLSL
# define INPUT_SAMPLE_COUNT 8
# include "frag_ao.cginc"
# define INPUT_SAMPLE_COUNT 14
# include "frag_ao.cginc"
# define INPUT_SAMPLE_COUNT 26
# include "frag_ao.cginc"
# define INPUT_SAMPLE_COUNT 34
# include "frag_ao.cginc"
#else
# define INPUT_SAMPLE_COUNT
# include "frag_ao.cginc"
#endif
That’s the offending code. It’s shared with all the passes below. For HLSL it defines the function frag_ao multiple times with different sample counts. For GLSL it just leaves the sample count blank. GLSL seems to not like this. My fix was to break this up and move it into the passes that needed it. So for example my first pass looks like this: