mirror of
https://github.com/GayPizzaSpecifications/voxelotl-engine.git
synced 2025-08-03 13:11:33 +00:00
compile metal in cmake
This commit is contained in:
45
Sources/Voxelotl/shader.metal
Normal file
45
Sources/Voxelotl/shader.metal
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef SHADERTYPES_H
|
||||
#define SHADERTYPES_H
|
||||
|
||||
#ifdef __METAL_VERSION__
|
||||
# define NS_ENUM(TYPE, NAME) enum NAME : TYPE NAME; enum NAME : TYPE
|
||||
# define NSInteger metal::int32_t
|
||||
#else
|
||||
# import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#include <simd/simd.h>
|
||||
|
||||
typedef NS_ENUM(NSInteger, ShaderInputIdx) {
|
||||
ShaderInputIdxVertices = 0
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
vector_float4 position;
|
||||
vector_float4 color;
|
||||
} ShaderVertex;
|
||||
|
||||
#endif//SHADERTYPES_H
|
||||
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct FragmentInput {
|
||||
float4 position [[position]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
vertex FragmentInput vertexMain(
|
||||
uint vertexID [[vertex_id]],
|
||||
device const ShaderVertex* vtx [[buffer(ShaderInputIdxVertices)]]
|
||||
) {
|
||||
FragmentInput out;
|
||||
out.position = vtx[vertexID].position;
|
||||
out.color = vtx[vertexID].color;
|
||||
return out;
|
||||
}
|
||||
|
||||
fragment float4 fragmentMain(FragmentInput in [[stage_in]]) {
|
||||
return in.color;
|
||||
}
|
Reference in New Issue
Block a user