blob: 2ed231ba319a8d54ab3d4bd68786efc12debba6f [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];
};
#define TINT_ISOLATE_UB(VOLATILE_NAME) \
volatile bool VOLATILE_NAME = true; \
if (VOLATILE_NAME)
struct tint_private_vars_struct {
float u_Float;
float3 u_Color;
float2 vMainuv;
float4 v_output1;
bool gl_FrontFacing;
float2 v_uv;
float4 v_output2;
float4 glFragColor;
};
struct LeftOver_tint_packed_vec3 {
/* 0x0000 */ float4x4 u_World;
/* 0x0040 */ float4x4 u_ViewProjection;
/* 0x0080 */ float u_bumpStrength;
/* 0x0084 */ uint padding;
/* 0x0088 */ tint_array<int8_t, 8> tint_pad;
/* 0x0090 */ packed_float3 u_cameraPosition;
/* 0x009c */ float u_parallaxScale;
/* 0x00a0 */ float textureInfoName;
/* 0x00a4 */ uint padding_1;
/* 0x00a8 */ float2 tangentSpaceParameter0;
};
struct Light0_tint_packed_vec3 {
/* 0x0000 */ float4 vLightData;
/* 0x0010 */ float4 vLightDiffuse;
/* 0x0020 */ float4 vLightSpecular;
/* 0x0030 */ packed_float3 vLightGround;
/* 0x003c */ uint padding_2;
/* 0x0040 */ float4 shadowsInfo;
/* 0x0050 */ float2 depthValues;
/* 0x0058 */ tint_array<int8_t, 8> tint_pad_1;
};
struct lightingInfo {
float3 diffuse;
float3 specular;
};
struct LeftOver {
float4x4 u_World;
float4x4 u_ViewProjection;
float u_bumpStrength;
uint padding;
float3 u_cameraPosition;
float u_parallaxScale;
float textureInfoName;
uint padding_1;
float2 tangentSpaceParameter0;
};
struct Light0 {
float4 vLightData;
float4 vLightDiffuse;
float4 vLightSpecular;
float3 vLightGround;
uint padding_2;
float4 shadowsInfo;
float2 depthValues;
};
float3x3 cotangent_frame_vf3_vf3_vf2_vf2_(thread float3* const normal_1, thread float3* const p, thread float2* const uv, thread float2* const tangentSpaceParams) {
float3 dp1 = 0.0f;
float3 dp2 = 0.0f;
float2 duv1 = 0.0f;
float2 duv2 = 0.0f;
float3 dp2perp = 0.0f;
float3 dp1perp = 0.0f;
float3 tangent = 0.0f;
float3 bitangent = 0.0f;
float invmax = 0.0f;
float3 const x_133 = *(p);
dp1 = dfdx(x_133);
float3 const x_136 = *(p);
dp2 = dfdy(x_136);
float2 const x_139 = *(uv);
duv1 = dfdx(x_139);
float2 const x_142 = *(uv);
duv2 = dfdy(x_142);
float3 const x_145 = dp2;
float3 const x_146 = *(normal_1);
dp2perp = cross(x_145, x_146);
float3 const x_149 = *(normal_1);
float3 const x_150 = dp1;
dp1perp = cross(x_149, x_150);
float3 const x_153 = dp2perp;
float const x_155 = duv1[0];
float3 const x_157 = dp1perp;
float const x_159 = duv2[0];
tangent = ((x_153 * x_155) + (x_157 * x_159));
float3 const x_163 = dp2perp;
float const x_165 = duv1[1];
float3 const x_167 = dp1perp;
float const x_169 = duv2[1];
bitangent = ((x_163 * x_165) + (x_167 * x_169));
float const x_173 = (*(tangentSpaceParams))[0];
float3 const x_174 = tangent;
tangent = (x_174 * x_173);
float const x_177 = (*(tangentSpaceParams))[1];
float3 const x_178 = bitangent;
bitangent = (x_178 * x_177);
float3 const x_181 = tangent;
float3 const x_182 = tangent;
float3 const x_184 = bitangent;
float3 const x_185 = bitangent;
invmax = rsqrt(fmax(dot(x_181, x_182), dot(x_184, x_185)));
float3 const x_189 = tangent;
float const x_190 = invmax;
float3 const x_191 = (x_189 * x_190);
float3 const x_192 = bitangent;
float const x_193 = invmax;
float3 const x_194 = (x_192 * x_193);
float3 const x_195 = *(normal_1);
return float3x3(float3(x_191[0], x_191[1], x_191[2]), float3(x_194[0], x_194[1], x_194[2]), float3(x_195[0], x_195[1], x_195[2]));
}
float3x3 transposeMat3_mf33_(thread float3x3* const inMatrix) {
float3 i0 = 0.0f;
float3 i1 = 0.0f;
float3 i2 = 0.0f;
float3x3 outMatrix = float3x3(0.0f);
float3 const x_60 = (*(inMatrix))[0];
i0 = x_60;
float3 const x_64 = (*(inMatrix))[1];
i1 = x_64;
float3 const x_68 = (*(inMatrix))[2];
i2 = x_68;
float const x_73 = i0[0];
float const x_75 = i1[0];
float const x_77 = i2[0];
float3 const x_78 = float3(x_73, x_75, x_77);
float const x_81 = i0[1];
float const x_83 = i1[1];
float const x_85 = i2[1];
float3 const x_86 = float3(x_81, x_83, x_85);
float const x_89 = i0[2];
float const x_91 = i1[2];
float const x_93 = i2[2];
float3 const x_94 = float3(x_89, x_91, x_93);
outMatrix = float3x3(float3(x_78[0], x_78[1], x_78[2]), float3(x_86[0], x_86[1], x_86[2]), float3(x_94[0], x_94[1], x_94[2]));
float3x3 const x_110 = outMatrix;
return x_110;
}
float3 perturbNormalBase_mf33_vf3_f1_(thread float3x3* const cotangentFrame, thread float3* const normal, thread float* const scale) {
float3x3 const x_113 = *(cotangentFrame);
float3 const x_114 = *(normal);
return normalize((x_113 * x_114));
}
float3 perturbNormal_mf33_vf3_f1_(thread float3x3* const cotangentFrame_1, thread float3* const textureSample, thread float* const scale_1) {
float3x3 param = float3x3(0.0f);
float3 param_1 = 0.0f;
float param_2 = 0.0f;
float3 const x_119 = *(textureSample);
float3x3 const x_125 = *(cotangentFrame_1);
param = x_125;
param_1 = ((x_119 * 2.0f) - float3(1.0f));
float const x_128 = *(scale_1);
param_2 = x_128;
float3 const x_129 = perturbNormalBase_mf33_vf3_f1_(&(param), &(param_1), &(param_2));
return x_129;
}
lightingInfo computeHemisphericLighting_vf3_vf3_vf4_vf3_vf3_vf3_f1_(thread float3* const viewDirectionW, thread float3* const vNormal, thread float4* const lightData, thread float3* const diffuseColor, thread float3* const specularColor, thread float3* const groundColor, thread float* const glossiness) {
float ndl = 0.0f;
lightingInfo result = {};
float3 angleW = 0.0f;
float specComp = 0.0f;
float3 const x_212 = *(vNormal);
float4 const x_213 = *(lightData);
ndl = ((dot(x_212, float3(x_213[0], x_213[1], x_213[2])) * 0.5f) + 0.5f);
float3 const x_220 = *(groundColor);
float3 const x_221 = *(diffuseColor);
float const x_222 = ndl;
result.diffuse = mix(x_220, x_221, float3(x_222, x_222, x_222));
float3 const x_227 = *(viewDirectionW);
float4 const x_228 = *(lightData);
angleW = normalize((x_227 + float3(x_228[0], x_228[1], x_228[2])));
float3 const x_233 = *(vNormal);
float3 const x_234 = angleW;
specComp = fmax(0.0f, dot(x_233, x_234));
float const x_237 = specComp;
float const x_238 = *(glossiness);
specComp = powr(x_237, fmax(1.0f, x_238));
float const x_241 = specComp;
float3 const x_242 = *(specularColor);
result.specular = (x_242 * x_241);
lightingInfo const x_245 = result;
return x_245;
}
void main_1(thread tint_private_vars_struct* const tint_private_vars, texture2d<float, access::sample> tint_symbol_5, sampler tint_symbol_6, const constant LeftOver_tint_packed_vec3* const tint_symbol_7, texture2d<float, access::sample> tint_symbol_8, sampler tint_symbol_9, const constant Light0_tint_packed_vec3* const tint_symbol_10) {
float4 tempTextureRead = 0.0f;
float3 rgb = 0.0f;
float3 output5 = 0.0f;
float4 output4 = 0.0f;
float2 uvOffset = 0.0f;
float normalScale = 0.0f;
float2 TBNUV = 0.0f;
float2 x_299 = 0.0f;
float3x3 TBN = float3x3(0.0f);
float3 param_3 = 0.0f;
float3 param_4 = 0.0f;
float2 param_5 = 0.0f;
float2 param_6 = 0.0f;
float3x3 invTBN = float3x3(0.0f);
float3x3 param_7 = float3x3(0.0f);
float parallaxLimit = 0.0f;
float2 vOffsetDir = 0.0f;
float2 vMaxOffset = 0.0f;
float numSamples = 0.0f;
float stepSize = 0.0f;
float currRayHeight = 0.0f;
float2 vCurrOffset = 0.0f;
float2 vLastOffset = 0.0f;
float lastSampledHeight = 0.0f;
float currSampledHeight = 0.0f;
int i = 0;
float delta1 = 0.0f;
float delta2 = 0.0f;
float ratio = 0.0f;
float2 parallaxOcclusion_0 = 0.0f;
float3x3 param_8 = float3x3(0.0f);
float3 param_9 = 0.0f;
float param_10 = 0.0f;
float2 output6 = 0.0f;
float4 tempTextureRead1 = 0.0f;
float3 rgb1 = 0.0f;
float3 viewDirectionW_1 = 0.0f;
float shadow = 0.0f;
float glossiness_1 = 0.0f;
float3 diffuseBase = 0.0f;
float3 specularBase = 0.0f;
float3 normalW = 0.0f;
lightingInfo info = {};
float3 param_11 = 0.0f;
float3 param_12 = 0.0f;
float4 param_13 = 0.0f;
float3 param_14 = 0.0f;
float3 param_15 = 0.0f;
float3 param_16 = 0.0f;
float param_17 = 0.0f;
float3 diffuseOutput = 0.0f;
float3 specularOutput = 0.0f;
float3 output3 = 0.0f;
(*(tint_private_vars)).u_Float = 100.0f;
(*(tint_private_vars)).u_Color = float3(0.5f);
float2 const x_261 = (*(tint_private_vars)).vMainuv;
float4 const x_262 = tint_symbol_5.sample(tint_symbol_6, x_261);
tempTextureRead = x_262;
float4 const x_264 = tempTextureRead;
float const x_273 = (*(tint_symbol_7)).textureInfoName;
rgb = (float3(x_264[0], x_264[1], x_264[2]) * x_273);
float3 const x_279 = float3((*(tint_symbol_7)).u_cameraPosition);
float4 const x_282 = (*(tint_private_vars)).v_output1;
output5 = normalize((x_279 - float3(x_282[0], x_282[1], x_282[2])));
output4 = float4(0.0f);
uvOffset = float2(0.0f);
float const x_292 = (*(tint_symbol_7)).u_bumpStrength;
normalScale = (1.0f / x_292);
bool const x_298 = (*(tint_private_vars)).gl_FrontFacing;
if (x_298) {
float2 const x_303 = (*(tint_private_vars)).v_uv;
x_299 = x_303;
} else {
float2 const x_305 = (*(tint_private_vars)).v_uv;
x_299 = -(x_305);
}
float2 const x_307 = x_299;
TBNUV = x_307;
float4 const x_310 = (*(tint_private_vars)).v_output2;
float const x_312 = normalScale;
param_3 = (float3(x_310[0], x_310[1], x_310[2]) * x_312);
float4 const x_317 = (*(tint_private_vars)).v_output1;
param_4 = float3(x_317[0], x_317[1], x_317[2]);
float2 const x_320 = TBNUV;
param_5 = x_320;
float2 const x_324 = (*(tint_symbol_7)).tangentSpaceParameter0;
param_6 = x_324;
float3x3 const x_325 = cotangent_frame_vf3_vf3_vf2_vf2_(&(param_3), &(param_4), &(param_5), &(param_6));
TBN = x_325;
float3x3 const x_328 = TBN;
param_7 = x_328;
float3x3 const x_329 = transposeMat3_mf33_(&(param_7));
invTBN = x_329;
float3x3 const x_331 = invTBN;
float3 const x_332 = output5;
float3 const x_334 = (x_331 * -(x_332));
float3x3 const x_337 = invTBN;
float3 const x_338 = output5;
parallaxLimit = (length(float2(x_334[0], x_334[1])) / ((x_337 * -(x_338)))[2]);
float const x_345 = (*(tint_symbol_7)).u_parallaxScale;
float const x_346 = parallaxLimit;
parallaxLimit = (x_346 * x_345);
float3x3 const x_349 = invTBN;
float3 const x_350 = output5;
float3 const x_352 = (x_349 * -(x_350));
vOffsetDir = normalize(float2(x_352[0], x_352[1]));
float2 const x_356 = vOffsetDir;
float const x_357 = parallaxLimit;
vMaxOffset = (x_356 * x_357);
float3x3 const x_361 = invTBN;
float3 const x_362 = output5;
float3x3 const x_365 = invTBN;
float4 const x_366 = (*(tint_private_vars)).v_output2;
numSamples = (15.0f + (dot((x_361 * -(x_362)), (x_365 * float3(x_366[0], x_366[1], x_366[2]))) * -11.0f));
float const x_374 = numSamples;
stepSize = (1.0f / x_374);
currRayHeight = 1.0f;
vCurrOffset = float2(0.0f);
vLastOffset = float2(0.0f);
lastSampledHeight = 1.0f;
currSampledHeight = 1.0f;
i = 0;
TINT_ISOLATE_UB(tint_volatile_true) while(true) {
int const x_388 = i;
if ((x_388 < 15)) {
} else {
break;
}
float2 const x_394 = (*(tint_private_vars)).v_uv;
float2 const x_395 = vCurrOffset;
float4 const x_397 = float4(0.0f);
currSampledHeight = x_397[3];
float const x_400 = currSampledHeight;
float const x_401 = currRayHeight;
if ((x_400 > x_401)) {
float const x_406 = currSampledHeight;
float const x_407 = currRayHeight;
delta1 = (x_406 - x_407);
float const x_410 = currRayHeight;
float const x_411 = stepSize;
float const x_413 = lastSampledHeight;
delta2 = ((x_410 + x_411) - x_413);
float const x_416 = delta1;
float const x_417 = delta1;
float const x_418 = delta2;
ratio = (x_416 / (x_417 + x_418));
float const x_421 = ratio;
float2 const x_422 = vLastOffset;
float const x_424 = ratio;
float2 const x_426 = vCurrOffset;
vCurrOffset = ((x_422 * x_421) + (x_426 * (1.0f - x_424)));
break;
} else {
float const x_431 = stepSize;
float const x_432 = currRayHeight;
currRayHeight = (x_432 - x_431);
float2 const x_434 = vCurrOffset;
vLastOffset = x_434;
float const x_435 = stepSize;
float2 const x_436 = vMaxOffset;
float2 const x_438 = vCurrOffset;
vCurrOffset = (x_438 + (x_436 * x_435));
float const x_440 = currSampledHeight;
lastSampledHeight = x_440;
}
{
int const x_441 = i;
i = as_type<int>((as_type<uint>(x_441) + as_type<uint>(1)));
}
}
float2 const x_444 = vCurrOffset;
parallaxOcclusion_0 = x_444;
float2 const x_445 = parallaxOcclusion_0;
uvOffset = x_445;
float2 const x_449 = (*(tint_private_vars)).v_uv;
float2 const x_450 = uvOffset;
float4 const x_452 = tint_symbol_5.sample(tint_symbol_6, (x_449 + x_450));
float const x_454 = (*(tint_symbol_7)).u_bumpStrength;
float3x3 const x_457 = TBN;
param_8 = x_457;
param_9 = float3(x_452[0], x_452[1], x_452[2]);
param_10 = (1.0f / x_454);
float3 const x_461 = perturbNormal_mf33_vf3_f1_(&(param_8), &(param_9), &(param_10));
float4 const x_462 = output4;
output4 = float4(x_461[0], x_461[1], x_461[2], x_462[3]);
float2 const x_465 = (*(tint_private_vars)).v_uv;
float2 const x_466 = uvOffset;
output6 = (x_465 + x_466);
float2 const x_474 = output6;
float4 const x_475 = tint_symbol_8.sample(tint_symbol_9, x_474);
tempTextureRead1 = x_475;
float4 const x_477 = tempTextureRead1;
rgb1 = float3(x_477[0], x_477[1], x_477[2]);
float3 const x_481 = float3((*(tint_symbol_7)).u_cameraPosition);
float4 const x_482 = (*(tint_private_vars)).v_output1;
viewDirectionW_1 = normalize((x_481 - float3(x_482[0], x_482[1], x_482[2])));
shadow = 1.0f;
float const x_488 = (*(tint_private_vars)).u_Float;
glossiness_1 = (1.0f * x_488);
diffuseBase = float3(0.0f);
specularBase = float3(0.0f);
float4 const x_494 = output4;
normalW = float3(x_494[0], x_494[1], x_494[2]);
float3 const x_501 = viewDirectionW_1;
param_11 = x_501;
float3 const x_503 = normalW;
param_12 = x_503;
float4 const x_507 = (*(tint_symbol_10)).vLightData;
param_13 = x_507;
float4 const x_510 = (*(tint_symbol_10)).vLightDiffuse;
param_14 = float3(x_510[0], x_510[1], x_510[2]);
float4 const x_514 = (*(tint_symbol_10)).vLightSpecular;
param_15 = float3(x_514[0], x_514[1], x_514[2]);
float3 const x_518 = float3((*(tint_symbol_10)).vLightGround);
param_16 = x_518;
float const x_520 = glossiness_1;
param_17 = x_520;
lightingInfo const x_521 = computeHemisphericLighting_vf3_vf3_vf4_vf3_vf3_vf3_f1_(&(param_11), &(param_12), &(param_13), &(param_14), &(param_15), &(param_16), &(param_17));
info = x_521;
shadow = 1.0f;
float3 const x_523 = info.diffuse;
float const x_524 = shadow;
float3 const x_526 = diffuseBase;
diffuseBase = (x_526 + (x_523 * x_524));
float3 const x_529 = info.specular;
float const x_530 = shadow;
float3 const x_532 = specularBase;
specularBase = (x_532 + (x_529 * x_530));
float3 const x_535 = diffuseBase;
float3 const x_536 = rgb1;
diffuseOutput = (x_535 * x_536);
float3 const x_539 = specularBase;
float3 const x_540 = (*(tint_private_vars)).u_Color;
specularOutput = (x_539 * x_540);
float3 const x_543 = diffuseOutput;
float3 const x_544 = specularOutput;
output3 = (x_543 + x_544);
float3 const x_548 = output3;
(*(tint_private_vars)).glFragColor = float4(x_548[0], x_548[1], x_548[2], 1.0f);
return;
}
struct main_out {
float4 glFragColor_1;
};
struct tint_symbol_2 {
float4 v_output1_param [[user(locn0)]];
float2 vMainuv_param [[user(locn1)]];
float4 v_output2_param [[user(locn2)]];
float2 v_uv_param [[user(locn3)]];
};
struct tint_symbol_3 {
float4 glFragColor_1 [[color(0)]];
};
main_out tint_symbol_inner(float2 vMainuv_param, float4 v_output1_param, bool gl_FrontFacing_param, float2 v_uv_param, float4 v_output2_param, thread tint_private_vars_struct* const tint_private_vars, texture2d<float, access::sample> tint_symbol_11, sampler tint_symbol_12, const constant LeftOver_tint_packed_vec3* const tint_symbol_13, texture2d<float, access::sample> tint_symbol_14, sampler tint_symbol_15, const constant Light0_tint_packed_vec3* const tint_symbol_16) {
(*(tint_private_vars)).vMainuv = vMainuv_param;
(*(tint_private_vars)).v_output1 = v_output1_param;
(*(tint_private_vars)).gl_FrontFacing = gl_FrontFacing_param;
(*(tint_private_vars)).v_uv = v_uv_param;
(*(tint_private_vars)).v_output2 = v_output2_param;
main_1(tint_private_vars, tint_symbol_11, tint_symbol_12, tint_symbol_13, tint_symbol_14, tint_symbol_15, tint_symbol_16);
main_out const tint_symbol_4 = {.glFragColor_1=(*(tint_private_vars)).glFragColor};
return tint_symbol_4;
}
fragment tint_symbol_3 tint_symbol(texture2d<float, access::sample> tint_symbol_17 [[texture(0)]], sampler tint_symbol_18 [[sampler(0)]], const constant LeftOver_tint_packed_vec3* tint_symbol_19 [[buffer(0)]], texture2d<float, access::sample> tint_symbol_20 [[texture(1)]], sampler tint_symbol_21 [[sampler(1)]], const constant Light0_tint_packed_vec3* tint_symbol_22 [[buffer(1)]], bool gl_FrontFacing_param [[front_facing]], tint_symbol_2 tint_symbol_1 [[stage_in]]) {
thread tint_private_vars_struct tint_private_vars = {};
main_out const inner_result = tint_symbol_inner(tint_symbol_1.vMainuv_param, tint_symbol_1.v_output1_param, gl_FrontFacing_param, tint_symbol_1.v_uv_param, tint_symbol_1.v_output2_param, &(tint_private_vars), tint_symbol_17, tint_symbol_18, tint_symbol_19, tint_symbol_20, tint_symbol_21, tint_symbol_22);
tint_symbol_3 wrapper_result = {};
wrapper_result.glFragColor_1 = inner_result.glFragColor_1;
return wrapper_result;
}