blob: 5a500d262081d8a60323986c7637b8260de2031c [file] [log] [blame]
#include <metal_stdlib>
using namespace metal;
template<typename T, size_t N>
struct tint_array {
const constant T& operator[](size_t i) const constant { return elements[i]; }
device T& operator[](size_t i) device { return elements[i]; }
const device T& operator[](size_t i) const device { return elements[i]; }
thread T& operator[](size_t i) thread { return elements[i]; }
const thread T& operator[](size_t i) const thread { return elements[i]; }
threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
T elements[N];
};
struct LeftOver_packed_vec3 {
/* 0x0000 */ float time;
/* 0x0004 */ uint padding;
/* 0x0008 */ tint_array<int8_t, 8> tint_pad;
/* 0x0010 */ float4x4 worldViewProjection;
/* 0x0050 */ float2 outputSize;
/* 0x0058 */ float2 stageSize;
/* 0x0060 */ float2 spriteMapSize;
/* 0x0068 */ float stageScale;
/* 0x006c */ float spriteCount;
/* 0x0070 */ packed_float3 colorMul;
/* 0x007c */ tint_array<int8_t, 4> tint_pad_1;
};
struct tint_module_vars_struct {
const constant LeftOver_packed_vec3* x_20;
texture2d<float, access::sample> frameMapTexture;
sampler frameMapSampler;
thread float2* tUV;
texture2d<float, access::sample> tileMapsTexture0;
sampler tileMapsSampler;
texture2d<float, access::sample> tileMapsTexture1;
texture2d<float, access::sample> animationMapTexture;
sampler animationMapSampler;
thread float* mt;
texture2d<float, access::sample> spriteSheetTexture;
sampler spriteSheetSampler;
thread float4* glFragColor;
thread float2* tileID_1;
thread float2* levelUnits;
thread float2* stageUnits_1;
thread float3* vPosition;
thread float2* vUV;
};
#define TINT_ISOLATE_UB(VOLATILE_NAME) \
volatile bool VOLATILE_NAME = true; \
if (VOLATILE_NAME)
struct main_out {
float4 glFragColor_1;
};
struct tint_symbol_outputs {
float4 main_out_glFragColor_1 [[color(0)]];
};
struct tint_symbol_inputs {
float2 tUV_param [[user(locn2)]];
float2 tileID_1_param [[user(locn5)]];
float2 levelUnits_param [[user(locn4)]];
float2 stageUnits_1_param [[user(locn3)]];
float3 vPosition_param [[user(locn0)]];
float2 vUV_param [[user(locn1)]];
};
float4x4 getFrameData_f1_(thread float* const frameID, tint_module_vars_struct tint_module_vars) {
float fX = 0.0f;
float const x_15 = (*frameID);
float const x_25 = (*tint_module_vars.x_20).spriteCount;
fX = (x_15 / x_25);
float const x_37 = fX;
float2 const v = float2(x_37, 0.0f);
float4 const x_40 = tint_module_vars.frameMapTexture.sample(tint_module_vars.frameMapSampler, v, bias(0.0f));
float const x_44 = fX;
float2 const v_1 = float2(x_44, 0.25f);
float4 const x_47 = tint_module_vars.frameMapTexture.sample(tint_module_vars.frameMapSampler, v_1, bias(0.0f));
float const x_51 = fX;
float2 const v_2 = float2(x_51, 0.5f);
float4 const x_54 = tint_module_vars.frameMapTexture.sample(tint_module_vars.frameMapSampler, v_2, bias(0.0f));
float4 const v_3 = float4(x_40[0u], x_40[1u], x_40[2u], x_40[3u]);
float4 const v_4 = float4(x_47[0u], x_47[1u], x_47[2u], x_47[3u]);
return float4x4(v_3, v_4, float4(x_54[0u], x_54[1u], x_54[2u], x_54[3u]), float4(0.0f));
}
void main_1(tint_module_vars_struct tint_module_vars) {
float4 color = 0.0f;
float2 tileUV = 0.0f;
float2 tileID = 0.0f;
float2 sheetUnits = 0.0f;
float spriteUnits = 0.0f;
float2 stageUnits = 0.0f;
int i = 0;
float frameID_1 = 0.0f;
float4 animationData = 0.0f;
float f = 0.0f;
float4x4 frameData = float4x4(0.0f);
float param = 0.0f;
float2 frameSize = 0.0f;
float2 offset_1 = 0.0f;
float2 ratio = 0.0f;
float4 nc = 0.0f;
float alpha = 0.0f;
float3 mixed = 0.0f;
color = float4(0.0f);
float2 const x_86 = (*tint_module_vars.tUV);
tileUV = fract(x_86);
float const x_91 = tileUV[1u];
tileUV[1u] = (1.0f - x_91);
float2 const x_95 = (*tint_module_vars.tUV);
tileID = floor(x_95);
float2 const x_101 = (*tint_module_vars.x_20).spriteMapSize;
sheetUnits = (float2(1.0f) / x_101);
float const x_106 = (*tint_module_vars.x_20).spriteCount;
spriteUnits = (1.0f / x_106);
float2 const x_111 = (*tint_module_vars.x_20).stageSize;
stageUnits = (float2(1.0f) / x_111);
i = 0;
{
TINT_ISOLATE_UB(tint_volatile_true) while(true) {
int const x_122 = i;
if ((x_122 < 2)) {
} else {
break;
}
int const x_126 = i;
switch(x_126) {
case 1:
{
float2 const x_150 = tileID;
float2 const x_154 = (*tint_module_vars.x_20).stageSize;
float4 const x_156 = tint_module_vars.tileMapsTexture1.sample(tint_module_vars.tileMapsSampler, ((x_150 + float2(0.5f)) / x_154), bias(0.0f));
frameID_1 = x_156[0u];
break;
}
case 0:
{
float2 const x_136 = tileID;
float2 const x_140 = (*tint_module_vars.x_20).stageSize;
float4 const x_142 = tint_module_vars.tileMapsTexture0.sample(tint_module_vars.tileMapsSampler, ((x_136 + float2(0.5f)) / x_140), bias(0.0f));
frameID_1 = x_142[0u];
break;
}
default:
{
break;
}
}
float const x_166 = frameID_1;
float const x_169 = (*tint_module_vars.x_20).spriteCount;
float2 const v_5 = float2(((x_166 + 0.5f) / x_169), 0.0f);
float4 const x_172 = tint_module_vars.animationMapTexture.sample(tint_module_vars.animationMapSampler, v_5, bias(0.0f));
animationData = x_172;
float const x_174 = animationData[1u];
if ((x_174 > 0.0f)) {
float const x_181 = (*tint_module_vars.x_20).time;
float const x_184 = animationData[2u];
(*tint_module_vars.mt) = fmod((x_181 * x_184), 1.0f);
f = 0.0f;
{
TINT_ISOLATE_UB(tint_volatile_true_1) while(true) {
float const x_193 = f;
if ((x_193 < 8.0f)) {
} else {
break;
}
float const x_197 = animationData[1u];
float const x_198 = (*tint_module_vars.mt);
if ((x_197 > x_198)) {
float const x_203 = animationData[0u];
frameID_1 = x_203;
break;
}
float const x_208 = frameID_1;
float const x_211 = (*tint_module_vars.x_20).spriteCount;
float const x_214 = f;
float4 const x_217 = float4(0.0f);
animationData = x_217;
{
float const x_218 = f;
f = (x_218 + 1.0f);
}
continue;
}
}
}
float const x_222 = frameID_1;
param = (x_222 + 0.5f);
float4x4 const x_225 = getFrameData_f1_((&param), tint_module_vars);
frameData = x_225;
float4 const x_228 = frameData[0];
float2 const x_231 = (*tint_module_vars.x_20).spriteMapSize;
frameSize = (float2(x_228[3u], x_228[2u]) / x_231);
float4 const x_235 = frameData[0];
float2 const x_237 = sheetUnits;
offset_1 = (float2(x_235[0u], x_235[1u]) * x_237);
float4 const x_241 = frameData[2];
float4 const x_244 = frameData[0];
float2 const v_6 = float2(x_241[0u], x_241[1u]);
ratio = (v_6 / float2(x_244[3u], x_244[2u]));
float const x_248 = frameData[2][2u];
if ((x_248 == 1.0f)) {
float2 const x_252 = tileUV;
tileUV = float2(x_252[1u], x_252[0u]);
}
int const x_254 = i;
if ((x_254 == 0)) {
float2 const x_263 = tileUV;
float2 const x_264 = frameSize;
float2 const x_266 = offset_1;
float4 const x_268 = tint_module_vars.spriteSheetTexture.sample(tint_module_vars.spriteSheetSampler, ((x_263 * x_264) + x_266));
color = x_268;
} else {
float2 const x_274 = tileUV;
float2 const x_275 = frameSize;
float2 const x_277 = offset_1;
float4 const x_279 = tint_module_vars.spriteSheetTexture.sample(tint_module_vars.spriteSheetSampler, ((x_274 * x_275) + x_277));
nc = x_279;
float const x_283 = color[3u];
float const x_285 = nc[3u];
alpha = min((x_283 + x_285), 1.0f);
float4 const x_290 = color;
float4 const x_292 = nc;
float const x_295 = nc[3u];
float3 const v_7 = float3(x_290[0u], x_290[1u], x_290[2u]);
float3 const v_8 = float3(x_292[0u], x_292[1u], x_292[2u]);
mixed = mix(v_7, v_8, float3(x_295, x_295, x_295));
float3 const x_298 = mixed;
float const x_299 = alpha;
color = float4(x_298[0u], x_298[1u], x_298[2u], x_299);
}
{
int const x_304 = i;
i = as_type<int>((as_type<uint>(x_304) + as_type<uint>(1)));
}
continue;
}
}
float3 const x_310 = float3((*tint_module_vars.x_20).colorMul);
float4 const x_311 = color;
float3 const x_313 = (float3(x_311[0u], x_311[1u], x_311[2u]) * x_310);
float4 const x_314 = color;
color = float4(x_313[0u], x_313[1u], x_313[2u], x_314[3u]);
float4 const x_318 = color;
(*tint_module_vars.glFragColor) = x_318;
}
main_out tint_symbol_inner(float2 tUV_param, float2 tileID_1_param, float2 levelUnits_param, float2 stageUnits_1_param, float3 vPosition_param, float2 vUV_param, tint_module_vars_struct tint_module_vars) {
(*tint_module_vars.tUV) = tUV_param;
(*tint_module_vars.tileID_1) = tileID_1_param;
(*tint_module_vars.levelUnits) = levelUnits_param;
(*tint_module_vars.stageUnits_1) = stageUnits_1_param;
(*tint_module_vars.vPosition) = vPosition_param;
(*tint_module_vars.vUV) = vUV_param;
main_1(tint_module_vars);
return main_out{.glFragColor_1=(*tint_module_vars.glFragColor)};
}
fragment tint_symbol_outputs tint_symbol(tint_symbol_inputs inputs [[stage_in]], const constant LeftOver_packed_vec3* x_20 [[buffer(0)]], texture2d<float, access::sample> frameMapTexture [[texture(3)]], sampler frameMapSampler [[sampler(2)]], texture2d<float, access::sample> tileMapsTexture0 [[texture(1)]], sampler tileMapsSampler [[sampler(0)]], texture2d<float, access::sample> tileMapsTexture1 [[texture(0)]], texture2d<float, access::sample> animationMapTexture [[texture(2)]], sampler animationMapSampler [[sampler(1)]], texture2d<float, access::sample> spriteSheetTexture [[texture(4)]], sampler spriteSheetSampler [[sampler(3)]]) {
thread float2 tUV = 0.0f;
thread float mt = 0.0f;
thread float4 glFragColor = 0.0f;
thread float2 tileID_1 = 0.0f;
thread float2 levelUnits = 0.0f;
thread float2 stageUnits_1 = 0.0f;
thread float3 vPosition = 0.0f;
thread float2 vUV = 0.0f;
tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.x_20=x_20, .frameMapTexture=frameMapTexture, .frameMapSampler=frameMapSampler, .tUV=(&tUV), .tileMapsTexture0=tileMapsTexture0, .tileMapsSampler=tileMapsSampler, .tileMapsTexture1=tileMapsTexture1, .animationMapTexture=animationMapTexture, .animationMapSampler=animationMapSampler, .mt=(&mt), .spriteSheetTexture=spriteSheetTexture, .spriteSheetSampler=spriteSheetSampler, .glFragColor=(&glFragColor), .tileID_1=(&tileID_1), .levelUnits=(&levelUnits), .stageUnits_1=(&stageUnits_1), .vPosition=(&vPosition), .vUV=(&vUV)};
tint_symbol_outputs tint_wrapper_result = {};
tint_wrapper_result.main_out_glFragColor_1 = tint_symbol_inner(inputs.tUV_param, inputs.tileID_1_param, inputs.levelUnits_param, inputs.stageUnits_1_param, inputs.vPosition_param, inputs.vUV_param, tint_module_vars).glFragColor_1;
return tint_wrapper_result;
}