determining a texture pixel format from fragment function

I have a simple fragment shader that supports sampling a texture, and tinting the output with another color. Inputs to this shader can include both rgba content (which will get tinted by the color) and single channel content which should just get colorized by the tint color.


The rgba content is being encoded with pixelformat of MTLPixelFormatRGBA8Unorm. In the fragment shader, the sampled color appears to be (r,g,b,a)... al good so far.


The single channel content is being encoded with pixelformat of MTLPixelFormatR8Unorm. In the fragment shader, the sampled color appears to be (red,0,0,0).


Is there a way to setup the shader to behave more like opengl and splat that value to all channels (red,red,red,red)?

Is there any way to determine the texture's pixel format in the shader?

Do I have to set things up to have two different pipelines for these two formats?


Thanks, mike.

determining a texture pixel format from fragment function
 
 
Q