1struct mesh_vertex_output__MeshVertexOutput { 2 @location(0) world_position: vec4<f32>, 3 @location(1) world_normal: vec3<f32>, 4 @location(2) uv: vec2<f32>, 7struct pbr_types__StandardMaterial { 10 perceptual_roughness: f32, 17struct mesh_types__Mesh { 19 inverse_transpose_model: mat4x4<f32>, 23struct mesh_view_types__View { 24 view_proj: mat4x4<f32>, 25 inverse_view_proj: mat4x4<f32>, 27 inverse_view: mat4x4<f32>, 28 projection: mat4x4<f32>, 29 inverse_projection: mat4x4<f32>, 30 world_position: vec3<f32>, 35struct mesh_view_types__PointLight { 36 light_custom_data: vec4<f32>, 37 color_inverse_square_range: vec4<f32>, 38 position_radius: vec4<f32>, 40 shadow_depth_bias: f32, 41 shadow_normal_bias: f32, 42 spot_light_tan_angle: f32, 45struct mesh_view_types__DirectionalLight { 46 view_projection: mat4x4<f32>, 48 direction_to_light: vec3<f32>, 50 shadow_depth_bias: f32, 51 shadow_normal_bias: f32, 54struct mesh_view_types__Lights { 55 directional_lights: array<mesh_view_types__DirectionalLight,1u>, 56 ambient_color: vec4<f32>, 57 cluster_dimensions: vec4<u32>, 58 cluster_factors: vec4<f32>, 59 n_directional_lights: u32, 60 spot_light_shadowmap_offset: i32, 63struct mesh_view_types__PointLights { 64 data: array<mesh_view_types__PointLight>, 67struct mesh_view_types__ClusterLightIndexLists { 71struct mesh_view_types__ClusterOffsetsAndCounts { 72 data: array<vec4<u32>>, 75struct pbr_functions__PbrInput { 76 material: pbr_types__StandardMaterial, 78 frag_coord: vec4<f32>, 79 world_position: vec4<f32>, 80 world_normal: vec3<f32>, 83 is_orthographic: bool, 86const pbr_types__STANDARD_MATERIAL_FLAGS_EMISSIVE_TEXTURE_BIT: u32 = 2u; 88const pbr_types__STANDARD_MATERIAL_FLAGS_UNLIT_BIT: u32 = 32u; 90const pbr_types__STANDARD_MATERIAL_FLAGS_ALPHA_MODE_BLEND: u32 = 256u; 92const pbr_types__STANDARD_MATERIAL_FLAGS_TWO_COMPONENT_NORMAL_MAP: u32 = 512u; 94const pbr_types__STANDARD_MATERIAL_FLAGS_ALPHA_MODE_MASK: u32 = 128u; 96const pbr_types__STANDARD_MATERIAL_FLAGS_DOUBLE_SIDED_BIT: u32 = 16u; 98const pbr_types__STANDARD_MATERIAL_FLAGS_BASE_COLOR_TEXTURE_BIT: u32 = 1u; 100const pbr_types__STANDARD_MATERIAL_FLAGS_METALLIC_ROUGHNESS_TEXTURE_BIT: u32 = 4u; 102const pbr_types__STANDARD_MATERIAL_FLAGS_OCCLUSION_TEXTURE_BIT: u32 = 8u; 104const pbr_types__STANDARD_MATERIAL_FLAGS_ALPHA_MODE_OPAQUE: u32 = 64u; 106const pbr_types__STANDARD_MATERIAL_FLAGS_FLIP_NORMAL_MAP_Y: u32 = 1024u; 108const mesh_types__MESH_FLAGS_SHADOW_RECEIVER_BIT: u32 = 1u; 110const mesh_view_types__POINT_LIGHT_FLAGS_SPOT_LIGHT_Y_NEGATIVE: u32 = 2u; 112const mesh_view_types__DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT: u32 = 1u; 114const mesh_view_types__POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT: u32 = 1u; 116const utils__PI: f32 = 3.1415927410125732; 118const clustered_forward__CLUSTER_COUNT_SIZE: u32 = 9u; 121var<uniform> mesh_bindings__mesh: mesh_types__Mesh; 123var<uniform> mesh_view_bindings__view: mesh_view_types__View; 125var mesh_view_bindings__point_shadow_textures: texture_depth_cube_array; 127var mesh_view_bindings__directional_shadow_textures_sampler: sampler_comparison; 129var<storage> mesh_view_bindings__point_lights: mesh_view_types__PointLights; 131var<uniform> mesh_view_bindings__lights: mesh_view_types__Lights; 133var mesh_view_bindings__point_shadow_textures_sampler: sampler_comparison; 135var mesh_view_bindings__directional_shadow_textures: texture_depth_2d_array; 137var<storage> mesh_view_bindings__cluster_light_index_lists: mesh_view_types__ClusterLightIndexLists; 139var<storage> mesh_view_bindings__cluster_offsets_and_counts: mesh_view_types__ClusterOffsetsAndCounts; 141var pbr_bindings__occlusion_sampler: sampler; 143var<uniform> pbr_bindings__material: pbr_types__StandardMaterial; 145var pbr_bindings__emissive_texture: texture_2d<f32>; 147var pbr_bindings__base_color_texture: texture_2d<f32>; 149var pbr_bindings__metallic_roughness_texture: texture_2d<f32>; 151var pbr_bindings__emissive_sampler: sampler; 153var pbr_bindings__metallic_roughness_sampler: sampler; 155var pbr_bindings__base_color_sampler: sampler; 156@group(1) @binding(10) 157var pbr_bindings__normal_map_sampler: sampler; 159var pbr_bindings__normal_map_texture: texture_2d<f32>; 161var pbr_bindings__occlusion_texture: texture_2d<f32>; 163fn pbr_types__standard_material_new() -> pbr_types__StandardMaterial { 164 var material: pbr_types__StandardMaterial; 166 material.base_color = vec4<f32>(1.0, 1.0, 1.0, 1.0); 167 material.emissive = vec4<f32>(0.0, 0.0, 0.0, 1.0); 168 material.perceptual_roughness = 0.08900000154972076; 169 material.metallic = 0.009999999776482582; 170 material.reflectance = 0.5; 171 material.flags = pbr_types__STANDARD_MATERIAL_FLAGS_ALPHA_MODE_OPAQUE; 172 material.alpha_cutoff = 0.5; 173 let _e33: pbr_types__StandardMaterial = material; 177fn utils__saturate(value: f32) -> f32 { 178 return clamp(value, 0.0, 1.0); 181fn utils__hsv2rgb(hue: f32, saturation: f32, value_1: f32) -> vec3<f32> { 182 let rgb: vec3<f32> = clamp((abs((((vec3<f32>((hue * 6.0)) + vec3<f32>(0.0, 4.0, 2.0)) % vec3<f32>(6.0)) - vec3<f32>(3.0))) - vec3<f32>(1.0)), vec3<f32>(0.0), vec3<f32>(1.0)); 183 return (value_1 * mix(vec3<f32>(1.0), rgb, vec3<f32>(saturation))); 186fn utils__random1D(s: f32) -> f32 { 187 return fract((sin((s * 12.989800453186035)) * 43758.546875)); 190fn lighting__getDistanceAttenuation(distanceSquare: f32, inverseRangeSquared: f32) -> f32 { 191 let factor: f32 = (distanceSquare * inverseRangeSquared); 192 let _e10: f32 = utils__saturate((1.0 - (factor * factor))); 193 let attenuation: f32 = (_e10 * _e10); 194 return ((attenuation * 1.0) / max(distanceSquare, 9.999999747378752e-5)); 197fn lighting__D_GGX(roughness: f32, NoH: f32, h: vec3<f32>) -> f32 { 198 let oneMinusNoHSquared: f32 = (1.0 - (NoH * NoH)); 199 let a: f32 = (NoH * roughness); 200 let k: f32 = (roughness / (oneMinusNoHSquared + (a * a))); 201 let d: f32 = ((k * k) * (1.0 / utils__PI)); 205fn lighting__V_SmithGGXCorrelated(roughness_1: f32, NoV: f32, NoL: f32) -> f32 { 206 let a2_: f32 = (roughness_1 * roughness_1); 207 let lambdaV: f32 = (NoL * sqrt((((NoV - (a2_ * NoV)) * NoV) + a2_))); 208 let lambdaL: f32 = (NoV * sqrt((((NoL - (a2_ * NoL)) * NoL) + a2_))); 209 let v_1: f32 = (0.5 / (lambdaV + lambdaL)); 213fn lighting__F_Schlick_vec(f0_: vec3<f32>, f90_: f32, VoH: f32) -> vec3<f32> { 214 return (f0_ + ((vec3<f32>(f90_) - f0_) * pow((1.0 - VoH), 5.0))); 217fn lighting__F_Schlick(f0_1: f32, f90_1: f32, VoH_1: f32) -> f32 { 218 return (f0_1 + ((f90_1 - f0_1) * pow((1.0 - VoH_1), 5.0))); 221fn lighting__fresnel(f0_2: vec3<f32>, LoH: f32) -> vec3<f32> { 222 let _e11: f32 = utils__saturate(dot(f0_2, vec3<f32>((50.0 * 0.33000001311302185)))); 223 let _e12: vec3<f32> = lighting__F_Schlick_vec(f0_2, _e11, LoH); 227fn lighting__specular(f0_3: vec3<f32>, roughness_2: f32, h_1: vec3<f32>, NoV_1: f32, NoL_1: f32, NoH_1: f32, LoH_1: f32, specularIntensity: f32) -> vec3<f32> { 228 let _e12: f32 = lighting__D_GGX(roughness_2, NoH_1, h_1); 229 let _e13: f32 = lighting__V_SmithGGXCorrelated(roughness_2, NoV_1, NoL_1); 230 let _e14: vec3<f32> = lighting__fresnel(f0_3, LoH_1); 231 return (((specularIntensity * _e12) * _e13) * _e14); 234fn lighting__Fd_Burley(roughness_3: f32, NoV_2: f32, NoL_2: f32, LoH_2: f32) -> f32 { 235 let f90_2: f32 = (0.5 + (((2.0 * roughness_3) * LoH_2) * LoH_2)); 236 let _e15: f32 = lighting__F_Schlick(1.0, f90_2, NoL_2); 237 let _e17: f32 = lighting__F_Schlick(1.0, f90_2, NoV_2); 238 return ((_e15 * _e17) * (1.0 / utils__PI)); 241fn lighting__EnvBRDFApprox(f0_4: vec3<f32>, perceptual_roughness_1: f32, NoV_3: f32) -> vec3<f32> { 242 let c0_: vec4<f32> = vec4<f32>(-1.0, -0.027499999850988388, -0.5720000267028809, 0.02199999988079071); 243 let c1_: vec4<f32> = vec4<f32>(1.0, 0.042500000447034836, 1.0399999618530273, -0.03999999910593033); 244 let r: vec4<f32> = ((perceptual_roughness_1 * c0_) + c1_); 245 let a004_: f32 = ((min((r.x * r.x), exp2((-9.279999732971191 * NoV_3))) * r.x) + r.y); 246 let AB: vec2<f32> = ((vec2<f32>(-1.0399999618530273, 1.0399999618530273) * a004_) + r.zw); 247 return ((f0_4 * AB.x) + vec3<f32>(AB.y)); 250fn lighting__perceptualRoughnessToRoughness(perceptualRoughness: f32) -> f32 { 251 let clampedPerceptualRoughness: f32 = clamp(perceptualRoughness, 0.08900000154972076, 1.0); 252 return (clampedPerceptualRoughness * clampedPerceptualRoughness); 255fn lighting__reinhard(color: vec3<f32>) -> vec3<f32> { 256 return (color / (vec3<f32>(1.0) + color)); 259fn lighting__reinhard_extended(color_1: vec3<f32>, max_white: f32) -> vec3<f32> { 260 let numerator: vec3<f32> = (color_1 * (vec3<f32>(1.0) + (color_1 / vec3<f32>((max_white * max_white))))); 261 return (numerator / (vec3<f32>(1.0) + color_1)); 264fn lighting__luminance(v: vec3<f32>) -> f32 { 265 return dot(v, vec3<f32>(0.2125999927520752, 0.7152000069618225, 0.0722000002861023)); 268fn lighting__change_luminance(c_in: vec3<f32>, l_out: f32) -> vec3<f32> { 269 let _e6: f32 = lighting__luminance(c_in); 270 return (c_in * (l_out / _e6)); 273fn lighting__reinhard_luminance(color_2: vec3<f32>) -> vec3<f32> { 274 let _e5: f32 = lighting__luminance(color_2); 275 let l_new: f32 = (_e5 / (1.0 + _e5)); 276 let _e9: vec3<f32> = lighting__change_luminance(color_2, l_new); 280fn lighting__reinhard_extended_luminance(color_3: vec3<f32>, max_white_l: f32) -> vec3<f32> { 281 let _e6: f32 = lighting__luminance(color_3); 282 let numerator_1: f32 = (_e6 * (1.0 + (_e6 / (max_white_l * max_white_l)))); 283 let l_new_1: f32 = (numerator_1 / (1.0 + _e6)); 284 let _e15: vec3<f32> = lighting__change_luminance(color_3, l_new_1); 288fn lighting__point_light(world_position: vec3<f32>, light: mesh_view_types__PointLight, roughness_4: f32, NdotV: f32, N: vec3<f32>, V: vec3<f32>, R: vec3<f32>, F0_: vec3<f32>, diffuseColor: vec3<f32>) -> vec3<f32> { 295 let light_to_frag: vec3<f32> = (light.position_radius.xyz - world_position.xyz); 296 let distance_square: f32 = dot(light_to_frag, light_to_frag); 297 let _e20: f32 = lighting__getDistanceAttenuation(distance_square, light.color_inverse_square_range.w); 298 let centerToRay: vec3<f32> = ((dot(light_to_frag, R) * R) - light_to_frag); 299 let _e29: f32 = utils__saturate((light.position_radius.w * inverseSqrt(dot(centerToRay, centerToRay)))); 300 let closestPoint: vec3<f32> = (light_to_frag + (centerToRay * _e29)); 301 let LspecLengthInverse: f32 = inverseSqrt(dot(closestPoint, closestPoint)); 302 let _e40: f32 = utils__saturate((roughness_4 + ((light.position_radius.w * 0.5) * LspecLengthInverse))); 303 let normalizationFactor: f32 = (roughness_4 / _e40); 304 let specularIntensity_1: f32 = (normalizationFactor * normalizationFactor); 305 L = (closestPoint * LspecLengthInverse); 306 let _e45: vec3<f32> = L; 307 H = normalize((_e45 + V)); 308 let _e49: vec3<f32> = L; 309 let _e51: f32 = utils__saturate(dot(N, _e49)); 311 let _e53: vec3<f32> = H; 312 let _e55: f32 = utils__saturate(dot(N, _e53)); 314 let _e57: vec3<f32> = L; 315 let _e58: vec3<f32> = H; 316 let _e60: f32 = utils__saturate(dot(_e57, _e58)); 318 let _e62: vec3<f32> = H; 319 let _e63: f32 = NoL_3; 320 let _e64: f32 = NoH_2; 321 let _e65: f32 = LoH_3; 322 let _e66: vec3<f32> = lighting__specular(F0_, roughness_4, _e62, NdotV, _e63, _e64, _e65, specularIntensity_1); 323 L = normalize(light_to_frag); 324 let _e68: vec3<f32> = L; 325 H = normalize((_e68 + V)); 326 let _e71: vec3<f32> = L; 327 let _e73: f32 = utils__saturate(dot(N, _e71)); 329 let _e74: vec3<f32> = H; 330 let _e76: f32 = utils__saturate(dot(N, _e74)); 332 let _e77: vec3<f32> = L; 333 let _e78: vec3<f32> = H; 334 let _e80: f32 = utils__saturate(dot(_e77, _e78)); 336 let _e81: f32 = NoL_3; 337 let _e82: f32 = LoH_3; 338 let _e83: f32 = lighting__Fd_Burley(roughness_4, NdotV, _e81, _e82); 339 let diffuse: vec3<f32> = (diffuseColor * _e83); 340 let _e89: f32 = NoL_3; 341 return (((diffuse + _e66) * light.color_inverse_square_range.xyz) * (_e20 * _e89)); 344fn lighting__spot_light(world_position_1: vec3<f32>, light_1: mesh_view_types__PointLight, roughness_5: f32, NdotV_1: f32, N_1: vec3<f32>, V_1: vec3<f32>, R_1: vec3<f32>, F0_1: vec3<f32>, diffuseColor_1: vec3<f32>) -> vec3<f32> { 345 var spot_dir: vec3<f32>; 347 let _e13: vec3<f32> = lighting__point_light(world_position_1, light_1, roughness_5, NdotV_1, N_1, V_1, R_1, F0_1, diffuseColor_1); 348 spot_dir = vec3<f32>(light_1.light_custom_data.x, 0.0, light_1.light_custom_data.y); 349 let _e24: f32 = spot_dir.x; 350 let _e26: f32 = spot_dir.x; 351 let _e30: f32 = spot_dir.z; 352 let _e32: f32 = spot_dir.z; 353 spot_dir.y = sqrt(((1.0 - (_e24 * _e26)) - (_e30 * _e32))); 354 if ((light_1.flags & mesh_view_types__POINT_LIGHT_FLAGS_SPOT_LIGHT_Y_NEGATIVE) != 0u) { 355 let _e42: f32 = spot_dir.y; 356 spot_dir.y = -(_e42); 358 let light_to_frag_1: vec3<f32> = (light_1.position_radius.xyz - world_position_1.xyz); 359 let _e48: vec3<f32> = spot_dir; 360 let cd: f32 = dot(-(_e48), normalize(light_to_frag_1)); 361 let _e58: f32 = utils__saturate(((cd * light_1.light_custom_data.z) + light_1.light_custom_data.w)); 362 let spot_attenuation: f32 = (_e58 * _e58); 363 return (_e13 * spot_attenuation); 366fn lighting__directional_light(light_2: mesh_view_types__DirectionalLight, roughness_6: f32, NdotV_2: f32, normal: vec3<f32>, view: vec3<f32>, R_2: vec3<f32>, F0_2: vec3<f32>, diffuseColor_2: vec3<f32>) -> vec3<f32> { 367 let incident_light: vec3<f32> = light_2.direction_to_light.xyz; 368 let half_vector: vec3<f32> = normalize((incident_light + view)); 369 let _e17: f32 = utils__saturate(dot(normal, incident_light)); 370 let _e19: f32 = utils__saturate(dot(normal, half_vector)); 371 let _e21: f32 = utils__saturate(dot(incident_light, half_vector)); 372 let _e22: f32 = lighting__Fd_Burley(roughness_6, NdotV_2, _e17, _e21); 373 let diffuse_1: vec3<f32> = (diffuseColor_2 * _e22); 374 let _e25: vec3<f32> = lighting__specular(F0_2, roughness_6, half_vector, NdotV_2, _e17, _e19, _e21, 1.0); 375 return (((_e25 + diffuse_1) * light_2.color.xyz) * _e17); 378fn clustered_forward__view_z_to_z_slice(view_z: f32, is_orthographic: bool) -> u32 { 379 var z_slice: u32 = 0u; 382 let _e18: f32 = mesh_view_bindings__lights.cluster_factors.z; 383 let _e22: f32 = mesh_view_bindings__lights.cluster_factors.w; 384 z_slice = u32(floor(((view_z - _e18) * _e22))); 386 let _e30: f32 = mesh_view_bindings__lights.cluster_factors.z; 387 let _e34: f32 = mesh_view_bindings__lights.cluster_factors.w; 388 z_slice = u32((((log(-(view_z)) * _e30) - _e34) + 1.0)); 390 let _e39: u32 = z_slice; 391 let _e42: u32 = mesh_view_bindings__lights.cluster_dimensions.z; 392 return min(_e39, (_e42 - 1u)); 395fn clustered_forward__fragment_cluster_index(frag_coord_1: vec2<f32>, view_z_1: f32, is_orthographic_1: bool) -> u32 { 396 let _e16: vec4<f32> = mesh_view_bindings__lights.cluster_factors; 397 let xy: vec2<u32> = vec2<u32>(floor((frag_coord_1 * _e16.xy))); 398 let _e21: u32 = clustered_forward__view_z_to_z_slice(view_z_1, is_orthographic_1); 399 let _e25: u32 = mesh_view_bindings__lights.cluster_dimensions.x; 400 let _e31: u32 = mesh_view_bindings__lights.cluster_dimensions.z; 401 let _e36: u32 = mesh_view_bindings__lights.cluster_dimensions.w; 402 return min(((((xy.y * _e25) + xy.x) * _e31) + _e21), (_e36 - 1u)); 405fn clustered_forward__unpack_offset_and_counts(cluster_index: u32) -> vec3<u32> { 406 let _e16: vec4<u32> = mesh_view_bindings__cluster_offsets_and_counts.data[cluster_index]; 410fn clustered_forward__get_light_id(index: u32) -> u32 { 411 let _e16: u32 = mesh_view_bindings__cluster_light_index_lists.data[index]; 415fn clustered_forward__cluster_debug_visualization(output_color_1: vec4<f32>, view_z_2: f32, is_orthographic_2: bool, offset_and_counts: vec3<u32>, cluster_index_1: u32) -> vec4<f32> { 416 return output_color_1; 419fn shadows__fetch_point_shadow(light_id: u32, frag_position: vec4<f32>, surface_normal: vec3<f32>) -> f32 { 420 let light_3: mesh_view_types__PointLight = mesh_view_bindings__point_lights.data[light_id]; 421 let surface_to_light: vec3<f32> = (light_3.position_radius.xyz - frag_position.xyz); 422 let surface_to_light_abs: vec3<f32> = abs(surface_to_light); 423 let distance_to_light: f32 = max(surface_to_light_abs.x, max(surface_to_light_abs.y, surface_to_light_abs.z)); 424 let normal_offset: vec3<f32> = ((light_3.shadow_normal_bias * distance_to_light) * surface_normal.xyz); 425 let depth_offset: vec3<f32> = (light_3.shadow_depth_bias * normalize(surface_to_light.xyz)); 426 let offset_position: vec3<f32> = ((frag_position.xyz + normal_offset) + depth_offset); 427 let frag_ls: vec3<f32> = (light_3.position_radius.xyz - offset_position.xyz); 428 let abs_position_ls: vec3<f32> = abs(frag_ls); 429 let major_axis_magnitude: f32 = max(abs_position_ls.x, max(abs_position_ls.y, abs_position_ls.z)); 430 let zw: vec2<f32> = ((-(major_axis_magnitude) * light_3.light_custom_data.xy) + light_3.light_custom_data.zw); 431 let depth: f32 = (zw.x / zw.y); 432 let _e60: f32 = textureSampleCompareLevel(mesh_view_bindings__point_shadow_textures, mesh_view_bindings__point_shadow_textures_sampler, frag_ls, i32(light_id), depth); 436fn shadows__fetch_spot_shadow(light_id_1: u32, frag_position_1: vec4<f32>, surface_normal_1: vec3<f32>) -> f32 { 437 var spot_dir_1: vec3<f32>; 438 var sign: f32 = -1.0; 440 let light_4: mesh_view_types__PointLight = mesh_view_bindings__point_lights.data[light_id_1]; 441 let surface_to_light_1: vec3<f32> = (light_4.position_radius.xyz - frag_position_1.xyz); 442 spot_dir_1 = vec3<f32>(light_4.light_custom_data.x, 0.0, light_4.light_custom_data.y); 443 let _e32: f32 = spot_dir_1.x; 444 let _e34: f32 = spot_dir_1.x; 445 let _e38: f32 = spot_dir_1.z; 446 let _e40: f32 = spot_dir_1.z; 447 spot_dir_1.y = sqrt(((1.0 - (_e32 * _e34)) - (_e38 * _e40))); 448 if ((light_4.flags & mesh_view_types__POINT_LIGHT_FLAGS_SPOT_LIGHT_Y_NEGATIVE) != 0u) { 449 let _e50: f32 = spot_dir_1.y; 450 spot_dir_1.y = -(_e50); 452 let _e52: vec3<f32> = spot_dir_1; 453 let fwd: vec3<f32> = -(_e52); 454 let distance_to_light_1: f32 = dot(fwd, surface_to_light_1); 455 let offset_position_1: vec3<f32> = ((-(surface_to_light_1) + (light_4.shadow_depth_bias * normalize(surface_to_light_1))) + ((surface_normal_1.xyz * light_4.shadow_normal_bias) * distance_to_light_1)); 459 let _e73: f32 = sign; 460 let a_1: f32 = (-1.0 / (fwd.z + _e73)); 461 let b: f32 = ((fwd.x * fwd.y) * a_1); 462 let _e81: f32 = sign; 463 let _e88: f32 = sign; 464 let _e90: f32 = sign; 465 let up_dir: vec3<f32> = vec3<f32>((1.0 + (((_e81 * fwd.x) * fwd.x) * a_1)), (_e88 * b), (-(_e90) * fwd.x)); 466 let _e96: f32 = sign; 467 let right_dir: vec3<f32> = vec3<f32>(-(b), (-(_e96) - ((fwd.y * fwd.y) * a_1)), fwd.y); 468 let light_inv_rot: mat3x3<f32> = mat3x3<f32>(right_dir, up_dir, fwd); 469 let projected_position: vec3<f32> = (offset_position_1 * light_inv_rot); 470 let f_div_minus_z: f32 = (1.0 / (light_4.spot_light_tan_angle * -(projected_position.z))); 471 let shadow_xy_ndc: vec2<f32> = (projected_position.xy * f_div_minus_z); 472 let shadow_uv: vec2<f32> = ((shadow_xy_ndc * vec2<f32>(0.5, -0.5)) + vec2<f32>(0.5, 0.5)); 473 let depth_1: f32 = (0.10000000149011612 / -(projected_position.z)); 474 let _e129: i32 = mesh_view_bindings__lights.spot_light_shadowmap_offset; 475 let _e131: f32 = textureSampleCompareLevel(mesh_view_bindings__directional_shadow_textures, mesh_view_bindings__directional_shadow_textures_sampler, shadow_uv, (i32(light_id_1) + _e129), depth_1); 479fn shadows__fetch_directional_shadow(light_id_2: u32, frag_position_2: vec4<f32>, surface_normal_2: vec3<f32>) -> f32 { 480 let light_5: mesh_view_types__DirectionalLight = mesh_view_bindings__lights.directional_lights[light_id_2]; 481 let normal_offset_1: vec3<f32> = (light_5.shadow_normal_bias * surface_normal_2.xyz); 482 let depth_offset_1: vec3<f32> = (light_5.shadow_depth_bias * light_5.direction_to_light.xyz); 483 let offset_position_2: vec4<f32> = vec4<f32>(((frag_position_2.xyz + normal_offset_1) + depth_offset_1), frag_position_2.w); 484 let offset_position_clip: vec4<f32> = (light_5.view_projection * offset_position_2); 485 if (offset_position_clip.w <= 0.0) { 488 let offset_position_ndc: vec3<f32> = (offset_position_clip.xyz / vec3<f32>(offset_position_clip.w)); 489 if ((any((offset_position_ndc.xy < vec2<f32>(-1.0))) || (offset_position_ndc.z < 0.0)) || any((offset_position_ndc > vec3<f32>(1.0)))) { 492 let flip_correction: vec2<f32> = vec2<f32>(0.5, -0.5); 493 let light_local: vec2<f32> = ((offset_position_ndc.xy * flip_correction) + vec2<f32>(0.5, 0.5)); 494 let depth_2: f32 = offset_position_ndc.z; 495 let _e66: f32 = textureSampleCompareLevel(mesh_view_bindings__directional_shadow_textures, mesh_view_bindings__directional_shadow_textures_sampler, light_local, i32(light_id_2), depth_2); 499fn pbr_functions__prepare_normal(standard_material_flags: u32, world_normal: vec3<f32>, uv: vec2<f32>, is_front_1: bool) -> vec3<f32> { 502 N_2 = normalize(world_normal); 503 if ((standard_material_flags & pbr_types__STANDARD_MATERIAL_FLAGS_DOUBLE_SIDED_BIT) != 0u) { 505 let _e37: vec3<f32> = N_2; 509 let _e39: vec3<f32> = N_2; 513fn pbr_functions__calculate_view(world_position_2: vec4<f32>, is_orthographic_3: bool) -> vec3<f32> { 516 if is_orthographic_3 { 517 let _e34: f32 = mesh_view_bindings__view.view_proj[0][2]; 518 let _e39: f32 = mesh_view_bindings__view.view_proj[1][2]; 519 let _e44: f32 = mesh_view_bindings__view.view_proj[2][2]; 520 V_2 = normalize(vec3<f32>(_e34, _e39, _e44)); 522 let _e48: vec3<f32> = mesh_view_bindings__view.world_position; 523 V_2 = normalize((_e48.xyz - world_position_2.xyz)); 525 let _e53: vec3<f32> = V_2; 529fn pbr_functions__pbr_input_new() -> pbr_functions__PbrInput { 530 var pbr_input_1: pbr_functions__PbrInput; 532 let _e29: pbr_types__StandardMaterial = pbr_types__standard_material_new(); 533 pbr_input_1.material = _e29; 534 pbr_input_1.occlusion = 1.0; 535 pbr_input_1.frag_coord = vec4<f32>(0.0, 0.0, 0.0, 1.0); 536 pbr_input_1.world_position = vec4<f32>(0.0, 0.0, 0.0, 1.0); 537 pbr_input_1.world_normal = vec3<f32>(0.0, 0.0, 1.0); 538 pbr_input_1.is_orthographic = false; 539 pbr_input_1.N = vec3<f32>(0.0, 0.0, 1.0); 540 pbr_input_1.V = vec3<f32>(1.0, 0.0, 0.0); 541 let _e61: pbr_functions__PbrInput = pbr_input_1; 545fn pbr_functions__pbr(in: pbr_functions__PbrInput) -> vec4<f32> { 546 var output_color_2: vec4<f32>; 547 var light_accum: vec3<f32>; 555 output_color_2 = in.material.base_color; 556 let emissive_1: vec4<f32> = in.material.emissive; 557 let metallic_1: f32 = in.material.metallic; 558 let perceptual_roughness_2: f32 = in.material.perceptual_roughness; 559 let _e37: f32 = lighting__perceptualRoughnessToRoughness(perceptual_roughness_2); 560 let occlusion_1: f32 = in.occlusion; 561 if ((in.material.flags & pbr_types__STANDARD_MATERIAL_FLAGS_ALPHA_MODE_OPAQUE) != 0u) { 562 output_color_2.w = 1.0; 564 if ((in.material.flags & pbr_types__STANDARD_MATERIAL_FLAGS_ALPHA_MODE_MASK) != 0u) { 565 let _e52: f32 = output_color_2.w; 566 if (_e52 >= in.material.alpha_cutoff) { 567 output_color_2.w = 1.0; 573 let NdotV_3: f32 = max(dot(in.N, in.V), 9.999999747378752e-5); 574 let reflectance: f32 = in.material.reflectance; 575 let _e71: vec4<f32> = output_color_2; 576 let F0_3: vec3<f32> = (vec3<f32>((((0.1599999964237213 * reflectance) * reflectance) * (1.0 - metallic_1))) + (_e71.xyz * metallic_1)); 577 let _e76: vec4<f32> = output_color_2; 578 let diffuse_color: vec3<f32> = (_e76.xyz * (1.0 - metallic_1)); 579 let R_3: vec3<f32> = reflect(-(in.V), in.N); 580 light_accum = vec3<f32>(0.0); 581 let _e92: f32 = mesh_view_bindings__view.inverse_view[0][2]; 582 let _e97: f32 = mesh_view_bindings__view.inverse_view[1][2]; 583 let _e102: f32 = mesh_view_bindings__view.inverse_view[2][2]; 584 let _e107: f32 = mesh_view_bindings__view.inverse_view[3][2]; 585 let view_z_3: f32 = dot(vec4<f32>(_e92, _e97, _e102, _e107), in.world_position); 586 let _e114: u32 = clustered_forward__fragment_cluster_index(in.frag_coord.xy, view_z_3, in.is_orthographic); 587 let _e115: vec3<u32> = clustered_forward__unpack_offset_and_counts(_e114); 591 if (_e119 < (_e115.x + _e115.y)) { 596 let _e130: u32 = clustered_forward__get_light_id(_e129); 597 let light_6: mesh_view_types__PointLight = mesh_view_bindings__point_lights.data[_e130]; 599 let _e137: u32 = mesh_bindings__mesh.flags; 600 if (((_e137 & mesh_types__MESH_FLAGS_SHADOW_RECEIVER_BIT) != 0u) && ((light_6.flags & mesh_view_types__POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u)) { 601 let _e148: f32 = shadows__fetch_point_shadow(_e130, in.world_position, in.world_normal); 604 let _e153: vec3<f32> = lighting__point_light(in.world_position.xyz, light_6, _e37, NdotV_3, in.N, in.V, R_3, F0_3, diffuse_color); 605 let _e154: vec3<f32> = light_accum; 606 let _e155: f32 = shadow; 607 light_accum = (_e154 + (_e153 * _e155)); 613 i_1 = (_e115.x + _e115.y); 615 let _e164: u32 = i_1; 616 if (_e164 < ((_e115.x + _e115.y) + _e115.z)) { 620 let _e177: u32 = i_1; 621 let _e178: u32 = clustered_forward__get_light_id(_e177); 622 let light_7: mesh_view_types__PointLight = mesh_view_bindings__point_lights.data[_e178]; 624 let _e185: u32 = mesh_bindings__mesh.flags; 625 if (((_e185 & mesh_types__MESH_FLAGS_SHADOW_RECEIVER_BIT) != 0u) && ((light_7.flags & mesh_view_types__POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u)) { 626 let _e196: f32 = shadows__fetch_spot_shadow(_e178, in.world_position, in.world_normal); 629 let _e201: vec3<f32> = lighting__spot_light(in.world_position.xyz, light_7, _e37, NdotV_3, in.N, in.V, R_3, F0_3, diffuse_color); 630 let _e202: vec3<f32> = light_accum; 631 let _e203: f32 = shadow_1; 632 light_accum = (_e202 + (_e201 * _e203)); 634 let _e174: u32 = i_1; 638 let n_directional_lights: u32 = mesh_view_bindings__lights.n_directional_lights; 640 let _e210: u32 = i_2; 641 if (_e210 < n_directional_lights) { 645 let _e216: u32 = i_2; 646 let light_8: mesh_view_types__DirectionalLight = mesh_view_bindings__lights.directional_lights[_e216]; 648 let _e222: u32 = mesh_bindings__mesh.flags; 649 if (((_e222 & mesh_types__MESH_FLAGS_SHADOW_RECEIVER_BIT) != 0u) && ((light_8.flags & mesh_view_types__DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u)) { 650 let _e231: u32 = i_2; 651 let _e234: f32 = shadows__fetch_directional_shadow(_e231, in.world_position, in.world_normal); 654 let _e237: vec3<f32> = lighting__directional_light(light_8, _e37, NdotV_3, in.N, in.V, R_3, F0_3, diffuse_color); 655 let _e238: vec3<f32> = light_accum; 656 let _e239: f32 = shadow_2; 657 light_accum = (_e238 + (_e237 * _e239)); 659 let _e212: u32 = i_2; 663 let _e243: vec3<f32> = lighting__EnvBRDFApprox(diffuse_color, 1.0, NdotV_3); 664 let _e244: vec3<f32> = lighting__EnvBRDFApprox(F0_3, perceptual_roughness_2, NdotV_3); 665 let _e245: vec3<f32> = light_accum; 666 let _e248: vec4<f32> = mesh_view_bindings__lights.ambient_color; 667 let _e255: f32 = output_color_2.w; 668 let _e259: f32 = output_color_2.w; 669 output_color_2 = vec4<f32>(((_e245 + (((_e243 + _e244) * _e248.xyz) * occlusion_1)) + (emissive_1.xyz * _e255)), _e259); 670 let _e261: vec4<f32> = output_color_2; 671 let _e263: vec4<f32> = clustered_forward__cluster_debug_visualization(_e261, view_z_3, in.is_orthographic, _e115, _e114); 672 output_color_2 = _e263; 673 let _e264: vec4<f32> = output_color_2; 677fn pbr_functions__tone_mapping(in_1: vec4<f32>) -> vec4<f32> { 678 let _e29: vec3<f32> = lighting__reinhard_luminance(in_1.xyz); 679 return vec4<f32>(_e29, in_1.w); 683fn fragment(mesh: mesh_vertex_output__MeshVertexOutput, @builtin(front_facing) is_front: bool, @builtin(position) frag_coord: vec4<f32>) -> @location(0) vec4<f32> { 684 var output_color: vec4<f32>; 685 var pbr_input: pbr_functions__PbrInput; 686 var emissive: vec4<f32>; 688 var perceptual_roughness: f32; 691 let _e42: vec4<f32> = pbr_bindings__material.base_color; 693 let _e45: u32 = pbr_bindings__material.flags; 694 if ((_e45 & pbr_types__STANDARD_MATERIAL_FLAGS_BASE_COLOR_TEXTURE_BIT) != 0u) { 695 let _e49: vec4<f32> = output_color; 696 let _e51: vec4<f32> = textureSample(pbr_bindings__base_color_texture, pbr_bindings__base_color_sampler, mesh.uv); 697 output_color = (_e49 * _e51); 699 let _e54: u32 = pbr_bindings__material.flags; 700 if ((_e54 & pbr_types__STANDARD_MATERIAL_FLAGS_UNLIT_BIT) == 0u) { 701 let _e61: vec4<f32> = output_color; 702 pbr_input.material.base_color = _e61; 703 let _e65: f32 = pbr_bindings__material.reflectance; 704 pbr_input.material.reflectance = _e65; 705 let _e69: u32 = pbr_bindings__material.flags; 706 pbr_input.material.flags = _e69; 707 let _e73: f32 = pbr_bindings__material.alpha_cutoff; 708 pbr_input.material.alpha_cutoff = _e73; 709 let _e75: vec4<f32> = pbr_bindings__material.emissive; 711 let _e78: u32 = pbr_bindings__material.flags; 712 if ((_e78 & pbr_types__STANDARD_MATERIAL_FLAGS_EMISSIVE_TEXTURE_BIT) != 0u) { 713 let _e82: vec4<f32> = emissive; 714 let _e85: vec4<f32> = textureSample(pbr_bindings__emissive_texture, pbr_bindings__emissive_sampler, mesh.uv); 715 emissive = vec4<f32>((_e82.xyz * _e85.xyz), 1.0); 717 let _e92: vec4<f32> = emissive; 718 pbr_input.material.emissive = _e92; 719 let _e94: f32 = pbr_bindings__material.metallic; 721 let _e97: f32 = pbr_bindings__material.perceptual_roughness; 722 perceptual_roughness = _e97; 723 let _e100: u32 = pbr_bindings__material.flags; 724 if ((_e100 & pbr_types__STANDARD_MATERIAL_FLAGS_METALLIC_ROUGHNESS_TEXTURE_BIT) != 0u) { 725 let metallic_roughness: vec4<f32> = textureSample(pbr_bindings__metallic_roughness_texture, pbr_bindings__metallic_roughness_sampler, mesh.uv); 726 let _e106: f32 = metallic; 727 metallic = (_e106 * metallic_roughness.z); 728 let _e109: f32 = perceptual_roughness; 729 perceptual_roughness = (_e109 * metallic_roughness.y); 731 let _e114: f32 = metallic; 732 pbr_input.material.metallic = _e114; 733 let _e117: f32 = perceptual_roughness; 734 pbr_input.material.perceptual_roughness = _e117; 736 let _e121: u32 = pbr_bindings__material.flags; 737 if ((_e121 & pbr_types__STANDARD_MATERIAL_FLAGS_OCCLUSION_TEXTURE_BIT) != 0u) { 738 let _e126: vec4<f32> = textureSample(pbr_bindings__occlusion_texture, pbr_bindings__occlusion_sampler, mesh.uv); 741 let _e129: f32 = occlusion; 742 pbr_input.occlusion = _e129; 743 pbr_input.frag_coord = frag_coord; 744 pbr_input.world_position = mesh.world_position; 745 pbr_input.world_normal = mesh.world_normal; 746 let _e140: f32 = mesh_view_bindings__view.projection[3][3]; 747 pbr_input.is_orthographic = (_e140 == 1.0); 748 let _e145: u32 = pbr_bindings__material.flags; 749 let _e148: vec3<f32> = pbr_functions__prepare_normal(_e145, mesh.world_normal, mesh.uv, is_front); 751 let _e152: bool = pbr_input.is_orthographic; 752 let _e153: vec3<f32> = pbr_functions__calculate_view(mesh.world_position, _e152); 754 let _e154: pbr_functions__PbrInput = pbr_input; 755 let _e155: vec4<f32> = pbr_functions__pbr(_e154); 756 let _e156: vec4<f32> = pbr_functions__tone_mapping(_e155); 757 output_color = _e156; 759 let _e157: vec4<f32> = output_color;