bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Start Revive of Depth Prepass

Open ChristopherBiscardi opened this issue 1 year ago • 1 comments

reviving: 9262c8f (#3072)

temp link to original discord thread: https://discord.com/channels/691052431525675048/1002129015936655361/1002480744360317008

Objective

Adds a depth pre-pass so that custom materials can access the depth buffer data when implementing effects such as drawing the intersection of an opaque and an alpha-blended object on the alpha blended object.

Solution

  • Describe the solution used to achieve the objective above.

Changelog

This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section.

  • What changed as a result of this PR?
  • If applicable, organize changes under "Added", "Changed", or "Fixed" sub-headings
  • Stick to one or two sentences. If more detail is needed for a particular change, consider adding it to the "Solution" section
    • If you can't summarize the work, your change may be unreasonably large / unrelated. Consider splitting your PR to make it easier to review and merge!

Migration Guide

This section is optional. If there are no breaking changes, you can delete this section.

  • If this PR is a breaking change (relative to the last release of Bevy), describe how a user might need to migrate their code to support these changes
  • Simply adding new functionality is not a breaking change.
  • Fixing behavior that was definitely a bug, rather than a questionable design choice is not a breaking change.

ChristopherBiscardi avatar Aug 01 '22 08:08 ChristopherBiscardi

solved

~~Current issue is that I'm not sure if the RenderAsset trait should be implemented for StandardMaterial.~~

error[E0277]: the trait bound `pbr_material::StandardMaterial: RenderAsset` is not satisfied
   --> crates/bevy_pbr/src/render/depth_prepass.rs:415:27
    |
415 |     render_materials: Res<RenderAssets<StandardMaterial>>,
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `RenderAsset` is not implemented for `pbr_material::StandardMaterial`
    |
    = help: the following other types implement trait `RenderAsset`:
              Mesh
              bevy_render::texture::Image

Fixed with:

pub fn queue_depth_prepass_meshes<M: Material>(
    ...
    render_materials: Res<RenderMaterials<M>>,
)

ChristopherBiscardi avatar Aug 01 '22 08:08 ChristopherBiscardi

The PR is almost compiling.

Two major outstanding issues are accessing the active 3d camera (ActiveCameras was removed in https://github.com/bevyengine/bevy/pull/4745) and some material related api changes since the original depth prepass pr used StandardMaterial and now we have the Material trait.

ChristopherBiscardi avatar Aug 17 '22 21:08 ChristopherBiscardi

@superdump said they're choosing to pursue a different approach, so closing this.

ChristopherBiscardi avatar Aug 22 '22 19:08 ChristopherBiscardi