diff --git a/crates/bevy_pbr/src/deferred/pbr_deferred_functions.wgsl b/crates/bevy_pbr/src/deferred/pbr_deferred_functions.wgsl index 495ee6b734..d8d923ede8 100644 --- a/crates/bevy_pbr/src/deferred/pbr_deferred_functions.wgsl +++ b/crates/bevy_pbr/src/deferred/pbr_deferred_functions.wgsl @@ -1,7 +1,7 @@ #define_import_path bevy_pbr::pbr_deferred_functions #import bevy_pbr::{ - pbr_types::{PbrInput, standard_material_new, STANDARD_MATERIAL_FLAGS_UNLIT_BIT}, + pbr_types::{PbrInput, pbr_input_new, STANDARD_MATERIAL_FLAGS_UNLIT_BIT}, pbr_deferred_types as deferred_types, pbr_functions, rgb9e5, @@ -58,8 +58,7 @@ fn deferred_gbuffer_from_pbr_input(in: PbrInput) -> vec4 { // Creates a PbrInput from the deferred gbuffer. fn pbr_input_from_deferred_gbuffer(frag_coord: vec4, gbuffer: vec4) -> PbrInput { - var pbr: PbrInput; - pbr.material = standard_material_new(); + var pbr = pbr_input_new(); let flags = deferred_types::unpack_flags(gbuffer.a); let deferred_flags = deferred_types::mesh_material_flags_from_deferred_flags(flags); diff --git a/crates/bevy_pbr/src/render/pbr_types.wgsl b/crates/bevy_pbr/src/render/pbr_types.wgsl index cd7170275b..72a70e45c8 100644 --- a/crates/bevy_pbr/src/render/pbr_types.wgsl +++ b/crates/bevy_pbr/src/render/pbr_types.wgsl @@ -24,7 +24,7 @@ struct StandardMaterial { }; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -// NOTE: if these flags are updated or changed. Be sure to also update +// NOTE: if these flags are updated or changed. Be sure to also update // deferred_flags_from_mesh_material_flags and mesh_material_flags_from_deferred_flags // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! const STANDARD_MATERIAL_FLAGS_BASE_COLOR_TEXTURE_BIT: u32 = 1u; @@ -74,13 +74,15 @@ fn standard_material_new() -> StandardMaterial { material.max_parallax_layer_count = 16.0; material.max_relief_mapping_search_steps = 5u; material.deferred_lighting_pass_id = 1u; - + return material; } struct PbrInput { material: StandardMaterial, + // Note: this gets monochromized upon deferred PbrInput reconstruction. diffuse_occlusion: vec3, + // Note: this is 1.0 (entirely unoccluded) when SSAO is off. specular_occlusion: f32, frag_coord: vec4, world_position: vec4, @@ -103,6 +105,7 @@ fn pbr_input_new() -> PbrInput { pbr_input.material = standard_material_new(); pbr_input.diffuse_occlusion = vec3(1.0); + // If SSAO is enabled, then this gets overwritten with proper specular occlusion. If its not, then we get specular environment map unoccluded (we have no data with which to occlude it with). pbr_input.specular_occlusion = 1.0; pbr_input.frag_coord = vec4(0.0, 0.0, 0.0, 1.0);