I am trying to pass GLKVector4to a shader, which should get it as vec4. I use the fragment shader modifier:
material.shaderModifiers = [ SCNShaderModifierEntryPoint.fragment: shaderModifier ]
where shaderModifier:
// color changes
uniform float colorModifier;
uniform vec4 colorOffset;
vec4 color = _output.color;
color = color + colorOffset;
color = color + vec4(0.0, colorModifier, 0.0, 0.0);
_output.color = color;
(I just add color offset) I tried:
material.setValue(GLKVector4(v: (250.0, 0.0, 0.0, 0.0)), "colorOffset")
which does not work (no offset is added, and the shader uses the default value (0, 0, 0, 0)). The same thing happens if I replaced GLKVector4withSCNVector4
Following this , I also tried:
let points: [float2] = [float2(250.0), float2(0.0), float2(0.0), float2(0.0)]
material.setValue(NSData(bytes: points, length: points.count * sizeof(float2)), "colorOffset")
However, I can easily pass the float value to a uniform colorModifierone by doing:
material.setValue(250.0, forKey: "colorModifier")
and this will increase the green channel as excluded