4 pbr_bindings::material, 7 pbr_functions::SampleBias, 10 mesh_view_bindings::view, 13#import bevy_render::bindless::{bindless_samplers_filtering, bindless_textures_2d} 15#ifdef MESHLET_MESH_MATERIAL_PASS 16#import bevy_pbr::meshlet_visibility_buffer_resolve::resolve_vertex_output 20#import bevy_pbr::pbr_bindings::material_indices 23#ifdef PREPASS_FRAGMENT 26#ifdef MESHLET_MESH_MATERIAL_PASS 27 @builtin(position) frag_coord: vec4<f32>, 29 in: prepass_io::VertexOutput, 30 @builtin(front_facing) is_front: bool, 32) -> prepass_io::FragmentOutput { 33#ifdef MESHLET_MESH_MATERIAL_PASS 34 let in = resolve_vertex_output(frag_coord); 36#else // MESHLET_MESH_MATERIAL_PASS 39 let slot = mesh[in.instance_index].material_and_lightmap_bind_group_slot & 0xffffu; 40 let flags = pbr_bindings::material_array[material_indices[slot].material].flags; 41 let uv_transform = pbr_bindings::material_array[material_indices[slot].material].uv_transform; 43 let flags = pbr_bindings::material.flags; 44 let uv_transform = pbr_bindings::material.uv_transform; 49#ifdef VISIBILITY_RANGE_DITHER 50 pbr_functions::visibility_range_dither(in.position, in.visibility_range_dither); 51#endif // VISIBILITY_RANGE_DITHER 53 pbr_prepass_functions::prepass_alpha_discard(in); 54#endif // MESHLET_MESH_MATERIAL_PASS 56 var out: prepass_io::FragmentOutput; 58#ifdef UNCLIPPED_DEPTH_ORTHO_EMULATION 59 out.frag_depth = in.unclipped_depth; 60#endif // UNCLIPPED_DEPTH_ORTHO_EMULATION 64 if (flags & pbr_types::STANDARD_MATERIAL_FLAGS_UNLIT_BIT) == 0u { 65 let double_sided = (flags & pbr_types::STANDARD_MATERIAL_FLAGS_DOUBLE_SIDED_BIT) != 0u; 67 let world_normal = pbr_functions::prepare_world_normal( 73 var normal = world_normal; 77#ifdef STANDARD_MATERIAL_NORMAL_MAP 80#ifdef STANDARD_MATERIAL_NORMAL_MAP_UV_B 81 let uv = (uv_transform * vec3(in.uv_b, 1.0)).xy; 83 let uv = (uv_transform * vec3(in.uv, 1.0)).xy; 88#ifdef MESHLET_MESH_MATERIAL_PASS 89 bias.ddx_uv = in.ddx_uv; 90 bias.ddy_uv = in.ddy_uv; 91#else // MESHLET_MESH_MATERIAL_PASS 92 bias.mip_bias = view.mip_bias; 93#endif // MESHLET_MESH_MATERIAL_PASS 96#ifdef MESHLET_MESH_MATERIAL_PASS 98#else // MESHLET_MESH_MATERIAL_PASS 100#endif // MESHLET_MESH_MATERIAL_PASS 102 bindless_textures_2d[material_indices[slot].normal_map_texture], 103 bindless_samplers_filtering[material_indices[slot].normal_map_sampler], 105 pbr_bindings::normal_map_texture, 106 pbr_bindings::normal_map_sampler, 109#ifdef MESHLET_MESH_MATERIAL_PASS 112#else // MESHLET_MESH_MATERIAL_PASS 114#endif // MESHLET_MESH_MATERIAL_PASS 116 let TBN = pbr_functions::calculate_tbn_mikktspace(normal, in.world_tangent); 118 normal = pbr_functions::apply_normal_mapping( 126#endif // STANDARD_MATERIAL_NORMAL_MAP 127#endif // VERTEX_TANGENTS 130 out.normal = vec4(normal * 0.5 + vec3(0.5), 1.0); 132 out.normal = vec4(in.world_normal * 0.5 + vec3(0.5), 1.0); 134#endif // NORMAL_PREPASS 136#ifdef MOTION_VECTOR_PREPASS 137#ifdef MESHLET_MESH_MATERIAL_PASS 138 out.motion_vector = in.motion_vector; 140 out.motion_vector = pbr_prepass_functions::calculate_motion_vector(in.world_position, in.previous_world_position); 148fn fragment(in: prepass_io::VertexOutput) { 149 pbr_prepass_functions::prepass_alpha_discard(in); 151#endif // PREPASS_FRAGMENT