Skip to content

Commit 1a21cbe

Browse files
authored
Revert Screen Space Transmission Gate for Mesh Bind Groups (#24089)
# Objective - Alongside #24086, helps with #24084, although I think we should double check any other added conditionals for bind group entries to make sure they are accurate. ## Solution So, originally the `SCREEN_SPACE_TRANSMISSION` was enabled with `key.intersects(MeshPipelineKey::SCREEN_SPACE_SPECULAR_TRANSMISSION_RESERVED_BITS)`. However, a low quality transmission would make this false, since low’s MeshPipelineKey is configured like this: `const SCREEN_SPACE_SPECULAR_TRANSMISSION_LOW = 0 << Self::SCREEN_SPACE_SPECULAR_TRANSMISSION_SHIFT_BITS;`. So, a ScreenSpaceTransmission with Low Quality would break rendering (since another if-block merely checks that the `ScreenSpaceTransmission` component exists) Making it so that the low transmission truly does *not* include the view_transmission_textures makes the transmission render not properly - the spheres disappear! So, I think the proper fix here is to remove the gating around transmission textures. Edit: Another potential fix is to change the condition of the `intersects` but I’m not sure how to encode what we want unless we want to add another bit for `ScreenSpaceTransmission` component exists essentially? Happy to close this PR if that is an acceptable direction. ## Testing `cargo run --example transmission` works for all quality levels.
1 parent 68e5a15 commit 1a21cbe

4 files changed

Lines changed: 23 additions & 42 deletions

File tree

crates/bevy_pbr/src/deferred/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,6 @@ impl SpecializedRenderPipeline for DeferredLightingLayout {
290290
if key.contains(MeshPipelineKey::ATMOSPHERE) {
291291
shader_defs.push("ATMOSPHERE".into());
292292
}
293-
if key.intersects(MeshPipelineKey::SCREEN_SPACE_SPECULAR_TRANSMISSION_RESERVED_BITS) {
294-
shader_defs.push("SCREEN_SPACE_TRANSMISSION".into());
295-
}
296293
shader_defs.push("STANDARD_MATERIAL_CLEARCOAT".into());
297294

298295
// Always true, since we're in the deferred lighting pipeline

crates/bevy_pbr/src/render/mesh.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3555,10 +3555,6 @@ impl SpecializedMeshPipeline for MeshPipeline {
35553555
shader_defs.push("SHADOW_FILTER_METHOD_TEMPORAL".into());
35563556
}
35573557

3558-
if key.intersects(MeshPipelineKey::SCREEN_SPACE_SPECULAR_TRANSMISSION_RESERVED_BITS) {
3559-
shader_defs.push("SCREEN_SPACE_TRANSMISSION".into());
3560-
}
3561-
35623558
let blur_quality =
35633559
key.intersection(MeshPipelineKey::SCREEN_SPACE_SPECULAR_TRANSMISSION_RESERVED_BITS);
35643560

crates/bevy_pbr/src/render/mesh_view_bindings.rs

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::{
2-
AreaLightLuts, DfgLut, ScreenSpaceTransmission, ViewEnvironmentMapUniformOffset,
3-
ViewFogUniformOffset, ViewLightProbesUniformOffset, ViewLightsUniformOffset,
4-
ViewScreenSpaceReflectionsUniformOffset,
2+
AreaLightLuts, DfgLut, ViewEnvironmentMapUniformOffset, ViewFogUniformOffset,
3+
ViewLightProbesUniformOffset, ViewLightsUniformOffset, ViewScreenSpaceReflectionsUniformOffset,
54
};
65
use bevy_core_pipeline::{
76
oit::{
@@ -94,10 +93,9 @@ bitflags::bitflags! {
9493
const SCREEN_SPACE_AMBIENT_OCCLUSION = 1 << 10;
9594
const IRRADIANCE_VOLUME = 1 << 11;
9695
const SCREEN_SPACE_REFLECTIONS = 1 << 12;
97-
const SCREEN_SPACE_TRANSMISSION = 1 << 13;
98-
const CONTACT_SHADOWS = 1 << 14;
99-
const DISTANCE_FOG = 1 << 15;
100-
const AREA_LIGHT_LUTS = 1 << 16;
96+
const CONTACT_SHADOWS = 1 << 13;
97+
const DISTANCE_FOG = 1 << 14;
98+
const AREA_LIGHT_LUTS = 1 << 15;
10199
}
102100
}
103101

@@ -170,9 +168,6 @@ impl From<MeshPipelineKey> for MeshPipelineViewLayoutKey {
170168
if value.contains(MeshPipelineKey::SCREEN_SPACE_REFLECTIONS) {
171169
result |= MeshPipelineViewLayoutKey::SCREEN_SPACE_REFLECTIONS;
172170
}
173-
if value.intersects(MeshPipelineKey::SCREEN_SPACE_SPECULAR_TRANSMISSION_RESERVED_BITS) {
174-
result |= MeshPipelineViewLayoutKey::SCREEN_SPACE_TRANSMISSION;
175-
}
176171
if value.contains(MeshPipelineKey::CONTACT_SHADOWS) {
177172
result |= MeshPipelineViewLayoutKey::CONTACT_SHADOWS;
178173
}
@@ -408,16 +403,14 @@ fn layout_entries(
408403
}
409404
}
410405

411-
if layout_key.contains(MeshPipelineViewLayoutKey::SCREEN_SPACE_TRANSMISSION) {
412-
// View Transmission Texture
413-
entries = entries.extend_with_indices((
414-
(
415-
25,
416-
texture_2d(TextureSampleType::Float { filterable: true }),
417-
),
418-
(26, sampler(SamplerBindingType::Filtering)),
419-
));
420-
}
406+
// View Transmission Texture
407+
entries = entries.extend_with_indices((
408+
(
409+
25,
410+
texture_2d(TextureSampleType::Float { filterable: true }),
411+
),
412+
(26, sampler(SamplerBindingType::Filtering)),
413+
));
421414

422415
// OIT
423416
if layout_key.contains(MeshPipelineViewLayoutKey::OIT_ENABLED) {
@@ -649,7 +642,7 @@ pub fn prepare_mesh_view_bind_groups(
649642
Option<&RenderViewLightProbes<EnvironmentMapLight>>,
650643
Option<&RenderViewLightProbes<IrradianceVolume>>,
651644
),
652-
(Has<ExtractedAtmosphere>, Has<ScreenSpaceTransmission>),
645+
Has<ExtractedAtmosphere>,
653646
(
654647
&ViewUniformOffset,
655648
&ViewLightsUniformOffset,
@@ -728,7 +721,7 @@ pub fn prepare_mesh_view_bind_groups(
728721
atmosphere_textures,
729722
tonemapping,
730723
(render_view_environment_maps, render_view_irradiance_volumes),
731-
(has_atmosphere, has_transmission),
724+
has_atmosphere,
732725
(
733726
view_uniform_offset,
734727
view_lights_offset,
@@ -869,19 +862,16 @@ pub fn prepare_mesh_view_bind_groups(
869862
entries = entries.extend_with_indices(((17, ssao_view),));
870863
}
871864

872-
if has_transmission {
873-
layout_key |= MeshPipelineViewLayoutKey::SCREEN_SPACE_TRANSMISSION;
874-
let transmission_view = transmission_texture
875-
.map(|transmission| &transmission.view)
876-
.unwrap_or(&fallback_image_zero.texture_view);
865+
let transmission_view = transmission_texture
866+
.map(|transmission| &transmission.view)
867+
.unwrap_or(&fallback_image_zero.texture_view);
877868

878-
let transmission_sampler = transmission_texture
879-
.map(|transmission| &transmission.sampler)
880-
.unwrap_or(&fallback_image_zero.sampler);
869+
let transmission_sampler = transmission_texture
870+
.map(|transmission| &transmission.sampler)
871+
.unwrap_or(&fallback_image_zero.sampler);
881872

882-
entries = entries
883-
.extend_with_indices(((25, transmission_view), (26, transmission_sampler)));
884-
}
873+
entries =
874+
entries.extend_with_indices(((25, transmission_view), (26, transmission_sampler)));
885875

886876
// When using WebGL, we can't have a multisampled texture with `TEXTURE_BINDING`
887877
// See https://github.com/gfx-rs/wgpu/issues/5263

crates/bevy_pbr/src/render/mesh_view_bindings.wgsl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,8 @@ const VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE: u32 = 64u;
103103
@group(0) @binding(24) var deferred_prepass_texture: texture_2d<u32>;
104104
#endif // DEFERRED_PREPASS
105105

106-
#ifdef SCREEN_SPACE_TRANSMISSION
107106
@group(0) @binding(25) var view_transmission_texture: texture_2d<f32>;
108107
@group(0) @binding(26) var view_transmission_sampler: sampler;
109-
#endif
110108

111109
#ifdef OIT_ENABLED
112110
@group(0) @binding(27) var<uniform> oit_settings: types::OrderIndependentTransparencySettings;

0 commit comments

Comments
 (0)