Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions crates/bevy_pbr/src/deferred/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,6 @@ impl SpecializedRenderPipeline for DeferredLightingLayout {
if key.contains(MeshPipelineKey::ATMOSPHERE) {
shader_defs.push("ATMOSPHERE".into());
}
if key.intersects(MeshPipelineKey::SCREEN_SPACE_SPECULAR_TRANSMISSION_RESERVED_BITS) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not check all the bits for the different quality levels?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand your question and the code correctly, the quality level is encoded in 2 bits (for low, medium, high, and ultra), a low quality level is encoded as a 0, and we want SCREEN_SPACE_TRANSMISSION to be enabled in that scenario anyway (or else low quality just doesn’t render — I tested with the transmission example). Checking the bits for each individual quality would be redundant in that case since any combo of bits should result in screen space transmission being enabled, so I’m removing the useless gating.

I’m interpreting that you mean to check every individual quality level as already done so here:

let blur_quality =
key.intersection(MeshPipelineKey::SCREEN_SPACE_SPECULAR_TRANSMISSION_RESERVED_BITS);
shader_defs.push(ShaderDefVal::Int(
"SCREEN_SPACE_SPECULAR_TRANSMISSION_BLUR_TAPS".into(),
match blur_quality {
MeshPipelineKey::SCREEN_SPACE_SPECULAR_TRANSMISSION_LOW => 4,
MeshPipelineKey::SCREEN_SPACE_SPECULAR_TRANSMISSION_MEDIUM => 8,
MeshPipelineKey::SCREEN_SPACE_SPECULAR_TRANSMISSION_HIGH => 16,
MeshPipelineKey::SCREEN_SPACE_SPECULAR_TRANSMISSION_ULTRA => 32,
_ => unreachable!(), // Not possible, since the mask is 2 bits, and we've covered all 4 cases
},
));

shader_defs.push("SCREEN_SPACE_TRANSMISSION".into());
}
shader_defs.push("STANDARD_MATERIAL_CLEARCOAT".into());

// Always true, since we're in the deferred lighting pipeline
Expand Down
4 changes: 0 additions & 4 deletions crates/bevy_pbr/src/render/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3555,10 +3555,6 @@ impl SpecializedMeshPipeline for MeshPipeline {
shader_defs.push("SHADOW_FILTER_METHOD_TEMPORAL".into());
}

if key.intersects(MeshPipelineKey::SCREEN_SPACE_SPECULAR_TRANSMISSION_RESERVED_BITS) {
shader_defs.push("SCREEN_SPACE_TRANSMISSION".into());
}

let blur_quality =
key.intersection(MeshPipelineKey::SCREEN_SPACE_SPECULAR_TRANSMISSION_RESERVED_BITS);

Expand Down
56 changes: 23 additions & 33 deletions crates/bevy_pbr/src/render/mesh_view_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{
AreaLightLuts, DfgLut, ScreenSpaceTransmission, ViewEnvironmentMapUniformOffset,
ViewFogUniformOffset, ViewLightProbesUniformOffset, ViewLightsUniformOffset,
ViewScreenSpaceReflectionsUniformOffset,
AreaLightLuts, DfgLut, ViewEnvironmentMapUniformOffset, ViewFogUniformOffset,
ViewLightProbesUniformOffset, ViewLightsUniformOffset, ViewScreenSpaceReflectionsUniformOffset,
};
use bevy_core_pipeline::{
oit::{
Expand Down Expand Up @@ -94,10 +93,9 @@ bitflags::bitflags! {
const SCREEN_SPACE_AMBIENT_OCCLUSION = 1 << 10;
const IRRADIANCE_VOLUME = 1 << 11;
const SCREEN_SPACE_REFLECTIONS = 1 << 12;
const SCREEN_SPACE_TRANSMISSION = 1 << 13;
const CONTACT_SHADOWS = 1 << 14;
const DISTANCE_FOG = 1 << 15;
const AREA_LIGHT_LUTS = 1 << 16;
const CONTACT_SHADOWS = 1 << 13;
const DISTANCE_FOG = 1 << 14;
const AREA_LIGHT_LUTS = 1 << 15;
}
}

Expand Down Expand Up @@ -170,9 +168,6 @@ impl From<MeshPipelineKey> for MeshPipelineViewLayoutKey {
if value.contains(MeshPipelineKey::SCREEN_SPACE_REFLECTIONS) {
result |= MeshPipelineViewLayoutKey::SCREEN_SPACE_REFLECTIONS;
}
if value.intersects(MeshPipelineKey::SCREEN_SPACE_SPECULAR_TRANSMISSION_RESERVED_BITS) {
result |= MeshPipelineViewLayoutKey::SCREEN_SPACE_TRANSMISSION;
}
if value.contains(MeshPipelineKey::CONTACT_SHADOWS) {
result |= MeshPipelineViewLayoutKey::CONTACT_SHADOWS;
}
Expand Down Expand Up @@ -408,16 +403,14 @@ fn layout_entries(
}
}

if layout_key.contains(MeshPipelineViewLayoutKey::SCREEN_SPACE_TRANSMISSION) {
// View Transmission Texture
entries = entries.extend_with_indices((
(
25,
texture_2d(TextureSampleType::Float { filterable: true }),
),
(26, sampler(SamplerBindingType::Filtering)),
));
}
// View Transmission Texture
entries = entries.extend_with_indices((
(
25,
texture_2d(TextureSampleType::Float { filterable: true }),
),
(26, sampler(SamplerBindingType::Filtering)),
));

// OIT
if layout_key.contains(MeshPipelineViewLayoutKey::OIT_ENABLED) {
Expand Down Expand Up @@ -649,7 +642,7 @@ pub fn prepare_mesh_view_bind_groups(
Option<&RenderViewLightProbes<EnvironmentMapLight>>,
Option<&RenderViewLightProbes<IrradianceVolume>>,
),
(Has<ExtractedAtmosphere>, Has<ScreenSpaceTransmission>),
Has<ExtractedAtmosphere>,
(
&ViewUniformOffset,
&ViewLightsUniformOffset,
Expand Down Expand Up @@ -728,7 +721,7 @@ pub fn prepare_mesh_view_bind_groups(
atmosphere_textures,
tonemapping,
(render_view_environment_maps, render_view_irradiance_volumes),
(has_atmosphere, has_transmission),
has_atmosphere,
(
view_uniform_offset,
view_lights_offset,
Expand Down Expand Up @@ -869,19 +862,16 @@ pub fn prepare_mesh_view_bind_groups(
entries = entries.extend_with_indices(((17, ssao_view),));
}

if has_transmission {
layout_key |= MeshPipelineViewLayoutKey::SCREEN_SPACE_TRANSMISSION;
let transmission_view = transmission_texture
.map(|transmission| &transmission.view)
.unwrap_or(&fallback_image_zero.texture_view);
let transmission_view = transmission_texture
.map(|transmission| &transmission.view)
.unwrap_or(&fallback_image_zero.texture_view);

let transmission_sampler = transmission_texture
.map(|transmission| &transmission.sampler)
.unwrap_or(&fallback_image_zero.sampler);
let transmission_sampler = transmission_texture
.map(|transmission| &transmission.sampler)
.unwrap_or(&fallback_image_zero.sampler);

entries = entries
.extend_with_indices(((25, transmission_view), (26, transmission_sampler)));
}
entries =
entries.extend_with_indices(((25, transmission_view), (26, transmission_sampler)));

// When using WebGL, we can't have a multisampled texture with `TEXTURE_BINDING`
// See https://github.com/gfx-rs/wgpu/issues/5263
Expand Down
2 changes: 0 additions & 2 deletions crates/bevy_pbr/src/render/mesh_view_bindings.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,8 @@ const VISIBILITY_RANGE_UNIFORM_BUFFER_SIZE: u32 = 64u;
@group(0) @binding(24) var deferred_prepass_texture: texture_2d<u32>;
#endif // DEFERRED_PREPASS

#ifdef SCREEN_SPACE_TRANSMISSION
@group(0) @binding(25) var view_transmission_texture: texture_2d<f32>;
@group(0) @binding(26) var view_transmission_sampler: sampler;
#endif

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