#import bevy_pbr::{ pbr_prepass_functions, pbr_bindings::material, pbr_types, pbr_functions, prepass_io, mesh_view_bindings::view, } #ifdef PREPASS_FRAGMENT @fragment fn fragment( in: prepass_io::VertexOutput, @builtin(front_facing) is_front: bool, ) -> prepass_io::FragmentOutput { pbr_prepass_functions::prepass_alpha_discard(in); var out: prepass_io::FragmentOutput; #ifdef DEPTH_CLAMP_ORTHO out.frag_depth = in.clip_position_unclamped.z; #endif // DEPTH_CLAMP_ORTHO #ifdef NORMAL_PREPASS // NOTE: Unlit bit not set means == 0 is true, so the true case is if lit if (material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_UNLIT_BIT) == 0u { let double_sided = (material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_DOUBLE_SIDED_BIT) != 0u; let world_normal = pbr_functions::prepare_world_normal( in.world_normal, double_sided, is_front, ); let normal = pbr_functions::apply_normal_mapping( material.flags, world_normal, double_sided, is_front, #ifdef VERTEX_TANGENTS #ifdef STANDARDMATERIAL_NORMAL_MAP in.world_tangent, #endif // STANDARDMATERIAL_NORMAL_MAP #endif // VERTEX_TANGENTS #ifdef VERTEX_UVS in.uv, #endif // VERTEX_UVS view.mip_bias, ); out.normal = vec4(normal * 0.5 + vec3(0.5), 1.0); } else { out.normal = vec4(in.world_normal * 0.5 + vec3(0.5), 1.0); } #endif // NORMAL_PREPASS #ifdef MOTION_VECTOR_PREPASS out.motion_vector = pbr_prepass_functions::calculate_motion_vector(in.world_position, in.previous_world_position); #endif return out; } #else @fragment fn fragment(in: prepass_io::VertexOutput) { pbr_prepass_functions::prepass_alpha_discard(in); } #endif // PREPASS_FRAGMENT