struct SpriteMask { row_major float4x4 uvTransform; float2 uvMin; float2 uvMax; uint tint; uint extraData; float2 padding_; }; cbuffer spriteMaskUniforms : register(b1) { float4 _239_vertices[4] : packoffset(c0); uint _239_tint : packoffset(c4); uint _239_extraData : packoffset(c4.y); uint _239_numMasks : packoffset(c4.z); float _239_padding_ : packoffset(c4.w); SpriteMask _239_masks[4] : packoffset(c5); }; Texture2D mask0 : register(t1); SamplerState _mask0_sampler : register(s1); Texture2D mask1 : register(t2); SamplerState _mask1_sampler : register(s2); Texture2D mask2 : register(t3); SamplerState _mask2_sampler : register(s3); Texture2D mask3 : register(t4); SamplerState _mask3_sampler : register(s4); Texture2D tex : register(t0); SamplerState _tex_sampler : register(s0); static uint vExtra; static float4 vTint; static float2 vMask0UV; static float2 vMask1UV; static float2 vMask2UV; static float2 vMask3UV; static float2 vUV; static float4 fragColor; static float4 lightColor; struct SPIRV_Cross_Input { float2 vUV : TEXCOORD0; float4 vTint : TEXCOORD1; nointerpolation uint vExtra : TEXCOORD2; float2 vMask0UV : TEXCOORD3; float2 vMask1UV : TEXCOORD4; float2 vMask2UV : TEXCOORD5; float2 vMask3UV : TEXCOORD6; }; struct SPIRV_Cross_Output { float4 fragColor : SV_Target0; float4 lightColor : SV_Target1; }; float4 applySpriteFlags(inout float4 color, float4 tint, uint extra) { if ((vExtra & 4u) != 0u) { color = float4(color.www - color.xyz, color.w); } if ((vExtra & 2u) == 0u) { color *= tint; } else { float alpha = color.w * tint.w; float3 x = (color.xyz * tint.xyz) * 2.0f; float3 y = alpha.xxx - (((color.w.xxx - color.xyz) * 2.0f) * (tint.w.xxx - tint.xyz)); float _122; if (color.x < (0.5f * color.w)) { _122 = x.x; } else { _122 = y.x; } color.x = _122; float _139; if (color.y < (0.5f * color.w)) { _139 = x.y; } else { _139 = y.y; } color.y = _139; float _155; if (color.z < (0.5f * color.w)) { _155 = x.z; } else { _155 = y.z; } color.z = _155; color.w = alpha; } if ((extra & 1u) != 0u) { float4 _172 = color; float3 _179 = dot(_172.xyz, float3(0.2989999949932098388671875f, 0.58700001239776611328125f, 0.114000000059604644775390625f)).xxx; color.x = _179.x; color.y = _179.y; color.z = _179.z; } return color; } float4 getFragColor(float4 color, uint extra) { bool4 _217 = ((extra & 16u) != 0u).xxxx; return float4(_217.x ? 0.0f.xxxx.x : color.x, _217.y ? 0.0f.xxxx.y : color.y, _217.z ? 0.0f.xxxx.z : color.z, _217.w ? 0.0f.xxxx.w : color.w); } float4 textureMask(int maskIndex, Texture2D maskTex, SamplerState _maskTex_sampler, float2 uv) { float clamp = ((step(_239_masks[maskIndex].uvMin.x, uv.x) * step(uv.x, _239_masks[maskIndex].uvMax.x)) * step(_239_masks[maskIndex].uvMin.y, uv.y)) * step(uv.y, _239_masks[maskIndex].uvMax.y); float4 maskColor = maskTex.Sample(_maskTex_sampler, uv); float4 tint = float4(float((_239_masks[maskIndex].tint >> uint(0)) & 255u), float((_239_masks[maskIndex].tint >> uint(8)) & 255u), float((_239_masks[maskIndex].tint >> uint(16)) & 255u), float((_239_masks[maskIndex].tint >> uint(24)) & 255u)) / 255.0f.xxxx; float4 param = maskColor; float4 param_1 = tint; uint param_2 = _239_masks[maskIndex].extraData; float4 _320 = applySpriteFlags(param, param_1, param_2); float4 param_3 = _320; uint param_4 = vExtra; return getFragColor(param_3, param_4) * clamp; } float4 blend(float4 underColor, float4 overColor) { return overColor + (underColor * (1.0f - overColor.w)); } float4 applySpriteFlags(float4 color) { float4 param = color; float4 param_1 = vTint; uint param_2 = vExtra; float4 _229 = applySpriteFlags(param, param_1, param_2); return _229; } float4 getLightColor(float4 color, uint extra) { float4 _193; if ((extra & 48u) != 0u) { _193 = float4(color.xyz, 0.0f); } else { _193 = float4(0.0f, 0.0f, 0.0f, color.w); } return _193; } void frag_main() { float4 maskColor = 0.0f.xxxx; if (_239_numMasks >= 1u) { int param = 0; float2 param_1 = vMask0UV; maskColor = textureMask(param, mask0, _mask0_sampler, param_1); } if (_239_numMasks >= 2u) { int param_2 = 1; float2 param_3 = vMask1UV; float4 param_4 = maskColor; float4 param_5 = textureMask(param_2, mask1, _mask1_sampler, param_3); maskColor = blend(param_4, param_5); } if (_239_numMasks >= 3u) { int param_6 = 2; float2 param_7 = vMask2UV; float4 param_8 = maskColor; float4 param_9 = textureMask(param_6, mask2, _mask2_sampler, param_7); maskColor = blend(param_8, param_9); } if (_239_numMasks >= 4u) { int param_10 = 3; float2 param_11 = vMask3UV; float4 param_12 = maskColor; float4 param_13 = textureMask(param_10, mask3, _mask3_sampler, param_11); maskColor = blend(param_12, param_13); } float4 spriteColor = tex.Sample(_tex_sampler, vUV); float4 param_14 = spriteColor; float4 color = applySpriteFlags(param_14); float4 param_15 = color; float4 param_16 = maskColor; color = blend(param_15, param_16); bool _414 = maskColor.w < 1.0f; bool _420; if (_414) { _420 = spriteColor.w > 0.0f; } else { _420 = _414; } color *= float(_420); float4 param_17 = color; uint param_18 = vExtra; fragColor = getFragColor(param_17, param_18); float4 param_19 = color; uint param_20 = vExtra; lightColor = getLightColor(param_19, param_20); } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) { vExtra = stage_input.vExtra; vTint = stage_input.vTint; vMask0UV = stage_input.vMask0UV; vMask1UV = stage_input.vMask1UV; vMask2UV = stage_input.vMask2UV; vMask3UV = stage_input.vMask3UV; vUV = stage_input.vUV; frag_main(); SPIRV_Cross_Output stage_output; stage_output.fragColor = fragColor; stage_output.lightColor = lightColor; return stage_output; }