Reputation: 23685
Every time I attempt to write a SceneKit shader modifier, I get a pink screen and a debug screen filled with errors. According to the documents, I should be able to write a SceneKit shader modifier in glsl, but all I get is these errors like
error: use of undeclared identifier 'vec3'; did you mean 'vec'?
Huh? Why can't I use vec3?
I've tried converting all vec3 to float3 manually, like this
#pragma arguments
float3 myFunction()
{
return float3(1,1,1);
}
#pragma transparent
#pragma body
float3 myVar = myFunction();
but then I just get an error like
[SceneKit] Error: FATAL ERROR : failed compiling shader:
Error Domain=MTLLibraryErrorDomain Code=3 "Compilation failed:
program_source:2847:41: error: expected parameter declarator
, constant return& float3
^
program_source:2847:50: error: expected ')'
, constant return& float3
^
program_source:2732:38: note: to match this '('
fragment SCNOutput commonprofile_frag(commonprofile_io in [[ stage_in ]]
^
program_source:3340:2: error: expected function body after function declarator
}
^
" UserInfo={NSLocalizedDescription=Compilation failed:
program_source:2847:41: error: expected parameter declarator
, constant return& float3
^
program_source:2847:50: error: expected ')'
, constant return& float3
^
program_source:2732:38: note: to match this '('
fragment SCNOutput commonprofile_frag(commonprofile_io in [[ stage_in ]]
^
program_source:3340:2: error: expected function body after function declarator
}
^
}
2019-08-31 20:30:28.724039-0700 zLab[3725:903320] [SceneKit] Error: FATAL ERROR : failed compiling shader:
Error Domain=MTLLibraryErrorDomain Code=3 "Compilation failed:
program_source:2847:41: error: expected parameter declarator
, constant return& float3
^
program_source:2847:50: error: expected ')'
, constant return& float3
^
program_source:2732:38: note: to match this '('
fragment SCNOutput commonprofile_frag(commonprofile_io in [[ stage_in ]]
^
program_source:3340:2: error: expected function body after function declarator
}
^
" UserInfo={NSLocalizedDescription=Compilation failed:
program_source:2847:41: error: expected parameter declarator
, constant return& float3
^
program_source:2847:50: error: expected ')'
, constant return& float3
^
program_source:2732:38: note: to match this '('
fragment SCNOutput commonprofile_frag(commonprofile_io in [[ stage_in ]]
^
program_source:3340:2: error: expected function body after function declarator
}
^
}
What does all this mean? What am I doing wrong?
Upvotes: 0
Views: 436
Reputation: 13462
The #pragma arguments
directive should be used to declare parameters of the shader modifier that are set from the CPU client code.
For custom functions and helpers you can use the #pragma declaration
instruction (see also Custom Variable Declarations Using Metal With Scene Kit Shader Modifiers)
Upvotes: 2