Shader modifiers - Custom global functions not working

My shader.frag file is not working with functions like "multiply".

float time = u_time; 
float multiply(float n) { 
return n*2.0; 
}; 
vec3 color = vec3(1.0,0.0,0.0); 
_surface.diffuse = vec4( color, 1.0 );


if I remove the multiply function everything works fine. According to the documentation of SCNShadable this should be possible, shouldn't it? It doesn't work with the method described in the SCNShadable docu. https://developer.apple.com/documentation/scenekit/scnshadable


What am I doing wrong? Thank you.

Accepted Reply

Here is the solution: https://stackoverflow.com/questions/46131252/shader-modifiers-to-extend-scenekit/46154799#46154799

Replies

Here is the solution: https://stackoverflow.com/questions/46131252/shader-modifiers-to-extend-scenekit/46154799#46154799