Files
voxelotl-engine/Sources/Voxelotl/shader.metal

33 lines
751 B
Metal
Raw Normal View History

2024-08-05 00:19:49 -07:00
#include "shadertypes.h"
2024-08-05 00:08:16 -07:00
#include <metal_stdlib>
using namespace metal;
struct FragmentInput {
float4 position [[position]];
2024-08-05 20:09:33 +10:00
float4 normal;
float2 texCoord;
2024-08-05 00:08:16 -07:00
};
vertex FragmentInput vertexMain(
uint vertexID [[vertex_id]],
device const ShaderVertex* vtx [[buffer(ShaderInputIdxVertices)]]
) {
FragmentInput out;
2024-08-05 20:09:33 +10:00
out.position = vtx[vertexID].position * float4(0.5, 0.5, 0.5, 1.0);
out.normal = vtx[vertexID].normal;
out.texCoord = vtx[vertexID].texCoord;
2024-08-05 00:08:16 -07:00
return out;
}
2024-08-05 20:09:33 +10:00
fragment half4 fragmentMain(
FragmentInput in [[stage_in]],
texture2d<half, access::sample> tex [[texture(0)]]
) {
constexpr sampler s(address::repeat, filter::nearest);
half4 albedo = tex.sample(s, in.texCoord);
return half4(albedo.rgb, 1.0);
2024-08-05 00:08:16 -07:00
}