Path: blob/a-new-beginning/Folium-iOS/Shaders/Mandarine.metal
2 views
//
// Mandarine.metal
// Folium-iOS
//
// Created by Jarrod Norwell on 1/3/2026.
//
#include <metal_stdlib>
using namespace metal;
struct VertexIn {
float2 position;
float2 texcoord;
};
struct VertexOut {
float4 position [[position]];
float2 texcoord;
};
vertex VertexOut mandarine_metal_vertex_main(
const device VertexIn* vertices [[buffer(0)]],
uint id [[vertex_id]])
{
VertexOut out;
float2 pos = vertices[id].position;
// Convert to NDC
pos.x = (pos.x / 512.0) * 2.0 - 1.0;
pos.y = 1.0 - (pos.y / 256.0) * 2.0;
out.position = float4(pos, 0, 1);
out.texcoord = vertices[id].texcoord;
return out;
}
fragment float4 mandarine_metal_fragment_main(
VertexOut in [[stage_in]],
texture2d<float> tex [[texture(0)]])
{
constexpr sampler s(address::clamp_to_edge,
filter::nearest);
return tex.sample(s, in.texcoord);
}