// language: metal1.0 #include #include using metal::uint; struct VertexInput { metal::float2 position; metal::float2 curve_uv; metal::float2 color_uv; char _pad3[8]; metal::float4 color1_; metal::float4 color2_; metal::float4 color3_; metal::float4 color4_; metal::float2 normal_uv; char _pad8[8]; metal::float3 normal1_; metal::float3 normal2_; metal::float3 normal3_; metal::float3 normal4_; }; struct VertexOutput { metal::float4 position; metal::float2 curve_uv; metal::float2 color_uv; metal::float4 color1_; metal::float4 color2_; metal::float4 color3_; metal::float4 color4_; metal::float2 normal_uv; char _pad8[8]; metal::float3 normal1_; metal::float3 normal2_; metal::float3 normal3_; metal::float3 normal4_; }; constant float SQRT_2_ = 0.70710677; float square( float in ) { return in * in; } float cube( float in_1 ) { return (in_1 * in_1) * in_1; } metal::float3 lerp( metal::float3 a, metal::float3 b, float t ) { return ((b - a) * t) + a; } metal::float3 oklab_to_linear_srgb( metal::float3 color ) { float _e10 = cube((color.x + (0.39633778 * color.y)) + (0.21580376 * color.z)); float _e20 = cube((color.x - (0.105561346 * color.y)) - (0.06385417 * color.z)); float _e30 = cube((color.x - (0.08948418 * color.y)) - (1.2914855 * color.z)); return metal::float3(((4.0767417 * _e10) - (3.3077116 * _e20)) + (0.23096994 * _e30), ((-1.268438 * _e10) + (2.6097574 * _e20)) - (0.34131938 * _e30), ((-0.0041960864 * _e10) - (0.7034186 * _e20)) + (1.7076147 * _e30)); } struct vs_mainInput { metal::float2 position [[attribute(0)]]; metal::float2 curve_uv [[attribute(1)]]; metal::float2 color_uv [[attribute(2)]]; metal::float4 color1_ [[attribute(3)]]; metal::float4 color2_ [[attribute(4)]]; metal::float4 color3_ [[attribute(5)]]; metal::float4 color4_ [[attribute(6)]]; metal::float2 normal_uv [[attribute(7)]]; metal::float3 normal1_ [[attribute(8)]]; metal::float3 normal2_ [[attribute(9)]]; metal::float3 normal3_ [[attribute(10)]]; metal::float3 normal4_ [[attribute(11)]]; }; struct vs_mainOutput { metal::float4 position [[position]]; metal::float2 curve_uv [[user(loc0), center_perspective]]; metal::float2 color_uv [[user(loc1), center_perspective]]; metal::float4 color1_ [[user(loc2), center_perspective]]; metal::float4 color2_ [[user(loc3), center_perspective]]; metal::float4 color3_ [[user(loc4), center_perspective]]; metal::float4 color4_ [[user(loc5), center_perspective]]; metal::float2 normal_uv [[user(loc6), center_perspective]]; metal::float3 normal1_ [[user(loc7), center_perspective]]; metal::float3 normal2_ [[user(loc8), center_perspective]]; metal::float3 normal3_ [[user(loc9), center_perspective]]; metal::float3 normal4_ [[user(loc10), center_perspective]]; }; vertex vs_mainOutput vs_main( vs_mainInput varyings [[stage_in]] ) { const VertexInput vertex_ = { varyings.position, varyings.curve_uv, varyings.color_uv, {}, varyings.color1_, varyings.color2_, varyings.color3_, varyings.color4_, varyings.normal_uv, {}, varyings.normal1_, varyings.normal2_, varyings.normal3_, varyings.normal4_ }; VertexOutput out = {}; out.position = metal::float4(vertex_.position, 1.0, 1.0); out.curve_uv = vertex_.curve_uv; out.color_uv = vertex_.color_uv; out.color1_ = vertex_.color1_; out.color2_ = vertex_.color2_; out.color3_ = vertex_.color3_; out.color4_ = vertex_.color4_; out.normal_uv = vertex_.normal_uv; out.normal1_ = vertex_.normal1_; out.normal2_ = vertex_.normal2_; out.normal3_ = vertex_.normal3_; out.normal4_ = vertex_.normal4_; VertexOutput _e29 = out; const auto _tmp = _e29; return vs_mainOutput { _tmp.position, _tmp.curve_uv, _tmp.color_uv, _tmp.color1_, _tmp.color2_, _tmp.color3_, _tmp.color4_, _tmp.normal_uv, _tmp.normal1_, _tmp.normal2_, _tmp.normal3_, _tmp.normal4_ }; } struct fs_mainInput { metal::float2 curve_uv [[user(loc0), center_perspective]]; metal::float2 color_uv [[user(loc1), center_perspective]]; metal::float4 color1_ [[user(loc2), center_perspective]]; metal::float4 color2_ [[user(loc3), center_perspective]]; metal::float4 color3_ [[user(loc4), center_perspective]]; metal::float4 color4_ [[user(loc5), center_perspective]]; metal::float2 normal_uv [[user(loc6), center_perspective]]; metal::float3 normal1_ [[user(loc7), center_perspective]]; metal::float3 normal2_ [[user(loc8), center_perspective]]; metal::float3 normal3_ [[user(loc9), center_perspective]]; metal::float3 normal4_ [[user(loc10), center_perspective]]; }; struct fs_mainOutput { metal::float4 member_1 [[color(0)]]; }; fragment fs_mainOutput fs_main( fs_mainInput varyings_1 [[stage_in]] , metal::float4 position [[position]] ) { const VertexOutput vertex_1 = { position, varyings_1.curve_uv, varyings_1.color_uv, varyings_1.color1_, varyings_1.color2_, varyings_1.color3_, varyings_1.color4_, varyings_1.normal_uv, {}, varyings_1.normal1_, varyings_1.normal2_, varyings_1.normal3_, varyings_1.normal4_ }; float radius = metal::length(vertex_1.curve_uv); float _e3 = metal::dfdx(radius); float _e4 = metal::dfdy(radius); float afwidth = metal::length(metal::float2(_e3, _e4)) * SQRT_2_; float in_circle = 1.0 - metal::smoothstep(1.0 - afwidth, 1.0 + afwidth, radius); metal::float3 _e22 = lerp(vertex_1.color1_.xyz, vertex_1.color2_.xyz, metal::length(vertex_1.color_uv)); metal::float3 _e23 = oklab_to_linear_srgb(_e22); metal::float3 _e32 = lerp(vertex_1.color3_.xyz, vertex_1.color4_.xyz, 1.0 - metal::length(vertex_1.color_uv)); metal::float3 _e33 = oklab_to_linear_srgb(_e32); metal::float3 _e34 = lerp(_e33, _e23, in_circle); metal::float3 _e39 = lerp(vertex_1.normal1_, vertex_1.normal2_, metal::length(vertex_1.normal_uv)); metal::float3 _e46 = lerp(vertex_1.normal3_, vertex_1.normal4_, 1.0 - metal::length(vertex_1.normal_uv)); metal::float3 _e47 = lerp(_e46, _e39, in_circle); return fs_mainOutput { metal::float4(_e34, in_circle) }; }