1#define_import_path bevy_gaussian_splatting::spherical_harmonics 3const shc = array<f32, 16>( 22fn srgb_to_linear(srgb_color: vec3<f32>) -> vec3<f32> { 23 var linear_color: vec3<f32>; 24 for (var i = 0u; i < 3u; i = i + 1u) { 25 if (srgb_color[i] <= 0.04045) { 26 linear_color[i] = srgb_color[i] / 12.92; 28 linear_color[i] = pow((srgb_color[i] + 0.055) / 1.055, 2.4); 34fn spherical_harmonics_lookup( 35 ray_direction: vec3<f32>, 36 sh: array<f32, #{SH_COEFF_COUNT}>, 38 let rds = ray_direction * ray_direction; 39 var color = vec3<f32>(0.5); 41 color += shc[ 0] * vec3<f32>(sh[0], sh[1], sh[2]); 43#if SH_COEFF_COUNT > 11 44 color += shc[ 1] * vec3<f32>(sh[ 3], sh[ 4], sh[ 5]) * ray_direction.y; 45 color += shc[ 2] * vec3<f32>(sh[ 6], sh[ 7], sh[ 8]) * ray_direction.z; 46 color += shc[ 3] * vec3<f32>(sh[ 9], sh[10], sh[11]) * ray_direction.x; 49#if SH_COEFF_COUNT > 26 50 color += shc[ 4] * vec3<f32>(sh[12], sh[13], sh[14]) * ray_direction.x * ray_direction.y; 51 color += shc[ 5] * vec3<f32>(sh[15], sh[16], sh[17]) * ray_direction.y * ray_direction.z; 52 color += shc[ 6] * vec3<f32>(sh[18], sh[19], sh[20]) * (2.0 * rds.z - rds.x - rds.y); 53 color += shc[ 7] * vec3<f32>(sh[21], sh[22], sh[23]) * ray_direction.x * ray_direction.z; 54 color += shc[ 8] * vec3<f32>(sh[24], sh[25], sh[26]) * (rds.x - rds.y); 57#if SH_COEFF_COUNT > 47 58 color += shc[ 9] * vec3<f32>(sh[27], sh[28], sh[29]) * ray_direction.y * (3.0 * rds.x - rds.y); 59 color += shc[10] * vec3<f32>(sh[30], sh[31], sh[32]) * ray_direction.x * ray_direction.y * ray_direction.z; 60 color += shc[11] * vec3<f32>(sh[33], sh[34], sh[35]) * ray_direction.y * (4.0 * rds.z - rds.x - rds.y); 61 color += shc[12] * vec3<f32>(sh[36], sh[37], sh[38]) * ray_direction.z * (2.0 * rds.z - 3.0 * rds.x - 3.0 * rds.y); 62 color += shc[13] * vec3<f32>(sh[39], sh[40], sh[41]) * ray_direction.x * (4.0 * rds.z - rds.x - rds.y); 63 color += shc[14] * vec3<f32>(sh[42], sh[43], sh[44]) * ray_direction.z * (rds.x - rds.y); 64 color += shc[15] * vec3<f32>(sh[45], sh[46], sh[47]) * ray_direction.x * (rds.x - 3.0 * rds.y);