-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Allow custom depth texture usage #6815
Merged
cart
merged 7 commits into
bevyengine:main
from
Neo-Zhixing:feat/depth-texture-usage-config
May 8, 2023
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7d10fbb
Allow custom depth texture usage
Neo-Zhixing 0b829ee
Merge branch 'main' into feat/depth-texture-usage-config
Neo-Zhixing 2a62c97
fixes
Neo-Zhixing 1a2ac99
Update mod.rs
Neo-Zhixing b2a4d77
Update mod.rs
Neo-Zhixing f1d4a30
Merge branch 'main' into feat/depth-texture-usage-config
Neo-Zhixing 2322135
Fix depth prepass
Neo-Zhixing File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,21 +8,47 @@ use bevy_render::{ | |
camera::{Camera, CameraRenderGraph, Projection}, | ||
extract_component::ExtractComponent, | ||
primitives::Frustum, | ||
render_resource::LoadOp, | ||
render_resource::{LoadOp, TextureUsages}, | ||
view::{ColorGrading, VisibleEntities}, | ||
}; | ||
use bevy_transform::prelude::{GlobalTransform, Transform}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Configuration for the "main 3d render graph". | ||
#[derive(Component, Reflect, Clone, Default, ExtractComponent)] | ||
#[derive(Component, Reflect, Clone, ExtractComponent)] | ||
#[extract_component_filter(With<Camera>)] | ||
#[reflect(Component)] | ||
pub struct Camera3d { | ||
/// The clear color operation to perform for the main 3d pass. | ||
pub clear_color: ClearColorConfig, | ||
/// The depth clear operation to perform for the main 3d pass. | ||
pub depth_load_op: Camera3dDepthLoadOp, | ||
/// The texture usages for the depth texture created for the main 3d pass. | ||
pub depth_texture_usages: Camera3dDepthTextureUsage, | ||
} | ||
|
||
impl Default for Camera3d { | ||
fn default() -> Self { | ||
Self { | ||
clear_color: ClearColorConfig::Default, | ||
depth_load_op: Default::default(), | ||
depth_texture_usages: TextureUsages::RENDER_ATTACHMENT.into(), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Clone, Copy, Reflect)] | ||
pub struct Camera3dDepthTextureUsage(u32); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Creating a custom class to wrap the |
||
|
||
impl From<TextureUsages> for Camera3dDepthTextureUsage { | ||
fn from(value: TextureUsages) -> Self { | ||
Self(value.bits()) | ||
} | ||
} | ||
impl From<Camera3dDepthTextureUsage> for TextureUsages { | ||
fn from(value: Camera3dDepthTextureUsage) -> Self { | ||
Self::from_bits_truncate(value.0) | ||
} | ||
} | ||
|
||
/// The depth clear operation to perform for the main 3d pass. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if I set a value without
TextureUsages::RENDER_ATTACHMENT
here? Should we consider it's present even if the user didn't set it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo the user should be allowed to set a value without
TextureUsages::RENDER_ATTACHMENT
. If they explicitly opted out of theRENDER_ATTACHMENT
usage, there's probably a reason for it.