Which attribute should I use to know which eye in the fragment shader?

Hi, I have an app based on Metal and it runs on VisionOS. It has a huge sphere mesh and renders video outputs (from AVPlayer) on it. What I want to do is rendering left portion of my video output on left eye, and right portion of my video output on right eye. In my fragment shader, I think I need to know that the thread in shader is for left eye or right eye. (I'm not using MV-hevc encoded video but just hevc encoded one) So, what I currently do is, I assume 'amplification_id' is for the thing which determines the side of eyes. But, I'm not sure this is correct.

I am trying how to specify different material texture based on which eye is being rendered. Did you even figure this out?

Elsewhere in the forum under a discussion of WWDC 23 "Discover Metal for Spatial Computing" there is a link to some GitHub sample code provided by indie developers.

In particular, this sample illustrates how to pass eye-specific parameters to a shader:

github.com/musesum/SpatialMetal2

My recommendation is to modify the Uniforms struct in ShaderTypes.h to include whatever eye specific data you require:

struct Uniforms {
    matrix_float4x4 projection;
    matrix_float4x4 viewModel;
};

struct UniformEyes {
    Uniforms eye[2];
};

Unfortunately this sample code uses parallel declarations of these structs which, to my knowledge, is not the correct way to pass structs from Swift to Metal. Structs that are destined for use in Metal must be declared in the C-language and imported into Swift using the Bridging header. Swift can reorder struct members and may use different rules for padding and alignment.

To that end your solution should probably be based off the Xcode template with modifications which have the same functionality as this sample.

Which attribute should I use to know which eye in the fragment shader?
 
 
Q