iOS Metal 着色器语言如何翻转 float2 中值的顺序?
iOS Metal shader language how to flip order of values inside float2?
如果我有金属着色器语言的结构:
如何访问单个结构(如 float2
)元素并翻转它们的顺序?
const float2 sampledCameraPoint = cameraSamplePatternBuffer[vertexID]; // (has x and y)
const float2 flipped = float2(?, ?) // how to get (sampledCameraPoint.y, sampledCameraPoint.x)?
您可以使用 x
、y
等访问元素,所以这应该有效:
float2 flipped = otherFloat2.yx;
如果我有金属着色器语言的结构:
如何访问单个结构(如 float2
)元素并翻转它们的顺序?
const float2 sampledCameraPoint = cameraSamplePatternBuffer[vertexID]; // (has x and y)
const float2 flipped = float2(?, ?) // how to get (sampledCameraPoint.y, sampledCameraPoint.x)?
您可以使用 x
、y
等访问元素,所以这应该有效:
float2 flipped = otherFloat2.yx;