Pass interpolated values to SceneKit Fragment Shader

I have a SceneKit fragment shader where I need to make some decisions about the alpha value based on an interpolated value between the vertexes. At each vertex there is a value and I need to know what the interpolated value for the given position that the fragment shader is determining the color for. Is there a way to do this?

This is what my shader looks like.

#pragma arguments
float myInterpolatedVlaue;

#pragma transparent
#pragma body

//Sample logic.  The actual logic has more too it.
if (myInterpolatedVlaue > 1.0 ) {
    _output.color.a = 0;
}

I want to set a value at each vertex and then get the interpolated value in my fragment shader. I would like to have myInterpolatedVlaue be set based on the interpolated values from the value at each vertex.

I figured out a way to do this, though it does seem like more of a hack than a real solution. I encoded my values in the red channel of a color, I then created an image with those colors, and then I assigned texture coordinates for each vertex. That allowed me to get the correct interpolated value out in my fragment shader.

Pass interpolated values to SceneKit Fragment Shader
 
 
Q