Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
folium-app
GitHub Repository: folium-app/Folium
Path: blob/a-new-beginning/Folium-iOS/Shaders/Guava.metal
2 views
//
//  Guava.metal
//  Folium-iOS
//
//  Created by Jarrod Norwell on 12/9/2025.
//

#include <metal_stdlib>
using namespace metal;

struct Vertex {
    float2 position [[attribute(0)]];
    float2 texcoord [[attribute(1)]];
};

struct Varying {
    float4 position [[position]];
    float2 texcoord;
};

vertex Varying guava_vertex_main(const device Vertex *vertices [[buffer(0)]], uint vid [[vertex_id]]) {
    Varying out;
    out.position = float4(vertices[vid].position, 0.0, 1.0);
    out.texcoord = vertices[vid].texcoord;
    return out;
}

fragment float4 guava_fragment_main(Varying in [[stage_in]],
                              texture2d<half> tex [[texture(0)]],
                              sampler samp [[sampler(0)]]) {
    constexpr sampler s(coord::normalized, address::clamp_to_edge, filter::nearest);
    half4 c = tex.sample(s, in.texcoord);
    return float4(c);
}