2023-08-02 04:36:07 +02:00
|
|
|
#include <metal_stdlib>
|
|
|
|
|
|
|
|
using namespace metal;
|
|
|
|
|
2023-08-03 01:56:59 +02:00
|
|
|
constant float2 quadVertices[] = {
|
|
|
|
float2(-1, -1),
|
|
|
|
float2(-1, 1),
|
|
|
|
float2( 1, 1),
|
|
|
|
float2(-1, -1),
|
|
|
|
float2( 1, 1),
|
|
|
|
float2( 1, -1)
|
2023-08-02 04:36:07 +02:00
|
|
|
};
|
|
|
|
|
2023-08-03 01:56:59 +02:00
|
|
|
struct CopyVertexOut {
|
|
|
|
float4 position [[position]];
|
|
|
|
float2 uv;
|
|
|
|
};
|
|
|
|
|
|
|
|
vertex CopyVertexOut vertexMain(unsigned short vid [[vertex_id]]) {
|
|
|
|
float2 position = quadVertices[vid];
|
|
|
|
|
|
|
|
CopyVertexOut out;
|
|
|
|
|
|
|
|
out.position = float4(position, 0, 1);
|
|
|
|
out.uv = position * 0.5f + 0.5f;
|
|
|
|
|
|
|
|
return out;
|
2023-08-02 04:36:07 +02:00
|
|
|
}
|
|
|
|
|
2023-08-03 01:56:59 +02:00
|
|
|
fragment float4 fragmentMain(CopyVertexOut in [[stage_in]],
|
|
|
|
texture2d<float> tex) {
|
|
|
|
constexpr sampler sam(min_filter::nearest, mag_filter::nearest, mip_filter::none);
|
|
|
|
|
|
|
|
float3 color = tex.sample(sam, in.uv).xyz;
|
|
|
|
return float4(color, 1.0f);
|
2023-08-02 04:36:07 +02:00
|
|
|
}
|