3 pbr_types::STANDARD_MATERIAL_FLAGS_UNLIT_BIT, 5 pbr_deferred_functions::pbr_input_from_deferred_gbuffer, 6 pbr_deferred_types::unpack_unorm3x4_plus_unorm_20_, 8 mesh_view_bindings::deferred_prepass_texture, 11#ifdef SCREEN_SPACE_AMBIENT_OCCLUSION 12#import bevy_pbr::mesh_view_bindings::screen_space_ambient_occlusion_texture 13#import bevy_pbr::ssao_utils::ssao_multibounce 16struct FullscreenVertexOutput { 23struct PbrDeferredLightingDepthId { 25#ifdef SIXTEEN_BYTE_ALIGNMENT 27 _webgl2_padding_0: f32, 28 _webgl2_padding_1: f32, 29 _webgl2_padding_2: f32, 33var<uniform> depth_id: PbrDeferredLightingDepthId; 36fn vertex(@builtin(vertex_index) vertex_index: u32) -> FullscreenVertexOutput { 38 let uv = vec2<f32>(f32(vertex_index >> 1u), f32(vertex_index & 1u)) * 2.0; 40 let clip_position = vec4<f32>(uv * vec2<f32>(2.0, -2.0) + vec2<f32>(-1.0, 1.0), f32(depth_id.depth_id) / 255.0, 1.0); 42 return FullscreenVertexOutput(clip_position, uv); 46fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> { 47 var frag_coord = vec4(in.position.xy, 0.0, 0.0); 49 let deferred_data = textureLoad(deferred_prepass_texture, vec2<i32>(frag_coord.xy), 0); 52 frag_coord.z = unpack_unorm3x4_plus_unorm_20_(deferred_data.b).w; 55 frag_coord.z = prepass_utils::prepass_depth(in.position, 0u); 59 var pbr_input = pbr_input_from_deferred_gbuffer(frag_coord, deferred_data); 60 var output_color = vec4(0.0); 63 if ((pbr_input.material.flags & STANDARD_MATERIAL_FLAGS_UNLIT_BIT) == 0u) { 65#ifdef SCREEN_SPACE_AMBIENT_OCCLUSION 66 let ssao = textureLoad(screen_space_ambient_occlusion_texture, vec2<i32>(in.position.xy), 0i).r; 67 let ssao_multibounce = ssao_multibounce(ssao, pbr_input.material.base_color.rgb); 68 pbr_input.diffuse_occlusion = min(pbr_input.diffuse_occlusion, ssao_multibounce); 71 let NdotV = max(dot(pbr_input.N, pbr_input.V), 0.0001); 72 var perceptual_roughness: f32 = pbr_input.material.perceptual_roughness; 73 let roughness = lighting::perceptualRoughnessToRoughness(perceptual_roughness); 76 pbr_input.specular_occlusion = saturate(pow(NdotV + ssao, exp2(-16.0 * roughness - 1.0)) - 1.0 + ssao); 77#endif // SCREEN_SPACE_AMBIENT_OCCLUSION 79 output_color = pbr_functions::apply_pbr_lighting(pbr_input); 81 output_color = pbr_input.material.base_color; 84 output_color = pbr_functions::main_pass_post_lighting_processing(pbr_input, output_color);