mirror of
https://github.com/GayPizzaSpecifications/voxelotl-engine.git
synced 2025-08-03 13:11:33 +00:00
29 lines
855 B
Metal
29 lines
855 B
Metal
|
#include "shadertypes.h"
|
||
|
#include <metal_stdlib>
|
||
|
|
||
|
|
||
|
struct FragmentInput {
|
||
|
float4 position [[position]];
|
||
|
float2 texCoord;
|
||
|
half4 color;
|
||
|
};
|
||
|
|
||
|
vertex FragmentInput vertex2DMain(uint vertexID [[vertex_id]],
|
||
|
device const Vertex2D* vtx [[buffer(VertexShaderInputIdxVertices)]],
|
||
|
constant Shader2DUniforms& u [[buffer(VertexShaderInputIdxUniforms)]]
|
||
|
) {
|
||
|
FragmentInput out;
|
||
|
out.position = u.projection * float4(vtx[vertexID].position, 0.0, 1.0);
|
||
|
out.texCoord = vtx[vertexID].texCoord;
|
||
|
out.color = half4(vtx[vertexID].color);
|
||
|
return out;
|
||
|
}
|
||
|
|
||
|
fragment half4 fragment2DMain(FragmentInput in [[stage_in]],
|
||
|
metal::texture2d<half, metal::access::sample> texture [[texture(0)]]
|
||
|
) {
|
||
|
constexpr metal::sampler sampler(metal::address::repeat, metal::filter::linear);
|
||
|
half4 texel = texture.sample(sampler, in.texCoord);
|
||
|
return texel * in.color;
|
||
|
}
|