#version 460 compatibility
#define COMP 1
/*
    References:
        [EPI20] Epic Games, Inc. "Unreal Engine Sky Atmosphere Rendering Technique". 2020.
            MIT License. Copyright (c) 2020 Epic Games, Inc.
            https:
        [INT17] Intel Corporation. "Outdoor Light Scattering Sample". 2017.
            Apache License 2.0. Copyright (c) 2017 Intel Corporation.
            https:

        You can find full license texts in /licenses
*/
/*
    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;
};
ScatteringResult scatteringResult_init() {
    ScatteringResult result;
    result.transmittance = vec3(1.0);
    result.inScattering = vec3(0.0);
    return result;
}
/*
    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:
*/
// This file is generated by options.main.kts. Do not edit this file manually.
#define TITLE_VERSION 3//[0 1 2 3 4 5]
#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_ALT_SCALE 1000//[1 2 3 4 5 6 7 8 9 10 10 20 30 40 50 60 70 80 90 100 100 200 300 400 500 600 700 800 900 1000 1000]
#define SETTING_ATM_D_SCALE 1000//[1 2 3 4 5 6 7 8 9 10 10 20 30 40 50 60 70 80 90 100 100 200 300 400 500 600 700 800 900 1000 1000]
#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_ATM_MIE_SCT_MUL 1.0//[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 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 4.05 4.1 4.15 4.2 4.25 4.3 4.35 4.4 4.45 4.5 4.55 4.6 4.65 4.7 4.75 4.8 4.85 4.9 4.95 5.0]
#define SETTING_ATM_MIE_ABS_MUL 0.1//[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 1.01 1.02 1.03 1.04 1.05 1.06 1.07 1.08 1.09 1.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.2 1.21 1.22 1.23 1.24 1.25 1.26 1.27 1.28 1.29 1.3 1.31 1.32 1.33 1.34 1.35 1.36 1.37 1.38 1.39 1.4 1.41 1.42 1.43 1.44 1.45 1.46 1.47 1.48 1.49 1.5 1.51 1.52 1.53 1.54 1.55 1.56 1.57 1.58 1.59 1.6 1.61 1.62 1.63 1.64 1.65 1.66 1.67 1.68 1.69 1.7 1.71 1.72 1.73 1.74 1.75 1.76 1.77 1.78 1.79 1.8 1.81 1.82 1.83 1.84 1.85 1.86 1.87 1.88 1.89 1.9 1.91 1.92 1.93 1.94 1.95 1.96 1.97 1.98 1.99 2.0]
#define SETTING_ATM_RAY_SCT_MUL 1.0//[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 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 4.05 4.1 4.15 4.2 4.25 4.3 4.35 4.4 4.45 4.5 4.55 4.6 4.65 4.7 4.75 4.8 4.85 4.9 4.95 5.0]
#define SETTING_ATM_OZO_ABS_MUL 1.0//[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 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 4.05 4.1 4.15 4.2 4.25 4.3 4.35 4.4 4.45 4.5 4.55 4.6 4.65 4.7 4.75 4.8 4.85 4.9 4.95 5.0]
#define SETTING_SKYVIEW_RES 256//[128 256 512 1024]
#define SETTING_LIGHT_SHAFT_SAMPLES 12//[4 8 12 16 20 24 28 32]
#define SETTING_LIGHT_SHAFT_SHADOW_SAMPLES 8//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
#define SETTING_WATER_LIGHT_SHAFT_SOFTNESS 7//[0 1 2 3 4 5 6 7 8 9 10]
#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_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_ASSUME_NVIDIA_GPU
#ifdef SETTING_ASSUME_NVIDIA_GPU
#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 int frameCounter;
uniform float near;
uniform float far;
uniform vec3 sunPosition;
uniform vec3 shadowLightPosition;
uniform vec3 cameraPosition;
uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferPreviousModelView;
uniform ivec2 eyeBrightnessSmooth;
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 vec3 uval_sunDirWorld;
uniform vec3 uval_moonDirWorld;
uniform vec3 uval_shadowLightDirView;
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;
    mat4 global_sceneToShadowNDC;
    mat4 global_shadowViewToShadowNDC;
    mat4 global_shadowNDCToScene;
    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 sampler2DShadow shadowtex0HW;
uniform sampler2D shadowtex1;
uniform usampler2D usam_rg32ui;
uniform sampler2D usam_rgba8;
uniform sampler2D usam_frgba16f;
uniform sampler2D usam_frgba16;
uniform usampler2D usam_epipolarData;
uniform sampler3D usam_stbnVec1;
uniform sampler3D usam_stbnUnitVec2;
#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_RGBA8_1_OFFSET (uval_mainImageSizeI * ivec2(0, 1))
#define _shadesmith_RGBA8_1_SIZE uval_mainImageSizeI
#define _shadesmith_RGBA8_1_TEXEL_TO_TEXEL(texelPos) _textile_texelToTexel(texelPos, _shadesmith_RGBA8_1_OFFSET, _shadesmith_RGBA8_1_SIZE)
#define transient_lmCoord_fetch(x) texelFetch(usam_rgba8, _shadesmith_RGBA8_1_TEXEL_TO_TEXEL(x), 0)
#define _shadesmith_RG32UI_0_OFFSET (uval_mainImageSizeI * ivec2(0, 0))
#define _shadesmith_RG32UI_0_SIZE uval_mainImageSizeI
#define _shadesmith_RG32UI_0_TEXEL_TO_TEXEL(texelPos) _textile_texelToTexel(texelPos, _shadesmith_RG32UI_0_OFFSET, _shadesmith_RG32UI_0_SIZE)
#define _shadesmith_RG32UI_1_OFFSET (uval_mainImageSizeI * ivec2(0, 1))
#define _shadesmith_RG32UI_1_SIZE uval_mainImageSizeI
#define _shadesmith_RG32UI_1_TEXEL_TO_TEXEL(texelPos) _textile_texelToTexel(texelPos, _shadesmith_RG32UI_1_OFFSET, _shadesmith_RG32UI_1_SIZE)
#define _shadesmith_RG32UI_2_OFFSET (uval_mainImageSizeI * ivec2(1, 0))
#define _shadesmith_RG32UI_2_SIZE uval_mainImageSizeI
#define _shadesmith_RG32UI_2_TEXEL_TO_TEXEL(texelPos) _textile_texelToTexel(texelPos, _shadesmith_RG32UI_2_OFFSET, _shadesmith_RG32UI_2_SIZE)
#define transient_translucentZLayer1_fetch(x) texelFetch(usam_rg32ui, _shadesmith_RG32UI_0_TEXEL_TO_TEXEL(x), 0)
#define transient_translucentZLayer2_fetch(x) texelFetch(usam_rg32ui, _shadesmith_RG32UI_1_TEXEL_TO_TEXEL(x), 0)
#define transient_translucentZLayer3_fetch(x) texelFetch(usam_rg32ui, _shadesmith_RG32UI_2_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_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 || defined SETTING_ASSUME_NVIDIA_GPU
#extension GL_NV_gpu_shader5 : enable
#else
#define NO_HALF a
#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
#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)
*/
/*
    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 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;
}
#ifndef NO_HALF
float16_t pow2(float16_t x) { return x * x; }
f16vec2 pow2(f16vec2 x) { return x * x; }
f16vec3 pow2(f16vec3 x) { return x * x; }
f16vec4 pow2(f16vec4 x) { return x * x; }
float16_t pow3(float16_t x) { return x * x * x; }
f16vec2 pow3(f16vec2 x) { return x * x * x; }
f16vec3 pow3(f16vec3 x) { return x * x * x; }
f16vec4 pow3(f16vec4 x) { return x * x * x; }
float16_t pow4(float16_t x) {
    float16_t x2 = x * x;
    return x2 * x2;
}
f16vec2 pow4(f16vec2 x) {
    f16vec2 x2 = x * x;
    return x2 * x2;
}
f16vec3 pow4(f16vec3 x) {
    f16vec3 x2 = x * x;
    return x2 * x2;
}
f16vec4 pow4(f16vec4 x) {
    f16vec4 x2 = x * x;
    return x2 * x2;
}
#endif
float raySphereIntersectNearest(vec3 r0, vec3 rd, vec3 s0, float sR) {
    float a = dot(rd, rd);
    vec3 s0_r0 = r0 - s0;
    float b = 2.0 * dot(rd, s0_r0);
    float c = dot(s0_r0, s0_r0) - (sR * sR);
    float delta = b * b - 4.0*a*c;
    float result = -1.0;
    if (delta >= 0.0 && a != 0.0) {
        float sol0 = (-b - sqrt(delta)) / (2.0*a);
        float sol1 = (-b + sqrt(delta)) / (2.0*a);
        if (sol0 >= 0.0 || sol1 >= 0.0) {
            if (sol0 < 0.0) {
                result = sol1;
            } else if (sol1 < 0.0) {
                result = sol0;
            } else {
                result = min(sol0, sol1);
            }
            result = max(0.0, result);
        }
    }
    return result;
}
#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)
#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;
};
vec3 atmosphere_mieCoefficientsPreetham(float turbidity) {
    const vec3 a0 = vec3(-0.00767542206226, -0.00822772032997, -0.0121707541321);
    const vec3 a1 = vec3(0.00771550875198, 0.00827069152678, 0.0122343187466);
    return colors2_constants_toWorkSpace(a0 + a1 * turbidity);
}
AtmosphereParameters getAtmosphereParameters() {
    const float ATMOSPHERE_BOTTOM = 6378.137;
    const float ATMOSPHERE_TOP = ATMOSPHERE_BOTTOM + 100.0;
    const float MIE_HEIGHT = 1.2;
    const vec3 RAYLEIGH_SCATTERING_BASE = colors2_constants_toWorkSpace(vec3(0.0120766817597, 0.0129498634753, 0.0275704559807));
    vec3 RAYLEIGH_SCATTERING = RAYLEIGH_SCATTERING_BASE * SETTING_ATM_RAY_SCT_MUL;
    vec3 MIE_SCATTERING_BASE = atmosphere_mieCoefficientsPreetham(global_turbidity);
    vec3 MIE_SCATTERING = MIE_SCATTERING_BASE * SETTING_ATM_MIE_SCT_MUL;
    vec3 MIE_ABOSORPTION = MIE_SCATTERING_BASE * SETTING_ATM_MIE_ABS_MUL;
    const float MIE_PHASE_G = 0.7034;
    const float MIE_PHASE_E = 2500.0;
    const vec3 OZONE_ABOSORPTION_BASE = colors2_constants_toWorkSpace(vec3(3.2964135827e-10, 2.9538443418e-10, 3.7326149468e-11) * 100000.0);
    const vec3 OZONE_ABOSORPTION = OZONE_ABOSORPTION_BASE * SETTING_ATM_OZO_ABS_MUL;
    AtmosphereParameters atmosphere;
    atmosphere.bottom = ATMOSPHERE_BOTTOM;
    atmosphere.top = ATMOSPHERE_TOP;
    atmosphere.mieHeight = MIE_HEIGHT;
    atmosphere.rayleighSctrCoeff = RAYLEIGH_SCATTERING;
    atmosphere.rayleighExtinction = RAYLEIGH_SCATTERING;
    atmosphere.miePhaseG = MIE_PHASE_G;
    atmosphere.miePhaseE = MIE_PHASE_E;
    atmosphere.mieSctrCoeff = MIE_SCATTERING;
    atmosphere.mieExtinction = MIE_SCATTERING + MIE_ABOSORPTION;
    atmosphere.ozoneExtinction = OZONE_ABOSORPTION;
    return atmosphere;
}
/*
    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
*/
float rand_stbnVec1(ivec2 texelPos, uint frame) {
    return texelFetch(usam_stbnVec1, ivec3(texelPos, frame) & ivec3(127, 127, 63), 0).x;
}
vec2 rand_stbnUnitVec211(ivec2 texelPos, uint frame) {
    return normalize(texelFetch(usam_stbnUnitVec2, ivec3(texelPos, frame) & ivec3(127, 127, 63), 0).xy * 2.0 - 1.0);
}
/*
    References:
        [FOU99] G. Fournier, M. Jonasz. “Computer-based underwater imaging analysis”.irborne and In-water Underwater Imaging. 1999.
        [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);
float phasefunc_Rayleigh(float cosTheta) {
    float k = 3.0 / (16.0 * PI);
    return k * (1.0 + pow2(cosTheta));
}
float phasefunc_KleinNishinaE(float cosTheta, float e) {
    return e / (2.0 * PI * (e * (1.0 - cosTheta) + 1.0) * log(2.0 * e + 1.0));
}
vec3 phasefunc_KleinNishinaE(float cosTheta, vec3 e) {
    return e / (2.0 * PI * (e * (1.0 - cosTheta) + 1.0) * log(2.0 * e + 1.0));
}
float sampleRayleighDensity(AtmosphereParameters atmosphere, float altitude) {
    const float a0 = 0.00947927584794;
    const float a1 = -0.138528179963;
    const float a2 = -0.00235619411773;
    return exp2(a0 + a1 * altitude + a2 * altitude * altitude);
}
float sampleMieDensity(AtmosphereParameters atmosphere, float altitude) {
    return exp(-altitude / atmosphere.mieHeight);
}
float sampleOzoneDensity(AtmosphereParameters atmosphere, float altitude) {
    float x = max(altitude, 0.0);
    float x2 = x * x;
    float x3 = x2 * x;
    float x4 = x2 * x2;
    const float d10 = 3.14463183276;
    const float d11 = 0.0498300739786;
    const float d12 = -0.13053950591;
    const float d13 = 0.021937805502;
    const float d14 = -0.000931031499395;
    float d1 = exp2(d10 + d11 * x + d12 * x2 + d13 * x3 + d14 * x4);
    const float d20 = -15.9975955967;
    const float d21 = 2.79421136239;
    const float d22 = -0.128226752502;
    const float d23 = 0.00249280242662;
    const float d24 = -0.0000185558309121;
    float d2 = exp2(d20 + d21 * x + d22 * x2 + d23 * x3 + d24 * x4);
    return d1 + d2;
}
vec3 sampleParticleDensity(AtmosphereParameters atmosphere, float height) {
    float altitude = height - atmosphere.bottom;
    return vec3(
        sampleRayleighDensity(atmosphere, altitude),
        sampleMieDensity(atmosphere, altitude),
        sampleOzoneDensity(atmosphere, altitude)
    );
}
float atmosphere_height(AtmosphereParameters atmosphere, float worldPosY) {
    float worldHeight = max(worldPosY - 62.0, float(SETTING_ATM_ALT_SCALE) * 0.001);
    return worldHeight * (1.0 / float(SETTING_ATM_ALT_SCALE)) + atmosphere.bottom;
}
vec3 atmosphere_viewToAtm(AtmosphereParameters atmosphere, vec3 viewPos) {
    vec3 feetPlayer = (gbufferModelViewInverse * vec4(viewPos, 1.0)).xyz;
    vec3 world = feetPlayer + cameraPosition;
    float height = atmosphere_height(atmosphere, world.y);
    return vec3(feetPlayer.x, 0.0, feetPlayer.z) * (1.0 / float(SETTING_ATM_D_SCALE)) + vec3(0.0, height, 0.0);
}
void packEpipolarData(out uvec4 epipolarData, ScatteringResult sctrResult, ivec2 texelPos) {
    epipolarData.x = packHalf2x16(sctrResult.inScattering.xy);
    epipolarData.y = packHalf2x16(vec2(sctrResult.inScattering.z, sctrResult.transmittance.x));
    epipolarData.z = packHalf2x16(sctrResult.transmittance.yz);
    epipolarData.w = bitfieldInsert(texelPos.x, texelPos.y, 16, 16);
}
#define INVALID_EPIPOLAR_LINE vec4(-1000.0, -1000.0, -100.0, -100.0)
bool isValidScreenLocation(vec2 f2XY) {
    const float SAFETY_EPSILON = 0.2f;
    return all(lessThanEqual(abs(f2XY), 1.0 - (1.0 - SAFETY_EPSILON) / vec2(uval_mainImageSizeI)));
}
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 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)
vec2 rtwsm_warpTexCoord(vec2 uv) {
    vec2 result = uv;
    vec4 warpTexelSize = persistent_rtwsm_warpTexelSize_sample(uv);
    result.xy += warpTexelSize.xy * 2.0 - 1.0;
    return result;
}
float rtwsm_sampleShadowDepth(sampler2DShadow shadowMap, vec3 coord, float lod) {
    vec2 ndcCoord = coord.xy * 2.0 - 1.0;
    float edgeCoord = max(abs(ndcCoord.x), abs(ndcCoord.y));
    return mix(textureLod(shadowMap, coord, lod), 1.0, linearStep(1.0 - SHADOW_MAP_SIZE.y * 16, 1.0, edgeCoord));
}
float rtwsm_sampleShadowDepth(sampler2D shadowMap, vec3 coord, float lod) {
    uint flag = uint(any(lessThan(coord.xy, vec2(0.0))));
    flag |= uint(any(greaterThan(coord.xy, vec2(1.0))));
    return mix(textureLod(shadowMap, coord.xy, lod).r, coord.z, float(flag));
}
/*
    References:
        [WRE18] Wrensch, Benjamin. "Reverse Z Cheatsheet". IOLITE Development Blog. 2023.
*/
vec3 coords_toViewCoord(vec2 texCoord, float viewZ, mat4 projInv) {
    vec2 ndcXY = texCoord * 2.0 - 1.0;
    vec2 clipXY = ndcXY * -viewZ;
    vec2 viewXY = clipXY * vec2(projInv[0][0], projInv[1][1]);
    return vec3(viewXY, viewZ);
}
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
);
#if SETTING_SLICE_SAMPLES == 128
#define WORK_GROUP_SIZE 128
#define LOOP_COUNT 1
#elif SETTING_SLICE_SAMPLES == 256
#define WORK_GROUP_SIZE 256
#define LOOP_COUNT 1
#elif SETTING_SLICE_SAMPLES == 512
#define WORK_GROUP_SIZE 256
#define LOOP_COUNT 2
#elif SETTING_SLICE_SAMPLES == 1024
#define WORK_GROUP_SIZE 256
#define LOOP_COUNT 4
#endif
layout(local_size_x = 1, local_size_y = WORK_GROUP_SIZE) in;
const ivec3 workGroups = ivec3(SETTING_EPIPOLAR_SLICES, 1, 1);
#define SHARED_MEMORY_SHADOW_SAMPLE a
/*
    References:
        [EPI20] Epic Games, Inc. "Unreal Engine Sky Atmosphere Rendering Technique". 2020.
            MIT License. Copyright (c) 2020 Epic Games, Inc.
            https:
        [INT17] Intel Corporation. "Outdoor Light Scattering Sample". 2017.
            Apache License 2.0. Copyright (c) 2017 Intel Corporation.
            https:

        You can find full license texts in /licenses
*/
#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:
        [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:

*/
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
);
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);
#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);
vec2 _processShadowSampleUV(vec2 sampleShadowUV, ivec2 randCoord) {
    float rv = rand_stbnVec1(randCoord, 0);
    vec2 dir = rand_stbnUnitVec211(randCoord, 0);
    float sqrtJitterR = sqrt(rv);
    float r = ldexp(sqrtJitterR, -12 + SETTING_WATER_LIGHT_SHAFT_SOFTNESS);
    vec2 result = sampleShadowUV;
    result += r * dir * vec2(global_shadowProjPrev[0][0], global_shadowProjPrev[1][1]);
    result = rtwsm_warpTexCoord(result);
    return result;
}
#ifdef SHARED_MEMORY_SHADOW_SAMPLE
shared vec4 shared_sliceShadowScreenStartEnd;
shared vec3 shared_sliceShadowScreenStartLength;
#define SHADOW_SAMPLE_COUNT (WORK_GROUP_SIZE * 8)
shared float shared_sliceShadowSamples[SHADOW_SAMPLE_COUNT];
void loadSharedShadowSample(uint index) {
    float fi = float(index);
    float t = saturate(pow2(fi / float(SHADOW_SAMPLE_COUNT - 1)));
    vec4 endPoints = shared_sliceShadowScreenStartEnd;
    vec2 sampleShadowUV = mix(endPoints.xy, endPoints.zw, saturate(t));
    ivec2 randCoord = ivec2(gl_WorkGroupID.x, index);
    sampleShadowUV.xy = _processShadowSampleUV(sampleShadowUV.xy, randCoord);
    float shadowSampleDepth = texture(shadowtex1, sampleShadowUV).r;
    vec2 ndcCoord = sampleShadowUV * 2.0 - 1.0;
    float edgeCoord = max(abs(ndcCoord.x), abs(ndcCoord.y));
    shadowSampleDepth = mix(shadowSampleDepth, 1.0, linearStep(1.0 - SHADOW_MAP_SIZE.y * 16, 1.0, edgeCoord));
    shared_sliceShadowSamples[index] = shadowSampleDepth;
}
void screenViewRaymarch_init(vec2 screenPos) {
    if (gl_LocalInvocationIndex == 0) {
        vec3 viewDir = normalize(coords_toViewCoord(screenPos, -1.0, global_camProjInverse));
        vec3 sliceNormal = normalize(cross(uval_shadowLightDirView, viewDir));
        vec3 perpViewDir = normalize(cross(uval_shadowLightDirView, sliceNormal));
        perpViewDir = faceforward(-perpViewDir, viewDir, perpViewDir);
        vec3 sliceShadowStartView = perpViewDir * near;
        vec3 sliceShadowEndView = perpViewDir * shadowDistance;
        vec4 sliceShadowStartScene = gbufferModelViewInverse * vec4(sliceShadowStartView, 1.0);
        vec4 sliceShadowEndScene = gbufferModelViewInverse * vec4(sliceShadowEndView, 1.0);
        vec4 sliceShadowStartShadowClip = global_shadowProjPrev * global_shadowRotationMatrix * global_shadowView * sliceShadowStartScene;
        vec4 sliceShadowEndShadowClip = global_shadowProjPrev * global_shadowRotationMatrix * global_shadowView * sliceShadowEndScene;
        vec2 sliceShadowStartShadowScreen = sliceShadowStartShadowClip.xy / sliceShadowStartShadowClip.w;
        sliceShadowStartShadowScreen = sliceShadowStartShadowScreen * 0.5 + 0.5;
        vec2 sliceShadowEndShadowScreen = sliceShadowEndShadowClip.xy / sliceShadowEndShadowClip.w;
        sliceShadowEndShadowScreen = sliceShadowEndShadowScreen * 0.5 + 0.5;
        shared_sliceShadowScreenStartEnd = vec4(sliceShadowStartShadowScreen, sliceShadowEndShadowScreen);
        shared_sliceShadowScreenStartLength = vec3(sliceShadowStartShadowScreen, distance(sliceShadowStartShadowScreen, sliceShadowEndShadowScreen));
    }
    barrier();
    loadSharedShadowSample(gl_LocalInvocationIndex);
    loadSharedShadowSample(gl_LocalInvocationIndex + WORK_GROUP_SIZE);
    loadSharedShadowSample(gl_LocalInvocationIndex + WORK_GROUP_SIZE * 2);
    loadSharedShadowSample(gl_LocalInvocationIndex + WORK_GROUP_SIZE * 3);
    loadSharedShadowSample(gl_LocalInvocationIndex + WORK_GROUP_SIZE * 4);
    loadSharedShadowSample(gl_LocalInvocationIndex + WORK_GROUP_SIZE * 5);
    loadSharedShadowSample(gl_LocalInvocationIndex + WORK_GROUP_SIZE * 6);
    loadSharedShadowSample(gl_LocalInvocationIndex + WORK_GROUP_SIZE * 7);
    barrier();
}
float compT(vec3 startLength, vec3 shadowPos) {
    return distance(shadowPos.xy, startLength.xy) / startLength.z;
}
float atmosphere_sample_shadow(vec3 startShadowPos, vec3 endShadowPos) {
    vec3 startLength = shared_sliceShadowScreenStartLength;
    float startT = sqrt(compT(startLength, startShadowPos));
    float endT = sqrt(compT(startLength, endShadowPos));
    float shadowSum = 0.0;
    const uint SHADOW_STEPS = SETTING_LIGHT_SHAFT_SHADOW_SAMPLES;
    vec2 startTAndDepth = vec2(startT, startShadowPos.z);
    vec2 stepT = vec2(endT - startT, endShadowPos.z - startShadowPos.z) / float(SHADOW_STEPS);
    for (uint i = 0u; i < SHADOW_STEPS; ++i) {
        float fi = float(i) + 0.5;
        vec2 sampleTAndDepth = startTAndDepth + fi * stepT;
        float indexF = sampleTAndDepth.x * float(SHADOW_SAMPLE_COUNT - 1);
        uint index = uint(indexF);
        float shadowTerm = float(shared_sliceShadowSamples[index] > saturate(sampleTAndDepth.y));
        shadowSum += saturate(shadowTerm + float(sampleTAndDepth.x > 1.0));
    }
    return shadowSum / float(SHADOW_STEPS);
}
#else
ivec2 _texelPos = ivec2(-1);
float atmosphere_sample_shadow(vec3 startShadowPos, vec3 endShadowPos) {
    vec3 sampleShadowUV = (startShadowPos + endShadowPos) * 0.5;
    sampleShadowUV.xy = _processShadowSampleUV(sampleShadowUV.xy, _texelPos);
    return rtwsm_sampleShadowDepth(shadowtex0HW, sampleShadowUV, 0.0);
}
#endif
struct MultiScatteringResult {
    vec3 inScattering;
    vec3 multiSctrAs1;
};
struct RaymarchParameters {
    vec3 rayStart;
    vec3 rayEnd;
    uint steps;
};
RaymarchParameters raymarchParameters_init() {
    RaymarchParameters params;
    params.rayStart = vec3(0.0);
    params.rayEnd = vec3(0.0);
    params.steps = 0u;
    return params;
}
bool setupRayEnd(AtmosphereParameters atmosphere, inout RaymarchParameters params, vec3 rayDir, float maxRayLen) {
    const vec3 earthCenter = vec3(0.0);
    float rayStartHeight = length(params.rayStart);
    if (rayStartHeight > atmosphere.top) {
        float tTop = raySphereIntersectNearest(params.rayStart, rayDir, earthCenter, atmosphere.top);
        if (tTop < 0.0) {
            return false;
        }
        vec3 upVector = params.rayStart / rayStartHeight;
        vec3 upOffset = upVector * -PLANET_RADIUS_OFFSET;
        params.rayStart += rayDir * tTop + upOffset;
    }
    float tBottom = raySphereIntersectNearest(params.rayStart, rayDir, earthCenter, atmosphere.bottom);
    float tTop = raySphereIntersectNearest(params.rayStart, rayDir, earthCenter, atmosphere.top);
    float rayLen = 0.0;
    if (tBottom < 0.0) {
        if (tTop < 0.0) {
            return false;
        } else {
            rayLen = tTop;
        }
    } else {
        if (tTop > 0.0) {
            rayLen = min(tTop, tBottom);
        }
    }
    params.rayEnd = params.rayStart + rayDir * min(rayLen, maxRayLen);
    return true;
}
bool setupRayEnd(AtmosphereParameters atmosphere, inout RaymarchParameters params, vec3 rayDir) {
    return setupRayEnd(atmosphere, params, rayDir, FLT_MAX);
}
struct LightParameters {
    vec3 lightDir;
    float rayleighPhase;
    float miePhase;
    vec3 irradiance;
};
LightParameters lightParameters_init(AtmosphereParameters atmosphere, vec3 irradiance, vec3 lightDir, vec3 rayDir) {
    LightParameters lightParams;
    lightParams.irradiance = irradiance;
    lightParams.lightDir = lightDir;
    float cosLightTheta = dot(rayDir, lightDir);
    lightParams.rayleighPhase = phasefunc_Rayleigh(cosLightTheta);
    lightParams.miePhase = phasefunc_KleinNishinaE(cosLightTheta, atmosphere.miePhaseE);
    return lightParams;
}
struct ScatteringParameters {
    LightParameters sunParams;
    LightParameters moonParams;
    float multiSctrFactor;
};
ScatteringParameters scatteringParameters_init(LightParameters sunParams, LightParameters moonParams, float multiSctrFactor) {
    ScatteringParameters params;
    params.sunParams = sunParams;
    params.moonParams = moonParams;
    params.multiSctrFactor = multiSctrFactor;
    return params;
}
vec3 computeOpticalDepth(AtmosphereParameters atmosphere, vec3 density) {
    vec3 result = vec3(0.0);
    result += atmosphere.rayleighExtinction * density.x;
    result += atmosphere.mieExtinction * density.y;
    result += atmosphere.ozoneExtinction * density.z;
    return result;
}
/*
    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
float _atmospherics_air_lut_fromUnitToSubUvs(float u, float resolution) { return (u + 0.5f / resolution) * (resolution / (resolution + 1.0f)); }
vec2 _atmospherics_air_lut_fromUnitToSubUvs(vec2 uv, vec2 resolution) { return (uv + 0.5 / resolution) * (resolution / (resolution + 1.0)); }
void _atmospherics_air_lut_lutTransmittanceParamsToUv(AtmosphereParameters atmosphere, float height, float cosZenith, out vec2 uv) {
    height = clamp(height, atmosphere.bottom + 0.0001, atmosphere.top - 0.0001);
    cosZenith = clamp(cosZenith, -1.0, 1.0);
    float H = sqrt(max(0.0, pow2(atmosphere.top) - pow2(atmosphere.bottom)));
    float rho = sqrt(max(0.0, pow2(height) - pow2(atmosphere.bottom)));
    float discriminant = pow2(height) * (cosZenith * cosZenith - 1.0) + pow2(atmosphere.top);
    float d = max(0.0, (-height * cosZenith + sqrt(discriminant)));
    float d_min = atmosphere.top - height;
    float d_max = rho + H;
    float x_mu = (d - d_min) / (d_max - d_min);
    float x_r = rho / H;
    uv = vec2(x_mu, x_r);
}
vec3 atmospherics_air_lut_sampleTransmittance(AtmosphereParameters atmosphere, float cosLightZenith, float sampleAltitude) {
    vec2 tLUTUV;
    _atmospherics_air_lut_lutTransmittanceParamsToUv(atmosphere, sampleAltitude, cosLightZenith, tLUTUV);
    uint cond = uint(any(lessThan(tLUTUV, vec2(0.0))));
    cond |= uint(any(greaterThan(tLUTUV, vec2(1.0))));
    if (bool(cond)) {
        return vec3(0.0);
    }
    return persistent_transmittanceLUT_sample(tLUTUV).rgb;
}
vec3 atmospherics_air_lut_sampleMultiSctr(AtmosphereParameters atmosphere, float cosLightZenith, float sampleAltitude) {
    vec2 uv = vec2(saturate(cosLightZenith * 0.5 + 0.5), linearStep(atmosphere.bottom, atmosphere.top, sampleAltitude));
    uv = _atmospherics_air_lut_fromUnitToSubUvs(uv, vec2(MULTI_SCTR_LUT_SIZE));
    return persistent_multiSctrLUT_sample(uv).rgb / LUT_QUANTIZATION_MUL;
}
struct SkyViewLutParams {
    bool intersectGround;
    float viewZenithCosAngle;
    float sunViewCosAngle;
    float moonViewCosAngle;
    float viewHeight;
};
vec3 raymarchTransmittance(
    AtmosphereParameters atmosphere,
    RaymarchParameters params,
    float stepJitter
);
MultiScatteringResult raymarchMultiScattering(
    AtmosphereParameters atmosphere,
    RaymarchParameters params,
    LightParameters lightParams,
    float stepJitter
);
ScatteringResult raymarchSkySingle(
    AtmosphereParameters atmosphere,
    RaymarchParameters params,
    LightParameters lightParams,
    float bottomOffset
);
ScatteringResult raymarchSky(
    AtmosphereParameters atmosphere,
    RaymarchParameters params,
    ScatteringParameters scatteringParams
);
ScatteringResult raymarchAerialPerspective(
    AtmosphereParameters atmosphere,
    RaymarchParameters params,
    ScatteringParameters scatteringParams,
    vec3 shadowStart,
    vec3 shadowEnd,
    float stepJitter
);
ScatteringResult raymarchAerialPerspective(AtmosphereParameters atmosphere, RaymarchParameters params, ScatteringParameters scatteringParams, vec3 shadowStart, vec3 shadowEnd, float stepJitter) {
    const vec3 earthCenter = vec3(0.0);
    float rcpSteps = 1.0 / float(params.steps);
    vec3 rayStepDelta = (params.rayEnd - params.rayStart) * rcpSteps;
    float rayStepLength = length(rayStepDelta);
    vec3 totalDensity = vec3(0.0);
    vec3 totalInSctr = vec3(0.0);
    vec3 shaodwStepDelta = (shadowEnd - shadowStart) * rcpSteps;
    float shadowIsSun = float(all(equal(sunPosition, shadowLightPosition)));
    vec3 samplePosMid = (params.rayEnd + params.rayStart) * 0.5;
    float sampleHeightMid = length(samplePosMid);
    vec3 upVectorMid = samplePosMid / sampleHeightMid;
    float cosZenithSun = dot(upVectorMid, scatteringParams.sunParams.lightDir);
    vec3 tSunToSampleMid = atmospherics_air_lut_sampleTransmittance(atmosphere, cosZenithSun, sampleHeightMid);
    vec3 earthShadowPos = vec3(0.0, 0.0, max(sampleHeightMid, atmosphere.bottom + PLANET_RADIUS_OFFSET));
    float tEarthSun = raySphereIntersectNearest(earthShadowPos, scatteringParams.sunParams.lightDir, earthCenter, atmosphere.bottom);
    tSunToSampleMid *= float(tEarthSun < 0.0);
    tSunToSampleMid *= scatteringParams.sunParams.irradiance;
    vec3 multiSctrLuminanceSun = atmospherics_air_lut_sampleMultiSctr(atmosphere, cosZenithSun, sampleHeightMid);
    multiSctrLuminanceSun *= scatteringParams.multiSctrFactor * scatteringParams.sunParams.irradiance;
    float cosZenithMoon = dot(upVectorMid, scatteringParams.moonParams.lightDir);
    vec3 tMoonToSampleMid = atmospherics_air_lut_sampleTransmittance(atmosphere, cosZenithMoon, sampleHeightMid);
    float tEarthMoon = raySphereIntersectNearest(earthShadowPos, scatteringParams.moonParams.lightDir, earthCenter, atmosphere.bottom);
    tMoonToSampleMid *= float(tEarthMoon < 0.0);
    tMoonToSampleMid *= scatteringParams.moonParams.irradiance;
    vec3 multiSctrLuminanceMoon = atmospherics_air_lut_sampleMultiSctr(atmosphere, cosZenithMoon, sampleHeightMid);
    multiSctrLuminanceMoon *= scatteringParams.multiSctrFactor * scatteringParams.moonParams.irradiance;
    for (uint stepIndex = 0u; stepIndex < params.steps; stepIndex++) {
        float stepIndexF = float(stepIndex);
        vec3 samplePos = params.rayStart + (stepIndexF + 0.5) * rayStepDelta;
        float sampleHeight = length(samplePos);
        vec3 sampleDensity = sampleParticleDensity(atmosphere, sampleHeight);
        vec3 upVector = samplePos / sampleHeight;
        vec3 sampleExtinction = computeOpticalDepth(atmosphere, sampleDensity);
        vec3 sampleOpticalDepth = sampleExtinction * rayStepLength;
        vec3 sampleTransmittance = exp(-sampleOpticalDepth);
        vec3 sampleRayleighInSctr = sampleDensity.x * atmosphere.rayleighSctrCoeff;
        vec3 sampleMieInSctr = sampleDensity.y * atmosphere.mieSctrCoeff;
        vec3 sampleTotalInSctr = sampleRayleighInSctr + sampleMieInSctr;
        vec3 tSampleToOrigin = exp(-computeOpticalDepth(atmosphere, totalDensity));
        totalDensity += sampleDensity * rayStepLength;
        {
            float startShadowT = max(stepIndexF + stepJitter - 0.5, 0.0);
            float endShadowT = min(stepIndexF + stepJitter + 0.5, float(params.steps));
            vec3 startShadowPos = shadowStart + startShadowT * shaodwStepDelta;
            vec3 endShadowPos = shadowStart + endShadowT * shaodwStepDelta;
            float shadowSample = atmosphere_sample_shadow(startShadowPos, endShadowPos);
            vec3 sampleInSctr = vec3(0.0);
            {
                float shadowTerm = mix(1.0, shadowSample, shadowIsSun);
                vec3 tSunToSample = tSunToSampleMid;
                tSunToSample *= shadowTerm;
                vec3 sampleInSctrC = sampleRayleighInSctr * scatteringParams.sunParams.rayleighPhase;
                sampleInSctrC += sampleMieInSctr * scatteringParams.sunParams.miePhase;
                sampleInSctr += sampleInSctrC * tSunToSample;
                sampleInSctr += multiSctrLuminanceSun * sampleTotalInSctr;
            }
            {
                float shadowTerm = mix(shadowSample, 1.0, shadowIsSun);
                vec3 tMoonToSample = tMoonToSampleMid;
                tMoonToSample *= shadowTerm;
                vec3 sampleInSctrC = sampleRayleighInSctr * scatteringParams.moonParams.rayleighPhase;
                sampleInSctrC += sampleMieInSctr * scatteringParams.moonParams.miePhase;
                sampleInSctr += sampleInSctrC * tMoonToSample;
                sampleInSctr += multiSctrLuminanceMoon * sampleTotalInSctr;
            }
            vec3 sampleInSctrInt = (sampleInSctr - sampleInSctr * sampleTransmittance) / sampleExtinction;
            totalInSctr += tSampleToOrigin * sampleInSctrInt;
        }
    }
    ScatteringResult result;
    vec3 totalOpticalDepth = computeOpticalDepth(atmosphere, totalDensity);
    vec3 tSampleToOrigin = exp(-totalOpticalDepth);
    result.transmittance = tSampleToOrigin;
    result.inScattering = totalInSctr;
    return result;
}
const vec3 ORIGIN_VIEW = vec3(0.0);
ScatteringResult raymarchScreenViewAtmosphere(ivec2 texelPos, float startZ, float endZ, uint steps, float noiseV) {
    #ifndef SHARED_MEMORY_SHADOW_SAMPLE
    _texelPos = texelPos;
    #endif
    ScatteringResult result = scatteringResult_init();
    vec2 screenPos = (vec2(texelPos) + 0.5) * uval_mainImageSizeRcp;
    vec3 startViewPos = coords_toViewCoord(screenPos, startZ, global_camProjInverse);
    vec3 endViewPos = coords_toViewCoord(screenPos, max(endZ, -shadowDistance), global_camProjInverse);
    float lmCoordSky = transient_lmCoord_fetch(texelPos).y;
    float multiSctrFactor = max(lmCoordSky, linearStep(0.0, 240.0, float(eyeBrightnessSmooth.y)));
    mat3 vectorView2World = mat3(gbufferModelViewInverse);
    vec3 viewDirWorld = normalize(vectorView2World * (endViewPos - startViewPos));
    vec3 rayDir = viewDirWorld;
    AtmosphereParameters atmosphere = getAtmosphereParameters();
    RaymarchParameters params = raymarchParameters_init();
    params.rayStart = atmosphere_viewToAtm(atmosphere, startViewPos);
    params.steps = steps;
    LightParameters sunParam = lightParameters_init(atmosphere, SUN_ILLUMINANCE , uval_sunDirWorld, rayDir);
    LightParameters moonParams = lightParameters_init(atmosphere, MOON_ILLUMINANCE, uval_moonDirWorld, rayDir);
    ScatteringParameters scatteringParams = scatteringParameters_init(sunParam, moonParams, multiSctrFactor);
    vec4 originScene = gbufferModelViewInverse * vec4(startViewPos, 1.0);
    vec4 endScene = gbufferModelViewInverse * vec4(endViewPos, 1.0);
    vec4 originShadowCS = global_shadowProjPrev * global_shadowRotationMatrix * global_shadowView * originScene;
    vec4 endShadowCS = global_shadowProjPrev * global_shadowRotationMatrix * global_shadowView * endScene;
    vec3 startShadow = originShadowCS.xyz / originShadowCS.w;
    startShadow = startShadow * 0.5 + 0.5;
    vec3 endShadow = endShadowCS.xyz / endShadowCS.w;
    endShadow = endShadow * 0.5 + 0.5;
    if (endZ == -65536.0) {
        scatteringParams.multiSctrFactor = 1.0;
        if (setupRayEnd(atmosphere, params, rayDir, shadowDistance / SETTING_ATM_D_SCALE)) {
            result = raymarchAerialPerspective(atmosphere, params, scatteringParams, startShadow, endShadow, noiseV);
        }
    } else {
        params.rayEnd = atmosphere_viewToAtm(atmosphere, endViewPos);
        result = raymarchAerialPerspective(atmosphere, params, scatteringParams, startShadow, endShadow, noiseV);
    }
    return result;
}
layout(rgba32ui) uniform restrict uimage2D uimg_epipolarData;
void main() {
    ivec2 imgSizei = ivec2(SETTING_EPIPOLAR_SLICES, SETTING_SLICE_SAMPLES);
    vec2 imgSize = vec2(SETTING_EPIPOLAR_SLICES, SETTING_SLICE_SAMPLES);
    uint sliceIndex = gl_WorkGroupID.x;
    vec4 sliceEndPoints = uintBitsToFloat(texelFetch(usam_epipolarData, ivec2(sliceIndex, 0), 0));
    uint cond = uint(isValidScreenLocation(sliceEndPoints.xy)) | uint(isValidScreenLocation(sliceEndPoints.zw));
    if (bool(cond)) {
        {
            vec2 screenPos = mix(sliceEndPoints.xy, sliceEndPoints.zw, 0.5) * 0.5 + 0.5;
            screenViewRaymarch_init(screenPos);
        }
        for (uint i = 0; i < LOOP_COUNT; i++) {
            uint sliceSampleIndex = gl_LocalInvocationID.y + i * WORK_GROUP_SIZE;
            float sliceSampleP = float(sliceSampleIndex) / float(SETTING_SLICE_SAMPLES - 1);
            vec2 screenPos = mix(sliceEndPoints.xy, sliceEndPoints.zw, sliceSampleP) * 0.5 + 0.5;
            vec2 texelPos = screenPos * uval_mainImageSize;
            texelPos = clamp(texelPos, vec2(0.5), vec2(uval_mainImageSize - 0.5));
            ivec2 texelPosI = ivec2(texelPos);
            float noiseV = rand_stbnVec1(texelPosI, frameCounter);
            ivec2 baseWriteTexelPos = ivec2(gl_GlobalInvocationID.x, sliceSampleIndex + 1u);
            for (int layerIndex = 0; layerIndex < 2; layerIndex++) {
                int actualIndex = layerIndex * 2;
                vec2 layerViewZ;
                if (actualIndex == 0) {
                    layerViewZ = uintBitsToFloat(transient_translucentZLayer1_fetch(texelPosI).xy);
                } else if (actualIndex == 1) {
                    layerViewZ = uintBitsToFloat(transient_translucentZLayer2_fetch(texelPosI).xy);
                } else {
                    layerViewZ = uintBitsToFloat(transient_translucentZLayer3_fetch(texelPosI).xy);
                }
                layerViewZ = -abs(layerViewZ);
                ScatteringResult result = scatteringResult_init();
                if (layerViewZ.x > -FLT_MAX) {
                    result = raymarchScreenViewAtmosphere(
                        texelPosI,
                        layerViewZ.x,
                        layerViewZ.y,
                        SETTING_LIGHT_SHAFT_SAMPLES,
                        noiseV
                    );
                }
                uvec4 outputData;
                packEpipolarData(outputData, result, texelPosI);
                ivec2 writeTexelPos = baseWriteTexelPos;
                writeTexelPos.y += actualIndex * int(SETTING_SLICE_SAMPLES);
                imageStore(uimg_epipolarData, writeTexelPos, outputData);
            }
        }
    } else {
        ivec2 texelPos = ivec2(65535);
        ScatteringResult result = scatteringResult_init();
        uvec4 outputData;
        packEpipolarData(outputData, result, texelPos);
        for (uint i = 0; i < LOOP_COUNT; i++) {
            ivec2 baseWriteTexelPos = ivec2(gl_GlobalInvocationID.xy);
            baseWriteTexelPos.y += int(1u + i * WORK_GROUP_SIZE);
            for (int layerIndex = 0; layerIndex < 2; layerIndex++) {
                int actualIndex = layerIndex * 2;
                ivec2 writeTexelPos = baseWriteTexelPos;
                writeTexelPos.y += actualIndex * int(SETTING_SLICE_SAMPLES);
                imageStore(uimg_epipolarData, writeTexelPos, outputData);
            }
        }
    }
}