Michael Ludwig | bf58add | 2021-03-16 10:40:11 -0400 | [diff] [blame] | 1 | #include <metal_stdlib> |
2 | #include <simd/simd.h> | ||||
3 | using namespace metal; | ||||
John Stiles | 639e812 | 2021-05-24 10:52:23 -0400 | [diff] [blame] | 4 | struct Uniforms { |
John Stiles | ed2baba | 2021-09-20 19:09:13 -0400 | [diff] [blame^] | 5 | float4 colorGreen; |
6 | float4 colorRed; | ||||
John Stiles | 639e812 | 2021-05-24 10:52:23 -0400 | [diff] [blame] | 7 | }; |
John Stiles | aeae3a5 | 2020-09-25 13:35:58 -0400 | [diff] [blame] | 8 | struct Inputs { |
9 | }; | ||||
10 | struct Outputs { | ||||
11 | float4 sk_FragColor [[color(0)]]; | ||||
12 | }; | ||||
John Stiles | 639e812 | 2021-05-24 10:52:23 -0400 | [diff] [blame] | 13 | fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { |
John Stiles | f7410bd | 2021-01-19 13:07:55 -0500 | [diff] [blame] | 14 | Outputs _out; |
John Stiles | 3727917 | 2021-01-21 22:24:28 -0500 | [diff] [blame] | 15 | (void)_out; |
John Stiles | ed2baba | 2021-09-20 19:09:13 -0400 | [diff] [blame^] | 16 | float4 color; |
17 | switch (int(_uniforms.colorGreen.y)) { | ||||
John Stiles | aeae3a5 | 2020-09-25 13:35:58 -0400 | [diff] [blame] | 18 | case 0: |
John Stiles | ed2baba | 2021-09-20 19:09:13 -0400 | [diff] [blame^] | 19 | color = _uniforms.colorRed; |
John Stiles | d288d8b | 2021-09-20 21:56:26 +0000 | [diff] [blame] | 20 | break; |
John Stiles | aeae3a5 | 2020-09-25 13:35:58 -0400 | [diff] [blame] | 21 | case 1: |
John Stiles | ed2baba | 2021-09-20 19:09:13 -0400 | [diff] [blame^] | 22 | color = _uniforms.colorGreen; |
John Stiles | d288d8b | 2021-09-20 21:56:26 +0000 | [diff] [blame] | 23 | break; |
John Stiles | aeae3a5 | 2020-09-25 13:35:58 -0400 | [diff] [blame] | 24 | default: |
John Stiles | ed2baba | 2021-09-20 19:09:13 -0400 | [diff] [blame^] | 25 | color = _uniforms.colorRed; |
26 | break; | ||||
John Stiles | aeae3a5 | 2020-09-25 13:35:58 -0400 | [diff] [blame] | 27 | } |
John Stiles | ed2baba | 2021-09-20 19:09:13 -0400 | [diff] [blame^] | 28 | _out.sk_FragColor = color; |
John Stiles | f7410bd | 2021-01-19 13:07:55 -0500 | [diff] [blame] | 29 | return _out; |
John Stiles | aeae3a5 | 2020-09-25 13:35:58 -0400 | [diff] [blame] | 30 | } |