I have the following code below, and it generates the following render. I am using a texture test image, and it looks like its just taking the bottom row of pixels of that image and repeating then. It looks like its correctly applied to the edge it starts on, at least. Any ideas?
// Create a sampler object
let samplerDescriptor = MTLSamplerDescriptor()
samplerDescriptor.minFilter = .linear
samplerDescriptor.magFilter = .linear
samplerDescriptor.mipFilter = .linear
samplerDescriptor.sAddressMode = .clampToEdge
samplerDescriptor.tAddressMode = .clampToEdge
textureSamplerState = device.makeSamplerState(descriptor: samplerDescriptor)!
// TEXTURES
let textureLoader = MTKTextureLoader(device: device)
try! textures.append(textureLoader.newTexture(name: "test", scaleFactor: 1.0, bundle: nil, options: nil))
My shader is:
fragment float4 fragmentShader(VertexOut vertexOut [[stage_in]],
metal::texture2d<float> texture [[texture(0)]],
metal::sampler textureSampler [[sampler(0)]])
{
float4 color = texture.sample(textureSampler, vertexOut.texCoord);
return color;
}