#version 460 compatibility
#define COMP 1
// This file is generated by options.main.kts. Do not edit this file manually.
#define SETTING_FIRE_TEMPERATURE 1400//[100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 3200 3300 3400 3500 3600 3700 3800 3900 4000 4100 4200 4300 4400 4500 4600 4700 4800 4900 5000]
#define SETTING_LAVA_TEMPERATURE 1300//[100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 3200 3300 3400 3500 3600 3700 3800 3900 4000 4100 4200 4300 4400 4500 4600 4700 4800 4900 5000]
#define SETTING_EMISSIVE_STRENGTH 4.0//[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.5 13.0 13.5 14.0 14.5 15.0 15.5 16.0]
#define SETTING_EMISSIVE_PBR_VALUE_CURVE 0.9//[0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1.0 1.05 1.1 1.15 1.2 1.25 1.3 1.35 1.4 1.45 1.5 1.55 1.6 1.65 1.7 1.75 1.8 1.85 1.9 1.95 2.0 2.05 2.1 2.15 2.2 2.25 2.3 2.35 2.4 2.45 2.5 2.55 2.6 2.65 2.7 2.75 2.8 2.85 2.9 2.95 3.0 3.05 3.1 3.15 3.2 3.25 3.3 3.35 3.4 3.45 3.5 3.55 3.6 3.65 3.7 3.75 3.8 3.85 3.9 3.95 4.0]
#define SETTING_EMISSIVE_ALBEDO_COLOR_CURVE 2.0//[0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1.0 1.05 1.1 1.15 1.2 1.25 1.3 1.35 1.4 1.45 1.5 1.55 1.6 1.65 1.7 1.75 1.8 1.85 1.9 1.95 2.0 2.05 2.1 2.15 2.2 2.25 2.3 2.35 2.4 2.45 2.5 2.55 2.6 2.65 2.7 2.75 2.8 2.85 2.9 2.95 3.0 3.05 3.1 3.15 3.2 3.25 3.3 3.35 3.4 3.45 3.5 3.55 3.6 3.65 3.7 3.75 3.8 3.85 3.9 3.95 4.0]
#define SETTING_EMISSIVE_ALBEDO_LUM_CURVE 0.0//[-4.0 -3.9 -3.8 -3.7 -3.6 -3.5 -3.4 -3.3 -3.2 -3.1 -3.0 -2.9 -2.8 -2.7 -2.6 -2.5 -2.4 -2.3 -2.2 -2.1 -2.0 -1.9 -1.8 -1.7 -1.6 -1.5 -1.4 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0]
#define SETTING_MINIMUM_F0 12//[4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32]
#define SETTING_SOLID_MINIMUM_ROUGHNESS 6//[4 5 6 7 8 9 10 11 12 13 14 15 16]
#define SETTING_SOLID_MAXIMUM_ROUGHNESS 5//[2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
#define SETTING_WATER_ROUGHNESS 9.0//[4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0]
#define SETTING_TRANSLUCENT_ROUGHNESS_REDUCTION 1.0//[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0]
#define SETTING_TRANSLUCENT_MINIMUM_ROUGHNESS 10.0//[4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.5 13.0 13.5 14.0 14.5 15.0 15.5 16.0]
#define SETTING_TRANSLUCENT_MAXIMUM_ROUGHNESS 5.0//[1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.5 13.0 13.5 14.0 14.5 15.0 15.5 16.0]
#define SETTING_SHADOW_MAP_RESOLUTION 2048//[1024 2048 3072 4096]
const float shadowDistance = 512.0;//[64.0 128.0 192.0 256.0 384.0 512.0]
#define SETTING_ATM_GROUND_ALBEDO_R 45//[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255]
#define SETTING_ATM_GROUND_ALBEDO_G 89//[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255]
#define SETTING_ATM_GROUND_ALBEDO_B 82//[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255]
#define SETTING_EPIPOLAR_SLICES 1024//[256 512 1024 2048]
#define SETTING_SLICE_SAMPLES 512//[128 256 512 1024]
#define SETTING_SKYVIEW_RES 256//[128 256 512 1024]
#define SETTING_CLOUDS_LOW_UPSCALE_FACTOR 2//[0 1 2 3 4 5 6]
#define SETTING_CLOUDS_LOW_MAX_ACCUM 16//[4 6 8 12 16 24 32 48 64 96 128]
#define SETTING_SUN_RADIUS 1.0//[0.0078125 0.015625 0.03125 0.0625 0.125 0.25 0.5 1.0 2.0 4.0 8.0 16.0 32.0 64.0 128.0 256.0 512.0 1024.0]
#define SETTING_SUN_DISTANCE 1.0//[0.0078125 0.015625 0.03125 0.0625 0.125 0.25 0.5 1.0 2.0 4.0 8.0 16.0 32.0 64.0 128.0 256.0 512.0 1024.0]
const float sunPathRotation = -20.0;//[-90.0 -89.0 -88.0 -87.0 -86.0 -85.0 -84.0 -83.0 -82.0 -81.0 -80.0 -79.0 -78.0 -77.0 -76.0 -75.0 -74.0 -73.0 -72.0 -71.0 -70.0 -69.0 -68.0 -67.0 -66.0 -65.0 -64.0 -63.0 -62.0 -61.0 -60.0 -59.0 -58.0 -57.0 -56.0 -55.0 -54.0 -53.0 -52.0 -51.0 -50.0 -49.0 -48.0 -47.0 -46.0 -45.0 -44.0 -43.0 -42.0 -41.0 -40.0 -39.0 -38.0 -37.0 -36.0 -35.0 -34.0 -33.0 -32.0 -31.0 -30.0 -29.0 -28.0 -27.0 -26.0 -25.0 -24.0 -23.0 -22.0 -21.0 -20.0 -19.0 -18.0 -17.0 -16.0 -15.0 -14.0 -13.0 -12.0 -11.0 -10.0 -9.0 -8.0 -7.0 -6.0 -5.0 -4.0 -3.0 -2.0 -1.0 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0 36.0 37.0 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0 49.0 50.0 51.0 52.0 53.0 54.0 55.0 56.0 57.0 58.0 59.0 60.0 61.0 62.0 63.0 64.0 65.0 66.0 67.0 68.0 69.0 70.0 71.0 72.0 73.0 74.0 75.0 76.0 77.0 78.0 79.0 80.0 81.0 82.0 83.0 84.0 85.0 86.0 87.0 88.0 89.0 90.0]
#define SETTING_REAL_SUN_TEMPERATURE
#ifdef SETTING_REAL_SUN_TEMPERATURE
#endif
#define SETTING_SUN_TEMPERATURE 5700//[1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 3200 3300 3400 3500 3600 3700 3800 3900 4000 4100 4200 4300 4400 4500 4600 4700 4800 4900 5000 5100 5200 5300 5400 5500 5600 5700 5800 5900 6000 6100 6200 6300 6400 6500 6600 6700 6800 6900 7000 7100 7200 7300 7400 7500 7600 7700 7800 7900 8000 8100 8200 8300 8400 8500 8600 8700 8800 8900 9000 9100 9200 9300 9400 9500 9600 9700 9800 9900 10000 11000 12000 13000 14000 15000 16000 17000 18000 19000 20000 21000 22000 23000 24000 25000 26000 27000 28000 29000 30000 31000 32000 33000 34000 35000 36000 37000 38000 39000 40000 41000 42000 43000 44000 45000 46000 47000 48000 49000 50000]
#define SETTING_MOON_RADIUS 1.0//[0.0078125 0.015625 0.03125 0.0625 0.125 0.25 0.5 1.0 2.0 4.0 8.0 16.0 32.0 64.0 128.0 256.0 512.0 1024.0]
#define SETTING_MOON_DISTANCE 1.0//[0.0078125 0.015625 0.03125 0.0625 0.125 0.25 0.5 1.0 2.0 4.0 8.0 16.0 32.0 64.0 128.0 256.0 512.0 1024.0]
#define SETTING_MOON_ALBEDO 0.12//[0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
#define SETTING_MOON_COLOR_R 0.8//[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
#define SETTING_MOON_COLOR_G 0.9//[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
#define SETTING_MOON_COLOR_B 1.0//[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
#define SETTING_TAA_CAS_SHARPNESS 0.5//[0.0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1.0]
#define SETTING_MATERIAL_COLOR_SPACE 1//[0 1 2 3 4 5 6 7 8]
#define SETTING_MATERIAL_TRANSFER_FUNC 3//[0 1 2 3 4 5 6 7]
#define SETTING_WORKING_COLOR_SPACE 8//[0 1 2 3 4 5 6 7 8]
#define SETTING_DRT_WORKING_COLOR_SPACE 1//[0 1 2 3 4 5 6 7 8]
#define SETTING_DEBUG_OUTPUT 0//[0 1 2 3 4]
#define SETTING_DEBUG_SCALE 1.0//[0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
#define SETTING_DEBUG_GAMMA_CORRECT
#ifdef SETTING_DEBUG_GAMMA_CORRECT
#endif
//#define SETTING_DEBUG_NEGATE
#ifdef SETTING_DEBUG_NEGATE
#endif
//#define SETTING_DEBUG_ALPHA
#ifdef SETTING_DEBUG_ALPHA
#endif
#define SETTING_DEBUG_EV_COARSE 0//[-16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
#define SETTING_DEBUG_EV_FINE 0.0//[-1.0 -0.99 -0.98 -0.97 -0.96 -0.95 -0.94 -0.93 -0.92 -0.91 -0.9 -0.89 -0.88 -0.87 -0.86 -0.85 -0.84 -0.83 -0.82 -0.81 -0.8 -0.79 -0.78 -0.77 -0.76 -0.75 -0.74 -0.73 -0.72 -0.71 -0.7 -0.69 -0.68 -0.67 -0.66 -0.65 -0.64 -0.63 -0.62 -0.61 -0.6 -0.59 -0.58 -0.57 -0.56 -0.55 -0.54 -0.53 -0.52 -0.51 -0.5 -0.49 -0.48 -0.47 -0.46 -0.45 -0.44 -0.43 -0.42 -0.41 -0.4 -0.39 -0.38 -0.37 -0.36 -0.35 -0.34 -0.33 -0.32 -0.31 -0.3 -0.29 -0.28 -0.27 -0.26 -0.25 -0.24 -0.23 -0.22 -0.21 -0.2 -0.19 -0.18 -0.17 -0.16 -0.15 -0.14 -0.13 -0.12 -0.11 -0.1 -0.09 -0.08 -0.07 -0.06 -0.05 -0.04 -0.03 -0.02 -0.01 0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
#define SETTING_DEBUG_TEMP_TEX 0//[0 1 2 3 4 5 6]
#define SETTING_DEBUG_GBUFFER_DATA 0//[0 1 2 3 4 5 6 7 8 9 10 11 12]
#define SETTING_DEBUG_NORMAL_MODE 0//[0 1]
#define SETTING_DEBUG_NORMAL_X_RANGE 1.0//[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
#define SETTING_DEBUG_NORMAL_Y_RANGE 1.0//[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
#define SETTING_DEBUG_NORMAL_Z_RANGE 1.0//[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
#define SETTING_DEBUG_GI_INPUTS 0//[0 1 2 3 4 5 6]
//#define SETTING_DEBUG_ENV_PROBE
#ifdef SETTING_DEBUG_ENV_PROBE
#endif
//#define SETTING_DEBUG_RTWSM
#ifdef SETTING_DEBUG_RTWSM
#endif
//#define SETTING_DEBUG_ATMOSPHERE
#ifdef SETTING_DEBUG_ATMOSPHERE
#endif
//#define SETTING_DEBUG_SKY_VIEW_LUT
#ifdef SETTING_DEBUG_SKY_VIEW_LUT
#endif
//#define SETTING_DEBUG_EPIPOLAR_LINES
#ifdef SETTING_DEBUG_EPIPOLAR_LINES
#endif
//#define SETTING_DEBUG_CLOUDS_AMBLUT
#ifdef SETTING_DEBUG_CLOUDS_AMBLUT
#endif
#define SETTING_DEBUG_CLOUDS_SS 0//[0 1 2 3 4]
//#define SETTING_DEBUG_STARMAP
#ifdef SETTING_DEBUG_STARMAP
#endif
//#define SETTING_DEBUG_AE
#ifdef SETTING_DEBUG_AE
#endif
#if SETTING_SHADOW_MAP_RESOLUTION == 1024
#define SHADOW_MAP_SIZE_D16 64
const int shadowMapResolution = 1024;
#elif SETTING_SHADOW_MAP_RESOLUTION == 2048
#define SHADOW_MAP_SIZE_D16 128
const int shadowMapResolution = 2048;
#elif SETTING_SHADOW_MAP_RESOLUTION == 3072
#define SHADOW_MAP_SIZE_D16 192
const int shadowMapResolution = 3072;
#elif SETTING_SHADOW_MAP_RESOLUTION == 4096
#define SHADOW_MAP_SIZE_D16 256
const int shadowMapResolution = 4096;
#endif
uniform float near;
uniform float far;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferPreviousModelView;
uniform mat4 textureMatrix = mat4(1.0);
#ifdef DISTANT_HORIZONS
uniform float dhNearPlane;
uniform float dhFarPlane;
float farPlane = max(dhFarPlane, far);
float nearPlane = min(dhNearPlane, near);
#else
float farPlane = far;
float nearPlane = near;
#endif
uniform vec2 uval_sunNdcPos;
uniform vec2 uval_mainImageSize;
uniform vec2 uval_mainImageSizeRcp;
uniform int uval_mainImageSizeIX;
uniform int uval_mainImageSizeIY;
ivec2 uval_mainImageSizeI = ivec2(uval_mainImageSizeIX, uval_mainImageSizeIY);
#ifndef GLOBAL_DATA_MODIFIER
#define GLOBAL_DATA_MODIFIER restrict readonly buffer
#endif
struct AEData {
    vec4 lastScreenAvgLum;
    vec4 screenAvgLum;
    vec4 expValues;
    vec2 hsPercents;
    uint shadowCount;
    uint highlightCount;
    uint weightSum;
    #ifdef SETTING_DEBUG_AE
    uint lumHistogram[256];
    uint lumHistogramMaxBinCount;
    float finalAvgLum;
    #endif
};
struct CameraData {
    uint frustumPlaneCount;
    vec4 frustumPlanes[6];
};
mat4 gbufferPrevModelView = gbufferPreviousModelView;
layout(std430, binding = 0) GLOBAL_DATA_MODIFIER GlobalData {
    uvec4 global_dispatchSize1;
    uvec4 global_dispatchSize2;
    uvec4 global_dispatchSize3;
    uvec4 global_dispatchSize4;
    mat4 gbufferPrevModelViewInverse;
    mat4 global_shadowRotationMatrix;
    mat4 global_shadowRotationMatrixInverse;
    mat4 global_taaJitterMat;
    mat4 global_camProj;
    mat4 global_camProjInverse;
    mat4 global_prevCamProj;
    mat4 global_prevCamProjInverse;
    mat4 global_shadowProjPrev;
    mat4 global_shadowProjInversePrev;
    mat4 global_shadowProj;
    mat4 global_shadowProjInverse;
    mat4 global_shadowView;
    mat4 global_shadowViewInverse;
    vec3 global_prevCameraDelta;
    vec2 global_prevTaaJitter;
    vec2 global_taaJitter;
    CameraData global_cameraData;
    vec2 global_mipmapSizes[16];
    vec2 global_mipmapSizesRcp[16];
    ivec4 global_mipmapTiles3[16];
    ivec2 global_mipmapSizesI[16];
    ivec2 global_mipmapSizePrefixesPadded[16];
    ivec2 global_mipmapSizePrefixes[16];
    ivec4 global_hizTiles[16];
    ivec4 global_mipmapTileCeil[16];
    ivec4 global_mipmapTileCeilPadded[16];
    ivec3 global_shadowAABBMinPrev;
    ivec3 global_shadowAABBMaxPrev;
    ivec3 global_shadowAABBMin;
    ivec3 global_shadowAABBMax;
    vec3 global_shadowAABBMinHistory;
    vec3 global_shadowAABBMaxHistory;
    ivec3 global_shadowAABBMinNew;
    ivec3 global_shadowAABBMaxNew;
    float global_focusDistance;
    int global_lastWorldTime;
    float global_historyResetFactor;
    vec4 global_motionFactor;
    vec4 global_taaResetFactor;
    float global_turbidity;
    AEData global_aeData;
    uint global_atomicCounters[16];
};
layout(std430, binding = 1) GLOBAL_DATA_MODIFIER IndirectComputeData {
    uint indirectComputeData[];
};
const vec2 SHADOW_MAP_SIZE = vec2(float(shadowMapResolution), 1.0 / float(shadowMapResolution));
uniform usampler2D usam_geometryNormal;
uniform usampler2D colortex8;
uniform usampler2D colortex9;
uniform sampler2D colortex10;
uniform sampler2D shadowtex0;
uniform sampler2D usam_rgba16f;
uniform sampler2D usam_frgba16f;
uniform sampler2D usam_fr32f;
uniform sampler2D usam_frgba16;
uniform sampler3D usam_skyViewLUT;
uniform usampler2D usam_epipolarData;
uniform sampler3D usam_cloudsAmbLUT;
uniform usampler2D usam_envProbe;
uniform sampler2D usam_starmap;
#define saturate(x) clamp(x, 0.0, 1.0)
ivec2 _textile_texelToTexel(ivec2 texelPos, ivec2 tileOffset, ivec2 tileSize) {
    return clamp(texelPos, ivec2(0), tileSize - 1) + tileOffset;
}
vec2 _textile_uvToUV(vec2 uv, vec2 tileOffsetF, vec2 tileSizeF, vec2 atlastSizeRcp) {
    vec2 textureTexelPos = clamp(uv * tileSizeF, vec2(0.5), tileSizeF - 0.5) + tileOffsetF;
    return saturate(textureTexelPos * atlastSizeRcp);
}
vec2 _textile_uvToGatherUV(vec2 uv, vec2 tileOffsetF, vec2 tileSizeF, vec2 atlastSizeRcp) {
    vec2 textureTexelPos = clamp(uv * tileSizeF, vec2(1.0), tileSizeF - 1.0) + tileOffsetF;
    return saturate(textureTexelPos * atlastSizeRcp);
}
vec2 _textile_texelToGatherUV(vec2 texelPos, vec2 tileOffsetF, vec2 tileSizeF, vec2 atlastSizeRcp) {
    vec2 textureTexelPos = clamp(texelPos, vec2(1.0), tileSizeF - 1.0) + tileOffsetF;
    return saturate(textureTexelPos * atlastSizeRcp);
}
#undef saturate
#define _shadesmith_RGBA16F_7_OFFSET (uval_mainImageSizeI * ivec2(2, 1))
#define _shadesmith_RGBA16F_7_SIZE uval_mainImageSizeI
#define _shadesmith_RGBA16F_7_TEXEL_TO_TEXEL(texelPos) _textile_texelToTexel(texelPos, _shadesmith_RGBA16F_7_OFFSET, _shadesmith_RGBA16F_7_SIZE)
#define _shadesmith_RGBA16F_8_OFFSET (uval_mainImageSizeI * ivec2(2, 2))
#define _shadesmith_RGBA16F_8_SIZE uval_mainImageSizeI
#define _shadesmith_RGBA16F_8_TEXEL_TO_TEXEL(texelPos) _textile_texelToTexel(texelPos, _shadesmith_RGBA16F_8_OFFSET, _shadesmith_RGBA16F_8_SIZE)
#define history_taa_store(x, v) imageStore(uimg_rgba16f, _shadesmith_RGBA16F_7_TEXEL_TO_TEXEL(x), v)
#define transient_taaOutput_fetch(x) texelFetch(usam_rgba16f, _shadesmith_RGBA16F_8_TEXEL_TO_TEXEL(x), 0)
#define _shadesmith_FRGBA16F_ATLAS_SIZE vec2(1024.0, 832.0)
#define _shadesmith_FRGBA16F_ATLAS_SIZE_RCP (vec2(1.0) / _shadesmith_FRGBA16F_ATLAS_SIZE)
#define _shadesmith_FRGBA16F_1_OFFSET_F vec2(0.0, 768.0)
#define _shadesmith_FRGBA16F_1_SIZE_F vec2(256.0, 64.0)
#define _shadesmith_FRGBA16F_1_UV_TO_UV(uv) _textile_uvToUV(uv, _shadesmith_FRGBA16F_1_OFFSET_F, _shadesmith_FRGBA16F_1_SIZE_F, _shadesmith_FRGBA16F_ATLAS_SIZE_RCP)
#define _shadesmith_FRGBA16F_2_OFFSET_F vec2(256.0, 768.0)
#define _shadesmith_FRGBA16F_2_SIZE_F vec2(32.0, 32.0)
#define _shadesmith_FRGBA16F_2_UV_TO_UV(uv) _textile_uvToUV(uv, _shadesmith_FRGBA16F_2_OFFSET_F, _shadesmith_FRGBA16F_2_SIZE_F, _shadesmith_FRGBA16F_ATLAS_SIZE_RCP)
#define persistent_transmittanceLUT_sample(x) texture(usam_frgba16f, _shadesmith_FRGBA16F_1_UV_TO_UV(x))
#define persistent_multiSctrLUT_sample(x) texture(usam_frgba16f, _shadesmith_FRGBA16F_2_UV_TO_UV(x))
#define _shadesmith_FR32F_ATLAS_SIZE vec2(256.0, 262.0)
#define _shadesmith_FR32F_ATLAS_SIZE_RCP (vec2(1.0) / _shadesmith_FR32F_ATLAS_SIZE)
#define _shadesmith_FR32F_0_OFFSET_F vec2(0.0, 0.0)
#define _shadesmith_FR32F_0_SIZE_F vec2(256.0, 256.0)
#define _shadesmith_FR32F_0_UV_TO_UV(uv) _textile_uvToUV(uv, _shadesmith_FR32F_0_OFFSET_F, _shadesmith_FR32F_0_SIZE_F, _shadesmith_FR32F_ATLAS_SIZE_RCP)
#define _shadesmith_FR32F_1_OFFSET_F vec2(0.0, 256.0)
#define _shadesmith_FR32F_1_SIZE_F vec2(256.0, 2.0)
#define _shadesmith_FR32F_1_UV_TO_UV(uv) _textile_uvToUV(uv, _shadesmith_FR32F_1_OFFSET_F, _shadesmith_FR32F_1_SIZE_F, _shadesmith_FR32F_ATLAS_SIZE_RCP)
#define _shadesmith_FR32F_2_OFFSET_F vec2(0.0, 258.0)
#define _shadesmith_FR32F_2_SIZE_F vec2(256.0, 2.0)
#define _shadesmith_FR32F_2_UV_TO_UV(uv) _textile_uvToUV(uv, _shadesmith_FR32F_2_OFFSET_F, _shadesmith_FR32F_2_SIZE_F, _shadesmith_FR32F_ATLAS_SIZE_RCP)
#define persistent_rtwsm_importance2D_sample(x) texture(usam_fr32f, _shadesmith_FR32F_0_UV_TO_UV(x))
#define persistent_rtwsm_importance1D_sample(x) texture(usam_fr32f, _shadesmith_FR32F_1_UV_TO_UV(x))
#define persistent_rtwsm_warp_sample(x) texture(usam_fr32f, _shadesmith_FR32F_2_UV_TO_UV(x))
#define _shadesmith_FRGBA16_ATLAS_SIZE vec2(256.0, 256.0)
#define _shadesmith_FRGBA16_ATLAS_SIZE_RCP (vec2(1.0) / _shadesmith_FRGBA16_ATLAS_SIZE)
#define _shadesmith_FRGBA16_0_OFFSET_F vec2(0.0, 0.0)
#define _shadesmith_FRGBA16_0_SIZE_F vec2(256.0, 256.0)
#define _shadesmith_FRGBA16_0_UV_TO_UV(uv) _textile_uvToUV(uv, _shadesmith_FRGBA16_0_OFFSET_F, _shadesmith_FRGBA16_0_SIZE_F, _shadesmith_FRGBA16_ATLAS_SIZE_RCP)
#define persistent_rtwsm_warpTexelSize_sample(x) texture(usam_frgba16, _shadesmith_FRGBA16_0_UV_TO_UV(x))
#if defined MC_GL_AMD_gpu_shader_half_float
#extension GL_AMD_gpu_shader_half_float : enable
#elif defined MC_GL_NV_gpu_shader5
#extension GL_NV_gpu_shader5 : enable
#else
#define NO_HALF
#define hf
#define float16_t float
#define f16vec2 vec2
#define f16vec3 vec3
#define f16vec4 vec4
#define f16mat2 mat2
#define f16mat3 mat3
#define f16mat4 mat4
#endif
vec4 rcas_loadInput(ivec2 texelPos, bool center);
void rcas_storeOutput(ivec2 texelPos, vec4 color);
float rcas_sharpness();
vec4 LoadRCas_Input(ivec2 p, bool center) {
    return rcas_loadInput(p, center);
}
void StoreRCasOutput(ivec2 p, vec4 color) {
    rcas_storeOutput(p, color);
}
uvec4 RCasConfig() {
    float sharpnessRemapped = rcas_sharpness() * -2.0 + 2.0;
    float sharpness = exp2(-sharpnessRemapped);
    uvec4 config = uvec4(0);
    config.x = floatBitsToUint(sharpness);
    config.y = packHalf2x16(vec2(sharpness));
    return config;
}
/*
    This file is part of the FidelityFX SDK.

    Copyright (C) 2024 Advanced Micro Devices, Inc.

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files(the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions :

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
*/
#define GROUP_SIZE  8
#define FSR_RCAS_DENOISE 1
#define FFX_GLSL 1
#define FFX_GPU 1
/*
    This file is part of the FidelityFX SDK.

    Copyright (C) 2024 Advanced Micro Devices, Inc.

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files(the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions :

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
*/
#ifndef FFX_COMMON_TYPES_H
#define FFX_COMMON_TYPES_H a
#define FFX_PARAMETER_IN        in
#define FFX_PARAMETER_OUT       out
#define FFX_PARAMETER_INOUT     inout
#define FfxFloat32Mat4 mat4
#define FfxFloat32Mat3 mat3
#define FfxBoolean   bool
#define FfxFloat32   float
#define FfxFloat32x2 vec2
#define FfxFloat32x3 vec3
#define FfxFloat32x4 vec4
#define FfxUInt32    uint
#define FfxUInt32x2  uvec2
#define FfxUInt32x3  uvec3
#define FfxUInt32x4  uvec4
#define FfxInt32     int
#define FfxInt32x2   ivec2
#define FfxInt32x3   ivec3
#define FfxInt32x4   ivec4
#define FfxFloat32x4x4 mat4
#define FfxFloat32x3x4 mat4x3
#define FfxFloat32x3x3 mat3
#define FfxFloat32x2x2 mat2
#if FFX_HALF
#define FfxFloat16   float16_t
#define FfxFloat16x2 f16vec2
#define FfxFloat16x3 f16vec3
#define FfxFloat16x4 f16vec4
#define FfxUInt16    uint16_t
#define FfxUInt16x2  u16vec2
#define FfxUInt16x3  u16vec3
#define FfxUInt16x4  u16vec4
#define FfxInt16     int16_t
#define FfxInt16x2   i16vec2
#define FfxInt16x3   i16vec3
#define FfxInt16x4   i16vec4
#endif 
#if FFX_HALF
#if FFX_HLSL_SM >= 62
#define FFX_MIN16_SCALAR( TypeName, BaseComponentType )           typedef BaseComponentType##16_t TypeName;
#define FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL )      typedef vector<BaseComponentType##16_t, COL> TypeName;
#define FFX_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType##16_t, ROW, COL> TypeName;
#define FFX_16BIT_SCALAR( TypeName, BaseComponentType )           typedef BaseComponentType##16_t TypeName;
#define FFX_16BIT_VECTOR( TypeName, BaseComponentType, COL )      typedef vector<BaseComponentType##16_t, COL> TypeName;
#define FFX_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType##16_t, ROW, COL> TypeName;
#else 
#define FFX_MIN16_SCALAR( TypeName, BaseComponentType )           typedef min16##BaseComponentType TypeName;
#define FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL )      typedef vector<min16##BaseComponentType, COL> TypeName;
#define FFX_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<min16##BaseComponentType, ROW, COL> TypeName;
#define FFX_16BIT_SCALAR( TypeName, BaseComponentType )           FFX_MIN16_SCALAR( TypeName, BaseComponentType );
#define FFX_16BIT_VECTOR( TypeName, BaseComponentType, COL )      FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL );
#define FFX_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) FFX_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL );
#endif 
#else 
#define FFX_MIN16_SCALAR( TypeName, BaseComponentType )           typedef BaseComponentType TypeName;
#define FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL )      typedef vector<BaseComponentType, COL> TypeName;
#define FFX_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType, ROW, COL> TypeName;
#define FFX_16BIT_SCALAR( TypeName, BaseComponentType )           typedef BaseComponentType TypeName;
#define FFX_16BIT_VECTOR( TypeName, BaseComponentType, COL )      typedef vector<BaseComponentType, COL> TypeName;
#define FFX_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType, ROW, COL> TypeName;
#endif 
#if FFX_HALF
#define  FFX_MIN16_F  float16_t
#define  FFX_MIN16_F2 f16vec2
#define  FFX_MIN16_F3 f16vec3
#define  FFX_MIN16_F4 f16vec4
#define  FFX_MIN16_I  int16_t
#define  FFX_MIN16_I2 i16vec2
#define  FFX_MIN16_I3 i16vec3
#define  FFX_MIN16_I4 i16vec4
#define  FFX_MIN16_U  uint16_t
#define  FFX_MIN16_U2 u16vec2
#define  FFX_MIN16_U3 u16vec3
#define  FFX_MIN16_U4 u16vec4
#define FFX_16BIT_F  float16_t
#define FFX_16BIT_F2 f16vec2
#define FFX_16BIT_F3 f16vec3
#define FFX_16BIT_F4 f16vec4
#define FFX_16BIT_I  int16_t
#define FFX_16BIT_I2 i16vec2
#define FFX_16BIT_I3 i16vec3
#define FFX_16BIT_I4 i16vec4
#define FFX_16BIT_U  uint16_t
#define FFX_16BIT_U2 u16vec2
#define FFX_16BIT_U3 u16vec3
#define FFX_16BIT_U4 u16vec4
#else 
#define  FFX_MIN16_F  float
#define  FFX_MIN16_F2 vec2
#define  FFX_MIN16_F3 vec3
#define  FFX_MIN16_F4 vec4
#define  FFX_MIN16_I  int
#define  FFX_MIN16_I2 ivec2
#define  FFX_MIN16_I3 ivec3
#define  FFX_MIN16_I4 ivec4
#define  FFX_MIN16_U  uint
#define  FFX_MIN16_U2 uvec2
#define  FFX_MIN16_U3 uvec3
#define  FFX_MIN16_U4 uvec4
#define FFX_16BIT_F  float
#define FFX_16BIT_F2 vec2
#define FFX_16BIT_F3 vec3
#define FFX_16BIT_F4 vec4
#define FFX_16BIT_I  int
#define FFX_16BIT_I2 ivec2
#define FFX_16BIT_I3 ivec3
#define FFX_16BIT_I4 ivec4
#define FFX_16BIT_U  uint
#define FFX_16BIT_U2 uvec2
#define FFX_16BIT_U3 uvec3
#define FFX_16BIT_U4 uvec4
#endif 
#endif 
/*
    This file is part of the FidelityFX SDK.

    Copyright (C) 2024 Advanced Micro Devices, Inc.

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files(the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions :

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
*/
#define FFX_SELECT(cond, arg1, arg2) cond ? arg1 : arg2
#define FFX_GROUPSHARED shared
#define FFX_GROUP_MEMORY_BARRIER groupMemoryBarrier(); barrier()
#define FFX_ATOMIC_ADD(x, y) atomicAdd(x, y)
#define FFX_ATOMIC_ADD_RETURN(x, y, r) r = atomicAdd(x, y)
#define FFX_ATOMIC_OR(x, y) atomicOr(x, y)
#define FFX_ATOMIC_MIN(x, y) atomicMin(x, y)
#define FFX_ATOMIC_MAX(x, y) atomicMax(x, y)
#define FFX_STATIC
#define FFX_UNROLL
#define FFX_GREATER_THAN(x, y) greaterThan(x, y)
#define FFX_GREATER_THAN_EQUAL(x, y) greaterThanEqual(x, y)
#define FFX_LESS_THAN(x, y) lessThan(x, y)
#define FFX_LESS_THAN_EQUAL(x, y) lessThanEqual(x, y)
#define FFX_EQUAL(x, y) equal(x, y)
#define FFX_NOT_EQUAL(x, y) notEqual(x, y)
#define FFX_MATRIX_MULTIPLY(a, b) (a * b)
#define FFX_TRANSFORM_VECTOR(a, b) (a * b)
#define FFX_MODULO(a, b) (mod(a, b))
#define FFX_BROADCAST_FLOAT32(x)   FfxFloat32(x)
#define FFX_BROADCAST_FLOAT32X2(x) FfxFloat32x2(FfxFloat32(x))
#define FFX_BROADCAST_FLOAT32X3(x) FfxFloat32x3(FfxFloat32(x))
#define FFX_BROADCAST_FLOAT32X4(x) FfxFloat32x4(FfxFloat32(x))
#define FFX_BROADCAST_UINT32(x)   FfxUInt32(x)
#define FFX_BROADCAST_UINT32X2(x) FfxUInt32x2(FfxUInt32(x))
#define FFX_BROADCAST_UINT32X3(x) FfxUInt32x3(FfxUInt32(x))
#define FFX_BROADCAST_UINT32X4(x) FfxUInt32x4(FfxUInt32(x))
#define FFX_BROADCAST_INT32(x)   FfxInt32(x)
#define FFX_BROADCAST_INT32X2(x) FfxInt32x2(FfxInt32(x))
#define FFX_BROADCAST_INT32X3(x) FfxInt32x3(FfxInt32(x))
#define FFX_BROADCAST_INT32X4(x) FfxInt32x4(FfxInt32(x))
#define FFX_BROADCAST_MIN_FLOAT16(x)   FFX_MIN16_F(x)
#define FFX_BROADCAST_MIN_FLOAT16X2(x) FFX_MIN16_F2(FFX_MIN16_F(x))
#define FFX_BROADCAST_MIN_FLOAT16X3(x) FFX_MIN16_F3(FFX_MIN16_F(x))
#define FFX_BROADCAST_MIN_FLOAT16X4(x) FFX_MIN16_F4(FFX_MIN16_F(x))
#define FFX_BROADCAST_MIN_UINT16(x)   FFX_MIN16_U(x)
#define FFX_BROADCAST_MIN_UINT16X2(x) FFX_MIN16_U2(FFX_MIN16_U(x))
#define FFX_BROADCAST_MIN_UINT16X3(x) FFX_MIN16_U3(FFX_MIN16_U(x))
#define FFX_BROADCAST_MIN_UINT16X4(x) FFX_MIN16_U4(FFX_MIN16_U(x))
#define FFX_BROADCAST_MIN_INT16(x)   FFX_MIN16_I(x)
#define FFX_BROADCAST_MIN_INT16X2(x) FFX_MIN16_I2(FFX_MIN16_I(x))
#define FFX_BROADCAST_MIN_INT16X3(x) FFX_MIN16_I3(FFX_MIN16_I(x))
#define FFX_BROADCAST_MIN_INT16X4(x) FFX_MIN16_I4(FFX_MIN16_I(x))
#if !defined(FFX_SKIP_EXT)
#if FFX_HALF
    #extension GL_EXT_shader_16bit_storage : require
#endif 
#if defined(FFX_LONG)
    #extension GL_ARB_gpu_shader_int64 : require
    #extension GL_NV_shader_atomic_int64 : require
#endif 
#if defined(FFX_WAVE)
    #extension GL_KHR_shader_subgroup_arithmetic : require
    #extension GL_KHR_shader_subgroup_ballot : require
    #extension GL_KHR_shader_subgroup_quad : require
    #extension GL_KHR_shader_subgroup_shuffle : require
#endif 
#endif 
FfxFloat32 ffxSqrt(FfxFloat32 x);
FfxFloat32x2 ffxSqrt(FfxFloat32x2 x);
FfxFloat32x3 ffxSqrt(FfxFloat32x3 x);
FfxFloat32x4 ffxSqrt(FfxFloat32x4 x);
FfxFloat32 ffxAsFloat(FfxUInt32 x)
{
    return uintBitsToFloat(x);
}
FfxFloat32x2 ffxAsFloat(FfxUInt32x2 x)
{
    return uintBitsToFloat(x);
}
FfxFloat32x3 ffxAsFloat(FfxUInt32x3 x)
{
    return uintBitsToFloat(x);
}
FfxFloat32x4 ffxAsFloat(FfxUInt32x4 x)
{
    return uintBitsToFloat(x);
}
FfxUInt32 ffxAsUInt32(FfxFloat32 x)
{
    return floatBitsToUint(x);
}
FfxUInt32x2 ffxAsUInt32(FfxFloat32x2 x)
{
    return floatBitsToUint(x);
}
FfxUInt32x3 ffxAsUInt32(FfxFloat32x3 x)
{
    return floatBitsToUint(x);
}
FfxUInt32x4 ffxAsUInt32(FfxFloat32x4 x)
{
    return floatBitsToUint(x);
}
FfxUInt32 ffxPackHalf2x16(FfxFloat32x2 value)
{
    return packHalf2x16(value);
}
FfxFloat32x2 ffxBroadcast2(FfxFloat32 value)
{
    return FfxFloat32x2(value, value);
}
FfxFloat32x3 ffxBroadcast3(FfxFloat32 value)
{
    return FfxFloat32x3(value, value, value);
}
FfxFloat32x4 ffxBroadcast4(FfxFloat32 value)
{
    return FfxFloat32x4(value, value, value, value);
}
FfxInt32x2 ffxBroadcast2(FfxInt32 value)
{
    return FfxInt32x2(value, value);
}
FfxInt32x3 ffxBroadcast3(FfxInt32 value)
{
    return FfxInt32x3(value, value, value);
}
FfxInt32x4 ffxBroadcast4(FfxInt32 value)
{
    return FfxInt32x4(value, value, value, value);
}
FfxUInt32x2 ffxBroadcast2(FfxUInt32 value)
{
    return FfxUInt32x2(value, value);
}
FfxUInt32x3 ffxBroadcast3(FfxUInt32 value)
{
    return FfxUInt32x3(value, value, value);
}
FfxUInt32x4 ffxBroadcast4(FfxUInt32 value)
{
    return FfxUInt32x4(value, value, value, value);
}
FfxFloat32 ffxMax3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z)
{
    return max(x, max(y, z));
}
FfxFloat32x2 ffxMax3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z)
{
    return max(x, max(y, z));
}
FfxFloat32x3 ffxMax3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z)
{
    return max(x, max(y, z));
}
FfxFloat32x4 ffxMax3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z)
{
    return max(x, max(y, z));
}
FfxUInt32 ffxMax3(FfxUInt32 x, FfxUInt32 y, FfxUInt32 z)
{
    return max(x, max(y, z));
}
FfxUInt32x2 ffxMax3(FfxUInt32x2 x, FfxUInt32x2 y, FfxUInt32x2 z)
{
    return max(x, max(y, z));
}
FfxUInt32x3 ffxMax3(FfxUInt32x3 x, FfxUInt32x3 y, FfxUInt32x3 z)
{
    return max(x, max(y, z));
}
FfxUInt32x4 ffxMax3(FfxUInt32x4 x, FfxUInt32x4 y, FfxUInt32x4 z)
{
    return max(x, max(y, z));
}
FfxFloat32 ffxMin3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z)
{
    return min(x, min(y, z));
}
FfxFloat32x2 ffxMin3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z)
{
    return min(x, min(y, z));
}
FfxFloat32x3 ffxMin3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z)
{
    return min(x, min(y, z));
}
FfxFloat32x4 ffxMin3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z)
{
    return min(x, min(y, z));
}
FfxUInt32 ffxMin3(FfxUInt32 x, FfxUInt32 y, FfxUInt32 z)
{
    return min(x, min(y, z));
}
FfxUInt32x2 ffxMin3(FfxUInt32x2 x, FfxUInt32x2 y, FfxUInt32x2 z)
{
    return min(x, min(y, z));
}
FfxUInt32x3 ffxMin3(FfxUInt32x3 x, FfxUInt32x3 y, FfxUInt32x3 z)
{
    return min(x, min(y, z));
}
FfxUInt32x4 ffxMin3(FfxUInt32x4 x, FfxUInt32x4 y, FfxUInt32x4 z)
{
    return min(x, min(y, z));
}
FfxFloat32 ffxReciprocal(FfxFloat32 x)
{
    return FfxFloat32(1.0) / x;
}
FfxFloat32x2 ffxReciprocal(FfxFloat32x2 x)
{
    return ffxBroadcast2(1.0) / x;
}
FfxFloat32x3 ffxReciprocal(FfxFloat32x3 x)
{
    return ffxBroadcast3(1.0) / x;
}
FfxFloat32x4 ffxReciprocal(FfxFloat32x4 x)
{
    return ffxBroadcast4(1.0) / x;
}
FfxFloat32 ffxSaturate(FfxFloat32 x)
{
    return clamp(x, FfxFloat32(0.0), FfxFloat32(1.0));
}
FfxFloat32x2 ffxSaturate(FfxFloat32x2 x)
{
    return clamp(x, ffxBroadcast2(0.0), ffxBroadcast2(1.0));
}
FfxFloat32x3 ffxSaturate(FfxFloat32x3 x)
{
    return clamp(x, ffxBroadcast3(0.0), ffxBroadcast3(1.0));
}
FfxFloat32x4 ffxSaturate(FfxFloat32x4 x)
{
    return clamp(x, ffxBroadcast4(0.0), ffxBroadcast4(1.0));
}
#if FFX_HALF
#define FFX_UINT32_TO_FLOAT16X2(x) unpackFloat2x16(FfxUInt32(x))
FfxFloat16x4 ffxUint32x2ToFloat16x4(FfxUInt32x2 x)
{
    return FfxFloat16x4(unpackFloat2x16(x.x), unpackFloat2x16(x.y));
}
#define FFX_UINT32X2_TO_FLOAT16X4(x) ffxUint32x2ToFloat16x4(FfxUInt32x2(x))
#define FFX_UINT32_TO_UINT16X2(x) unpackUint2x16(FfxUInt32(x))
#define FFX_UINT32X2_TO_UINT16X4(x) unpackUint4x16(pack64(FfxUInt32x2(x)))
#define FFX_FLOAT16X2_TO_UINT32(x) packFloat2x16(FfxFloat16x2(x))
FfxUInt32x2 ffxFloat16x4ToUint32x2(FfxFloat16x4 x)
{
    return FfxUInt32x2(packFloat2x16(x.xy), packFloat2x16(x.zw));
}
#define FFX_FLOAT16X4_TO_UINT32X2(x) ffxFloat16x4ToUint32x2(FfxFloat16x4(x))
#define FFX_UINT16X2_TO_UINT32(x) packUint2x16(FfxUInt16x2(x))
#define FFX_UINT16X4_TO_UINT32X2(x) unpack32(packUint4x16(FfxUInt16x4(x)))
#define FFX_TO_UINT16(x) halfBitsToUint16(FfxFloat16(x))
#define FFX_TO_UINT16X2(x) halfBitsToUint16(FfxFloat16x2(x))
#define FFX_TO_UINT16X3(x) halfBitsToUint16(FfxFloat16x3(x))
#define FFX_TO_UINT16X4(x) halfBitsToUint16(FfxFloat16x4(x))
#define FFX_TO_FLOAT16(x) uint16BitsToHalf(FfxUInt16(x))
#define FFX_TO_FLOAT16X2(x) uint16BitsToHalf(FfxUInt16x2(x))
#define FFX_TO_FLOAT16X3(x) uint16BitsToHalf(FfxUInt16x3(x))
#define FFX_TO_FLOAT16X4(x) uint16BitsToHalf(FfxUInt16x4(x))
#define FFX_BROADCAST_FLOAT16(a)   FfxFloat16(a)
#define FFX_BROADCAST_FLOAT16X2(a) FfxFloat16x2(FfxFloat16(a))
#define FFX_BROADCAST_FLOAT16X3(a) FfxFloat16x3(FfxFloat16(a))
#define FFX_BROADCAST_FLOAT16X4(a) FfxFloat16x4(FfxFloat16(a))
#define FFX_BROADCAST_INT16(a)   FfxInt16(a)
#define FFX_BROADCAST_INT16X2(a) FfxInt16x2(FfxInt16(a))
#define FFX_BROADCAST_INT16X3(a) FfxInt16x3(FfxInt16(a))
#define FFX_BROADCAST_INT16X4(a) FfxInt16x4(FfxInt16(a))
#define FFX_BROADCAST_UINT16(a)   FfxUInt16(a)
#define FFX_BROADCAST_UINT16X2(a) FfxUInt16x2(FfxUInt16(a))
#define FFX_BROADCAST_UINT16X3(a) FfxUInt16x3(FfxUInt16(a))
#define FFX_BROADCAST_UINT16X4(a) FfxUInt16x4(FfxUInt16(a))
FfxFloat16 ffxMax3Half(FfxFloat16 x, FfxFloat16 y, FfxFloat16 z)
{
    return max(x, max(y, z));
}
FfxFloat16x2 ffxMax3Half(FfxFloat16x2 x, FfxFloat16x2 y, FfxFloat16x2 z)
{
    return max(x, max(y, z));
}
FfxFloat16x3 ffxMax3Half(FfxFloat16x3 x, FfxFloat16x3 y, FfxFloat16x3 z)
{
    return max(x, max(y, z));
}
FfxFloat16x4 ffxMax3Half(FfxFloat16x4 x, FfxFloat16x4 y, FfxFloat16x4 z)
{
    return max(x, max(y, z));
}
FfxFloat16 ffxMin3Half(FfxFloat16 x, FfxFloat16 y, FfxFloat16 z)
{
    return min(x, min(y, z));
}
FfxFloat16x2 ffxMin3Half(FfxFloat16x2 x, FfxFloat16x2 y, FfxFloat16x2 z)
{
    return min(x, min(y, z));
}
FfxFloat16x3 ffxMin3Half(FfxFloat16x3 x, FfxFloat16x3 y, FfxFloat16x3 z)
{
    return min(x, min(y, z));
}
FfxFloat16x4 ffxMin3Half(FfxFloat16x4 x, FfxFloat16x4 y, FfxFloat16x4 z)
{
    return min(x, min(y, z));
}
FfxFloat16 ffxSaturate(FfxFloat16 x)
{
    return clamp(x, FFX_BROADCAST_FLOAT16(0.0), FFX_BROADCAST_FLOAT16(1.0));
}
FfxFloat16x2 ffxSaturate(FfxFloat16x2 x)
{
    return clamp(x, FFX_BROADCAST_FLOAT16X2(0.0), FFX_BROADCAST_FLOAT16X2(1.0));
}
FfxFloat16x3 ffxSaturate(FfxFloat16x3 x)
{
    return clamp(x, FFX_BROADCAST_FLOAT16X3(0.0), FFX_BROADCAST_FLOAT16X3(1.0));
}
FfxFloat16x4 ffxSaturate(FfxFloat16x4 x)
{
    return clamp(x, FFX_BROADCAST_FLOAT16X4(0.0), FFX_BROADCAST_FLOAT16X4(1.0));
}
#endif 
#if defined(FFX_WAVE)
#if defined(FFX_WAVE_ALL_TRUE)
#endif
#if FFX_HALF
#endif 
#endif 
/*
    This file is part of the FidelityFX SDK.

    Copyright (C) 2024 Advanced Micro Devices, Inc.

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files(the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions :

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
*/
#define FFX_TRUE (true)
#define FFX_FALSE (false)
#define FFX_POSITIVE_INFINITY_FLOAT ffxAsFloat(0x7f800000u)
#define FFX_NEGATIVE_INFINITY_FLOAT ffxAsFloat(0xff800000u)
#define FFX_PI  (3.14159)
FFX_STATIC const FfxFloat32 FFX_FP16_MIN = 6.10e-05f;
FFX_STATIC const FfxFloat32 FFX_FP16_MAX = 65504.0f;
FFX_STATIC const FfxFloat32 FFX_TONEMAP_EPSILON = 1.0f / FFX_FP16_MAX;
#define FFX_HAS_FLAG(v, f) ((v & f) == f)
FfxFloat32 ffxMin(FfxFloat32 x, FfxFloat32 y)
{
    return min(x, y);
}
FfxFloat32x2 ffxMin(FfxFloat32x2 x, FfxFloat32x2 y)
{
    return min(x, y);
}
FfxFloat32x3 ffxMin(FfxFloat32x3 x, FfxFloat32x3 y)
{
    return min(x, y);
}
FfxFloat32x4 ffxMin(FfxFloat32x4 x, FfxFloat32x4 y)
{
    return min(x, y);
}
FfxInt32 ffxMin(FfxInt32 x, FfxInt32 y)
{
    return min(x, y);
}
FfxInt32x2 ffxMin(FfxInt32x2 x, FfxInt32x2 y)
{
    return min(x, y);
}
FfxInt32x3 ffxMin(FfxInt32x3 x, FfxInt32x3 y)
{
    return min(x, y);
}
FfxInt32x4 ffxMin(FfxInt32x4 x, FfxInt32x4 y)
{
    return min(x, y);
}
FfxUInt32 ffxMin(FfxUInt32 x, FfxUInt32 y)
{
    return min(x, y);
}
FfxUInt32x2 ffxMin(FfxUInt32x2 x, FfxUInt32x2 y)
{
    return min(x, y);
}
FfxUInt32x3 ffxMin(FfxUInt32x3 x, FfxUInt32x3 y)
{
    return min(x, y);
}
FfxUInt32x4 ffxMin(FfxUInt32x4 x, FfxUInt32x4 y)
{
    return min(x, y);
}
FfxFloat32 ffxSqrt(FfxFloat32 x)
{
    return sqrt(x);
}
FfxFloat32x2 ffxSqrt(FfxFloat32x2 x)
{
    return sqrt(x);
}
FfxFloat32x3 ffxSqrt(FfxFloat32x3 x)
{
    return sqrt(x);
}
FfxFloat32x4 ffxSqrt(FfxFloat32x4 x)
{
    return sqrt(x);
}
FfxFloat32 ffxApproximateReciprocalMedium(FfxFloat32 value)
{
    FfxFloat32 b = ffxAsFloat(FfxUInt32(0x7ef19fff) - ffxAsUInt32(value));
    return b * (-b * value + FfxFloat32(2.0));
}
FfxFloat32x2 ffxApproximateReciprocalMedium(FfxFloat32x2 value)
{
    FfxFloat32x2 b = ffxAsFloat(ffxBroadcast2(0x7ef19fffu) - ffxAsUInt32(value));
    return b * (-b * value + ffxBroadcast2(2.0f));
}
FfxFloat32x3 ffxApproximateReciprocalMedium(FfxFloat32x3 value)
{
    FfxFloat32x3 b = ffxAsFloat(ffxBroadcast3(0x7ef19fffu) - ffxAsUInt32(value));
    return b * (-b * value + ffxBroadcast3(2.0f));
}
FfxFloat32x4 ffxApproximateReciprocalMedium(FfxFloat32x4 value)
{
    FfxFloat32x4 b = ffxAsFloat(ffxBroadcast4(0x7ef19fffu) - ffxAsUInt32(value));
    return b * (-b * value + ffxBroadcast4(2.0f));
}
/*
    This file is part of the FidelityFX SDK.

    Copyright (C) 2024 Advanced Micro Devices, Inc.

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files(the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions :

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
*/
#if FFX_HALF
#if FFX_HLSL_SM >= 62
#define FFX_POSITIVE_INFINITY_HALF FFX_TO_FLOAT16((uint16_t)0x7c00u)
#define FFX_NEGATIVE_INFINITY_HALF FFX_TO_FLOAT16((uint16_t)0xfc00u)
#else
#define FFX_POSITIVE_INFINITY_HALF FFX_TO_FLOAT16(0x7c00u)
#define FFX_NEGATIVE_INFINITY_HALF FFX_TO_FLOAT16(0xfc00u)
#endif 
FfxFloat16 ffxMin(FfxFloat16 x, FfxFloat16 y)
{
    return min(x, y);
}
FfxFloat16x2 ffxMin(FfxFloat16x2 x, FfxFloat16x2 y)
{
    return min(x, y);
}
FfxFloat16x3 ffxMin(FfxFloat16x3 x, FfxFloat16x3 y)
{
    return min(x, y);
}
FfxFloat16x4 ffxMin(FfxFloat16x4 x, FfxFloat16x4 y)
{
    return min(x, y);
}
FfxInt16 ffxMin(FfxInt16 x, FfxInt16 y)
{
    return min(x, y);
}
FfxInt16x2 ffxMin(FfxInt16x2 x, FfxInt16x2 y)
{
    return min(x, y);
}
FfxInt16x3 ffxMin(FfxInt16x3 x, FfxInt16x3 y)
{
    return min(x, y);
}
FfxInt16x4 ffxMin(FfxInt16x4 x, FfxInt16x4 y)
{
    return min(x, y);
}
FfxUInt16 ffxMin(FfxUInt16 x, FfxUInt16 y)
{
    return min(x, y);
}
FfxUInt16x2 ffxMin(FfxUInt16x2 x, FfxUInt16x2 y)
{
    return min(x, y);
}
FfxUInt16x3 ffxMin(FfxUInt16x3 x, FfxUInt16x3 y)
{
    return min(x, y);
}
FfxUInt16x4 ffxMin(FfxUInt16x4 x, FfxUInt16x4 y)
{
    return min(x, y);
}
FfxFloat16 ffxSqrt(FfxFloat16 x)
{
    return sqrt(x);
}
FfxFloat16x2 ffxSqrt(FfxFloat16x2 x)
{
    return sqrt(x);
}
FfxFloat16x3 ffxSqrt(FfxFloat16x3 x)
{
    return sqrt(x);
}
FfxFloat16x4 ffxSqrt(FfxFloat16x4 x)
{
    return sqrt(x);
}
#endif  
/*
    This file is part of the FidelityFX SDK.

    Copyright (C) 2024 Advanced Micro Devices, Inc.

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files(the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions :

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
*/
#if FFX_HALF
    #define FSR_RCAS_HX2 1
    FfxFloat16x4 FsrRcasLoadHx2(FfxInt16x2 p, bool center)
    {
        return LoadRCas_Input(p, center);
    }
    void FsrRcasInputHx2(inout FfxFloat16x2 r,inout FfxFloat16x2 g,inout FfxFloat16x2 b) {}
#else
    #define FSR_RCAS_F 1
    FfxFloat32x4 FsrRcasLoadF(FfxInt32x2 p, bool center)
    {
        return LoadRCas_Input(p, center);
    }
    void FsrRcasInputF(inout FfxFloat32 r, inout FfxFloat32 g, inout FfxFloat32 b) {}
#endif 
#if FFX_FSR1_OPTION_RCAS_PASSTHROUGH_ALPHA
    #define FSR_RCAS_PASSTHROUGH_ALPHA a
#endif 
FFX_STATIC void ffxFsrPopulateEasuConstants(
    FFX_PARAMETER_INOUT FfxUInt32x4 con0,
    FFX_PARAMETER_INOUT FfxUInt32x4 con1,
    FFX_PARAMETER_INOUT FfxUInt32x4 con2,
    FFX_PARAMETER_INOUT FfxUInt32x4 con3,
    FFX_PARAMETER_IN FfxFloat32 inputViewportInPixelsX,
    FFX_PARAMETER_IN FfxFloat32 inputViewportInPixelsY,
    FFX_PARAMETER_IN FfxFloat32 inputSizeInPixelsX,
    FFX_PARAMETER_IN FfxFloat32 inputSizeInPixelsY,
    FFX_PARAMETER_IN FfxFloat32 outputSizeInPixelsX,
    FFX_PARAMETER_IN FfxFloat32 outputSizeInPixelsY)
{
    con0[0] = ffxAsUInt32(inputViewportInPixelsX * ffxReciprocal(outputSizeInPixelsX));
    con0[1] = ffxAsUInt32(inputViewportInPixelsY * ffxReciprocal(outputSizeInPixelsY));
    con0[2] = ffxAsUInt32(FfxFloat32(0.5) * inputViewportInPixelsX * ffxReciprocal(outputSizeInPixelsX) - FfxFloat32(0.5));
    con0[3] = ffxAsUInt32(FfxFloat32(0.5) * inputViewportInPixelsY * ffxReciprocal(outputSizeInPixelsY) - FfxFloat32(0.5));
    con1[0] = ffxAsUInt32(ffxReciprocal(inputSizeInPixelsX));
    con1[1] = ffxAsUInt32(ffxReciprocal(inputSizeInPixelsY));
    con1[2] = ffxAsUInt32(FfxFloat32(1.0) * ffxReciprocal(inputSizeInPixelsX));
    con1[3] = ffxAsUInt32(FfxFloat32(-1.0) * ffxReciprocal(inputSizeInPixelsY));
    con2[0] = ffxAsUInt32(FfxFloat32(-1.0) * ffxReciprocal(inputSizeInPixelsX));
    con2[1] = ffxAsUInt32(FfxFloat32(2.0) * ffxReciprocal(inputSizeInPixelsY));
    con2[2] = ffxAsUInt32(FfxFloat32(1.0) * ffxReciprocal(inputSizeInPixelsX));
    con2[3] = ffxAsUInt32(FfxFloat32(2.0) * ffxReciprocal(inputSizeInPixelsY));
    con3[0] = ffxAsUInt32(FfxFloat32(0.0) * ffxReciprocal(inputSizeInPixelsX));
    con3[1] = ffxAsUInt32(FfxFloat32(4.0) * ffxReciprocal(inputSizeInPixelsY));
    con3[2] = con3[3] = 0;
}
FFX_STATIC void ffxFsrPopulateEasuConstantsOffset(
    FFX_PARAMETER_INOUT FfxUInt32x4 con0,
    FFX_PARAMETER_INOUT FfxUInt32x4 con1,
    FFX_PARAMETER_INOUT FfxUInt32x4 con2,
    FFX_PARAMETER_INOUT FfxUInt32x4 con3,
    FFX_PARAMETER_IN FfxFloat32 inputViewportInPixelsX,
    FFX_PARAMETER_IN FfxFloat32 inputViewportInPixelsY,
    FFX_PARAMETER_IN FfxFloat32 inputSizeInPixelsX,
    FFX_PARAMETER_IN FfxFloat32 inputSizeInPixelsY,
    FFX_PARAMETER_IN FfxFloat32 outputSizeInPixelsX,
    FFX_PARAMETER_IN FfxFloat32 outputSizeInPixelsY,
    FFX_PARAMETER_IN FfxFloat32 inputOffsetInPixelsX,
    FFX_PARAMETER_IN FfxFloat32 inputOffsetInPixelsY)
{
    ffxFsrPopulateEasuConstants(
        con0,
        con1,
        con2,
        con3,
        inputViewportInPixelsX,
        inputViewportInPixelsY,
        inputSizeInPixelsX,
        inputSizeInPixelsY,
        outputSizeInPixelsX,
        outputSizeInPixelsY);
    con0[2] = ffxAsUInt32(FfxFloat32(0.5) * inputViewportInPixelsX * ffxReciprocal(outputSizeInPixelsX) - FfxFloat32(0.5) + inputOffsetInPixelsX);
    con0[3] = ffxAsUInt32(FfxFloat32(0.5) * inputViewportInPixelsY * ffxReciprocal(outputSizeInPixelsY) - FfxFloat32(0.5) + inputOffsetInPixelsY);
}
#if defined(FFX_GPU) && defined(FFX_FSR_EASU_FLOAT)
FfxFloat32x4 FsrEasuRF(FfxFloat32x2 p);
FfxFloat32x4 FsrEasuGF(FfxFloat32x2 p);
FfxFloat32x4 FsrEasuBF(FfxFloat32x2 p);
#endif 
#if defined(FFX_GPU) && FFX_HALF == 1 && defined(FFX_FSR_EASU_HALF)
FfxFloat16x4 FsrEasuRH(FfxFloat32x2 p);
FfxFloat16x4 FsrEasuGH(FfxFloat32x2 p);
FfxFloat16x4 FsrEasuBH(FfxFloat32x2 p);
#endif 
#define FSR_RCAS_LIMIT (0.25-(1.0/16.0))
 FFX_STATIC void FsrRcasCon(FfxUInt32x4 con,
                            FfxFloat32 sharpness)
 {
     sharpness = exp2(-sharpness);
     FfxFloat32x2 hSharp = {sharpness, sharpness};
     con[0] = ffxAsUInt32(sharpness);
     con[1] = ffxPackHalf2x16(hSharp);
     con[2] = 0;
     con[3] = 0;
 }
#if defined(FFX_GPU)&&defined(FSR_RCAS_F)
 FfxFloat32x4 FsrRcasLoadF(FfxInt32x2 p, bool center);
 void FsrRcasInputF(inout FfxFloat32 r,inout FfxFloat32 g,inout FfxFloat32 b);
 void FsrRcasF(out FfxFloat32 pixR,
               out FfxFloat32 pixG,
               out FfxFloat32 pixB,
#ifdef FSR_RCAS_PASSTHROUGH_ALPHA
               out FfxFloat32 pixA,
#endif
               FfxUInt32x2 ip,
               FfxUInt32x4 con)
 {
     FfxInt32x2 sp = FfxInt32x2(ip);
     FfxFloat32x3 b = FsrRcasLoadF(sp + FfxInt32x2(0, -1), false).rgb;
     FfxFloat32x3 d = FsrRcasLoadF(sp + FfxInt32x2(-1, 0), false).rgb;
#ifdef FSR_RCAS_PASSTHROUGH_ALPHA
     FfxFloat32x4 ee = FsrRcasLoadF(sp, true);
     FfxFloat32x3 e = ee.rgb;
     pixA = ee.a;
#else
     FfxFloat32x3 e = FsrRcasLoadF(sp, true).rgb;
#endif
     FfxFloat32x3 f = FsrRcasLoadF(sp + FfxInt32x2(1, 0), false).rgb;
     FfxFloat32x3 h = FsrRcasLoadF(sp + FfxInt32x2(0, 1), false).rgb;
     FfxFloat32 bR = b.r;
     FfxFloat32 bG = b.g;
     FfxFloat32 bB = b.b;
     FfxFloat32 dR = d.r;
     FfxFloat32 dG = d.g;
     FfxFloat32 dB = d.b;
     FfxFloat32 eR = e.r;
     FfxFloat32 eG = e.g;
     FfxFloat32 eB = e.b;
     FfxFloat32 fR = f.r;
     FfxFloat32 fG = f.g;
     FfxFloat32 fB = f.b;
     FfxFloat32 hR = h.r;
     FfxFloat32 hG = h.g;
     FfxFloat32 hB = h.b;
     FsrRcasInputF(bR, bG, bB);
     FsrRcasInputF(dR, dG, dB);
     FsrRcasInputF(eR, eG, eB);
     FsrRcasInputF(fR, fG, fB);
     FsrRcasInputF(hR, hG, hB);
     FfxFloat32 bL = bB * FfxFloat32(0.5) + (bR * FfxFloat32(0.5) + bG);
     FfxFloat32 dL = dB * FfxFloat32(0.5) + (dR * FfxFloat32(0.5) + dG);
     FfxFloat32 eL = eB * FfxFloat32(0.5) + (eR * FfxFloat32(0.5) + eG);
     FfxFloat32 fL = fB * FfxFloat32(0.5) + (fR * FfxFloat32(0.5) + fG);
     FfxFloat32 hL = hB * FfxFloat32(0.5) + (hR * FfxFloat32(0.5) + hG);
     FfxFloat32 nz = FfxFloat32(0.25) * bL + FfxFloat32(0.25) * dL + FfxFloat32(0.25) * fL + FfxFloat32(0.25) * hL - eL;
     nz = ffxSaturate(abs(nz) * ffxApproximateReciprocalMedium(ffxMax3(ffxMax3(bL, dL, eL), fL, hL) - ffxMin3(ffxMin3(bL, dL, eL), fL, hL)));
     nz = FfxFloat32(-0.5) * nz + FfxFloat32(1.0);
     FfxFloat32 mn4R = ffxMin(ffxMin3(bR, dR, fR), hR);
     FfxFloat32 mn4G = ffxMin(ffxMin3(bG, dG, fG), hG);
     FfxFloat32 mn4B = ffxMin(ffxMin3(bB, dB, fB), hB);
     FfxFloat32 mx4R = max(ffxMax3(bR, dR, fR), hR);
     FfxFloat32 mx4G = max(ffxMax3(bG, dG, fG), hG);
     FfxFloat32 mx4B = max(ffxMax3(bB, dB, fB), hB);
     FfxFloat32x2 peakC = FfxFloat32x2(1.0, -1.0 * 4.0);
     FfxFloat32 hitMinR = mn4R * ffxReciprocal(FfxFloat32(4.0) * mx4R);
     FfxFloat32 hitMinG = mn4G * ffxReciprocal(FfxFloat32(4.0) * mx4G);
     FfxFloat32 hitMinB = mn4B * ffxReciprocal(FfxFloat32(4.0) * mx4B);
     FfxFloat32 hitMaxR = (peakC.x - mx4R) * ffxReciprocal(FfxFloat32(4.0) * mn4R + peakC.y);
     FfxFloat32 hitMaxG = (peakC.x - mx4G) * ffxReciprocal(FfxFloat32(4.0) * mn4G + peakC.y);
     FfxFloat32 hitMaxB = (peakC.x - mx4B) * ffxReciprocal(FfxFloat32(4.0) * mn4B + peakC.y);
     FfxFloat32 lobeR = max(-hitMinR, hitMaxR);
     FfxFloat32 lobeG = max(-hitMinG, hitMaxG);
     FfxFloat32 lobeB = max(-hitMinB, hitMaxB);
     FfxFloat32 lobe = max(FfxFloat32(-FSR_RCAS_LIMIT), ffxMin(ffxMax3(lobeR, lobeG, lobeB), FfxFloat32(0.0))) * ffxAsFloat
     (con.x);
#ifdef FSR_RCAS_DENOISE
     lobe *= nz;
#endif
     FfxFloat32 rcpL = ffxApproximateReciprocalMedium(FfxFloat32(4.0) * lobe + FfxFloat32(1.0));
     pixR = (lobe * bR + lobe * dR + lobe * hR + lobe * fR + eR) * rcpL;
     pixG = (lobe * bG + lobe * dG + lobe * hG + lobe * fG + eG) * rcpL;
     pixB = (lobe * bB + lobe * dB + lobe * hB + lobe * fB + eB) * rcpL;
     return;
 }
#endif
#if defined(FFX_GPU) && FFX_HALF == 1 && defined(FSR_RCAS_H)
 FfxFloat16x4 FsrRcasLoadH(FfxInt16x2 p);
 void FsrRcasInputH(inout FfxFloat16 r,inout FfxFloat16 g,inout FfxFloat16 b);
 void FsrRcasH(
 out FfxFloat16 pixR,
 out FfxFloat16 pixG,
 out FfxFloat16 pixB,
 #ifdef FSR_RCAS_PASSTHROUGH_ALPHA
  out FfxFloat16 pixA,
 #endif
 FfxUInt32x2 ip,
 FfxUInt32x4 con){
  FfxInt16x2 sp=FfxInt16x2(ip);
  FfxFloat16x3 b=FsrRcasLoadH(sp+FfxInt16x2( 0,-1)).rgb;
  FfxFloat16x3 d=FsrRcasLoadH(sp+FfxInt16x2(-1, 0)).rgb;
  #ifdef FSR_RCAS_PASSTHROUGH_ALPHA
   FfxFloat16x4 ee=FsrRcasLoadH(sp);
   FfxFloat16x3 e=ee.rgb;pixA=ee.a;
  #else
   FfxFloat16x3 e=FsrRcasLoadH(sp).rgb;
  #endif
  FfxFloat16x3 f=FsrRcasLoadH(sp+FfxInt16x2( 1, 0)).rgb;
  FfxFloat16x3 h=FsrRcasLoadH(sp+FfxInt16x2( 0, 1)).rgb;
  FfxFloat16 bR=b.r;
  FfxFloat16 bG=b.g;
  FfxFloat16 bB=b.b;
  FfxFloat16 dR=d.r;
  FfxFloat16 dG=d.g;
  FfxFloat16 dB=d.b;
  FfxFloat16 eR=e.r;
  FfxFloat16 eG=e.g;
  FfxFloat16 eB=e.b;
  FfxFloat16 fR=f.r;
  FfxFloat16 fG=f.g;
  FfxFloat16 fB=f.b;
  FfxFloat16 hR=h.r;
  FfxFloat16 hG=h.g;
  FfxFloat16 hB=h.b;
  FsrRcasInputH(bR,bG,bB);
  FsrRcasInputH(dR,dG,dB);
  FsrRcasInputH(eR,eG,eB);
  FsrRcasInputH(fR,fG,fB);
  FsrRcasInputH(hR,hG,hB);
  FfxFloat16 bL=bB*FFX_BROADCAST_FLOAT16(0.5)+(bR*FFX_BROADCAST_FLOAT16(0.5)+bG);
  FfxFloat16 dL=dB*FFX_BROADCAST_FLOAT16(0.5)+(dR*FFX_BROADCAST_FLOAT16(0.5)+dG);
  FfxFloat16 eL=eB*FFX_BROADCAST_FLOAT16(0.5)+(eR*FFX_BROADCAST_FLOAT16(0.5)+eG);
  FfxFloat16 fL=fB*FFX_BROADCAST_FLOAT16(0.5)+(fR*FFX_BROADCAST_FLOAT16(0.5)+fG);
  FfxFloat16 hL=hB*FFX_BROADCAST_FLOAT16(0.5)+(hR*FFX_BROADCAST_FLOAT16(0.5)+hG);
  FfxFloat16 nz=FFX_BROADCAST_FLOAT16(0.25)*bL+FFX_BROADCAST_FLOAT16(0.25)*dL+FFX_BROADCAST_FLOAT16(0.25)*fL+FFX_BROADCAST_FLOAT16(0.25)*hL-eL;
  nz=ffxSaturate(abs(nz)*ffxApproximateReciprocalMediumHalf(ffxMax3Half(ffxMax3Half(bL,dL,eL),fL,hL)-ffxMin3Half(ffxMin3Half(bL,dL,eL),fL,hL)));
  nz=FFX_BROADCAST_FLOAT16(-0.5)*nz+FFX_BROADCAST_FLOAT16(1.0);
  FfxFloat16 mn4R=min(ffxMin3Half(bR,dR,fR),hR);
  FfxFloat16 mn4G=min(ffxMin3Half(bG,dG,fG),hG);
  FfxFloat16 mn4B=min(ffxMin3Half(bB,dB,fB),hB);
  FfxFloat16 mx4R=max(ffxMax3Half(bR,dR,fR),hR);
  FfxFloat16 mx4G=max(ffxMax3Half(bG,dG,fG),hG);
  FfxFloat16 mx4B=max(ffxMax3Half(bB,dB,fB),hB);
  FfxFloat16x2 peakC=FfxFloat16x2(1.0,-1.0*4.0);
  FfxFloat16 hitMinR=mn4R*ffxReciprocalHalf(FFX_BROADCAST_FLOAT16(4.0)*mx4R);
  FfxFloat16 hitMinG=mn4G*ffxReciprocalHalf(FFX_BROADCAST_FLOAT16(4.0)*mx4G);
  FfxFloat16 hitMinB=mn4B*ffxReciprocalHalf(FFX_BROADCAST_FLOAT16(4.0)*mx4B);
  FfxFloat16 hitMaxR=(peakC.x-mx4R)*ffxReciprocalHalf(FFX_BROADCAST_FLOAT16(4.0)*mn4R+peakC.y);
  FfxFloat16 hitMaxG=(peakC.x-mx4G)*ffxReciprocalHalf(FFX_BROADCAST_FLOAT16(4.0)*mn4G+peakC.y);
  FfxFloat16 hitMaxB=(peakC.x-mx4B)*ffxReciprocalHalf(FFX_BROADCAST_FLOAT16(4.0)*mn4B+peakC.y);
  FfxFloat16 lobeR=max(-hitMinR,hitMaxR);
  FfxFloat16 lobeG=max(-hitMinG,hitMaxG);
  FfxFloat16 lobeB=max(-hitMinB,hitMaxB);
  FfxFloat16 lobe=max(FFX_BROADCAST_FLOAT16(-FSR_RCAS_LIMIT),min(ffxMax3Half(lobeR,lobeG,lobeB),FFX_BROADCAST_FLOAT16(0.0)))*FFX_UINT32_TO_FLOAT16X2(con.y).x;
  #ifdef FSR_RCAS_DENOISE
   lobe*=nz;
  #endif
  FfxFloat16 rcpL=ffxApproximateReciprocalMediumHalf(FFX_BROADCAST_FLOAT16(4.0)*lobe+FFX_BROADCAST_FLOAT16(1.0));
  pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL;
  pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL;
  pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL;
}
#endif
#if defined(FFX_GPU)&& FFX_HALF == 1 && defined(FSR_RCAS_HX2)
 FfxFloat16x4 FsrRcasLoadHx2(FfxInt16x2 p);
 void FsrRcasInputHx2(inout FfxFloat16x2 r,inout FfxFloat16x2 g,inout FfxFloat16x2 b);
 void FsrRcasHx2(
 out FfxFloat16x2 pixR,
 out FfxFloat16x2 pixG,
 out FfxFloat16x2 pixB,
 #ifdef FSR_RCAS_PASSTHROUGH_ALPHA
  out FfxFloat16x2 pixA,
 #endif
 FfxUInt32x2 ip,
 FfxUInt32x4 con){
  FfxInt16x2 sp0=FfxInt16x2(ip);
  FfxFloat16x3 b0=FsrRcasLoadHx2(sp0+FfxInt16x2( 0,-1)).rgb;
  FfxFloat16x3 d0=FsrRcasLoadHx2(sp0+FfxInt16x2(-1, 0)).rgb;
  #ifdef FSR_RCAS_PASSTHROUGH_ALPHA
   FfxFloat16x4 ee0=FsrRcasLoadHx2(sp0);
   FfxFloat16x3 e0=ee0.rgb;pixA.r=ee0.a;
  #else
   FfxFloat16x3 e0=FsrRcasLoadHx2(sp0).rgb;
  #endif
  FfxFloat16x3 f0=FsrRcasLoadHx2(sp0+FfxInt16x2( 1, 0)).rgb;
  FfxFloat16x3 h0=FsrRcasLoadHx2(sp0+FfxInt16x2( 0, 1)).rgb;
  FfxInt16x2 sp1=sp0+FfxInt16x2(8,0);
  FfxFloat16x3 b1=FsrRcasLoadHx2(sp1+FfxInt16x2( 0,-1)).rgb;
  FfxFloat16x3 d1=FsrRcasLoadHx2(sp1+FfxInt16x2(-1, 0)).rgb;
  #ifdef FSR_RCAS_PASSTHROUGH_ALPHA
   FfxFloat16x4 ee1=FsrRcasLoadHx2(sp1);
   FfxFloat16x3 e1=ee1.rgb;pixA.g=ee1.a;
  #else
   FfxFloat16x3 e1=FsrRcasLoadHx2(sp1).rgb;
  #endif
  FfxFloat16x3 f1=FsrRcasLoadHx2(sp1+FfxInt16x2( 1, 0)).rgb;
  FfxFloat16x3 h1=FsrRcasLoadHx2(sp1+FfxInt16x2( 0, 1)).rgb;
  FfxFloat16x2 bR=FfxFloat16x2(b0.r,b1.r);
  FfxFloat16x2 bG=FfxFloat16x2(b0.g,b1.g);
  FfxFloat16x2 bB=FfxFloat16x2(b0.b,b1.b);
  FfxFloat16x2 dR=FfxFloat16x2(d0.r,d1.r);
  FfxFloat16x2 dG=FfxFloat16x2(d0.g,d1.g);
  FfxFloat16x2 dB=FfxFloat16x2(d0.b,d1.b);
  FfxFloat16x2 eR=FfxFloat16x2(e0.r,e1.r);
  FfxFloat16x2 eG=FfxFloat16x2(e0.g,e1.g);
  FfxFloat16x2 eB=FfxFloat16x2(e0.b,e1.b);
  FfxFloat16x2 fR=FfxFloat16x2(f0.r,f1.r);
  FfxFloat16x2 fG=FfxFloat16x2(f0.g,f1.g);
  FfxFloat16x2 fB=FfxFloat16x2(f0.b,f1.b);
  FfxFloat16x2 hR=FfxFloat16x2(h0.r,h1.r);
  FfxFloat16x2 hG=FfxFloat16x2(h0.g,h1.g);
  FfxFloat16x2 hB=FfxFloat16x2(h0.b,h1.b);
  FsrRcasInputHx2(bR,bG,bB);
  FsrRcasInputHx2(dR,dG,dB);
  FsrRcasInputHx2(eR,eG,eB);
  FsrRcasInputHx2(fR,fG,fB);
  FsrRcasInputHx2(hR,hG,hB);
  FfxFloat16x2 bL=bB*FFX_BROADCAST_FLOAT16X2(0.5)+(bR*FFX_BROADCAST_FLOAT16X2(0.5)+bG);
  FfxFloat16x2 dL=dB*FFX_BROADCAST_FLOAT16X2(0.5)+(dR*FFX_BROADCAST_FLOAT16X2(0.5)+dG);
  FfxFloat16x2 eL=eB*FFX_BROADCAST_FLOAT16X2(0.5)+(eR*FFX_BROADCAST_FLOAT16X2(0.5)+eG);
  FfxFloat16x2 fL=fB*FFX_BROADCAST_FLOAT16X2(0.5)+(fR*FFX_BROADCAST_FLOAT16X2(0.5)+fG);
  FfxFloat16x2 hL=hB*FFX_BROADCAST_FLOAT16X2(0.5)+(hR*FFX_BROADCAST_FLOAT16X2(0.5)+hG);
  FfxFloat16x2 nz=FFX_BROADCAST_FLOAT16X2(0.25)*bL+FFX_BROADCAST_FLOAT16X2(0.25)*dL+FFX_BROADCAST_FLOAT16X2(0.25)*fL+FFX_BROADCAST_FLOAT16X2(0.25)*hL-eL;
  nz=ffxSaturate(abs(nz)*ffxApproximateReciprocalMediumHalf(ffxMax3Half(ffxMax3Half(bL,dL,eL),fL,hL)-ffxMin3Half(ffxMin3Half(bL,dL,eL),fL,hL)));
  nz=FFX_BROADCAST_FLOAT16X2(-0.5)*nz+FFX_BROADCAST_FLOAT16X2(1.0);
  FfxFloat16x2 mn4R=min(ffxMin3Half(bR,dR,fR),hR);
  FfxFloat16x2 mn4G=min(ffxMin3Half(bG,dG,fG),hG);
  FfxFloat16x2 mn4B=min(ffxMin3Half(bB,dB,fB),hB);
  FfxFloat16x2 mx4R=max(ffxMax3Half(bR,dR,fR),hR);
  FfxFloat16x2 mx4G=max(ffxMax3Half(bG,dG,fG),hG);
  FfxFloat16x2 mx4B=max(ffxMax3Half(bB,dB,fB),hB);
  FfxFloat16x2 peakC=FfxFloat16x2(1.0,-1.0*4.0);
  FfxFloat16x2 hitMinR=mn4R*ffxReciprocalHalf(FFX_BROADCAST_FLOAT16X2(4.0)*mx4R);
  FfxFloat16x2 hitMinG=mn4G*ffxReciprocalHalf(FFX_BROADCAST_FLOAT16X2(4.0)*mx4G);
  FfxFloat16x2 hitMinB=mn4B*ffxReciprocalHalf(FFX_BROADCAST_FLOAT16X2(4.0)*mx4B);
  FfxFloat16x2 hitMaxR=(peakC.x-mx4R)*ffxReciprocalHalf(FFX_BROADCAST_FLOAT16X2(4.0)*mn4R+peakC.y);
  FfxFloat16x2 hitMaxG=(peakC.x-mx4G)*ffxReciprocalHalf(FFX_BROADCAST_FLOAT16X2(4.0)*mn4G+peakC.y);
  FfxFloat16x2 hitMaxB=(peakC.x-mx4B)*ffxReciprocalHalf(FFX_BROADCAST_FLOAT16X2(4.0)*mn4B+peakC.y);
  FfxFloat16x2 lobeR=max(-hitMinR,hitMaxR);
  FfxFloat16x2 lobeG=max(-hitMinG,hitMaxG);
  FfxFloat16x2 lobeB=max(-hitMinB,hitMaxB);
  FfxFloat16x2 lobe=max(FFX_BROADCAST_FLOAT16X2(-FSR_RCAS_LIMIT),min(ffxMax3Half(lobeR,lobeG,lobeB),FFX_BROADCAST_FLOAT16X2(0.0)))*FFX_BROADCAST_FLOAT16X2(FFX_UINT32_TO_FLOAT16X2(con.y).x);
  #ifdef FSR_RCAS_DENOISE
   lobe*=nz;
  #endif
  FfxFloat16x2 rcpL=ffxApproximateReciprocalMediumHalf(FFX_BROADCAST_FLOAT16X2(4.0)*lobe+FFX_BROADCAST_FLOAT16X2(1.0));
  pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL;
  pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL;
  pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL;}
#endif
#if defined(FFX_GPU)
#endif
#if defined(FFX_GPU)&& FFX_HALF == 1
#endif
#if defined(FFX_GPU)
#endif
#if defined(FFX_GPU )&& FFX_HALF == 1
#endif
#if defined(FFX_GPU)
#endif
#if defined(FFX_GPU)&& FFX_HALF == 1
#endif
layout(local_size_x = 16, local_size_y = 16) in;
void main() {
    ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
    vec3 c;
    FsrRcasF(c.r, c.g, c.b, pos, RCasConfig());
    StoreRCasOutput(pos, vec4(c, 1.0));
}
/*
    References:
        [WHY23] Whyte, Killian. "Soft Clamp Function". 2023.
            https:

        You can find full license texts in /licenses
*/
#define PI 3.14159265358979323846
#define PI_2 (2.0 * PI)
#define PI_HALF (0.5 * PI)
#define PI_QUARTER (0.25 * PI)
#define RCP_PI (1.0 / PI)
#define RCP_PI_2 (1.0 / PI_2)
#define RCP_PI_HALF (1.0 / PI_HALF)
#define GOLDEN_RATIO 1.618033988749
#define GOLDEN_ANGLE 2.39996322972865332
#define SPHERE_SOLID_ANGLE (4.0 * PI)
#define FLT_MAX uintBitsToFloat(0x7F7FFFFF)
#define FLT_MIN uintBitsToFloat(0x00800000)
#define FLT_TRUE_MIN uintBitsToFloat(0x00000001)
#define FLT_POS_INF uintBitsToFloat(0x7F800000)
#define FLT_NEG_INF uintBitsToFloat(0xFF800000)
#define FP16_MAX 65504.0
#define INT32_MAX 2147483647
#define INT32_MIN -2147483648
#define rcp(x) (1.0 / (x))
#define saturate(x) clamp(x, 0.0, 1.0)
float min2(float x, float y) { return min(x, y); }
float min2(vec2 v) { return min(v.x, v.y); }
float linearStep(float edge0, float edge1, float x) { return saturate((x - edge0) / (edge1 - edge0)); }
vec2 linearStep(float edge0, float edge1, vec2 x) { return saturate((x - edge0) / (edge1 - edge0)); }
vec3 linearStep(float edge0, float edge1, vec3 x) { return saturate((x - edge0) / (edge1 - edge0)); }
vec4 linearStep(float edge0, float edge1, vec4 x) { return saturate((x - edge0) / (edge1 - edge0)); }
float pow2(float x) { return x * x; }
vec2 pow2(vec2 x) { return x * x; }
vec3 pow2(vec3 x) { return x * x; }
vec4 pow2(vec4 x) { return x * x; }
float pow3(float x) { return x * x * x; }
vec2 pow3(vec2 x) { return x * x * x; }
vec3 pow3(vec3 x) { return x * x * x; }
vec4 pow3(vec4 x) { return x * x * x; }
float pow4(float x) {
    float x2 = x * x;
    return x2 * x2;
}
vec2 pow4(vec2 x) {
    vec2 x2 = x * x;
    return x2 * x2;
}
vec3 pow4(vec3 x) {
    vec3 x2 = x * x;
    return x2 * x2;
}
vec4 pow4(vec4 x) {
    vec4 x2 = x * x;
    return x2 * x2;
}
float pow5(float x) {
    float x2 = x * x;
    return x2 * x2 * x;
}
vec2 pow5(vec2 x) {
    vec2 x2 = x * x;
    return x2 * x2 * x;
}
vec3 pow5(vec3 x) {
    vec3 x2 = x * x;
    return x2 * x2 * x;
}
vec4 pow5(vec4 x) {
    vec4 x2 = x * x;
    return x2 * x2 * x;
}
/*
    References:
        [ERI07] Ericson, Christer. "Converting RGB to LogLuv in a fragment shader". 2007.
            https:
        [ITU11] ITU. "Recommendation ITU-R BT.601-7". 2011.
            https:
        [ITU15] ITU. "Recommendation ITU-R BT.709-6". 2015.
            https:
        [KAR13] Karis, Brian. "Tone mapping". Graphic Rants. 2013.
            https:
        [LAR98] Wikipedia. "The LogLuv Encoding for Full Gamut, High Dynamic Range Images". 1998.
            http:
        [LOT16] Lottes, Timothy. "Optimized Reversible Tonemapper for Resolve". 2016.
            https:
        [ROS18] Rosseaux, Benjamin. "Matrix-based RGB from/to YCoCg color space conversion". 2018.
            CC0 License (Public Domain).
            https:
        [WIK25a] Wikipedia. "Rec. 601". 2025.
            https:
        [WIK25b] Wikipedia. "Rec. 709". 2025.
            https:
        [WIK25c] Wikipedia. "sRGB". 2025.
            https:
        [WIK26a] Wikipedia. "CIELUV". 2026.
            https:

*/
#define COLORS2_COLORSPACES_CIE_XYZ 0
#define COLORS2_COLORSPACES_SRGB 1
#define COLORS2_COLORSPACES_REC709 2
#define COLORS2_COLORSPACES_REC2020 3
#define COLORS2_COLORSPACES_DCI_P3 4
#define COLORS2_COLORSPACES_ADOBE_RGB_1998 5
#define COLORS2_COLORSPACES_ACES_AP0 6
#define COLORS2_COLORSPACES_ACES_AP1 7
#define COLORS2_COLORSPACES_COLOR_MCSPACEFACE 8
#define _colors2_colorspaces_convert(a, b, x) colors2_colorspaces_ ## a ## _to_ ## b ##(x)
#define colors2_colorspaces_convert(a, b, x) _colors2_colorspaces_convert(a, b, x)
#define _colors2_colorspaces_luma(a, x) colors2_colorspaces_ ## a ## _luma(x)
#define colors2_colorspaces_luma(a, x) _colors2_colorspaces_luma(a, x)
const mat3 _colors2_colorspaces_mat_CIE_XYZ_to_CIE_XYZ = mat3(
    1.0, 0.0, 0.0,
    0.0, 1.0, 0.0,
    0.0, 0.0, 1.0
);
const mat3 _colors2_colorspaces_mat_CIE_XYZ_to_SRGB = mat3(
    3.2406, -1.5372, -0.4986,
    -0.9689, 1.8758, 0.0415,
    0.0557, -0.204, 1.057
);
const mat3 _colors2_colorspaces_mat_CIE_XYZ_to_REC709 = mat3(
    3.2409699419, -1.5373831776, -0.4986107603,
    -0.9692436363, 1.8759675015, 0.0415550574,
    0.0556300797, -0.2039769589, 1.0569715142
);
const mat3 _colors2_colorspaces_mat_CIE_XYZ_to_REC2020 = mat3(
    1.716651188, -0.3556707838, -0.2533662814,
    -0.6666843518, 1.6164812366, 0.0157685458,
    0.0176398574, -0.0427706133, 0.9421031212
);
const mat3 _colors2_colorspaces_mat_CIE_XYZ_to_DCI_P3 = mat3(
    2.7253940305, -1.0180030062, -0.4401631952,
    -0.7951680258, 1.6897320548, 0.0226471906,
    0.0412418914, -0.0876390192, 1.1009293786
);
const mat3 _colors2_colorspaces_mat_CIE_XYZ_to_ADOBE_RGB_1998 = mat3(
    2.04159, -0.56501, -0.34473,
    -0.96924, 1.87597, 0.04156,
    0.01344, -0.11836, 1.01517
);
const mat3 _colors2_colorspaces_mat_CIE_XYZ_to_ACES_AP0 = mat3(
    1.0498110175, 0.0, -9.74845e-05,
    -0.4959030231, 1.3733130458, 0.0982400361,
    0.0, 0.0, 0.9912520182
);
const mat3 _colors2_colorspaces_mat_CIE_XYZ_to_ACES_AP1 = mat3(
    1.6410233797, -0.3248032942, -0.2364246952,
    -0.6636628587, 1.6153315917, 0.0167563477,
    0.0117218943, -0.008284442, 0.9883948585
);
const mat3 _colors2_colorspaces_mat_CIE_XYZ_to_COLOR_MCSPACEFACE = mat3(
    1.8036169276, -0.4552904521, -0.2378028419,
    -0.8777214976, 1.7861935367, 0.044102742,
    -0.0076302897, 0.0213060993, 0.9055290952
);
const mat3 _colors2_colorspaces_mat_SRGB_to_CIE_XYZ = mat3(
    0.4124, 0.3576, 0.1805,
    0.2126, 0.7152, 0.0722,
    0.0193, 0.1192, 0.9505
);
const mat3 _colors2_colorspaces_mat_SRGB_to_SRGB = mat3(
    1.0, 0.0, 0.0,
    0.0, 1.0, 0.0,
    0.0, 0.0, 1.0
);
const mat3 _colors2_colorspaces_mat_SRGB_to_REC709 = mat3(
    1.0, 0.0, 0.0,
    0.0, 1.0, 0.0,
    0.0, 0.0, 1.0
);
const mat3 _colors2_colorspaces_mat_SRGB_to_REC2020 = mat3(
    0.6274413721, 0.3292974595, 0.0433514584,
    0.0690276171, 0.9195806669, 0.0113614226,
    0.0163642351, 0.0880171625, 0.8955649727
);
const mat3 _colors2_colorspaces_mat_SRGB_to_DCI_P3 = mat3(
    0.8686602648, 0.1289247846, 0.0025580657,
    0.034463766, 0.9618535095, 0.0036450448,
    0.0167452803, 0.071043109, 0.9121578398
);
const mat3 _colors2_colorspaces_mat_SRGB_to_ADOBE_RGB_1998 = mat3(
    0.715177301, 0.284885616, 4.7408e-05,
    -8.1246e-05, 1.000047472, -6e-09,
    -2.7899e-05, 0.041163336, 0.958799413
);
const mat3 _colors2_colorspaces_mat_SRGB_to_ACES_AP0 = mat3(
    0.439643004, 0.3830054714, 0.1773993089,
    0.0897157319, 0.8134750538, 0.0967822524,
    0.0175127205, 0.1115514385, 0.870882793
);
const mat3 _colors2_colorspaces_mat_SRGB_to_ACES_AP1 = mat3(
    0.6131324224, 0.3395380158, 0.047416696,
    0.0701243808, 0.9163940113, 0.013451524,
    0.0205876575, 0.1095745716, 0.869785404
);
const mat3 _colors2_colorspaces_mat_SRGB_to_COLOR_MCSPACEFACE = mat3(
    0.6424391956, 0.2910124185, 0.066641612,
    0.01862347, 0.9688787528, 0.0124565459,
    0.0188551746, 0.1204306855, 0.8606615207
);
const mat3 _colors2_colorspaces_mat_REC709_to_CIE_XYZ = mat3(
    0.4123907993, 0.3575843394, 0.1804807884,
    0.2126390059, 0.7151686788, 0.0721923154,
    0.0193308187, 0.1191947798, 0.9505321522
);
const mat3 _colors2_colorspaces_mat_REC709_to_SRGB = mat3(
    1.0, 0.0, 0.0,
    0.0, 1.0, 0.0,
    0.0, 0.0, 1.0
);
const mat3 _colors2_colorspaces_mat_REC709_to_REC709 = mat3(
    1.0, 0.0, 0.0,
    0.0, 1.0, 0.0,
    0.0, 0.0, 1.0
);
const mat3 _colors2_colorspaces_mat_REC709_to_REC2020 = mat3(
    0.6274038959, 0.3292830384, 0.0433130657,
    0.0690972894, 0.9195403951, 0.0113623156,
    0.0163914389, 0.0880133079, 0.8955952532
);
const mat3 _colors2_colorspaces_mat_REC709_to_DCI_P3 = mat3(
    0.8685797397, 0.1289191385, 0.0025011218,
    0.0345404103, 0.9618113864, 0.0036482034,
    0.016771429, 0.0710399978, 0.9121885732
);
const mat3 _colors2_colorspaces_mat_REC709_to_ADOBE_RGB_1998 = mat3(
    0.715125854, 0.2848731398, 1.4438e-06,
    2.1264e-06, 1.0000036763, 5.5347e-06,
    -1.3532e-06, 0.0411615333, 0.9588327043
);
const mat3 _colors2_colorspaces_mat_REC709_to_ACES_AP0 = mat3(
    0.4396329819, 0.3829886982, 0.17737832,
    0.0897764429, 0.8134394287, 0.0967841283,
    0.0175411704, 0.1115465533, 0.8709122763
);
const mat3 _colors2_colorspaces_mat_REC709_to_ACES_AP1 = mat3(
    0.6130974024, 0.3395231462, 0.0473794514,
    0.0701937225, 0.9163538791, 0.0134523985,
    0.0206155929, 0.1095697729, 0.8698146342
);
const mat3 _colors2_colorspaces_mat_REC709_to_COLOR_MCSPACEFACE = mat3(
    0.6423975126, 0.290999674, 0.0666028135,
    0.0187025778, 0.968836322, 0.0124611002,
    0.0188839772, 0.1204254114, 0.8606906114
);
const mat3 _colors2_colorspaces_mat_REC2020_to_CIE_XYZ = mat3(
    0.6369580483, 0.1446169036, 0.1688809752,
    0.262700212, 0.6779980715, 0.0593017165,
    0.0, 0.028072693, 1.0609850577
);
const mat3 _colors2_colorspaces_mat_REC2020_to_SRGB = mat3(
    1.6603034854, -0.5875701425, -0.0728900602,
    -0.1243755953, 1.1328344814, -0.0083597372,
    -0.01811228, -0.1005836085, 1.1187703262
);
const mat3 _colors2_colorspaces_mat_REC2020_to_REC709 = mat3(
    1.6604910021, -0.5876411388, -0.0728498633,
    -0.1245504745, 1.1328998971, -0.0083494226,
    -0.0181507634, -0.100578898, 1.1187296614
);
const mat3 _colors2_colorspaces_mat_REC2020_to_REC2020 = mat3(
    1.0, 0.0, 0.0,
    0.0, 1.0, 0.0,
    0.0, 0.0, 1.0
);
const mat3 _colors2_colorspaces_mat_REC2020_to_DCI_P3 = mat3(
    1.4261665053, -0.3646122688, -0.0615542365,
    -0.0625062418, 1.0689717224, -0.0064654806,
    0.0024438227, -0.0211212969, 1.0186774743
);
const mat3 _colors2_colorspaces_mat_REC2020_to_ADOBE_RGB_1998 = mat3(
    1.151978935, -0.0975047657, -0.0544737317,
    -0.124547502, 1.1329022557, -0.0083434163,
    -0.0225324809, -0.0498056448, 1.0723310102
);
const mat3 _colors2_colorspaces_mat_REC2020_to_ACES_AP0 = mat3(
    0.6790856347, 0.1577009146, 0.1632134507,
    0.0460020031, 0.859054673, 0.094943324,
    -0.0005739432, 0.0284677684, 0.9721061748
);
const mat3 _colors2_colorspaces_mat_REC2020_to_ACES_AP1 = mat3(
    0.9748949779, 0.0195991086, 0.0055059134,
    0.0021795628, 0.9955354689, 0.0022849683,
    0.0047972397, 0.0245320166, 0.9706707437
);
const mat3 _colors2_colorspaces_mat_REC2020_to_COLOR_MCSPACEFACE = mat3(
    1.02924225, -0.0545245427, 0.0252822927,
    -0.08983974, 1.0853508417, 0.0044888983,
    0.0007354405, 0.0387656211, 0.9604989385
);
const mat3 _colors2_colorspaces_mat_DCI_P3_to_CIE_XYZ = mat3(
    0.4451698156, 0.2771344092, 0.1722826698,
    0.2094916779, 0.7215952542, 0.0689130679,
    -0.0, 0.0470605601, 0.9073553944
);
const mat3 _colors2_colorspaces_mat_DCI_P3_to_SRGB = mat3(
    1.1573859234, -0.1549414014, -0.0026012394,
    -0.041378309, 1.0455482025, -0.0040707446,
    -0.0180228775, -0.0785725929, 1.0966699081
);
const mat3 _colors2_colorspaces_mat_DCI_P3_to_REC709 = mat3(
    1.1575164062, -0.1549623781, -0.0025540281,
    -0.0415000715, 1.0455679231, -0.0040678515,
    -0.018050039, -0.0785782727, 1.0966283116
);
const mat3 _colors2_colorspaces_mat_DCI_P3_to_REC2020 = mat3(
    0.7117832307, 0.2436603169, 0.0445564524,
    0.0416151636, 0.9498416297, 0.0085432067,
    -0.0008447284, 0.0191095072, 0.9817352212
);
const mat3 _colors2_colorspaces_mat_DCI_P3_to_DCI_P3 = mat3(
    1.0, 0.0, 0.0,
    0.0, 1.0, 0.0,
    0.0, 0.0, 1.0
);
const mat3 _colors2_colorspaces_mat_DCI_P3_to_ADOBE_RGB_1998 = mat3(
    0.8159476268, 0.1870365007, -0.0029836898,
    -0.0414978627, 1.0455710024, -0.0040618024,
    -0.0190167405, -0.0323060291, 1.0513156541
);
const mat3 _colors2_colorspaces_mat_DCI_P3_to_ACES_AP0 = mat3(
    0.4897866453, 0.3183760433, 0.1918373114,
    0.0684129538, 0.8289890733, 0.1025979728,
    -4.4998e-05, 0.0454764943, 0.9545685037
);
const mat3 _colors2_colorspaces_mat_DCI_P3_to_ACES_AP1 = mat3(
    0.6947248661, 0.2562644839, 0.04901065,
    0.0429788175, 0.9461757697, 0.0108454127,
    0.0036155455, 0.0430194671, 0.9533649873
);
const mat3 _colors2_colorspaces_mat_DCI_P3_to_COLOR_MCSPACEFACE = mat3(
    0.7303069694, 0.1994789445, 0.0702140861,
    -0.0187831594, 1.0091068134, 0.009676346,
    0.0013253512, 0.0553550597, 0.9433195891
);
const mat3 _colors2_colorspaces_mat_ADOBE_RGB_1998_to_CIE_XYZ = mat3(
    0.57667, 0.18556, 0.18823,
    0.29734, 0.62736, 0.07529,
    0.02703, 0.07069, 0.99134
);
const mat3 _colors2_colorspaces_mat_ADOBE_RGB_1998_to_SRGB = mat3(
    1.398208596, -0.39829809, -3.9774e-05,
    0.000136554, 0.999946439, -6.455e-06,
    3.3869e-05, -0.042926418, 1.042971631
);
const mat3 _colors2_colorspaces_mat_ADOBE_RGB_1998_to_REC709 = mat3(
    1.3983671735, -0.3983451225, 5.4016e-06,
    -1.03176e-05, 0.9999916496, -3.9459e-06,
    -3.709e-07, -0.042926951, 1.0429319656
);
const mat3 _colors2_colorspaces_mat_ADOBE_RGB_1998_to_REC2020 = mat3(
    0.8773375991, 0.0774977091, 0.0451746704,
    0.0966138895, 0.8915203988, 0.011846867,
    0.0229200098, 0.0430379497, 0.9340446591
);
const mat3 _colors2_colorspaces_mat_ADOBE_RGB_1998_to_DCI_P3 = mat3(
    1.2145920645, -0.2171838064, 0.0026126829,
    0.0482902509, 0.9478877447, 0.0038012193,
    0.0234515446, 0.0252011134, 0.9513504319
);
const mat3 _colors2_colorspaces_mat_ADOBE_RGB_1998_to_ADOBE_RGB_1998 = mat3(
    1.0, 0.0, 0.0,
    0.0, 1.0, 0.0,
    0.0, 0.0, 1.0
);
const mat3 _colors2_colorspaces_mat_ADOBE_RGB_1998_to_ACES_AP0 = mat3(
    0.614764313, 0.2002455356, 0.1849943834,
    0.1255320021, 0.7735159805, 0.1009365364,
    0.024527523, 0.0671725736, 0.9083019068
);
const mat3 _colors2_colorspaces_mat_ADOBE_RGB_1998_to_ACES_AP1 = mat3(
    0.857331761, 0.0932620958, 0.0494155164,
    0.0981471377, 0.8878074297, 0.0140266997,
    0.0288267153, 0.0640182469, 0.9071571651
);
const mat3 _colors2_colorspaces_mat_ADOBE_RGB_1998_to_COLOR_MCSPACEFACE = mat3(
    0.8983045668, 0.0322422724, 0.0694645249,
    0.0261430701, 0.9608432342, 0.0129923579,
    0.0264051721, 0.0759552419, 0.897641378
);
const mat3 _colors2_colorspaces_mat_ACES_AP0_to_CIE_XYZ = mat3(
    0.9525523959, 0.0, 9.36786e-05,
    0.3439664498, 0.7281660966, -0.0721325464,
    0.0, 0.0, 1.0088251844
);
const mat3 _colors2_colorspaces_mat_ACES_AP0_to_SRGB = mat3(
    2.5214008886, -1.1339957494, -0.3875618568,
    -0.2762140616, 1.3725955663, -0.0962823557,
    -0.0153202001, -0.1529925618, 1.1683871996
);
const mat3 _colors2_colorspaces_mat_ACES_AP0_to_REC709 = mat3(
    2.5216861866, -1.1341309882, -0.3875551986,
    -0.2764799141, 1.3727190876, -0.0962391734,
    -0.015378065, -0.1529753359, 1.1683534009
);
const mat3 _colors2_colorspaces_mat_ACES_AP0_to_REC2020 = mat3(
    1.4904095205, -0.2661709193, -0.2242386013,
    -0.0801674998, 1.1821671211, -0.1019996212,
    0.0032276312, -0.0347764757, 1.0315488446
);
const mat3 _colors2_colorspaces_mat_ACES_AP0_to_DCI_P3 = mat3(
    2.1546035168, -0.8084960464, -0.3461074707,
    -0.1788775564, 1.280565414, -0.1016878576,
    0.0086234533, -0.0610453898, 1.0524219365
);
const mat3 _colors2_colorspaces_mat_ACES_AP0_to_ADOBE_RGB_1998 = mat3(
    1.7245612643, -0.4199958158, -0.304565011,
    -0.2764756536, 1.3727208758, -0.0962338848,
    -0.0261287411, -0.0901729979, 1.1162946235
);
const mat3 _colors2_colorspaces_mat_ACES_AP0_to_ACES_AP0 = mat3(
    1.0, 0.0, 0.0,
    0.0, 1.0, 0.0,
    0.0, 0.0, 1.0
);
const mat3 _colors2_colorspaces_mat_ACES_AP0_to_ACES_AP1 = mat3(
    1.4514393161, -0.2365107469, -0.2149285693,
    -0.0765537733, 1.1762296998, -0.0996759265,
    0.0083161484, -0.0060324498, 0.9977163014
);
const mat3 _colors2_colorspaces_mat_ACES_AP0_to_COLOR_MCSPACEFACE = mat3(
    1.5384451464, -0.3392907066, -0.19915444,
    -0.2208933788, 1.3068226981, -0.0859293193,
    0.0010885009, 0.0122289218, 0.9866825774
);
const mat3 _colors2_colorspaces_mat_ACES_AP1_to_CIE_XYZ = mat3(
    0.6624541811, 0.1340042065, 0.156187687,
    0.2722287168, 0.6740817658, 0.0536895174,
    -0.0055746495, 0.0040607335, 1.0103391003
);
const mat3 _colors2_colorspaces_mat_ACES_AP1_to_SRGB = mat3(
    1.7048586763, -0.6217160219, -0.0832993717,
    -0.1300768242, 1.1407357748, -0.0105598017,
    -0.0239640729, -0.1289755083, 1.1530140189
);
const mat3 _colors2_colorspaces_mat_ACES_AP1_to_REC709 = mat3(
    1.7050509927, -0.6217921207, -0.083258872,
    -0.1302564175, 1.1408047366, -0.0105483191,
    -0.0240033568, -0.1289689761, 1.1529723329
);
const mat3 _colors2_colorspaces_mat_ACES_AP1_to_REC2020 = mat3(
    1.0258247477, -0.0200531908, -0.0057715568,
    -0.0022343695, 1.0045865019, -0.0023521324,
    -0.0050133515, -0.0252900718, 1.0303034233
);
const mat3 _colors2_colorspaces_mat_ACES_AP1_to_DCI_P3 = mat3(
    1.464120167, -0.3933270416, -0.0707931253,
    -0.0664765138, 1.0752915253, -0.0088150114,
    -0.0025528617, -0.0470296027, 1.0495824644
);
const mat3 _colors2_colorspaces_mat_ACES_AP1_to_ADOBE_RGB_1998 = mat3(
    1.182219458, -0.1196751803, -0.06254384,
    -0.1302534036, 1.1408068945, -0.0105421535,
    -0.0283790646, -0.0767015586, 1.1050735076
);
const mat3 _colors2_colorspaces_mat_ACES_AP1_to_ACES_AP0 = mat3(
    0.6954522414, 0.1406786965, 0.1638690622,
    0.0447945634, 0.8596711184, 0.0955343182,
    -0.0055258826, 0.0040252103, 1.0015006723
);
const mat3 _colors2_colorspaces_mat_ACES_AP1_to_ACES_AP1 = mat3(
    1.0, 0.0, 0.0,
    0.0, 1.0, 0.0,
    0.0, 0.0, 1.0
);
const mat3 _colors2_colorspaces_mat_ACES_AP1_to_COLOR_MCSPACEFACE = mat3(
    1.0558172503, -0.0760536019, 0.0202363516,
    -0.0946074079, 1.0920168543, 0.0025905536,
    -0.0041475025, 0.0146375846, 0.9895099179
);
const mat3 _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_CIE_XYZ = mat3(
    0.6326705035, 0.1593748231, 0.1583847254,
    0.3109383344, 0.6385030652, 0.0505586004,
    -0.0019849432, -0.0136803265, 1.1044717614
);
const mat3 _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_SRGB = mat3(
    1.5732175875, -0.4582177853, -0.1151565195,
    -0.0298175917, 1.0427085222, -0.0127917816,
    -0.0302889016, -0.1358492065, 1.1662125458
);
const mat3 _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_REC709 = mat3(
    1.5733946999, -0.4582756388, -0.1151190611,
    -0.0299830237, 1.0427599524, -0.0127769286,
    -0.0303259165, -0.1358452479, 1.1661711645
);
const mat3 _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_REC2020 = mat3(
    0.975967555, 0.0499553701, -0.0259229251,
    0.0808021347, 0.9256507776, -0.0064529123,
    -0.004008449, -0.0373974036, 1.0414058526
);
const mat3 _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_DCI_P3 = mat3(
    1.3626775245, -0.2639569859, -0.0987205386,
    0.0253970497, 0.9866137758, -0.0120108255,
    -0.0034048709, -0.0575247555, 1.0609296265
);
const mat3 _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_ADOBE_RGB_1998 = mat3(
    1.1166338266, -0.030670652, -0.0859627369,
    -0.0299799561, 1.0427620595, -0.0127707659,
    -0.0303137568, -0.0873306478, 1.1176372892
);
const mat3 _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_ACES_AP0 = mat3(
    0.6748538843, 0.1737961892, 0.1513499266,
    0.1139293384, 0.7939320393, 0.0921386223,
    -0.0021565314, -0.0100317066, 1.012188238
);
const mat3 _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_ACES_AP1 = mat3(
    0.9530274476, 0.0666372627, -0.0196647103,
    0.0825594145, 0.9215416099, -0.0041010244,
    0.0027733055, -0.0133528374, 1.010579532
);
const mat3 _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_COLOR_MCSPACEFACE = mat3(
    1.0, 0.0, 0.0,
    0.0, 1.0, 0.0,
    0.0, 0.0, 1.0
);
#define colors2_colorspaces_SRGB_luma(x) dot(x, _colors2_colorspaces_mat_SRGB_to_CIE_XYZ[1])
#define colors2_colorspaces_1_luma(x) colors2_colorspaces_SRGB_luma(x)
#define colors2_colorspaces_REC709_luma(x) dot(x, _colors2_colorspaces_mat_REC709_to_CIE_XYZ[1])
#define colors2_colorspaces_2_luma(x) colors2_colorspaces_REC709_luma(x)
#define colors2_colorspaces_REC2020_luma(x) dot(x, _colors2_colorspaces_mat_REC2020_to_CIE_XYZ[1])
#define colors2_colorspaces_3_luma(x) colors2_colorspaces_REC2020_luma(x)
#define colors2_colorspaces_DCI_P3_luma(x) dot(x, _colors2_colorspaces_mat_DCI_P3_to_CIE_XYZ[1])
#define colors2_colorspaces_4_luma(x) colors2_colorspaces_DCI_P3_luma(x)
#define colors2_colorspaces_ADOBE_RGB_1998_luma(x) dot(x, _colors2_colorspaces_mat_ADOBE_RGB_1998_to_CIE_XYZ[1])
#define colors2_colorspaces_5_luma(x) colors2_colorspaces_ADOBE_RGB_1998_luma(x)
#define colors2_colorspaces_ACES_AP0_luma(x) dot(x, _colors2_colorspaces_mat_ACES_AP0_to_CIE_XYZ[1])
#define colors2_colorspaces_6_luma(x) colors2_colorspaces_ACES_AP0_luma(x)
#define colors2_colorspaces_ACES_AP1_luma(x) dot(x, _colors2_colorspaces_mat_ACES_AP1_to_CIE_XYZ[1])
#define colors2_colorspaces_7_luma(x) colors2_colorspaces_ACES_AP1_luma(x)
#define colors2_colorspaces_COLOR_MCSPACEFACE_luma(x) dot(x, _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_CIE_XYZ[1])
#define colors2_colorspaces_8_luma(x) colors2_colorspaces_COLOR_MCSPACEFACE_luma(x)
#define colors2_colorspaces_CIE_XYZ_to_CIE_XYZ(x) (x * _colors2_colorspaces_mat_CIE_XYZ_to_CIE_XYZ)
#define colors2_colorspaces_0_to_0(x) colors2_colorspaces_CIE_XYZ_to_CIE_XYZ(x)
#define colors2_colorspaces_CIE_XYZ_to_SRGB(x) (x * _colors2_colorspaces_mat_CIE_XYZ_to_SRGB)
#define colors2_colorspaces_0_to_1(x) colors2_colorspaces_CIE_XYZ_to_SRGB(x)
#define colors2_colorspaces_CIE_XYZ_to_REC709(x) (x * _colors2_colorspaces_mat_CIE_XYZ_to_REC709)
#define colors2_colorspaces_0_to_2(x) colors2_colorspaces_CIE_XYZ_to_REC709(x)
#define colors2_colorspaces_CIE_XYZ_to_REC2020(x) (x * _colors2_colorspaces_mat_CIE_XYZ_to_REC2020)
#define colors2_colorspaces_0_to_3(x) colors2_colorspaces_CIE_XYZ_to_REC2020(x)
#define colors2_colorspaces_CIE_XYZ_to_DCI_P3(x) (x * _colors2_colorspaces_mat_CIE_XYZ_to_DCI_P3)
#define colors2_colorspaces_0_to_4(x) colors2_colorspaces_CIE_XYZ_to_DCI_P3(x)
#define colors2_colorspaces_CIE_XYZ_to_ADOBE_RGB_1998(x) (x * _colors2_colorspaces_mat_CIE_XYZ_to_ADOBE_RGB_1998)
#define colors2_colorspaces_0_to_5(x) colors2_colorspaces_CIE_XYZ_to_ADOBE_RGB_1998(x)
#define colors2_colorspaces_CIE_XYZ_to_ACES_AP0(x) (x * _colors2_colorspaces_mat_CIE_XYZ_to_ACES_AP0)
#define colors2_colorspaces_0_to_6(x) colors2_colorspaces_CIE_XYZ_to_ACES_AP0(x)
#define colors2_colorspaces_CIE_XYZ_to_ACES_AP1(x) (x * _colors2_colorspaces_mat_CIE_XYZ_to_ACES_AP1)
#define colors2_colorspaces_0_to_7(x) colors2_colorspaces_CIE_XYZ_to_ACES_AP1(x)
#define colors2_colorspaces_CIE_XYZ_to_COLOR_MCSPACEFACE(x) (x * _colors2_colorspaces_mat_CIE_XYZ_to_COLOR_MCSPACEFACE)
#define colors2_colorspaces_0_to_8(x) colors2_colorspaces_CIE_XYZ_to_COLOR_MCSPACEFACE(x)
#define colors2_colorspaces_SRGB_to_CIE_XYZ(x) (x * _colors2_colorspaces_mat_SRGB_to_CIE_XYZ)
#define colors2_colorspaces_1_to_0(x) colors2_colorspaces_SRGB_to_CIE_XYZ(x)
#define colors2_colorspaces_SRGB_to_SRGB(x) (x * _colors2_colorspaces_mat_SRGB_to_SRGB)
#define colors2_colorspaces_1_to_1(x) colors2_colorspaces_SRGB_to_SRGB(x)
#define colors2_colorspaces_SRGB_to_REC709(x) (x * _colors2_colorspaces_mat_SRGB_to_REC709)
#define colors2_colorspaces_1_to_2(x) colors2_colorspaces_SRGB_to_REC709(x)
#define colors2_colorspaces_SRGB_to_REC2020(x) (x * _colors2_colorspaces_mat_SRGB_to_REC2020)
#define colors2_colorspaces_1_to_3(x) colors2_colorspaces_SRGB_to_REC2020(x)
#define colors2_colorspaces_SRGB_to_DCI_P3(x) (x * _colors2_colorspaces_mat_SRGB_to_DCI_P3)
#define colors2_colorspaces_1_to_4(x) colors2_colorspaces_SRGB_to_DCI_P3(x)
#define colors2_colorspaces_SRGB_to_ADOBE_RGB_1998(x) (x * _colors2_colorspaces_mat_SRGB_to_ADOBE_RGB_1998)
#define colors2_colorspaces_1_to_5(x) colors2_colorspaces_SRGB_to_ADOBE_RGB_1998(x)
#define colors2_colorspaces_SRGB_to_ACES_AP0(x) (x * _colors2_colorspaces_mat_SRGB_to_ACES_AP0)
#define colors2_colorspaces_1_to_6(x) colors2_colorspaces_SRGB_to_ACES_AP0(x)
#define colors2_colorspaces_SRGB_to_ACES_AP1(x) (x * _colors2_colorspaces_mat_SRGB_to_ACES_AP1)
#define colors2_colorspaces_1_to_7(x) colors2_colorspaces_SRGB_to_ACES_AP1(x)
#define colors2_colorspaces_SRGB_to_COLOR_MCSPACEFACE(x) (x * _colors2_colorspaces_mat_SRGB_to_COLOR_MCSPACEFACE)
#define colors2_colorspaces_1_to_8(x) colors2_colorspaces_SRGB_to_COLOR_MCSPACEFACE(x)
#define colors2_colorspaces_REC709_to_CIE_XYZ(x) (x * _colors2_colorspaces_mat_REC709_to_CIE_XYZ)
#define colors2_colorspaces_2_to_0(x) colors2_colorspaces_REC709_to_CIE_XYZ(x)
#define colors2_colorspaces_REC709_to_SRGB(x) (x * _colors2_colorspaces_mat_REC709_to_SRGB)
#define colors2_colorspaces_2_to_1(x) colors2_colorspaces_REC709_to_SRGB(x)
#define colors2_colorspaces_REC709_to_REC709(x) (x * _colors2_colorspaces_mat_REC709_to_REC709)
#define colors2_colorspaces_2_to_2(x) colors2_colorspaces_REC709_to_REC709(x)
#define colors2_colorspaces_REC709_to_REC2020(x) (x * _colors2_colorspaces_mat_REC709_to_REC2020)
#define colors2_colorspaces_2_to_3(x) colors2_colorspaces_REC709_to_REC2020(x)
#define colors2_colorspaces_REC709_to_DCI_P3(x) (x * _colors2_colorspaces_mat_REC709_to_DCI_P3)
#define colors2_colorspaces_2_to_4(x) colors2_colorspaces_REC709_to_DCI_P3(x)
#define colors2_colorspaces_REC709_to_ADOBE_RGB_1998(x) (x * _colors2_colorspaces_mat_REC709_to_ADOBE_RGB_1998)
#define colors2_colorspaces_2_to_5(x) colors2_colorspaces_REC709_to_ADOBE_RGB_1998(x)
#define colors2_colorspaces_REC709_to_ACES_AP0(x) (x * _colors2_colorspaces_mat_REC709_to_ACES_AP0)
#define colors2_colorspaces_2_to_6(x) colors2_colorspaces_REC709_to_ACES_AP0(x)
#define colors2_colorspaces_REC709_to_ACES_AP1(x) (x * _colors2_colorspaces_mat_REC709_to_ACES_AP1)
#define colors2_colorspaces_2_to_7(x) colors2_colorspaces_REC709_to_ACES_AP1(x)
#define colors2_colorspaces_REC709_to_COLOR_MCSPACEFACE(x) (x * _colors2_colorspaces_mat_REC709_to_COLOR_MCSPACEFACE)
#define colors2_colorspaces_2_to_8(x) colors2_colorspaces_REC709_to_COLOR_MCSPACEFACE(x)
#define colors2_colorspaces_REC2020_to_CIE_XYZ(x) (x * _colors2_colorspaces_mat_REC2020_to_CIE_XYZ)
#define colors2_colorspaces_3_to_0(x) colors2_colorspaces_REC2020_to_CIE_XYZ(x)
#define colors2_colorspaces_REC2020_to_SRGB(x) (x * _colors2_colorspaces_mat_REC2020_to_SRGB)
#define colors2_colorspaces_3_to_1(x) colors2_colorspaces_REC2020_to_SRGB(x)
#define colors2_colorspaces_REC2020_to_REC709(x) (x * _colors2_colorspaces_mat_REC2020_to_REC709)
#define colors2_colorspaces_3_to_2(x) colors2_colorspaces_REC2020_to_REC709(x)
#define colors2_colorspaces_REC2020_to_REC2020(x) (x * _colors2_colorspaces_mat_REC2020_to_REC2020)
#define colors2_colorspaces_3_to_3(x) colors2_colorspaces_REC2020_to_REC2020(x)
#define colors2_colorspaces_REC2020_to_DCI_P3(x) (x * _colors2_colorspaces_mat_REC2020_to_DCI_P3)
#define colors2_colorspaces_3_to_4(x) colors2_colorspaces_REC2020_to_DCI_P3(x)
#define colors2_colorspaces_REC2020_to_ADOBE_RGB_1998(x) (x * _colors2_colorspaces_mat_REC2020_to_ADOBE_RGB_1998)
#define colors2_colorspaces_3_to_5(x) colors2_colorspaces_REC2020_to_ADOBE_RGB_1998(x)
#define colors2_colorspaces_REC2020_to_ACES_AP0(x) (x * _colors2_colorspaces_mat_REC2020_to_ACES_AP0)
#define colors2_colorspaces_3_to_6(x) colors2_colorspaces_REC2020_to_ACES_AP0(x)
#define colors2_colorspaces_REC2020_to_ACES_AP1(x) (x * _colors2_colorspaces_mat_REC2020_to_ACES_AP1)
#define colors2_colorspaces_3_to_7(x) colors2_colorspaces_REC2020_to_ACES_AP1(x)
#define colors2_colorspaces_REC2020_to_COLOR_MCSPACEFACE(x) (x * _colors2_colorspaces_mat_REC2020_to_COLOR_MCSPACEFACE)
#define colors2_colorspaces_3_to_8(x) colors2_colorspaces_REC2020_to_COLOR_MCSPACEFACE(x)
#define colors2_colorspaces_DCI_P3_to_CIE_XYZ(x) (x * _colors2_colorspaces_mat_DCI_P3_to_CIE_XYZ)
#define colors2_colorspaces_4_to_0(x) colors2_colorspaces_DCI_P3_to_CIE_XYZ(x)
#define colors2_colorspaces_DCI_P3_to_SRGB(x) (x * _colors2_colorspaces_mat_DCI_P3_to_SRGB)
#define colors2_colorspaces_4_to_1(x) colors2_colorspaces_DCI_P3_to_SRGB(x)
#define colors2_colorspaces_DCI_P3_to_REC709(x) (x * _colors2_colorspaces_mat_DCI_P3_to_REC709)
#define colors2_colorspaces_4_to_2(x) colors2_colorspaces_DCI_P3_to_REC709(x)
#define colors2_colorspaces_DCI_P3_to_REC2020(x) (x * _colors2_colorspaces_mat_DCI_P3_to_REC2020)
#define colors2_colorspaces_4_to_3(x) colors2_colorspaces_DCI_P3_to_REC2020(x)
#define colors2_colorspaces_DCI_P3_to_DCI_P3(x) (x * _colors2_colorspaces_mat_DCI_P3_to_DCI_P3)
#define colors2_colorspaces_4_to_4(x) colors2_colorspaces_DCI_P3_to_DCI_P3(x)
#define colors2_colorspaces_DCI_P3_to_ADOBE_RGB_1998(x) (x * _colors2_colorspaces_mat_DCI_P3_to_ADOBE_RGB_1998)
#define colors2_colorspaces_4_to_5(x) colors2_colorspaces_DCI_P3_to_ADOBE_RGB_1998(x)
#define colors2_colorspaces_DCI_P3_to_ACES_AP0(x) (x * _colors2_colorspaces_mat_DCI_P3_to_ACES_AP0)
#define colors2_colorspaces_4_to_6(x) colors2_colorspaces_DCI_P3_to_ACES_AP0(x)
#define colors2_colorspaces_DCI_P3_to_ACES_AP1(x) (x * _colors2_colorspaces_mat_DCI_P3_to_ACES_AP1)
#define colors2_colorspaces_4_to_7(x) colors2_colorspaces_DCI_P3_to_ACES_AP1(x)
#define colors2_colorspaces_DCI_P3_to_COLOR_MCSPACEFACE(x) (x * _colors2_colorspaces_mat_DCI_P3_to_COLOR_MCSPACEFACE)
#define colors2_colorspaces_4_to_8(x) colors2_colorspaces_DCI_P3_to_COLOR_MCSPACEFACE(x)
#define colors2_colorspaces_ADOBE_RGB_1998_to_CIE_XYZ(x) (x * _colors2_colorspaces_mat_ADOBE_RGB_1998_to_CIE_XYZ)
#define colors2_colorspaces_5_to_0(x) colors2_colorspaces_ADOBE_RGB_1998_to_CIE_XYZ(x)
#define colors2_colorspaces_ADOBE_RGB_1998_to_SRGB(x) (x * _colors2_colorspaces_mat_ADOBE_RGB_1998_to_SRGB)
#define colors2_colorspaces_5_to_1(x) colors2_colorspaces_ADOBE_RGB_1998_to_SRGB(x)
#define colors2_colorspaces_ADOBE_RGB_1998_to_REC709(x) (x * _colors2_colorspaces_mat_ADOBE_RGB_1998_to_REC709)
#define colors2_colorspaces_5_to_2(x) colors2_colorspaces_ADOBE_RGB_1998_to_REC709(x)
#define colors2_colorspaces_ADOBE_RGB_1998_to_REC2020(x) (x * _colors2_colorspaces_mat_ADOBE_RGB_1998_to_REC2020)
#define colors2_colorspaces_5_to_3(x) colors2_colorspaces_ADOBE_RGB_1998_to_REC2020(x)
#define colors2_colorspaces_ADOBE_RGB_1998_to_DCI_P3(x) (x * _colors2_colorspaces_mat_ADOBE_RGB_1998_to_DCI_P3)
#define colors2_colorspaces_5_to_4(x) colors2_colorspaces_ADOBE_RGB_1998_to_DCI_P3(x)
#define colors2_colorspaces_ADOBE_RGB_1998_to_ADOBE_RGB_1998(x) (x * _colors2_colorspaces_mat_ADOBE_RGB_1998_to_ADOBE_RGB_1998)
#define colors2_colorspaces_5_to_5(x) colors2_colorspaces_ADOBE_RGB_1998_to_ADOBE_RGB_1998(x)
#define colors2_colorspaces_ADOBE_RGB_1998_to_ACES_AP0(x) (x * _colors2_colorspaces_mat_ADOBE_RGB_1998_to_ACES_AP0)
#define colors2_colorspaces_5_to_6(x) colors2_colorspaces_ADOBE_RGB_1998_to_ACES_AP0(x)
#define colors2_colorspaces_ADOBE_RGB_1998_to_ACES_AP1(x) (x * _colors2_colorspaces_mat_ADOBE_RGB_1998_to_ACES_AP1)
#define colors2_colorspaces_5_to_7(x) colors2_colorspaces_ADOBE_RGB_1998_to_ACES_AP1(x)
#define colors2_colorspaces_ADOBE_RGB_1998_to_COLOR_MCSPACEFACE(x) (x * _colors2_colorspaces_mat_ADOBE_RGB_1998_to_COLOR_MCSPACEFACE)
#define colors2_colorspaces_5_to_8(x) colors2_colorspaces_ADOBE_RGB_1998_to_COLOR_MCSPACEFACE(x)
#define colors2_colorspaces_ACES_AP0_to_CIE_XYZ(x) (x * _colors2_colorspaces_mat_ACES_AP0_to_CIE_XYZ)
#define colors2_colorspaces_6_to_0(x) colors2_colorspaces_ACES_AP0_to_CIE_XYZ(x)
#define colors2_colorspaces_ACES_AP0_to_SRGB(x) (x * _colors2_colorspaces_mat_ACES_AP0_to_SRGB)
#define colors2_colorspaces_6_to_1(x) colors2_colorspaces_ACES_AP0_to_SRGB(x)
#define colors2_colorspaces_ACES_AP0_to_REC709(x) (x * _colors2_colorspaces_mat_ACES_AP0_to_REC709)
#define colors2_colorspaces_6_to_2(x) colors2_colorspaces_ACES_AP0_to_REC709(x)
#define colors2_colorspaces_ACES_AP0_to_REC2020(x) (x * _colors2_colorspaces_mat_ACES_AP0_to_REC2020)
#define colors2_colorspaces_6_to_3(x) colors2_colorspaces_ACES_AP0_to_REC2020(x)
#define colors2_colorspaces_ACES_AP0_to_DCI_P3(x) (x * _colors2_colorspaces_mat_ACES_AP0_to_DCI_P3)
#define colors2_colorspaces_6_to_4(x) colors2_colorspaces_ACES_AP0_to_DCI_P3(x)
#define colors2_colorspaces_ACES_AP0_to_ADOBE_RGB_1998(x) (x * _colors2_colorspaces_mat_ACES_AP0_to_ADOBE_RGB_1998)
#define colors2_colorspaces_6_to_5(x) colors2_colorspaces_ACES_AP0_to_ADOBE_RGB_1998(x)
#define colors2_colorspaces_ACES_AP0_to_ACES_AP0(x) (x * _colors2_colorspaces_mat_ACES_AP0_to_ACES_AP0)
#define colors2_colorspaces_6_to_6(x) colors2_colorspaces_ACES_AP0_to_ACES_AP0(x)
#define colors2_colorspaces_ACES_AP0_to_ACES_AP1(x) (x * _colors2_colorspaces_mat_ACES_AP0_to_ACES_AP1)
#define colors2_colorspaces_6_to_7(x) colors2_colorspaces_ACES_AP0_to_ACES_AP1(x)
#define colors2_colorspaces_ACES_AP0_to_COLOR_MCSPACEFACE(x) (x * _colors2_colorspaces_mat_ACES_AP0_to_COLOR_MCSPACEFACE)
#define colors2_colorspaces_6_to_8(x) colors2_colorspaces_ACES_AP0_to_COLOR_MCSPACEFACE(x)
#define colors2_colorspaces_ACES_AP1_to_CIE_XYZ(x) (x * _colors2_colorspaces_mat_ACES_AP1_to_CIE_XYZ)
#define colors2_colorspaces_7_to_0(x) colors2_colorspaces_ACES_AP1_to_CIE_XYZ(x)
#define colors2_colorspaces_ACES_AP1_to_SRGB(x) (x * _colors2_colorspaces_mat_ACES_AP1_to_SRGB)
#define colors2_colorspaces_7_to_1(x) colors2_colorspaces_ACES_AP1_to_SRGB(x)
#define colors2_colorspaces_ACES_AP1_to_REC709(x) (x * _colors2_colorspaces_mat_ACES_AP1_to_REC709)
#define colors2_colorspaces_7_to_2(x) colors2_colorspaces_ACES_AP1_to_REC709(x)
#define colors2_colorspaces_ACES_AP1_to_REC2020(x) (x * _colors2_colorspaces_mat_ACES_AP1_to_REC2020)
#define colors2_colorspaces_7_to_3(x) colors2_colorspaces_ACES_AP1_to_REC2020(x)
#define colors2_colorspaces_ACES_AP1_to_DCI_P3(x) (x * _colors2_colorspaces_mat_ACES_AP1_to_DCI_P3)
#define colors2_colorspaces_7_to_4(x) colors2_colorspaces_ACES_AP1_to_DCI_P3(x)
#define colors2_colorspaces_ACES_AP1_to_ADOBE_RGB_1998(x) (x * _colors2_colorspaces_mat_ACES_AP1_to_ADOBE_RGB_1998)
#define colors2_colorspaces_7_to_5(x) colors2_colorspaces_ACES_AP1_to_ADOBE_RGB_1998(x)
#define colors2_colorspaces_ACES_AP1_to_ACES_AP0(x) (x * _colors2_colorspaces_mat_ACES_AP1_to_ACES_AP0)
#define colors2_colorspaces_7_to_6(x) colors2_colorspaces_ACES_AP1_to_ACES_AP0(x)
#define colors2_colorspaces_ACES_AP1_to_ACES_AP1(x) (x * _colors2_colorspaces_mat_ACES_AP1_to_ACES_AP1)
#define colors2_colorspaces_7_to_7(x) colors2_colorspaces_ACES_AP1_to_ACES_AP1(x)
#define colors2_colorspaces_ACES_AP1_to_COLOR_MCSPACEFACE(x) (x * _colors2_colorspaces_mat_ACES_AP1_to_COLOR_MCSPACEFACE)
#define colors2_colorspaces_7_to_8(x) colors2_colorspaces_ACES_AP1_to_COLOR_MCSPACEFACE(x)
#define colors2_colorspaces_COLOR_MCSPACEFACE_to_CIE_XYZ(x) (x * _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_CIE_XYZ)
#define colors2_colorspaces_8_to_0(x) colors2_colorspaces_COLOR_MCSPACEFACE_to_CIE_XYZ(x)
#define colors2_colorspaces_COLOR_MCSPACEFACE_to_SRGB(x) (x * _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_SRGB)
#define colors2_colorspaces_8_to_1(x) colors2_colorspaces_COLOR_MCSPACEFACE_to_SRGB(x)
#define colors2_colorspaces_COLOR_MCSPACEFACE_to_REC709(x) (x * _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_REC709)
#define colors2_colorspaces_8_to_2(x) colors2_colorspaces_COLOR_MCSPACEFACE_to_REC709(x)
#define colors2_colorspaces_COLOR_MCSPACEFACE_to_REC2020(x) (x * _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_REC2020)
#define colors2_colorspaces_8_to_3(x) colors2_colorspaces_COLOR_MCSPACEFACE_to_REC2020(x)
#define colors2_colorspaces_COLOR_MCSPACEFACE_to_DCI_P3(x) (x * _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_DCI_P3)
#define colors2_colorspaces_8_to_4(x) colors2_colorspaces_COLOR_MCSPACEFACE_to_DCI_P3(x)
#define colors2_colorspaces_COLOR_MCSPACEFACE_to_ADOBE_RGB_1998(x) (x * _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_ADOBE_RGB_1998)
#define colors2_colorspaces_8_to_5(x) colors2_colorspaces_COLOR_MCSPACEFACE_to_ADOBE_RGB_1998(x)
#define colors2_colorspaces_COLOR_MCSPACEFACE_to_ACES_AP0(x) (x * _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_ACES_AP0)
#define colors2_colorspaces_8_to_6(x) colors2_colorspaces_COLOR_MCSPACEFACE_to_ACES_AP0(x)
#define colors2_colorspaces_COLOR_MCSPACEFACE_to_ACES_AP1(x) (x * _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_ACES_AP1)
#define colors2_colorspaces_8_to_7(x) colors2_colorspaces_COLOR_MCSPACEFACE_to_ACES_AP1(x)
#define colors2_colorspaces_COLOR_MCSPACEFACE_to_COLOR_MCSPACEFACE(x) (x * _colors2_colorspaces_mat_COLOR_MCSPACEFACE_to_COLOR_MCSPACEFACE)
#define colors2_colorspaces_8_to_8(x) colors2_colorspaces_COLOR_MCSPACEFACE_to_COLOR_MCSPACEFACE(x)
/*
    References:
        [WIK25a] Wikipedia. "Rec. 601". 2025.
            https:
        [WIK25b] Wikipedia. "Rec. 709". 2025.
            https:
        [WIK25c] Wikipedia. "sRGB". 2025.
            https:
        [ITU25] ITU, "Recommendation BT.2100", 2025.
            https:
            
    Note:
        EOTF: Electro-Optical Transfer Function (decoding gamma, non-linear to linear)
        OETF: Opto-Electronic Transfer Function (encoding gamma, linear to non-linear)
*/
#define COLORS2_TF_IDENTITY 0
#define COLORS2_TF_REC601 1
#define COLORS2_TF_REC709 2
#define COLORS2_TF_SRGB   3
#define COLORS2_TF_EXP22  4
#define COLORS2_TF_EXP24  5
#define COLORS2_TF_PQ     6
#define COLORS2_TF_HLG    7
#define _colors2_oetf(a, x) colors2_oetf_## a ##(x)
#define colors2_oetf(a, x) _colors2_oetf(a, x)
#define _colors2_eotf(a, x) colors2_eotf_## a ##(x)
#define colors2_eotf(a, x) _colors2_eotf(a, x)
float colors2_oetf_identity(float c) {
    return c;
}
vec3 colors2_oetf_identity(vec3 c) {
    return c;
}
float colors2_eotf_identity(float c) {
    return c;
}
vec3 colors2_eotf_identity(vec3 c) {
    return c;
}
float colors2_oetf_Rec601(float c) {
    float lower = 4.5 * c;
    float higher = pow(c, 0.45) * 1.099 - 0.099;
    return mix(lower, higher, c >= 0.018);
}
vec3 colors2_oetf_Rec601(vec3 c) {
    vec3 lower = 4.5 * c;
    vec3 higher = pow(c, vec3(0.45)) * 1.099 - 0.099;
    return mix(lower, higher, greaterThanEqual(c, vec3(0.018)));
}
float colors2_eotf_Rec601(float c) {
    float lower = c / 4.5;
    float higher = pow((c + 0.099) / 1.099, 1.0 / 0.45);
    return mix(lower, higher, c >= 0.081);
}
vec3 colors2_eotf_Rec601(vec3 c) {
    vec3 lower = c / 4.5;
    vec3 higher = pow((c + 0.099) / 1.099, vec3(1.0 / 0.45));
    return mix(lower, higher, greaterThanEqual(c, vec3(0.081)));
}
float colors2_oetf_Rec709(float c) {
    return colors2_oetf_Rec601(c);
}
vec3 colors2_oetf_Rec709(vec3 c) {
    return colors2_oetf_Rec601(c);
}
float colors2_eotf_Rec709(float c) {
    return colors2_eotf_Rec601(c);
}
vec3 colors2_eotf_Rec709(vec3 c) {
    return colors2_eotf_Rec601(c);
}
float colors2_oetf_sRGB(float c) {
    float lower = 12.92 * c;
    float higher = pow(c, 1.0 / 2.4) * 1.055 - 0.055;
    return mix(lower, higher, c > 0.0031308);
}
vec3 colors2_oetf_sRGB(vec3 c) {
    vec3 lower = 12.92 * c;
    vec3 higher = pow(c, vec3(1.0 / 2.4)) * 1.055 - 0.055;
    return mix(lower, higher, greaterThan(c, vec3(0.0031308)));
}
float colors2_eotf_sRGB(float c) {
    float lower = c / 12.92;
    float higher = pow((c + 0.055) / 1.055, 2.4);
    return mix(lower, higher, c > 0.04045);
}
vec3 colors2_eotf_sRGB(vec3 c) {
    vec3 lower = c / 12.92;
    vec3 higher = pow((c + 0.055) / 1.055, vec3(2.4));
    return mix(lower, higher, greaterThan(c, vec3(0.04045)));
}
float colors2_oetf_Exp22(float c) {
    return pow(c, 1.0 / 2.2);
}
vec3 colors2_oetf_Exp22(vec3 c) {
    return pow(c, vec3(1.0 / 2.2));
}
float colors2_eotf_Exp22(float c) {
    return pow(c, 2.2);
}
vec3 colors2_eotf_Exp22(vec3 c) {
    return pow(c, vec3(2.2));
}
float colors2_oetf_Exp24(float c) {
    return pow(c, 1.0 / 2.4);
}
vec3 colors2_oetf_Exp24(vec3 c) {
    return pow(c, vec3(1.0 / 2.4));
}
float colors2_eotf_Exp24(float c) {
    return pow(c, 2.4);
}
vec3 colors2_eotf_Exp24(vec3 c) {
    return pow(c, vec3(2.4));
}
const float _PQ_M1 = 2610.0 / 16384.0;
const float _PQ_M2 = 2523.0 / 4096.0 * 128.0;
const float _PQ_C1 = 3424.0 / 4096.0;
const float _PQ_C2 = 2413.0 / 4096.0 * 32.0;
const float _PQ_C3 = 2392.0 / 4096.0 * 32.0;
const float _PQ_PEAK = 10000.0;
float colors2_oetf_PQ(float c) {
    float y = c / _PQ_PEAK;
    float yPow = pow(y, _PQ_M1);
    float numerator = _PQ_C1 + _PQ_C2 * yPow;
    float denominator = 1.0 + _PQ_C3 * yPow;
    return pow(numerator / denominator, _PQ_M2);
}
vec3 colors2_oetf_PQ(vec3 c) {
    vec3 y = c / _PQ_PEAK;
    vec3 yPow = pow(y, vec3(_PQ_M1));
    vec3 numerator = vec3(_PQ_C1) + vec3(_PQ_C2) * yPow;
    vec3 denominator = vec3(1.0) + vec3(_PQ_C3) * yPow;
    return pow(numerator / denominator, vec3(_PQ_M2));
}
float colors2_eotf_PQ(float c) {
    float ePow = pow(c, 1.0 / _PQ_M2);
    float numerator = max(ePow - _PQ_C1, 0.0);
    float denominator = _PQ_C2 - _PQ_C3 * ePow;
    float y = pow(numerator / denominator, 1.0 / _PQ_M1);
    return y * _PQ_PEAK;
}
vec3 colors2_eotf_PQ(vec3 c) {
    vec3 ePow = pow(c, vec3(1.0 / _PQ_M2));
    vec3 numerator = max(ePow - vec3(_PQ_C1), 0.0);
    vec3 denominator = _PQ_C2 - _PQ_C3 * ePow;
    vec3 y = pow(numerator / denominator, vec3(1.0 / _PQ_M1));
    return y * _PQ_PEAK;
}
const float _HLG_A = 0.17883277;
const float _HLG_B = 1.0 - 4.0 * _HLG_A;
const float _HLG_C = 0.5 - _HLG_A * log(4.0 * _HLG_A);
float colors2_oetf_HLG(float c) {
    float lower = sqrt(3.0 * c);
    float higher = _HLG_A * log(12.0 * c - _HLG_B) + _HLG_C;
    return mix(lower, higher, c > 1.0 / 12.0);
}
vec3 colors2_oetf_HLG(vec3 c) {
    vec3 lower = sqrt(3.0 * c);
    vec3 higher = _HLG_A * log(12.0 * c - _HLG_B) + _HLG_C;
    return mix(lower, higher, greaterThan(c, vec3(1.0 / 12.0)));
}
float colors2_eotf_HLG(float c) {
    float lower = c * c / 3.0;
    float higher = (exp((c - _HLG_C) / _HLG_A) + _HLG_B) / 12.0;
    return mix(lower, higher, c > 0.5);
}
vec3 colors2_eotf_HLG(vec3 c) {
    vec3 lower = c * c / 3.0;
    vec3 higher = (exp((c - vec3(_HLG_C)) / vec3(_HLG_A)) + vec3(_HLG_B)) / 12.0;
    return mix(lower, higher, greaterThan(c, vec3(0.5)));
}
float colors2_oetf_0(float c) { return colors2_eotf_identity(c); }
vec3 colors2_oetf_0(vec3 c) { return colors2_eotf_identity(c); }
float colors2_eotf_0(float c) { return colors2_oetf_identity(c); }
vec3 colors2_eotf_0(vec3 c) { return colors2_oetf_identity(c); }
float colors2_oetf_1(float c) { return colors2_oetf_Rec601(c); }
vec3 colors2_oetf_1(vec3 c) { return colors2_oetf_Rec601(c); }
float colors2_eotf_1(float c) { return colors2_eotf_Rec601(c); }
vec3 colors2_eotf_1(vec3 c) { return colors2_eotf_Rec601(c); }
float colors2_oetf_2(float c) { return colors2_oetf_Rec709(c); }
vec3 colors2_oetf_2(vec3 c) { return colors2_oetf_Rec709(c); }
float colors2_eotf_2(float c) { return colors2_eotf_Rec709(c); }
vec3 colors2_eotf_2(vec3 c) { return colors2_eotf_Rec709(c); }
float colors2_oetf_3(float c) { return colors2_oetf_sRGB(c); }
vec3 colors2_oetf_3(vec3 c) { return colors2_oetf_sRGB(c); }
float colors2_eotf_3(float c) { return colors2_eotf_sRGB(c); }
vec3 colors2_eotf_3(vec3 c) { return colors2_eotf_sRGB(c); }
float colors2_oetf_4(float c) { return colors2_oetf_Exp22(c); }
vec3 colors2_oetf_4(vec3 c) { return colors2_oetf_Exp22(c); }
float colors2_eotf_4(float c) { return colors2_eotf_Exp22(c); }
vec3 colors2_eotf_4(vec3 c) { return colors2_eotf_Exp22(c); }
float colors2_oetf_5(float c) { return colors2_oetf_Exp24(c); }
vec3 colors2_oetf_5(vec3 c) { return colors2_oetf_Exp24(c); }
float colors2_eotf_5(float c) { return colors2_eotf_Exp24(c); }
vec3 colors2_eotf_5(vec3 c) { return colors2_eotf_Exp24(c); }
float colors2_oetf_6(float c) { return colors2_oetf_PQ(c); }
vec3 colors2_oetf_6(vec3 c) { return colors2_oetf_PQ(c); }
float colors2_eotf_6(float c) { return colors2_eotf_PQ(c); }
vec3 colors2_eotf_6(vec3 c) { return colors2_eotf_PQ(c); }
float colors2_oetf_7(float c) { return colors2_oetf_HLG(c); }
vec3 colors2_oetf_7(vec3 c) { return colors2_oetf_HLG(c); }
float colors2_eotf_7(float c) { return colors2_eotf_HLG(c); }
vec3 colors2_eotf_7(vec3 c) { return colors2_eotf_HLG(c); }
#define COLORS2_MATERIAL_COLORSPACE SETTING_MATERIAL_COLOR_SPACE
#define COLORS2_MATERIAL_TF SETTING_MATERIAL_TRANSFER_FUNC
#define COLORS2_CONSTANTS_COLORSPACE COLORS2_COLORSPACES_ACES_AP0
#define COLORS2_CONSTANTS_TF COLORS2_TF_IDENTITY
#define COLORS2_WORKING_COLORSPACE SETTING_WORKING_COLOR_SPACE
#define COLORS2_DRT_WORKING_COLORSPACE SETTING_DRT_WORKING_COLOR_SPACE
#define COLORS2_OUTPUT_COLORSPACE COLORS2_COLORSPACES_SRGB
#define COLORS2_OUTPUT_TF COLORS2_TF_SRGB
#define colors2_material_toWorkSpace(x) colors2_colorspaces_convert(COLORS2_MATERIAL_COLORSPACE, COLORS2_WORKING_COLORSPACE, colors2_eotf(COLORS2_MATERIAL_TF, x))
#define colors2_constants_toWorkSpace(x) colors2_colorspaces_convert(COLORS2_CONSTANTS_COLORSPACE, COLORS2_WORKING_COLORSPACE, x)
float colors_sRGB_encodeGamma(float color) {
    float lower = 12.92 * color;
    float higher = pow(color, 1.0 / 2.4) * 1.055 - 0.055;
    return mix(lower, higher, color > 0.0031308);
}
vec2 colors_sRGB_encodeGamma(vec2 color) {
    vec2 lower = 12.92 * color;
    vec2 higher = pow(color, vec2(1.0 / 2.4)) * 1.055 - 0.055;
    return mix(lower, higher, greaterThan(color, vec2(0.0031308)));
}
vec3 colors_sRGB_encodeGamma(vec3 color) {
    vec3 lower = 12.92 * color;
    vec3 higher = pow(color, vec3(1.0 / 2.4)) * 1.055 - 0.055;
    return mix(lower, higher, greaterThan(color, vec3(0.0031308)));
}
vec4 colors_sRGB_encodeGamma(vec4 color) {
    vec4 lower = 12.92 * color;
    vec4 higher = pow(color, vec4(1.0 / 2.4)) * 1.055 - 0.055;
    return mix(lower, higher, greaterThan(color, vec4(0.0031308)));
}
const mat3 _SRGB_TO_YCOCG = mat3(
    0.25, 0.5, -0.25,
    0.5, 0.0, 0.5,
    0.25, -0.5, -0.25
);
const mat3 _YCOCG_TO_SRGB = mat3(
    1.0, 1.0, 1.0,
    1.0, 0.0, -1.0,
    -1.0, 1.0, -1.0
);
const mat3 _COLORS_LOGLUV32_M = mat3(
    0.2209, 0.3390, 0.4184,
    0.1138, 0.6780, 0.7319,
    0.0102, 0.1130, 0.2969
);
const mat3 _COLORS_LOGLUV32_INVERSE_M = mat3(
    6.0014, -2.7008, -1.7996,
    -1.3320, 3.1029, -5.7721,
    0.3008, -1.0882, 5.6268
);
vec3 colors_LogLuv32ToSRGB(in vec4 vLogLuv) {
    if (all(lessThanEqual(vLogLuv, vec4(0.0)))) {
        return vec3(0.0);
    }
    float Le = vLogLuv.z * 255 + vLogLuv.w;
    vec3 Xp_Y_XYZp;
    Xp_Y_XYZp.y = exp2((Le - 127) / 2);
    Xp_Y_XYZp.z = Xp_Y_XYZp.y / vLogLuv.y;
    Xp_Y_XYZp.x = vLogLuv.x * Xp_Y_XYZp.z;
    vec3 vRGB = _COLORS_LOGLUV32_INVERSE_M * Xp_Y_XYZp;
    return max(vRGB, 0);
}
const vec2 _COLORS_UV_MUL = vec2(6.4313725490, 14.4705882353);
const vec3 _COLORS_UV_DIV = vec3(1.0, 15.0, 3.0);
const float _COLORS_UV_INV_MUL = 0.6219512195;
const vec2 _COLORS_UV_Z_MUL = vec2(-3.0, -20.0);
const mat3 agx_mat = mat3(
    0.842479062253094, 0.0423282422610123, 0.0423756549057051,
    0.0784335999999992, 0.878468636469772, 0.0784336,
    0.0792237451477643, 0.0791661274605434, 0.879142973793104
);
const mat3 agx_mat_inv = mat3(
    1.19687900512017, -0.0528968517574562, -0.0529716355144438,
    -0.0980208811401368, 1.15190312990417, -0.0980434501171241,
    -0.0990297440797205, -0.0989611768448433, 1.15107367264116
);
vec3 _agxInvertible_decodeLog2Space(vec3 x) {
    const float EV_RANGE = 16.5;
    const float EV_RANGE_HALF = EV_RANGE * 0.5;
    x = x * EV_RANGE - EV_RANGE_HALF;
    x = exp2(x);
    return x;
}
vec3 agxInvertible_inverse(vec3 y) {
    vec3 x = saturate(y);
    x = _agxInvertible_decodeLog2Space(x);
    x = agx_mat_inv * x;
    return max(x, 0.0);
}
ivec2 _debug_texelPos = ivec2(0);
bool inViewPort(ivec4 originSize, out vec2 texCoord) {
    originSize = ivec4(vec4(originSize) * SETTING_DEBUG_SCALE);
    ivec2 min = originSize.xy;
    ivec2 max = originSize.xy + originSize.zw;
    texCoord = saturate((vec2(_debug_texelPos - min) + 0.5) / vec2(originSize.zw));
    if (all(greaterThanEqual(_debug_texelPos.xy, min)) && all(lessThan(_debug_texelPos.xy, max))) {
        return true;
    }
    return false;
}
/*
    References:
        [BRU08] Bruneton, Eric. "Precomputed Atmospheric Scattering". EGSR 2008. 2008.
            https:
        [EPI20] Epic Games, Inc. "Unreal Engine Sky Atmosphere Rendering Technique". 2020.
            MIT License. Copyright (c) 2020 Epic Games, Inc.
            https:
        [HIL20] Hillaire, Sébastien. "A Scalable and Production Ready Sky and Atmosphere Rendering Technique".
            EGSR 2020. 2020.
            https:
        [INT17] Intel Corporation. "Outdoor Light Scattering Sample". 2017.
            Apache License 2.0. Copyright (c) 2017 Intel Corporation.
            https:
        [YUS13] Yusov, Egor. “Practical Implementation of Light Scattering Effects Using Epipolar Sampling and
            1D Min/Max Binary Trees”. GDC 2013. 2013.
            http:

        You can find full license texts in /licenses
*/
struct ScatteringResult {
    vec3 transmittance;
    vec3 inScattering;
};
/*
    References:
        [EPI20] Epic Games, Inc. "Unreal Engine Sky Atmosphere Rendering Technique". 2020.
            MIT License. Copyright (c) 2020 Epic Games, Inc.
            https:
        [HIL20] Hillaire, Sébastien. "A Scalable and Production Ready Sky and Atmosphere Rendering Technique".
            EGSR 2020. 2020.
            https:
        [INT17] Intel Corporation. "Outdoor Light Scattering Sample". 2017.
            Apache License 2.0. Copyright (c) 2017 Intel Corporation.
            https:
        [PRE99] Preetham, A. J. et al. "A Practical Analytic Model for Daylight"
            SIGGRAPH 1999. 1999.
            https:

        You can find full license texts in /licenses

    Other Credits:
        Jessie - Helping with Mie coefficients (https:
*/
#if SETTING_EPIPOLAR_SLICES == 256
#define EPIPOLAR_SLICE_D16 16
#define EPIPOLAR_SLICE_D128 2
#elif SETTING_EPIPOLAR_SLICES == 512
#define EPIPOLAR_SLICE_D16 32
#define EPIPOLAR_SLICE_D128 4
#elif SETTING_EPIPOLAR_SLICES == 1024
#define EPIPOLAR_SLICE_D16 64
#define EPIPOLAR_SLICE_D128 8
#elif SETTING_EPIPOLAR_SLICES == 2048
#define EPIPOLAR_SLICE_D16 128
#define EPIPOLAR_SLICE_D128 16
#endif
#if SETTING_SLICE_SAMPLES == 128
#define EPIPOLAR_DATA_Y_SIZE 385
#define SLICE_SAMPLE_D16 8
#elif SETTING_SLICE_SAMPLES == 256
#define EPIPOLAR_DATA_Y_SIZE 769
#define SLICE_SAMPLE_D16 16
#elif SETTING_SLICE_SAMPLES == 512
#define EPIPOLAR_DATA_Y_SIZE 1537
#define SLICE_SAMPLE_D16 32
#elif SETTING_SLICE_SAMPLES == 1024
#define EPIPOLAR_DATA_Y_SIZE 3073
#define SLICE_SAMPLE_D16 64
#endif
#define PLANET_RADIUS_OFFSET 0.01
struct AtmosphereParameters {
    float bottom;
    float top;
    float mieHeight;
    vec3 rayleighSctrCoeff;
    vec3 rayleighExtinction;
    vec3 mieSctrCoeff;
    vec3 mieExtinction;
    float miePhaseG;
    float miePhaseE;
    vec3 ozoneExtinction;
};
/*
    References:
        [GIL23] Gilcher, Pascal. "A Better R2 Sequence". 2023.
            https:
        [JIM17] Jimenez, Jorge. "Interleaved Gradient Noise". 2017.
            https:
        [ROB18] Roberts, Martine. "The Unreasonable Effectiveness of Quasirandom Sequences". 2018.
            https:
        [WOL22] Wolfe, Alan. "Interleaved Gradient Noise: A Different Kind of Low Discrepancy Sequence". 2022.
            MIT License. Copyright (c) 2019 Alan Wolfe.
            https:

        You can find full license texts in /licenses
*/
/*
    References:
        [DRA03] Draine, B.T. "Scattering by Interstellar Dust Grains. I. Optical and Ultraviolet"
            The Astrophysical Journal. 2003.
            https:
        [JEN23] Jendersie, Johannes. d'Eon, Eugene. "An Approximate Mie Scattering Function for Fog and Cloud Rendering"
            SIGGRAPH 2023. 2023.
            https:

     Other Credits:
        Jessie - Bi-Lambertian plate and Klein-Nishina phase functions

        You can find full license texts in /licenses
*/
const float UNIFORM_PHASE = 1.0 / (4.0 * PI);
void unpackEpipolarData(uvec4 epipolarData, out ScatteringResult sctrResult, out float viewZ) {
    vec2 unpacked1 = unpackHalf2x16(epipolarData.x);
    vec2 unpacked2 = unpackHalf2x16(epipolarData.y);
    vec2 unpacked3 = unpackHalf2x16(epipolarData.z);
    sctrResult.inScattering = vec3(unpacked1.xy, unpacked2.x);
    sctrResult.transmittance = vec3(unpacked2.y, unpacked3.xy);
    viewZ = uintBitsToFloat(epipolarData.w);
}
#define INVALID_EPIPOLAR_LINE vec4(-1000.0, -1000.0, -100.0, -100.0)
vec4 getOutermostScreenPixelCoords() {
    return vec4(-1.0, -1.0, 1.0, 1.0) + vec4(1.0, 1.0, -1.0, -1.0) / uval_mainImageSizeI.xyxy;
}
const vec3 GROUND_ALBEDO_BASE = vec3(ivec3(SETTING_ATM_GROUND_ALBEDO_R, SETTING_ATM_GROUND_ALBEDO_G, SETTING_ATM_GROUND_ALBEDO_B)) / 255.0;
#define _LUMINOUS_EFFICACY 683.002 
#define _blackBody_func1_v0 vec3(-37290175.3986, -40810912.9676, -47350510.215)
#define _blackBody_func1_v1 vec3(7055.3581938, 6758.95549072, 4118.25228444)
#define _blackBody_func1_v2 vec3(0.00484537801959, 0.00491276883428, 0.00506185958018)
#define _blackBody_func1_v3 vec3(-6.810769857e-7, -6.950213321e-7, -6.9539565265e-7)
#define _blackBody_func1_v4 vec3(5.6731538598e-11, 5.8002399769e-11, 5.6337103621e-11)
#define _blackBody_func1_v5 vec3(-2.5703246799e-15, -2.6264426188e-15, -2.4816463488e-15)
#define _blackBody_func1_v6 vec3(4.8909354617e-20, 4.9886030965e-20, 4.5966064285e-20)
#define _blackBody_func1(x) exp2( _blackBody_func1_v0 * rcp(pow2(x)) + _blackBody_func1_v1 * rcp(x) + _blackBody_func1_v2 * x + _blackBody_func1_v3 * pow2(x) + _blackBody_func1_v4 * pow3(x) + _blackBody_func1_v5 * pow4(x) + _blackBody_func1_v6 * pow5(x) )
#define _blackBody_func2_v0 vec3(-8005.4231085, -12668.5089522, 90350.9871613)
#define _blackBody_func2_v1 vec3(-13.8986440037, -13.5414550402, -53.296767586)
#define _blackBody_func2_v2 vec3(0.00322233921192, 0.00326336194057, 0.00762350264707)
#define _blackBody_func2_v3 vec3(-8.7157145477e-8, -8.8899800557e-8, -2.0127905863e-7)
#define _blackBody_func2_v4 vec3(1.2119660239e-12, 1.242334591e-12, 2.7501969304e-12)
#define _blackBody_func2_v5 vec3(-6.7641067868e-18, -6.9583618131e-18, -1.5149377815e-17)
#define _blackBody_func2(x) _blackBody_func2_v0 + _blackBody_func2_v1 * x + _blackBody_func2_v2 * pow2(x) + _blackBody_func2_v3 * pow3(x) + _blackBody_func2_v4 * pow4(x) + _blackBody_func2_v5 * pow5(x)
#define blackBody_evalRadiance_AP0(temperture) (_LUMINOUS_EFFICACY * mix( _blackBody_func1(temperture), _blackBody_func2(temperture), smoothstep(9000.0, 10000.0, float(temperture)) ))
/*
    References:
        [WRE18] Wrensch, Benjamin. "Reverse Z Cheatsheet". IOLITE Development Blog. 2023.
*/
vec3 coords_octDecode11(vec2 f) {
    vec3 n = vec3(f.x, f.y, 1.0 - abs(f.x) - abs(f.y));
    float t = saturate(-n.z);
    n.xy += mix(vec2(t), vec2(-t), greaterThanEqual(n.xy, vec2(0.0)));
    return normalize(n);
}
const mat3 _COORDS_EQUATORIAL_TO_GALACTIC = mat3(
    -0.0548755604, 0.4941094279, -0.8676661490,
    -0.8734370902, -0.4448296300, -0.1980763734,
    -0.4838350155, 0.7469822445, 0.4559837762
);
const mat3 _COORDS_WORLD_TO_EQUATORIAL = mat3(
    0.0, 1.0, 0.0,
    1.0, 0.0, 0.0,
    0.0, 0.0, -1.0
);
vec3 coords_dir_worldToView(vec3 dirWorld) {
    return normalize((mat3(gbufferModelView) * dirWorld));
}
#ifdef SETTING_REAL_SUN_TEMPERATURE
#define SUN_TEMPERATURE 5772.0
#else
#define SUN_TEMPERATURE SETTING_SUN_TEMPERATURE
#endif
#define SUN_RADIUS (695700.0 * SETTING_SUN_RADIUS)
#define SUN_DISTANCE (149597870.7 * SETTING_SUN_DISTANCE)
#define SUN_ANGULAR_RADIUS atan(SUN_RADIUS / SUN_DISTANCE)
#define SUN_SOLID_ANGLE (2.0 * PI * (1.0 - sqrt(pow2(SUN_DISTANCE) - pow2(SUN_RADIUS)) / SUN_DISTANCE))
#define SUN_LUMINANCE colors2_constants_toWorkSpace(blackBody_evalRadiance_AP0(SUN_TEMPERATURE))
#define SUN_ILLUMINANCE (SUN_LUMINANCE * SUN_SOLID_ANGLE)
#define MOON_RADIUS (1737.4 * SETTING_MOON_RADIUS)
#define MOON_DISTANCE (384399 * SETTING_MOON_DISTANCE)
#define MOON_ANGULAR_RADIUS atan(MOON_RADIUS / MOON_DISTANCE)
#define MOON_SOLID_ANGLE (2.0 * PI * (1.0 - sqrt(pow2(MOON_DISTANCE) - pow2(MOON_RADIUS)) / MOON_DISTANCE))
#define MOON_ALBEDO (SETTING_MOON_ALBEDO * vec3(SETTING_MOON_COLOR_R, SETTING_MOON_COLOR_G, SETTING_MOON_COLOR_B))
#define MOON_LUMINANCE (SUN_ILLUMINANCE * MOON_ALBEDO * RCP_PI)
#define MOON_ILLUMINANCE (MOON_LUMINANCE * MOON_SOLID_ANGLE)
const float _CELESTIAL_STARMAP_MILKYWAY_LUMINANCE = 0.1927554;
const float _CELESTIAL_REAL_MILKYWAY_LUMINANCE_MCD = 1.5;
const float _CELESTIAL_REAL_MILKYWAY_LUMINANCE_KCD = _CELESTIAL_REAL_MILKYWAY_LUMINANCE_MCD / 1000000.0;
const float _CELESTIAL_STARMAP_EXP = _CELESTIAL_REAL_MILKYWAY_LUMINANCE_KCD / _CELESTIAL_STARMAP_MILKYWAY_LUMINANCE;
const vec2 _CELESTIAL_STARMAP_SIZE = vec2(8192.0, 4096.0);
vec3 nzpacking_unpackNormalOct32(uint packedNormal) {
    return coords_octDecode11(unpackSnorm2x16(packedNormal));
}
void nzpacking_unpackNormalOct16(uint packedNormal, out vec3 normal1, out vec3 normal2) {
    vec4 xyzw = unpackSnorm4x8(packedNormal);
    normal1 = coords_octDecode11(xyzw.xy);
    normal2 = coords_octDecode11(xyzw.zw);
}
/*
--------------------------------------------------------------------------------

  GLSL Debug Text Renderer by SixthSurge (updated 2023-04-08)

  Character set based on Monocraft by IdreesInc
  https:

  With additional characters added by WoMspace

  Usage:

  
  beginText(ivec2(gl_FragCoord.xy), ivec2(0, viewHeight));
            ^ fragment position     ^ text box position (upper left corner)

  
  printBool(false);
  printFloat(sqrt(-1.0)); 
  printInt(42);
  printVec3(skyColor);

  
  printString((_H, _e, _l, _l, _o, _comma, _space, _w, _o, _r, _l, _d));

  
  printLine();

  
  text.fgCol = vec4(1.0, 0.0, 0.0, 1.0);
  text.bgCol = vec4(0.0, 0.0, 0.0, 1.0);

  
  text.base = 16;
  text.fpPrecision = 4;

  
  endText(fragColor);

  Important: any variables you display must be the same for all fragments, or
  at least all of the fragments that the text covers. Otherwise, different
  fragments will try to print different values, resulting in, well, a mess

--------------------------------------------------------------------------------
*/
const uint _A = 0x747f18c4u;
const uint _B = 0xf47d18f8u;
const uint _C = 0x746108b8u;
const uint _D = 0xf46318f8u;
const uint _E = 0xfc39087cu;
const uint _F = 0xfc390840u;
const uint _G = 0x7c2718b8u;
const uint _H = 0x8c7f18c4u;
const uint _I = 0x71084238u;
const uint _J = 0x084218b8u;
const uint _K = 0x8cb928c4u;
const uint _L = 0x8421087cu;
const uint _M = 0x8eeb18c4u;
const uint _N = 0x8e6b38c4u;
const uint _O = 0x746318b8u;
const uint _P = 0xf47d0840u;
const uint _Q = 0x74631934u;
const uint _R = 0xf47d18c4u;
const uint _S = 0x7c1c18b8u;
const uint _T = 0xf9084210u;
const uint _U = 0x8c6318b8u;
const uint _V = 0x8c62a510u;
const uint _W = 0x8c635dc4u;
const uint _X = 0x8a88a8c4u;
const uint _Y = 0x8a884210u;
const uint _Z = 0xf844447cu;
const uint _a = 0x0382f8bcu;
const uint _b = 0x85b318f8u;
const uint _c = 0x03a308b8u;
const uint _d = 0x0b6718bcu;
const uint _e = 0x03a3f83cu;
const uint _f = 0x323c8420u;
const uint _g = 0x03e2f0f8u;
const uint _h = 0x842d98c4u;
const uint _i = 0x40308418u;
const uint _j = 0x080218b8u;
const uint _k = 0x4254c524u;
const uint _l = 0x6108420cu;
const uint _m = 0x06ab5ac4u;
const uint _n = 0x07a318c4u;
const uint _o = 0x03a318b8u;
const uint _p = 0x05b31f40u;
const uint _q = 0x03671784u;
const uint _r = 0x05b30840u;
const uint _s = 0x03e0e0f8u;
const uint _t = 0x211c420cu;
const uint _u = 0x046318bcu;
const uint _v = 0x04631510u;
const uint _w = 0x04635abcu;
const uint _x = 0x04544544u;
const uint _y = 0x0462f0f8u;
const uint _z = 0x07c4447cu;
const uint _0 = 0x746b58b8u;
const uint _1 = 0x23084238u;
const uint _2 = 0x744c88fcu;
const uint _3 = 0x744c18b8u;
const uint _4 = 0x19531f84u;
const uint _5 = 0xfc3c18b8u;
const uint _6 = 0x3221e8b8u;
const uint _7 = 0xfc422210u;
const uint _8 = 0x745d18b8u;
const uint _9 = 0x745e1130u;
const uint _space = 0x0000000u;
const uint _dot = 0x000010u;
const uint _minus = 0x0000e000u;
const uint _comma = 0x00000220u;
const uint _colon = 0x02000020u;
const uint _under = 0x000007Cu;
const uint _quote = 0x52800000u;
const uint _exclm = 0x21084010u;
const uint _gt = 0x02082220u;
const uint _lt = 0x00888208u;
const uint _opsqr = 0x3908421Cu;
const uint _clsqr = 0xE1084270u;
const uint _opprn = 0x11084208u;
const uint _clprn = 0x41084220u;
const uint _block = 0xFFFFFFFCu;
const uint _copyr = 0x03AB9AB8u;
const int charWidth = 5;
const int charHeight = 6;
const int charSpacing = 1;
const int lineSpacing = 1;
const ivec2 charSize = ivec2(charWidth, charHeight);
const ivec2 spaceSize = charSize + ivec2(charSpacing, lineSpacing);
struct Text {
 vec4 result;
 vec4 fgCol;
 vec4 bgCol;
 ivec2 fragPos;
 ivec2 textPos;
 ivec2 charPos;
 int base;
 int fpPrecision;
} text;
void beginText(ivec2 fragPos, ivec2 textPos) {
 text.result = vec4(0.0);
 text.fgCol = vec4(1.0);
 text.bgCol = vec4(0.0, 0.0, 0.0, 0.6);
 text.fragPos = fragPos;
 text.textPos = textPos;
 text.charPos = ivec2(0);
 text.base = 10;
 text.fpPrecision = 2;
}
void endText(inout vec3 fragColor) {
 fragColor = mix(fragColor.rgb, text.result.rgb, text.result.a);
}
void printChar(uint character) {
 ivec2 pos = text.fragPos - text.textPos - spaceSize * text.charPos * ivec2(1, -1) + ivec2(0, spaceSize.y);
 uint index = uint(charWidth - pos.x + pos.y * charWidth + 1);
 if (clamp(pos, ivec2(0), spaceSize - 1) == pos)
  text.result = mix(text.result, text.bgCol, text.bgCol.a);
 if (clamp(pos, ivec2(0), charSize - 1) == pos)
  text.result = mix(text.result, text.fgCol, text.fgCol.a * float(character >> index & 1u));
 text.charPos.x++;
}
#define printString(string) {                                               	uint[] characters = uint[] string;                                     	for (int i = 0; i < characters.length(); ++i) printChar(characters[i]); }
void printUnsignedInt(uint value, int len) {
 const uint[36] digits = uint[](
  _0, _1, _2, _3, _4, _5, _6, _7, _8, _9,
  _a, _b, _c, _d, _e, _f, _g, _h, _i, _j,
  _k, _l, _m, _n, _o, _p, _q, _r, _s, _t,
  _u, _v, _w, _x, _y, _z
 );
 text.charPos.x += len - 1;
 for (int i = 0; i < len; ++i) {
  printChar(digits[int(value) % text.base]);
  value /= uint(text.base);
  text.charPos.x -= 2;
 }
 text.charPos.x += len + 1;
}
void printUnsignedInt(uint value) {
 float logValue = log(float(value)) + 1e-6;
 float logBase = log(float(text.base));
 int len = int(ceil(logValue / logBase));
     len = max(len, 1);
 printUnsignedInt(value, len);
}
void printInt(int value) {
 if (value < 0) printChar(_minus);
 printUnsignedInt(uint(abs(value)));
}
void printIvec3(ivec3 value) {
 printInt(value.x);
 printString((_comma, _space));
 printInt(value.y);
 printString((_comma, _space));
 printInt(value.z);
}
void printLine() {
 text.charPos.x = 0;
 ++text.charPos.y;
}
const uint MATERIAL_ID_UNDEFINED = 65535u;
struct GBufferData {
    vec3 geomNormal;
    vec3 geomTangent;
    vec4 pbrSpecular;
    vec3 normal;
    vec2 lmCoord;
    uint materialID;
    vec3 albedo;
    bool isHand;
    int bitangentSign;
};
GBufferData gbufferData_init() {
    GBufferData gData;
    gData.geomNormal = vec3(0.0);
    gData.geomTangent = vec3(0.0);
    gData.pbrSpecular = vec4(0.0);
    gData.normal = vec3(0.0);
    gData.lmCoord = vec2(0.0);
    gData.materialID = MATERIAL_ID_UNDEFINED;
    gData.albedo = vec3(0.0);
    gData.isHand = false;
    return gData;
}
void gbufferData1_unpack_world(uvec4 packedData, inout GBufferData gData) {
    nzpacking_unpackNormalOct16(packedData.r, gData.geomNormal, gData.geomTangent);
    gData.geomNormal = gData.geomNormal;
    gData.geomTangent = gData.geomTangent;
    gData.pbrSpecular = unpackUnorm4x8(packedData.g);
    gData.normal = nzpacking_unpackNormalOct32(packedData.b);
    gData.lmCoord = unpackUnorm4x8(packedData.a).xy;
    gData.materialID = (packedData.a >> 16) & 0xFFFFu;
}
void gbufferData1_unpack(uvec4 packedData, inout GBufferData gData) {
    gbufferData1_unpack_world(packedData, gData);
    gData.geomNormal = coords_dir_worldToView(gData.geomNormal);
    gData.geomTangent = coords_dir_worldToView(gData.geomTangent);
    gData.normal = coords_dir_worldToView(gData.normal);
}
void gbufferData2_unpack(uvec4 packedData, inout GBufferData gData) {
    gData.albedo = unpackUnorm4x8(packedData.r).rgb;
    gData.isHand = bool(bitfieldExtract(packedData.r, 24, 1));
    gData.bitangentSign = int(bitfieldExtract(packedData.r, 25, 1)) * 2 - 1;
}
struct Material {
    vec3 albedo;
    float roughness;
    float f0;
    float metallic;
    vec3 emissive;
    float porosity;
    float sss;
    float hardCodedIOR;
    mat3 tbn;
    mat3 tbnInv;
    mat3 geomTbn;
    mat3 geomTbnInv;
};
#ifdef MATERIAL_TRANSLUCENT
const float _MATERIAL_F0_EPSILON = exp2(-SETTING_MINIMUM_F0);
const float _MATERIAL_ROUGHNESS_MULTIPLIER = exp2(-SETTING_TRANSLUCENT_ROUGHNESS_REDUCTION);
const float _MATERIAL_MINIMUM_ROUGHNESS = exp2(-SETTING_TRANSLUCENT_MINIMUM_ROUGHNESS);
const float _MATERIAL_MAXIMUM_ROUGHNESS = exp2(-SETTING_TRANSLUCENT_MAXIMUM_ROUGHNESS);
const float _MATERIAL_WATER_ROUGHNESS = exp2(-SETTING_WATER_ROUGHNESS);
#else
const float _MATERIAL_F0_EPSILON = exp2(-SETTING_MINIMUM_F0);
const float _MATERIAL_ROUGHNESS_MULTIPLIER = 1.0;
const float _MATERIAL_MINIMUM_ROUGHNESS = exp2(-SETTING_SOLID_MINIMUM_ROUGHNESS);
const float _MATERIAL_MAXIMUM_ROUGHNESS = 1.0 - exp2(-SETTING_SOLID_MAXIMUM_ROUGHNESS);
#endif
Material material_decode(GBufferData gData) {
    Material material;
    material.albedo = colors2_material_toWorkSpace(gData.albedo);
    material.roughness = 1.0 - gData.pbrSpecular.r;
    material.roughness *= material.roughness;
    material.roughness *= _MATERIAL_ROUGHNESS_MULTIPLIER;
    material.roughness = mix(_MATERIAL_MINIMUM_ROUGHNESS, _MATERIAL_MAXIMUM_ROUGHNESS, smoothstep(_MATERIAL_MINIMUM_ROUGHNESS, _MATERIAL_MAXIMUM_ROUGHNESS, material.roughness));
    #ifdef MATERIAL_TRANSLUCENT
    material.roughness = gData.materialID == 3u ? _MATERIAL_WATER_ROUGHNESS : material.roughness;
    #endif
    material.f0 = gData.pbrSpecular.g;
    #if SETTING_MINIMUM_F0_FACTOR > 0
    material.f0 = max(material.f0, _MATERIAL_F0_EPSILON);
    #endif
    material.metallic = float(material.f0 >= (229.5 / 255.0));
    float emissivePBR = pow(gData.pbrSpecular.a, SETTING_EMISSIVE_PBR_VALUE_CURVE);
    vec4 emissiveAlbedoCurve = vec4(vec3(SETTING_EMISSIVE_ALBEDO_COLOR_CURVE), SETTING_EMISSIVE_ALBEDO_LUM_CURVE);
    float albedoLuma = colors2_colorspaces_luma(COLORS2_MATERIAL_COLORSPACE, gData.albedo);
    vec4 emissiveAlbedo = pow(vec4(material.albedo, albedoLuma), emissiveAlbedoCurve);
    float MATERIAL_LAVA_LUMINANCE = colors2_colorspaces_luma(COLORS2_WORKING_COLORSPACE, colors2_constants_toWorkSpace(blackBody_evalRadiance_AP0(SETTING_LAVA_TEMPERATURE)));
    float MATERIAL_FIRE_LUMINANCE = colors2_colorspaces_luma(COLORS2_WORKING_COLORSPACE, colors2_constants_toWorkSpace(blackBody_evalRadiance_AP0(SETTING_FIRE_TEMPERATURE)));
    float emissiveValue = emissivePBR * 0.5;
    emissiveValue = gData.materialID == 1u ? MATERIAL_LAVA_LUMINANCE : emissiveValue;
    emissiveValue = gData.materialID == 2u ? MATERIAL_FIRE_LUMINANCE : emissiveValue;
    emissiveValue *= exp2(SETTING_EMISSIVE_STRENGTH);
    material.emissive = emissiveValue * emissiveAlbedo.a * emissiveAlbedo.rgb;
    const float _64o255 = 64.0 / 255.0;
    const float _65o255 = 65.0 / 255.0;
    float step64 = step(_65o255, gData.pbrSpecular.b);
    material.porosity = linearStep(0.0, _64o255, gData.pbrSpecular.b);
    material.porosity *= 1.0 - step64;
    material.sss = linearStep(_65o255, 1.0, gData.pbrSpecular.b);
    material.sss *= step64;
    material.sss = sqrt(material.sss);
    #ifdef MATERIAL_TRANSLUCENT
    material.hardCodedIOR = gData.materialID == 3u ? 1.3333 : 1.5;
    #else
    material.hardCodedIOR = 1.0;
    #endif
    vec3 newTangent = normalize(gData.geomTangent - gData.normal * dot(gData.normal, gData.geomTangent));
    vec3 newBitangent = cross(newTangent, gData.normal) * float(gData.bitangentSign);
    material.tbn = mat3(newTangent, newBitangent, gData.normal);
    material.tbnInv = inverse(material.tbn);
    vec3 geomBitangent = cross(gData.geomTangent, gData.geomNormal) * float(gData.bitangentSign);
    material.geomTbn = mat3(gData.geomTangent, geomBitangent, gData.geomNormal);
    material.geomTbnInv = inverse(material.geomTbn);
    return material;
}
const ivec2 ENV_PROBE_SIZEI = ivec2(256, 256);
const vec2 ENV_PROBE_SIZE = vec2(256.0, 256.0);
const vec2 ENV_PROBE_RCP = vec2(1.0 / 256.0, 1.0 / 256.0);
struct EnvProbeData {
    vec3 radiance;
    vec3 normal;
    vec3 scenePos;
};
bool envProbe_isSky(EnvProbeData envProbeData) {
    float distSq = dot(envProbeData.scenePos, envProbeData.scenePos);
    uint flag = uint(distSq == 0.0);
    flag |= uint(distSq > 4194304.0);
    return bool(flag);
}
EnvProbeData envProbe_decode(uvec4 packedData) {
    EnvProbeData unpackedData;
    vec2 temp1 = unpackHalf2x16(packedData.x);
    vec2 temp2 = unpackHalf2x16(packedData.y);
    vec2 temp3 = unpackHalf2x16(packedData.z);
    unpackedData.radiance = vec3(temp1, temp2.x);
    unpackedData.scenePos = vec3(temp2.y, temp3);
    unpackedData.normal = nzpacking_unpackNormalOct32(packedData.w);
    return unpackedData;
}
/*
    References:
        [EPI20] Epic Games, Inc. "Unreal Engine Sky Atmosphere Rendering Technique". 2020.
            MIT License. Copyright (c) 2020 Epic Games, Inc.
            https:
        [HIL20] Hillaire, Sébastien. "A Scalable and Production Ready Sky and Atmosphere Rendering Technique".
            EGSR 2020. 2020.
            https:

        You can find full license texts in /licenses
*/
/*
    References:
        [EPI20] Epic Games, Inc. "Unreal Engine Sky Atmosphere Rendering Technique". 2020.
            MIT License. Copyright (c) 2020 Epic Games, Inc.
            https:
        [HIL20] Hillaire, Sébastien. "A Scalable and Production Ready Sky and Atmosphere Rendering Technique".
            EGSR 2020. 2020.
            https:

        You can find full license texts in /licenses
*/
#define LUT_QUANTIZATION_MUL 512.0
#define TRANSMITTANCE_TEXTURE_WIDTH 256
#define TRANSMITTANCE_TEXTURE_HEIGHT 64
const vec2 TRANSMITTANCE_TEXTURE_SIZE = vec2(TRANSMITTANCE_TEXTURE_WIDTH, TRANSMITTANCE_TEXTURE_HEIGHT);
const vec2 TRANSMITTANCE_TEXEL_SIZE = 1.0 / TRANSMITTANCE_TEXTURE_SIZE;
#define MULTI_SCTR_LUT_SIZE 32
#define SKYVIEW_LUT_WIDTH (SETTING_SKYVIEW_RES / 2)
#define SKYVIEW_LUT_HEIGHT SETTING_SKYVIEW_RES
#define SKYVIEW_LUT_LAYERS 4
#define SKYVIEW_LUT_DEPTH 12
#define SKYVIEW_LUT_SIZE ivec2(SKYVIEW_LUT_WIDTH, SKYVIEW_LUT_HEIGHT)
#define SKYVIEW_LUT_SIZE_F vec2(SKYVIEW_LUT_WIDTH, SKYVIEW_LUT_HEIGHT)
#if SETTING_SKYVIEW_RES == 128
#define SKYVIEW_RES_D16 8
#elif SETTING_SKYVIEW_RES == 256
#define SKYVIEW_RES_D16 16
#elif SETTING_SKYVIEW_RES == 512
#define SKYVIEW_RES_D16 32
#elif SETTING_SKYVIEW_RES == 1024
#define SKYVIEW_RES_D16 64
#endif
vec3 _atmospherics_air_lut_sampleSkyViewSlice(vec2 sliceUV, float sliceIndex) {
    vec3 sampleUV = vec3(sliceUV, (sliceIndex + 0.5) / SKYVIEW_LUT_DEPTH);
    return texture(usam_skyViewLUT, sampleUV).rgb / LUT_QUANTIZATION_MUL;
}
struct SkyViewLutParams {
    bool intersectGround;
    float viewZenithCosAngle;
    float sunViewCosAngle;
    float moonViewCosAngle;
    float viewHeight;
};
#define RTWSM_IMAP_SIZE 256
#define IMAP_SIZE_D2 128
#define IMAP_SIZE_D16 16
#define IMAP_SIZE_D32 8
#define IMAP_SIZE_D128 2
#define IMAP1D_X_V (0.5 / 2.0)
#define IMAP1D_Y_V (1.5 / 2.0)
#define WARP_X_V (0.5 / 2.0)
#define WARP_Y_V (1.5 / 2.0)
#define TEXELSIZE_X_V (0.5 / 2.0)
#define TEXELSIZE_Y_V (1.5 / 2.0)
float rtwsm_linearDepth(float d) {
    return mix(-global_shadowAABBMaxPrev.z - 512.0, -global_shadowAABBMinPrev.z + 16.0, d);
}
#if SETTING_CLOUDS_LOW_UPSCALE_FACTOR == 0
#define UPSCALE_FACTOR 1.0
#define DOWNSCALE_DIVIDE(x) x
#define RENDER_MULTIPLIER 1.0
#define CHECK_MIP_LEVEL 3
#define CHECK_MIP_FACTOR 8.0
#elif SETTING_CLOUDS_LOW_UPSCALE_FACTOR == 1
#define UPSCALE_FACTOR 1.5
#define DOWNSCALE_DIVIDE(x) (x * 2 / 3)
#define RENDER_MULTIPLIER 0.6666666667
#define CHECK_MIP_LEVEL 3
#define CHECK_MIP_FACTOR 8.0
#elif SETTING_CLOUDS_LOW_UPSCALE_FACTOR == 2
#define UPSCALE_FACTOR 2.0
#define DOWNSCALE_DIVIDE(x) (x / 2)
#define RENDER_MULTIPLIER 0.5
#define CHECK_MIP_LEVEL 4
#define CHECK_MIP_FACTOR 16.0
#elif SETTING_CLOUDS_LOW_UPSCALE_FACTOR == 3
#define UPSCALE_FACTOR 2.5
#define DOWNSCALE_DIVIDE(x) (x * 2 / 5)
#define RENDER_MULTIPLIER 0.4
#define CHECK_MIP_LEVEL 4
#define CHECK_MIP_FACTOR 16.0
#elif SETTING_CLOUDS_LOW_UPSCALE_FACTOR == 4
#define UPSCALE_FACTOR 3.0
#define DOWNSCALE_DIVIDE(x) (x / 3)
#define RENDER_MULTIPLIER 0.3333333333
#define CHECK_MIP_LEVEL 5
#define CHECK_MIP_FACTOR 32.0
#elif SETTING_CLOUDS_LOW_UPSCALE_FACTOR == 5
#define UPSCALE_FACTOR 3.5
#define DOWNSCALE_DIVIDE(x) (x * 2 / 7)
#define RENDER_MULTIPLIER 0.2857142857
#define CHECK_MIP_LEVEL 5
#define CHECK_MIP_FACTOR 32.0
#elif SETTING_CLOUDS_LOW_UPSCALE_FACTOR == 6
#define UPSCALE_FACTOR 4.0
#define DOWNSCALE_DIVIDE(x) (x / 4)
#define RENDER_MULTIPLIER 0.25
#define CHECK_MIP_LEVEL 6
#define CHECK_MIP_FACTOR 64.0
#endif
ivec2 renderSize = DOWNSCALE_DIVIDE(uval_mainImageSizeI);
#define CLOUDS_SS_MAX_ACCUM SETTING_CLOUDS_LOW_MAX_ACCUM
struct CloudSSHistoryData {
    vec3 inScattering;
    vec3 transmittance;
    float hLen;
};
CloudSSHistoryData clouds_ss_historyData_init() {
    CloudSSHistoryData data;
    data.inScattering = vec3(0.0);
    data.transmittance = vec3(1.0);
    data.hLen = 0.0;
    return data;
}
uniform sampler2D usam_debug;
const vec3 turboCurve[] = vec3[](vec3(0.18995, 0.07176, 0.23217), vec3(0.19483, 0.08339, 0.26149), vec3(0.19956, 0.09498, 0.29024), vec3(0.20415, 0.10652, 0.31844), vec3(0.20860, 0.11802, 0.34607), vec3(0.21291, 0.12947, 0.37314), vec3(0.21708, 0.14087, 0.39964), vec3(0.22111, 0.15223, 0.42558), vec3(0.22500, 0.16354, 0.45096), vec3(0.22875, 0.17481, 0.47578), vec3(0.23236, 0.18603, 0.50004), vec3(0.23582, 0.19720, 0.52373), vec3(0.23915, 0.20833, 0.54686), vec3(0.24234, 0.21941, 0.56942), vec3(0.24539, 0.23044, 0.59142), vec3(0.24830, 0.24143, 0.61286), vec3(0.25107, 0.25237, 0.63374), vec3(0.25369, 0.26327, 0.65406), vec3(0.25618, 0.27412, 0.67381), vec3(0.25853, 0.28492, 0.69300), vec3(0.26074, 0.29568, 0.71162), vec3(0.26280, 0.30639, 0.72968), vec3(0.26473, 0.31706, 0.74718), vec3(0.26652, 0.32768, 0.76412), vec3(0.26816, 0.33825, 0.78050), vec3(0.26967, 0.34878, 0.79631), vec3(0.27103, 0.35926, 0.81156), vec3(0.27226, 0.36970, 0.82624), vec3(0.27334, 0.38008, 0.84037), vec3(0.27429, 0.39043, 0.85393), vec3(0.27509, 0.40072, 0.86692), vec3(0.27576, 0.41097, 0.87936), vec3(0.27628, 0.42118, 0.89123), vec3(0.27667, 0.43134, 0.90254), vec3(0.27691, 0.44145, 0.91328), vec3(0.27701, 0.45152, 0.92347), vec3(0.27698, 0.46153, 0.93309), vec3(0.27680, 0.47151, 0.94214), vec3(0.27648, 0.48144, 0.95064), vec3(0.27603, 0.49132, 0.95857), vec3(0.27543, 0.50115, 0.96594), vec3(0.27469, 0.51094, 0.97275), vec3(0.27381, 0.52069, 0.97899), vec3(0.27273, 0.53040, 0.98461), vec3(0.27106, 0.54015, 0.98930), vec3(0.26878, 0.54995, 0.99303), vec3(0.26592, 0.55979, 0.99583), vec3(0.26252, 0.56967, 0.99773), vec3(0.25862, 0.57958, 0.99876), vec3(0.25425, 0.58950, 0.99896), vec3(0.24946, 0.59943, 0.99835), vec3(0.24427, 0.60937, 0.99697), vec3(0.23874, 0.61931, 0.99485), vec3(0.23288, 0.62923, 0.99202), vec3(0.22676, 0.63913, 0.98851), vec3(0.22039, 0.64901, 0.98436), vec3(0.21382, 0.65886, 0.97959), vec3(0.20708, 0.66866, 0.97423), vec3(0.20021, 0.67842, 0.96833), vec3(0.19326, 0.68812, 0.96190), vec3(0.18625, 0.69775, 0.95498), vec3(0.17923, 0.70732, 0.94761), vec3(0.17223, 0.71680, 0.93981), vec3(0.16529, 0.72620, 0.93161), vec3(0.15844, 0.73551, 0.92305), vec3(0.15173, 0.74472, 0.91416), vec3(0.14519, 0.75381, 0.90496), vec3(0.13886, 0.76279, 0.89550), vec3(0.13278, 0.77165, 0.88580), vec3(0.12698, 0.78037, 0.87590), vec3(0.12151, 0.78896, 0.86581), vec3(0.11639, 0.79740, 0.85559), vec3(0.11167, 0.80569, 0.84525), vec3(0.10738, 0.81381, 0.83484), vec3(0.10357, 0.82177, 0.82437), vec3(0.10026, 0.82955, 0.81389), vec3(0.09750, 0.83714, 0.80342), vec3(0.09532, 0.84455, 0.79299), vec3(0.09377, 0.85175, 0.78264), vec3(0.09287, 0.85875, 0.77240), vec3(0.09267, 0.86554, 0.76230), vec3(0.09320, 0.87211, 0.75237), vec3(0.09451, 0.87844, 0.74265), vec3(0.09662, 0.88454, 0.73316), vec3(0.09958, 0.89040, 0.72393), vec3(0.10342, 0.89600, 0.71500), vec3(0.10815, 0.90142, 0.70599), vec3(0.11374, 0.90673, 0.69651), vec3(0.12014, 0.91193, 0.68660), vec3(0.12733, 0.91701, 0.67627), vec3(0.13526, 0.92197, 0.66556), vec3(0.14391, 0.92680, 0.65448), vec3(0.15323, 0.93151, 0.64308), vec3(0.16319, 0.93609, 0.63137), vec3(0.17377, 0.94053, 0.61938), vec3(0.18491, 0.94484, 0.60713), vec3(0.19659, 0.94901, 0.59466), vec3(0.20877, 0.95304, 0.58199), vec3(0.22142, 0.95692, 0.56914), vec3(0.23449, 0.96065, 0.55614), vec3(0.24797, 0.96423, 0.54303), vec3(0.26180, 0.96765, 0.52981), vec3(0.27597, 0.97092, 0.51653), vec3(0.29042, 0.97403, 0.50321), vec3(0.30513, 0.97697, 0.48987), vec3(0.32006, 0.97974, 0.47654), vec3(0.33517, 0.98234, 0.46325), vec3(0.35043, 0.98477, 0.45002), vec3(0.36581, 0.98702, 0.43688), vec3(0.38127, 0.98909, 0.42386), vec3(0.39678, 0.99098, 0.41098), vec3(0.41229, 0.99268, 0.39826), vec3(0.42778, 0.99419, 0.38575), vec3(0.44321, 0.99551, 0.37345), vec3(0.45854, 0.99663, 0.36140), vec3(0.47375, 0.99755, 0.34963), vec3(0.48879, 0.99828, 0.33816), vec3(0.50362, 0.99879, 0.32701), vec3(0.51822, 0.99910, 0.31622), vec3(0.53255, 0.99919, 0.30581), vec3(0.54658, 0.99907, 0.29581), vec3(0.56026, 0.99873, 0.28623), vec3(0.57357, 0.99817, 0.27712), vec3(0.58646, 0.99739, 0.26849), vec3(0.59891, 0.99638, 0.26038), vec3(0.61088, 0.99514, 0.25280), vec3(0.62233, 0.99366, 0.24579), vec3(0.63323, 0.99195, 0.23937), vec3(0.64362, 0.98999, 0.23356), vec3(0.65394, 0.98775, 0.22835), vec3(0.66428, 0.98524, 0.22370), vec3(0.67462, 0.98246, 0.21960), vec3(0.68494, 0.97941, 0.21602), vec3(0.69525, 0.97610, 0.21294), vec3(0.70553, 0.97255, 0.21032), vec3(0.71577, 0.96875, 0.20815), vec3(0.72596, 0.96470, 0.20640), vec3(0.73610, 0.96043, 0.20504), vec3(0.74617, 0.95593, 0.20406), vec3(0.75617, 0.95121, 0.20343), vec3(0.76608, 0.94627, 0.20311), vec3(0.77591, 0.94113, 0.20310), vec3(0.78563, 0.93579, 0.20336), vec3(0.79524, 0.93025, 0.20386), vec3(0.80473, 0.92452, 0.20459), vec3(0.81410, 0.91861, 0.20552), vec3(0.82333, 0.91253, 0.20663), vec3(0.83241, 0.90627, 0.20788), vec3(0.84133, 0.89986, 0.20926), vec3(0.85010, 0.89328, 0.21074), vec3(0.85868, 0.88655, 0.21230), vec3(0.86709, 0.87968, 0.21391), vec3(0.87530, 0.87267, 0.21555), vec3(0.88331, 0.86553, 0.21719), vec3(0.89112, 0.85826, 0.21880), vec3(0.89870, 0.85087, 0.22038), vec3(0.90605, 0.84337, 0.22188), vec3(0.91317, 0.83576, 0.22328), vec3(0.92004, 0.82806, 0.22456), vec3(0.92666, 0.82025, 0.22570), vec3(0.93301, 0.81236, 0.22667), vec3(0.93909, 0.80439, 0.22744), vec3(0.94489, 0.79634, 0.22800), vec3(0.95039, 0.78823, 0.22831), vec3(0.95560, 0.78005, 0.22836), vec3(0.96049, 0.77181, 0.22811), vec3(0.96507, 0.76352, 0.22754), vec3(0.96931, 0.75519, 0.22663), vec3(0.97323, 0.74682, 0.22536), vec3(0.97679, 0.73842, 0.22369), vec3(0.98000, 0.73000, 0.22161), vec3(0.98289, 0.72140, 0.21918), vec3(0.98549, 0.71250, 0.21650), vec3(0.98781, 0.70330, 0.21358), vec3(0.98986, 0.69382, 0.21043), vec3(0.99163, 0.68408, 0.20706), vec3(0.99314, 0.67408, 0.20348), vec3(0.99438, 0.66386, 0.19971), vec3(0.99535, 0.65341, 0.19577), vec3(0.99607, 0.64277, 0.19165), vec3(0.99654, 0.63193, 0.18738), vec3(0.99675, 0.62093, 0.18297), vec3(0.99672, 0.60977, 0.17842), vec3(0.99644, 0.59846, 0.17376), vec3(0.99593, 0.58703, 0.16899), vec3(0.99517, 0.57549, 0.16412), vec3(0.99419, 0.56386, 0.15918), vec3(0.99297, 0.55214, 0.15417), vec3(0.99153, 0.54036, 0.14910), vec3(0.98987, 0.52854, 0.14398), vec3(0.98799, 0.51667, 0.13883), vec3(0.98590, 0.50479, 0.13367), vec3(0.98360, 0.49291, 0.12849), vec3(0.98108, 0.48104, 0.12332), vec3(0.97837, 0.46920, 0.11817), vec3(0.97545, 0.45740, 0.11305), vec3(0.97234, 0.44565, 0.10797), vec3(0.96904, 0.43399, 0.10294), vec3(0.96555, 0.42241, 0.09798), vec3(0.96187, 0.41093, 0.09310), vec3(0.95801, 0.39958, 0.08831), vec3(0.95398, 0.38836, 0.08362), vec3(0.94977, 0.37729, 0.07905), vec3(0.94538, 0.36638, 0.07461), vec3(0.94084, 0.35566, 0.07031), vec3(0.93612, 0.34513, 0.06616), vec3(0.93125, 0.33482, 0.06218), vec3(0.92623, 0.32473, 0.05837), vec3(0.92105, 0.31489, 0.05475), vec3(0.91572, 0.30530, 0.05134), vec3(0.91024, 0.29599, 0.04814), vec3(0.90463, 0.28696, 0.04516), vec3(0.89888, 0.27824, 0.04243), vec3(0.89298, 0.26981, 0.03993), vec3(0.88691, 0.26152, 0.03753), vec3(0.88066, 0.25334, 0.03521), vec3(0.87422, 0.24526, 0.03297), vec3(0.86760, 0.23730, 0.03082), vec3(0.86079, 0.22945, 0.02875), vec3(0.85380, 0.22170, 0.02677), vec3(0.84662, 0.21407, 0.02487), vec3(0.83926, 0.20654, 0.02305), vec3(0.83172, 0.19912, 0.02131), vec3(0.82399, 0.19182, 0.01966), vec3(0.81608, 0.18462, 0.01809), vec3(0.80799, 0.17753, 0.01660), vec3(0.79971, 0.17055, 0.01520), vec3(0.79125, 0.16368, 0.01387), vec3(0.78260, 0.15693, 0.01264), vec3(0.77377, 0.15028, 0.01148), vec3(0.76476, 0.14374, 0.01041), vec3(0.75556, 0.13731, 0.00942), vec3(0.74617, 0.13098, 0.00851), vec3(0.73661, 0.12477, 0.00769), vec3(0.72686, 0.11867, 0.00695), vec3(0.71692, 0.11268, 0.00629), vec3(0.70680, 0.10680, 0.00571), vec3(0.69650, 0.10102, 0.00522), vec3(0.68602, 0.09536, 0.00481), vec3(0.67535, 0.08980, 0.00449), vec3(0.66449, 0.08436, 0.00424), vec3(0.65345, 0.07902, 0.00408), vec3(0.64223, 0.07380, 0.00401), vec3(0.63082, 0.06868, 0.00401), vec3(0.61923, 0.06367, 0.00410), vec3(0.60746, 0.05878, 0.00427), vec3(0.59550, 0.05399, 0.00453), vec3(0.58336, 0.04931, 0.00486), vec3(0.57103, 0.04474, 0.00529), vec3(0.55852, 0.04028, 0.00579), vec3(0.54583, 0.03593, 0.00638), vec3(0.53295, 0.03169, 0.00705), vec3(0.51989, 0.02756, 0.00780), vec3(0.50664, 0.02354, 0.00863), vec3(0.49321, 0.01963, 0.00955), vec3(0.47960, 0.01583, 0.01055));
vec3 interpolateTurbo(float x) {
    if (x < 0.0) {
        return vec3(0.0);
    } else if (x > 1.0) {
        return vec3(1.0);
    }
    x *= 255.0;
    return turboCurve[int(x)] + (turboCurve[min(255, int(x) + 1)] - turboCurve[int(x)]) * fract(x);
}
#if SETTING_DEBUG_TEMP_TEX == 1
#define DEBUG_TEX_NAME usam_temp1
#elif SETTING_DEBUG_TEMP_TEX == 2
#define DEBUG_TEX_NAME usam_temp2
#elif SETTING_DEBUG_TEMP_TEX == 3
#define DEBUG_TEX_NAME usam_temp3
#elif SETTING_DEBUG_TEMP_TEX == 4
#define DEBUG_TEX_NAME usam_temp4
#elif SETTING_DEBUG_TEMP_TEX == 5
#define DEBUG_TEX_NAME usam_temp5
#elif SETTING_DEBUG_TEMP_TEX == 6
#define DEBUG_TEX_NAME usam_overlays
#elif SETTING_DEBUG_TEMP_TEX == 7
#define DEBUG_TEX_NAME usam_geometryNormal
#endif
float applyExposure(float color) {
    return color * exp2(float(SETTING_DEBUG_EV_COARSE) + SETTING_DEBUG_EV_FINE);
}
vec2 applyExposure(vec2 color) {
    return color * exp2(float(SETTING_DEBUG_EV_COARSE) + SETTING_DEBUG_EV_FINE);
}
vec3 applyExposure(vec3 color) {
    return color * exp2(float(SETTING_DEBUG_EV_COARSE) + SETTING_DEBUG_EV_FINE);
}
vec4 applyExposure(vec4 color) {
    return color * exp2(float(SETTING_DEBUG_EV_COARSE) + SETTING_DEBUG_EV_FINE);
}
#if defined(SETTING_DEBUG_GAMMA_CORRECT) && (SETTING_DEBUG_OUTPUT == 4)
float gammaCorrect(float color) {
    return colors_sRGB_encodeGamma(color);
}
vec2 gammaCorrect(vec2 color) {
    return colors_sRGB_encodeGamma(color);
}
vec3 gammaCorrect(vec3 color) {
    return colors_sRGB_encodeGamma(color);
}
vec4 gammaCorrect(vec4 color) {
    return vec4(colors_sRGB_encodeGamma(color.rgb), color.a);
}
#else
float gammaCorrect(float color) {
    return color;
}
vec2 gammaCorrect(vec2 color) {
    return color;
}
vec3 gammaCorrect(vec3 color) {
    return color;
}
vec4 gammaCorrect(vec4 color) {
    return color;
}
#endif
float expGamma(float color) {
    return gammaCorrect(applyExposure(color));
}
vec2 expGamma(vec2 color) {
    return gammaCorrect(applyExposure(color));
}
vec3 expGamma(vec3 color) {
    return gammaCorrect(applyExposure(color));
}
vec4 expGamma(vec4 color) {
    return gammaCorrect(applyExposure(color));
}
vec3 displayViewZ(float viewZ) {
    #ifdef DISTANT_HORIZONS
    float viewZRemapped = linearStep(-near, -dhFarPlane, viewZ);
    #else
    float viewZRemapped = linearStep(-near, -far, viewZ);
    #endif
    return interpolateTurbo(sqrt(viewZRemapped));
}
void debugOutput(ivec2 texelPos, inout vec4 outputColor) {
    _debug_texelPos = texelPos;
    beginText(texelPos >> ivec2(2), ivec2(0, uval_mainImageSizeI.y >> 2));
    printLine();
    printLine();
    text.fpPrecision = 4;
    ivec2 scaledTextureSize = ivec2(uval_mainImageSize * SETTING_DEBUG_SCALE);
    if (all(lessThan(texelPos, scaledTextureSize))) {
        ivec2 scaledTexelPos = ivec2((vec2(texelPos) + 0.5) / SETTING_DEBUG_SCALE);
        #ifdef DEBUG_TEX_NAME
        outputColor = texelFetch(DEBUG_TEX_NAME, scaledTexelPos, 0);
        #endif
        GBufferData gData = gbufferData_init();
        gbufferData1_unpack(texelFetch(colortex8, scaledTexelPos, 0), gData);
        gbufferData2_unpack(texelFetch(colortex9, scaledTexelPos, 0), gData);
        Material material = material_decode(gData);
        #if SETTING_DEBUG_GBUFFER_DATA == 1
        outputColor.rgb = displayViewZ(texelFetch(colortex10, scaledTexelPos, 0).r);
        #elif SETTING_DEBUG_GBUFFER_DATA == 2
        outputColor.rgb = gammaCorrect(material.albedo);
        #elif SETTING_DEBUG_GBUFFER_DATA == 3 || SETTING_DEBUG_GBUFFER_DATA == 4
        #if SETTING_DEBUG_GBUFFER_DATA == 3
        outputColor.rgb = gData.normal;
        #else
        outputColor.rgb = gData.geomNormal;
        #endif
        #if SETTING_DEBUG_NORMAL_MODE == 0
        outputColor.rgb = mat3(gbufferModelViewInverse) * outputColor.rgb;
        #endif
        outputColor.r = linearStep(-SETTING_DEBUG_NORMAL_X_RANGE, SETTING_DEBUG_NORMAL_X_RANGE, outputColor.r);
        outputColor.g = linearStep(-SETTING_DEBUG_NORMAL_Y_RANGE, SETTING_DEBUG_NORMAL_Y_RANGE, outputColor.g);
        outputColor.b = linearStep(-SETTING_DEBUG_NORMAL_Z_RANGE, SETTING_DEBUG_NORMAL_Z_RANGE, outputColor.b);
        #elif SETTING_DEBUG_GBUFFER_DATA == 5
        outputColor.rgb = vec3(material.roughness);
        #elif SETTING_DEBUG_GBUFFER_DATA == 6
        outputColor.rgb = vec3(material.f0);
        #elif SETTING_DEBUG_GBUFFER_DATA == 7
        outputColor.rgb = vec3(material.porosity);
        #elif SETTING_DEBUG_GBUFFER_DATA == 8
        outputColor.rgb = vec3(material.sss);
        #elif SETTING_DEBUG_GBUFFER_DATA == 9
        outputColor.rgb = vec3(gData.pbrSpecular.a);
        #elif SETTING_DEBUG_GBUFFER_DATA == 10
        outputColor.rgb = vec3(gData.lmCoord.x);
        #elif SETTING_DEBUG_GBUFFER_DATA == 11
        outputColor.rgb = vec3(gData.lmCoord.y);
        #elif SETTING_DEBUG_GBUFFER_DATA == 12
        outputColor.rgb = vec3(float(gData.isHand));
        #endif
        outputColor = applyExposure(outputColor);
        #ifdef SETTING_DEBUG_NEGATE
        outputColor = -outputColor;
        #endif
        #ifdef SETTING_DEBUG_ALPHA
        outputColor.rgb = outputColor.aaa;
        #else
        outputColor.a = 1.0;
        #endif
        outputColor = gammaCorrect(outputColor);
    }
    #if SETTING_DEBUG_GI_INPUTS != 0
    #endif
    #if SETTING_DEBUG_GI_INPUTS == 6
    #endif
    vec2 screenPos = (vec2(texelPos) + 0.5) * uval_mainImageSizeRcp;
    vec2 debugTexCoord;
    #ifdef SETTING_DEBUG_RTWSM
    printIvec3(global_shadowAABBMin);
    printLine();
    printLine();
    printIvec3(global_shadowAABBMax);
    if (inViewPort(ivec4(0, 0, 512, 512), debugTexCoord)) {
        float linearDepth = rtwsm_linearDepth(texture(shadowtex0, debugTexCoord).r);
        float remappedDepth = linearStep(-global_shadowAABBMaxPrev.z, -global_shadowAABBMinPrev.z, linearDepth);
        outputColor.rgb = vec3(remappedDepth);
    }
    if (inViewPort(ivec4(0, 512, 512, 512), debugTexCoord)) {
        outputColor.rgb = gammaCorrect(persistent_rtwsm_importance2D_sample(debugTexCoord).r * 0.5).rrr;
    }
    if (inViewPort(ivec4(0, 1024 + 4, 512, 16), debugTexCoord)) {
        outputColor.rgb = gammaCorrect(persistent_rtwsm_importance1D_sample(vec2(debugTexCoord.x, IMAP1D_X_V)).r * 0.1).rrr;
    }
    if (inViewPort(ivec4(512 + 4, 512, 16, 512), debugTexCoord)) {
        outputColor.rgb = gammaCorrect(persistent_rtwsm_importance1D_sample(vec2(debugTexCoord.y, IMAP1D_Y_V)).r * 0.1).rrr;
    }
    if (inViewPort(ivec4(0, 1024 + 4 + 16 + 4, 512, 16), debugTexCoord)) {
        float v = persistent_rtwsm_warp_sample(vec2(debugTexCoord.x, WARP_X_V)).r;
        outputColor.rgb = vec3(max(v, 0.0), max(-v, 0.0), 0.0);
    }
    if (inViewPort(ivec4(0, 1024 + 4 + 16 + 4 + 16 + 4, 512, 16), debugTexCoord)) {
        vec4 warpTexelSize = persistent_rtwsm_warpTexelSize_sample(debugTexCoord);
        float v = warpTexelSize.r * 2.0 - 1.0;
        outputColor.rgb = vec3(max(v, 0.0), max(-v, 0.0), 0.0);
    }
    if (inViewPort(ivec4(512 + 4 + 16 + 4, 512, 16, 512), debugTexCoord)) {
        float v = persistent_rtwsm_warp_sample(vec2(debugTexCoord.y, WARP_Y_V)).r;
        outputColor.rgb = vec3(max(v, 0.0), max(-v, 0.0), 0.0);
    }
    if (inViewPort(ivec4(512 + 4 + 16 + 4 + 16 + 4, 512, 16, 512), debugTexCoord)) {
        vec4 warpTexelSize = persistent_rtwsm_warpTexelSize_sample(debugTexCoord);
        float v = warpTexelSize.g * 2.0 - 1.0;
        outputColor.rgb = vec3(max(v, 0.0), max(-v, 0.0), 0.0);
    }
    #endif
    #ifdef SETTING_DEBUG_ATMOSPHERE
    const float EPIPOLAR_SLICE_END_POINTS_V = 0.5 / float(EPIPOLAR_DATA_Y_SIZE);
    if (inViewPort(ivec4(0, 0, 1024, 16), debugTexCoord)) {
        outputColor.rgb = vec3(uintBitsToFloat(texture(usam_epipolarData, vec2(debugTexCoord.x, EPIPOLAR_SLICE_END_POINTS_V)).rg), 0.0);
    }
    if (inViewPort(ivec4(0, 16, 1024, 16), debugTexCoord)) {
        outputColor.rgb = vec3(uintBitsToFloat(texture(usam_epipolarData, vec2(debugTexCoord.x, EPIPOLAR_SLICE_END_POINTS_V)).ba), 0.0);
    }
    if (inViewPort(ivec4(0, 32, 256, 64), debugTexCoord)) {
        outputColor.rgb = gammaCorrect(persistent_transmittanceLUT_sample(debugTexCoord).rgb);
    }
    if (inViewPort(ivec4(0, 32 + 64 + 256, 256, 256), debugTexCoord)) {
        outputColor.rgb = gammaCorrect(persistent_multiSctrLUT_sample(debugTexCoord).rgb);
    }
    float whRatio = float(SETTING_EPIPOLAR_SLICES) / float(SETTING_SLICE_SAMPLES);
    if (inViewPort(ivec4(256, 32, whRatio * 512, 768), debugTexCoord)) {
        ScatteringResult sampleResult;
        float viewZ;
        vec2 sampleTexCoord = debugTexCoord;
        sampleTexCoord.y = mix(1.0 / EPIPOLAR_DATA_Y_SIZE, 1.0, sampleTexCoord.y);
        unpackEpipolarData(texture(usam_epipolarData, sampleTexCoord), sampleResult, viewZ);
        outputColor.rgb = expGamma(sampleResult.inScattering);
    }
    #endif
    #ifdef SETTING_DEBUG_SKY_VIEW_LUT
    for (int i = 0; i < SKYVIEW_LUT_LAYERS; i++) {
        if (inViewPort(ivec4(i * 256, 0, 256, 256), debugTexCoord)) {
        outputColor.rgb = expGamma(_atmospherics_air_lut_sampleSkyViewSlice(debugTexCoord, 0.0 + float(i * 3)));
        }
        if (inViewPort(ivec4(i * 256, 256, 256, 256), debugTexCoord)) {
            outputColor.rgb = expGamma(_atmospherics_air_lut_sampleSkyViewSlice(debugTexCoord, 1.0 + float(i * 3)));
        }
        if (inViewPort(ivec4(i * 256, 512, 256, 256), debugTexCoord)) {
            outputColor.rgb = gammaCorrect(_atmospherics_air_lut_sampleSkyViewSlice(debugTexCoord, 2.0 + float(i * 3)));
        }
    }
    #endif
    #ifdef SETTING_DEBUG_CLOUDS_AMBLUT
    #define CLOUDS_AMB_LUT_SIZE 128
    for (int i = 0; i < 6; i++) {
        if (inViewPort(ivec4(0, CLOUDS_AMB_LUT_SIZE * i, CLOUDS_AMB_LUT_SIZE, CLOUDS_AMB_LUT_SIZE), debugTexCoord)) {
            vec3 lutCoord = vec3(debugTexCoord, (float(i) + 0.5) / 6.0);
            outputColor.rgb = gammaCorrect(applyExposure(texture(usam_cloudsAmbLUT, lutCoord).rgb));
        }
        if (inViewPort(ivec4(CLOUDS_AMB_LUT_SIZE, CLOUDS_AMB_LUT_SIZE * i, CLOUDS_AMB_LUT_SIZE, CLOUDS_AMB_LUT_SIZE), debugTexCoord)) {
            vec3 lutCoord = vec3(debugTexCoord, (float(i) + 0.5) / 6.0);
            outputColor.rgb = interpolateTurbo(texture(usam_cloudsAmbLUT, lutCoord).a);
        }
    }
    #endif
    #if SETTING_DEBUG_CLOUDS_SS
    {
        CloudSSHistoryData historyData = clouds_ss_historyData_init();
        #if SETTING_DEBUG_CLOUDS_SS == 1
        outputColor.rgb = expGamma(historyData.inScattering);
        #elif SETTING_DEBUG_CLOUDS_SS == 2
        outputColor.rgb = expGamma(historyData.transmittance);
        #elif SETTING_DEBUG_CLOUDS_SS == 3
        outputColor.rgb = interpolateTurbo(linearStep(0.0, 64.0, historyData.viewZ));
        #elif SETTING_DEBUG_CLOUDS_SS == 4
        outputColor.rgb = interpolateTurbo(1.0 - (historyData.hLen - 2.0) / (float(CLOUDS_SS_MAX_ACCUM) - 2.0));
        #endif
    }
    #endif
    #ifdef SETTING_DEBUG_ENV_PROBE
    if (inViewPort(ivec4(0, 0, 512, 768), debugTexCoord)) {
        ivec2 texelPos = ivec2(debugTexCoord * ENV_PROBE_SIZE * vec2(2.0, 3.0));
        EnvProbeData envProbeData = envProbe_decode(texelFetch(usam_envProbe, texelPos, 0));
        bool envProbeIsSky = envProbe_isSky(envProbeData);
        outputColor.rgb = envProbeIsSky ? vec3(0.0) : envProbeData.radiance;
        outputColor.rgb = expGamma(outputColor.rgb);
    }
    #endif
    #ifdef SETTING_DEBUG_STARMAP
    outputColor.rgb = gammaCorrect(colors2_colorspaces_convert(COLORS2_COLORSPACES_SRGB, COLORS2_WORKING_COLORSPACE, colors_LogLuv32ToSRGB(texture(usam_starmap, screenPos))));
    #endif
    #ifdef SETTING_DEBUG_EPIPOLAR_LINES
    {
        vec2 ndcPos = screenPos * 2.0 - 1.0;
        vec2 f2RayDir = normalize(ndcPos - uval_sunNdcPos);
        vec4 f4Boundaries = getOutermostScreenPixelCoords();
        vec4 f4HalfSpaceEquationTerms = (ndcPos.xxyy - f4Boundaries.xzyw) * f2RayDir.yyxx;
        uvec4 b4HalfSpaceFlags = uvec4(lessThan(f4HalfSpaceEquationTerms.xyyx, f4HalfSpaceEquationTerms.zzww));
        uvec4 b4SectorFlags = b4HalfSpaceFlags.wxyz & (1u - b4HalfSpaceFlags.xyzw);
        vec4 f4DistToBoundaries = (f4Boundaries - uval_sunNdcPos.xyxy) / (f2RayDir.xyxy + vec4(lessThan(abs(f2RayDir.xyxy), vec4(1e-6))));
        float fDistToExitBoundary = dot(vec4(b4SectorFlags), f4DistToBoundaries);
        vec2 f2ExitPoint = uval_sunNdcPos + f2RayDir * fDistToExitBoundary;
        vec4 f4EpipolarSlice = vec4(0.0, 0.25, 0.5, 0.75) +
        saturate((f2ExitPoint.yxyx - f4Boundaries.wxyz) * vec4(-1.0, 1.0, 1.0, -1.0) / (f4Boundaries.wzwz - f4Boundaries.yxyx)) / 4.0;
        float fEpipolarSlice = dot(vec4(b4SectorFlags), f4EpipolarSlice);
        float fEpipolarSliceIndex = fEpipolarSlice * SETTING_EPIPOLAR_SLICES;
        fEpipolarSliceIndex = fract(fEpipolarSliceIndex + 0.5);
        float lineWidth = SETTING_EPIPOLAR_SLICES / min2(uval_mainImageSize);
        lineWidth *= 0.25;
        lineWidth = saturate(lineWidth / distance(uval_sunNdcPos, ndcPos) * (1.0 + length(uval_sunNdcPos)));
        float lineAlpha = smoothstep(0.5 - lineWidth, 0.5, fEpipolarSliceIndex);
        lineAlpha *= smoothstep(0.5 + lineWidth, 0.5, fEpipolarSliceIndex);
        outputColor.rgb = mix(outputColor.rgb, vec3(1.0, 0.5, 0.5), lineAlpha);
    }
    #endif
    #ifdef SETTING_DEBUG_DEDICATED
    outputColor = expGamma(texelFetch(usam_debug, ivec2((vec2(texelPos) + 0.5) / SETTING_DEBUG_SCALE), 0));
    #endif
    endText(outputColor.rgb);
}
const vec2 workGroupsRender = vec2(1.0, 1.0);
layout(rgba16f) uniform restrict writeonly image2D colorimg0;
layout(rgba16f) uniform restrict image2D uimg_rgba16f;
vec4 rcas_loadInput(ivec2 texelPos, bool center) {
    vec4 data = transient_taaOutput_fetch(texelPos);
    if (center) {
        history_taa_store(texelPos, data);
    }
    return data;
}
void rcas_storeOutput(ivec2 texelPos, vec4 color) {
    if (all(lessThan(texelPos, uval_mainImageSizeI))) {
        #if SETTING_DEBUG_OUTPUT == 2
        debugOutput(texelPos, color);
        #endif
        color.a = 1.0;
        color.rgb = agxInvertible_inverse(color.rgb);
        imageStore(colorimg0, texelPos, color);
    }
}
float rcas_sharpness() {
    return SETTING_TAA_CAS_SHARPNESS;
}