bevyengine / bevyengine/bevy

Allow more operations on the 3D View depth buffer texture

Open
#3,790 4 comments 3 reactions 0 assignees View on GitHub
A-Rendering C-Feature
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

Some post-processing or rendering effects want to be able to read from the depth buffer of previous render passes as a texture.
Currently in `prepre_core_views_system()` the "view_depth_texture" is only marked with the usage `TextureUsages::RENDER_ATTACHMENT` so it cannot be used be used either as a the source of a Texture-Texture copy or as a Texture directly.

## What solution would you like?

I think the best solution would be to add `TextureUsages::COPY_SRC` to the "view_depth_texture".
Users who want texture access to the depth buffer can copy the buffer off to their own texture and use that texture as a sampling source.

## What alternative(s) have you considered?

An alternative would be to add `TextureUsages::TEXTURE_BINDING` and allow users to directly bind the depth texture.
The downside of this configuration is that you cannot use the depth texture as both a render attachment and a texture at the same time.
This prevents some rendering configurations which want to write new meshes with correct depth filtering while using the depth of the previous pass as part of the calculation (eg water shaders).

## Additional context

This would need #3776 to be resolved and probably also wants to be implemented in concert with #3552.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.