cube defender of the polyverse

This commit is contained in:
2024-08-05 20:09:33 +10:00
parent 5aab9ec831
commit c0393e2687
6 changed files with 249 additions and 25 deletions

View File

@ -6,7 +6,8 @@ using namespace metal;
struct FragmentInput {
float4 position [[position]];
float4 color;
float4 normal;
float2 texCoord;
};
vertex FragmentInput vertexMain(
@ -14,11 +15,18 @@ vertex FragmentInput vertexMain(
device const ShaderVertex* vtx [[buffer(ShaderInputIdxVertices)]]
) {
FragmentInput out;
out.position = vtx[vertexID].position;
out.color = vtx[vertexID].color;
out.position = vtx[vertexID].position * float4(0.5, 0.5, 0.5, 1.0);
out.normal = vtx[vertexID].normal;
out.texCoord = vtx[vertexID].texCoord;
return out;
}
fragment float4 fragmentMain(FragmentInput in [[stage_in]]) {
return in.color;
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);
}