Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write to depth buffer in alpha mask mode #305

Merged
merged 1 commit into from
Mar 19, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The following modifiers' `via_property()` function now takes a `PropertyHandle` instead of a property name: `AccelModifier`, `RadialAccelModifier`, `TangentAccelModifier`.
- `Expr` is now `Copy`, making it even more lightweight.
- `ExprWriter::prop()` now panics if the property doesn't exist. This ensures the created `WriterExpr` is well-formed, which was impossible to validate at expression write time previously.
- Effects rendered with `AlphaMode::Mask` now write to the depth buffer. Other effects continue to not write to it. This fixes particle flickering for alpha masked effects only.

### Removed

Expand All @@ -54,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixed a panic in rendering randomly occurring when no effect is present.
- Fixed invalid WGSL being generated for large `u32` values.
- Fixed particle flickering, only for particles rendered through the `AlphaMask3d` render pass (`EffectAsset::alpha_mode == AlphaMode::Mask`). (#183)

## [0.10.0] 2024-02-24

Expand Down
6 changes: 4 additions & 2 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,8 @@ impl SpecializedRenderPipeline for ParticlesRenderPipeline {
PipelineMode::Camera2d => None,
PipelineMode::Camera3d => Some(DepthStencilState {
format: TextureFormat::Depth32Float,
depth_write_enabled: false,
// Use depth buffer with alpha-masked particles, not with transparent ones
depth_write_enabled: key.use_alpha_mask,
// Bevy uses reverse-Z, so Greater really means closer
depth_compare: CompareFunction::Greater,
stencil: StencilState::default(),
Expand All @@ -1198,7 +1199,8 @@ impl SpecializedRenderPipeline for ParticlesRenderPipeline {
#[cfg(all(feature = "3d", not(feature = "2d")))]
let depth_stencil = Some(DepthStencilState {
format: TextureFormat::Depth32Float,
depth_write_enabled: false,
// Use depth buffer with alpha-masked particles, not with transparent ones
depth_write_enabled: key.use_alpha_mask,
// Bevy uses reverse-Z, so Greater really means closer
depth_compare: CompareFunction::Greater,
stencil: StencilState::default(),
Expand Down
Loading