I am trying to use shader modifiers with Metal. I can't figure out to declare a form ... So far, my fragment modifier is:
#pragma arguments
float4x4 u_color_transformation;
#pragma body
_output.color.rgb = vec3(1.0) - (u_color_transformation * _output.color).rgb;
This displays a purple texture without a log. If I only _output.color.rgb = (u_color_transformation * _output.color).rgb, everything is in order. I think I follow the doc , but maybe not!
Unit is set using:
material.shaderModifiers =
[ SCNShaderModifierEntryPoint.fragment: theShaderAbove ]
material.setValue(NSValue(mat4: GLKMatrix4Identity), forKey: "u_color_transformation")
It all worked great with openGL
Update:
Apparently, SceneKit shader modifiers use glsl code and take care of converting it to metal. So I changed the shader as follows:
#pragma arguments
uniform mat4 u_color_transformation;
#pragma body
_output.color.rgb = vec3(1.0) - (u_color_transformation * _output.color).rgb;
(, ), , u_color_transformation , , .