static const float _178[3] = { 0.2874059975147247314453125f, 0.42518699169158935546875f, 0.2874059975147247314453125f }; static const float _256[5] = { 0.1446709930896759033203125f, 0.22499300539493560791015625f, 0.2606720030307769775390625f, 0.22499300539493560791015625f, 0.1446709930896759033203125f }; static const float _336[7] = { 0.09442000091075897216796875f, 0.13819299638271331787109375f, 0.17367599904537200927734375f, 0.18742300570011138916015625f, 0.17367599904537200927734375f, 0.13819299638271331787109375f, 0.09442000091075897216796875f }; static const float _411[11] = { 0.055036999285221099853515625f, 0.07280600070953369140625f, 0.09050600230693817138671875f, 0.1057260036468505859375f, 0.1160610020160675048828125f, 0.119726002216339111328125f, 0.1160610020160675048828125f, 0.1057260036468505859375f, 0.09050600230693817138671875f, 0.07280600070953369140625f, 0.055036999285221099853515625f }; cbuffer _71 { float4 _71_globalColor : packoffset(c0); float2 _71_atlasSize : packoffset(c1); float _71_begin : packoffset(c1.z); float _71_end : packoffset(c1.w); float _71_searchRadius : packoffset(c2); float _71_alphaMultiplier : packoffset(c2.y); }; Texture2D tex : register(t0); SamplerState _tex_sampler : register(s0); static float2 vUV1; static float2 vUV2; static float4 vTint; static float4 fragColor; struct SPIRV_Cross_Input { float2 vUV1 : TEXCOORD0; float2 vUV2 : TEXCOORD1; float4 vTint : TEXCOORD2; }; struct SPIRV_Cross_Output { float4 fragColor : SV_Target0; }; float mipMapLevel(float2 uv) { float2 dx_vtc = ddx(uv); float2 dy_vtc = ddy(uv); float delta_max_sqr = max(dot(dx_vtc, dx_vtc), dot(dy_vtc, dy_vtc)); return 0.5f * log2(delta_max_sqr); } bool insideBounds(float2 v) { float4 test = float4(v.x, v.y, 1.0f - v.x, 1.0f - v.y); return all(bool4(test.x > 0.0f.xxxx.x, test.y > 0.0f.xxxx.y, test.z > 0.0f.xxxx.z, test.w > 0.0f.xxxx.w)); } void frag_main() { float2 param = vUV1 * _71_atlasSize; float mipLevel = mipMapLevel(param); float2 dTexel = 1.0f.xx / _71_atlasSize; float2 dUV1 = float2(ddx(vUV1).x, ddy(vUV1).y); float2 dUV2 = float2(ddx(vUV2).x, ddy(vUV2).y) * (dTexel / dUV1); float4 mipIndicator = 0.0f.xxxx; float samplingOffset = _71_searchRadius / 5.0f; float acc = 0.0f; if (mipLevel > 1.0f) { float uvMultiplier = samplingOffset * 3.6666667461395263671875f; for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { float2 mulUV = float2(float(x - 1), float(y - 1)) * uvMultiplier; float2 param_1 = vUV2 + (dUV2 * mulUV); if (insideBounds(param_1)) { acc += ((tex.SampleLevel(_tex_sampler, vUV1 + (dTexel * mulUV), mipLevel).w * _178[x]) * _178[y]); } } } } else { if (mipLevel > 0.0f) { float uvMultiplier_1 = samplingOffset * 2.2000000476837158203125f; for (int y_1 = 0; y_1 < 5; y_1++) { for (int x_1 = 0; x_1 < 5; x_1++) { float2 mulUV_1 = float2(float(x_1 - 2), float(y_1 - 2)) * uvMultiplier_1; float2 param_2 = vUV2 + (dUV2 * mulUV_1); if (insideBounds(param_2)) { acc += ((tex.SampleLevel(_tex_sampler, vUV1 + (dTexel * mulUV_1), mipLevel).w * _256[x_1]) * _256[y_1]); } } } } else { if (_71_searchRadius < 9.5f) { float uvMultiplier_2 = samplingOffset * 1.5714285373687744140625f; for (int y_2 = 0; y_2 < 7; y_2++) { for (int x_2 = 0; x_2 < 7; x_2++) { float2 mulUV_2 = float2(float(x_2 - 3), float(y_2 - 3)) * uvMultiplier_2; float2 param_3 = vUV2 + (dUV2 * mulUV_2); if (insideBounds(param_3)) { acc += ((tex.SampleLevel(_tex_sampler, vUV1 + (dTexel * mulUV_2), mipLevel).w * _336[x_2]) * _336[y_2]); } } } } else { float uvMultiplier_3 = samplingOffset * 1.0f; for (int y_3 = 0; y_3 < 11; y_3++) { for (int x_3 = 0; x_3 < 11; x_3++) { float2 mulUV_3 = float2(float(x_3 - 5), float(y_3 - 5)) * uvMultiplier_3; float2 param_4 = vUV2 + (dUV2 * mulUV_3); if (insideBounds(param_4)) { acc += ((tex.SampleLevel(_tex_sampler, vUV1 + (dTexel * mulUV_3), mipLevel).w * _411[x_3]) * _411[y_3]); } } } } } } float4 tint = vTint; float4 result = tint * clamp(acc * _71_alphaMultiplier, 0.0f, 1.0f); if (result.w < 0.03125f) { discard; } fragColor = result; } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) { vUV1 = stage_input.vUV1; vUV2 = stage_input.vUV2; vTint = stage_input.vTint; frag_main(); SPIRV_Cross_Output stage_output; stage_output.fragColor = fragColor; return stage_output; }