#include #include using namespace metal; struct type_Uniforms { float4 viewPos; float4 lightPosition; float4 directionalLight; float4 directionalLightColor; float2 screenSize; float lightPower; float time; }; struct Scene { float4x4 Model; uint textureMode; int animation; uint flags; float float0; }; struct type_StructuredBuffer_Scene { Scene _m0[1]; }; constant float4 _92 = {}; constant float3 _94 = {}; struct main0_out { float4 out_var_SV_Target0 [[color(0)]]; float4 out_var_SV_Target1 [[color(1)]]; float4 out_var_SV_Target2 [[color(2)]]; float4 out_var_SV_Target3 [[color(3)]]; }; struct main0_in { float2 in_var_TEXCOORD0 [[user(locn0)]]; float3 in_var_TEXCOORD1 [[user(locn1)]]; float3 in_var_TEXCOORD2 [[user(locn2)]]; float4 in_var_TEXCOORD3 [[user(locn3)]]; uint in_var_TEXCOORD4 [[user(locn4)]]; float3 in_var_TEXCOORD5 [[user(locn5)]]; }; fragment main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], const device type_StructuredBuffer_Scene& scene [[buffer(1)]], texture2d Texture0 [[texture(0)]], texture2d Texture1 [[texture(1)]], texture2d Texture2 [[texture(2)]], texture2d DirectionalShadowDepthMap [[texture(3)]], sampler Sampler0 [[sampler(0)]], sampler Sampler1 [[sampler(1)]], sampler Sampler2 [[sampler(2)]], sampler DirectionalShadowSampler [[sampler(3)]]) { main0_out out = {}; int _104 = int(scene._m0[in.in_var_TEXCOORD4].textureMode); int _105 = _104 & 240; float4 _139; if (_105 == 16) { float3 _126 = float3(Texture0.sample(Sampler0, in.in_var_TEXCOORD0).x, Texture1.sample(Sampler1, in.in_var_TEXCOORD0).x, Texture2.sample(Sampler2, in.in_var_TEXCOORD0).x) + float3(-0.0625, -0.5, -0.5); _139 = float4(dot(_126, float3(1.164000034332275390625, 0.0, 1.7929999828338623046875)), dot(_126, float3(1.164000034332275390625, -0.212999999523162841796875, -0.53299999237060546875)), dot(_126, float3(1.164000034332275390625, 2.111999988555908203125, 0.0)), 1.0); } else { float4 _138; if (_105 == 0) { _138 = Texture0.sample(Sampler0, in.in_var_TEXCOORD0); } else { _138 = _92; } _139 = _138; } float4 _145; if ((_104 & 1) == 1) { _145 = powr(_139, float4(2.2000000476837158203125)); } else { _145 = _139; } if (_145.w < 0.00999999977648258209228515625) { discard_fragment(); } float3 _155 = float3(0.800000011920928955078125, 0.800000011920928955078125, 0.5) * Uniforms.lightPower; float3 _202; do { float3 _159 = Uniforms.lightPosition.xyz - in.in_var_TEXCOORD1; float _160 = length(_159); float _161 = _160 * _160; float _167; if (_160 > 2.0) { _167 = 0.5 / _161; } else { _167 = 1.0 / _161; } float _172; if (_160 > 4.0) { _172 = _167 * 0.5; } else { _172 = _167; } float _174 = (_160 > 15.0) ? 0.0 : _172; float _176 = (_174 > 1.0) ? 1.0 : _174; if (length(in.in_var_TEXCOORD2) < 0.100000001490116119384765625) { _202 = (in.in_var_TEXCOORD1 * _155) * _176; break; } float3 _183 = fast::normalize(_159); _202 = ((_155 * precise::max(dot(_183, in.in_var_TEXCOORD2), 0.0)) * _176) + (((_155 * powr(precise::max(dot(in.in_var_TEXCOORD2, fast::normalize(_183 + fast::normalize(in.in_var_TEXCOORD1 - Uniforms.viewPos.xyz))), 0.0), 30.0)) * 2.0) * _176); break; } while(false); float3 _219 = ((in.in_var_TEXCOORD3.xyz / float3(in.in_var_TEXCOORD3.w)) * 0.5) + float3(0.5); float3 _221; _221.x = _219.x; float2 _222 = _221.xy; _222.y = -_219.y; float _229; int _232; int _234; _229 = 0.0; _232 = 0; _234 = -2; float _230; int _233; for (; _234 <= 2; _229 = _230, _232 = _233, _234++) { _233 = _232; _230 = _229; for (int _243 = -2; _243 <= 2; ) { _233++; _230 += float((in.in_var_TEXCOORD3.z - 0.0030000000260770320892333984375) > DirectionalShadowDepthMap.sample(DirectionalShadowSampler, (_222 + float2(float(_243) * 0.000244140625, float(_234) * 0.000244140625))).x); _243++; continue; } } float3 _272; if ((_104 & 2) > 0) { _272 = powr(_145.xyz, float3(0.4545454680919647216796875)); } else { _272 = _145.xyz * ((float3(0.100000001490116119384765625) + _202) + ((Uniforms.directionalLightColor.xyz * precise::max(dot(Uniforms.directionalLight.xyz, in.in_var_TEXCOORD2), 0.0)) * (1.0 - (_229 / float(_232))))); } float4 _289; if (_272.x > 1.0) { float4 _288 = float4(0.0); _288.x = _272.x; _289 = _288; } else { _289 = float4(0.0); } float4 _294; if (_272.y > 1.0) { float4 _293 = _289; _293.y = _272.y; _294 = _293; } else { _294 = _289; } float4 _299; if (_272.z > 1.0) { float4 _298 = _294; _298.z = _272.z; _299 = _298; } else { _299 = _294; } out.out_var_SV_Target0 = float4(_272, _145.w); out.out_var_SV_Target1 = _299; out.out_var_SV_Target2 = float4(in.in_var_TEXCOORD1, 1.0); out.out_var_SV_Target3 = float4(in.in_var_TEXCOORD5, 1.0); return out; }