cbuffer _179 { int2 _179_offset : packoffset(c0); int _179_level : packoffset(c0.z); }; Texture2D tex : register(t0); SamplerState _tex_sampler : register(s0); Texture2D tex2 : register(t1); SamplerState _tex2_sampler : register(s1); static float4 gl_FragCoord; static float4 fragColor; static float2 vUV; struct SPIRV_Cross_Input { float2 vUV : TEXCOORD0; float4 gl_FragCoord : SV_Position; }; struct SPIRV_Cross_Output { float4 fragColor : SV_Target0; }; float4 YCoCgToRGB(float4 ycocg, float alpha) { float Y = ycocg.w; float scale = 1.0f / ((31.875f * ycocg.z) + 1.0f); float Co = (ycocg.x - 0.501960813999176025390625f) * scale; float Cg = (ycocg.y - 0.501960813999176025390625f) * scale; float R = (Y + Co) - Cg; float G = Y + Cg; float B = (Y - Co) - Cg; return float4(R, G, B, alpha); } float4 toLinear(float4 sRGB_A) { float a = sRGB_A.w; float rcpA = 1.0f / ((a != 0.0f) ? a : 1.0f); float3 sRGB = sRGB_A.xyz * rcpA; bool3 cutoff = bool3(sRGB.x < 0.040449999272823333740234375f.xxx.x, sRGB.y < 0.040449999272823333740234375f.xxx.y, sRGB.z < 0.040449999272823333740234375f.xxx.z); float3 higher = pow((abs(sRGB) + 0.054999999701976776123046875f.xxx) / 1.05499994754791259765625f.xxx, 2.400000095367431640625f.xxx); float3 lower = sRGB / 12.9200000762939453125f.xxx; return float4(float3(cutoff.x ? lower.x : higher.x, cutoff.y ? lower.y : higher.y, cutoff.z ? lower.z : higher.z) * a, a); } float4 fromLinear(float4 linearRGB_A) { float a = linearRGB_A.w; float rcpA = 1.0f / ((a != 0.0f) ? a : 1.0f); float3 linearRGB = linearRGB_A.xyz * rcpA; bool3 cutoff = bool3(linearRGB.x < 0.003130800090730190277099609375f.xxx.x, linearRGB.y < 0.003130800090730190277099609375f.xxx.y, linearRGB.z < 0.003130800090730190277099609375f.xxx.z); float3 higher = (1.05499994754791259765625f.xxx * pow(abs(linearRGB), 0.4166666567325592041015625f.xxx)) - 0.054999999701976776123046875f.xxx; float3 lower = linearRGB * 12.9200000762939453125f.xxx; return float4(float3(cutoff.x ? lower.x : higher.x, cutoff.y ? lower.y : higher.y, cutoff.z ? lower.z : higher.z) * a, a); } void frag_main() { int side = 1 << _179_level; float4 color = 0.0f.xxxx; int2 coord = (side.xx * int2(gl_FragCoord.xy)) + _179_offset; for (int y = 0; y < side; y++) { for (int x = 0; x < side; x++) { float4 t1 = tex.Load(int3(coord + int2(x, y), 0)); float a1 = tex2.Load(int3(coord + int2(x, y), 0)).x; float4 param = t1; float param_1 = a1; t1 = YCoCgToRGB(param, param_1); float4 param_2 = t1; color += toLinear(param_2); } } float4 param_3 = color * (1.0f / float(side * side)); fragColor = fromLinear(param_3); } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) { gl_FragCoord = stage_input.gl_FragCoord; vUV = stage_input.vUV; frag_main(); SPIRV_Cross_Output stage_output; stage_output.fragColor = fragColor; return stage_output; }