-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Render Debug Overlay #22412
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
Merged
alice-i-cecile
merged 24 commits into
bevyengine:main
from
aevyrie:render-debug-overlay
Jan 17, 2026
Merged
Render Debug Overlay #22412
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
d5d321f
impl overlay
aevyrie 88d3aa2
Cleanup
aevyrie b4b9dfa
Remove example
aevyrie b8cd5f8
Merge remote-tracking branch 'origin/main' into render-debug-overlay
aevyrie 6958c53
Merge remote-tracking branch 'origin/main' into render-debug-overlay
aevyrie 108f067
Add better deferred support
aevyrie 86e88e0
Review feedback
aevyrie 4f0bc59
Fix race condition with opacity setting, tweak alpha values
aevyrie d7aa59d
Clean up comments
aevyrie b599fbe
Lints
aevyrie f52290d
Use unmodified depth, format shader.
aevyrie 1bb0f8c
Update features
aevyrie ad331c8
Update features
aevyrie 49047c4
Merge branch 'main' into render-debug-overlay
aevyrie 6befba1
Merge branch 'main' into render-debug-overlay
aevyrie e62909d
Fix doc comment mistake from factoring out keybinds.
aevyrie 5144686
Formatting
aevyrie acc7b31
Merge branch 'main' into render-debug-overlay
aevyrie 9792356
Move render debug to dev tools, fix a texture format issue
aevyrie a3f9af0
Merge branch 'main' into render-debug-overlay
aevyrie 7f1de3d
Mix merge issue
aevyrie 6645454
Fix merge
aevyrie 34257a0
Fix runtime crashes in some feature configuratinos
aevyrie 9967580
Fix if collapse lint
aevyrie 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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| [package] | ||
| name = "bevy_render_debug" | ||
| version = "0.18.0-dev" | ||
| edition = "2024" | ||
| description = "Adds debug visualization to Bevy Engine" | ||
| homepage = "https://bevy.org" | ||
| repository = "https://github.com/bevyengine/bevy" | ||
| license = "MIT OR Apache-2.0" | ||
| keywords = ["bevy"] | ||
|
|
||
| [dependencies] | ||
| bevy_app = { path = "../bevy_app", version = "0.18.0-dev" } | ||
| bevy_asset = { path = "../bevy_asset", version = "0.18.0-dev" } | ||
| bevy_core_pipeline = { path = "../bevy_core_pipeline", version = "0.18.0-dev" } | ||
| bevy_ecs = { path = "../bevy_ecs", version = "0.18.0-dev" } | ||
| bevy_image = { path = "../bevy_image", version = "0.18.0-dev" } | ||
| bevy_input = { path = "../bevy_input", version = "0.18.0-dev" } | ||
| bevy_log = { path = "../bevy_log", version = "0.18.0-dev" } | ||
| bevy_pbr = { path = "../bevy_pbr", version = "0.18.0-dev" } | ||
| bevy_reflect = { path = "../bevy_reflect", version = "0.18.0-dev" } | ||
| bevy_render = { path = "../bevy_render", version = "0.18.0-dev" } | ||
| bevy_shader = { path = "../bevy_shader", version = "0.18.0-dev" } | ||
| bevy_camera = { path = "../bevy_camera", version = "0.18.0-dev" } | ||
|
|
||
| [lints] | ||
| workspace = true |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| #import bevy_pbr::mesh_view_bindings::view | ||
| #import bevy_pbr::mesh_view_bindings::depth_prepass_texture | ||
| #import bevy_pbr::mesh_view_bindings::normal_prepass_texture | ||
| #import bevy_pbr::mesh_view_bindings::motion_vector_prepass_texture | ||
| #import bevy_pbr::mesh_view_bindings::deferred_prepass_texture | ||
| #import bevy_pbr::view_transformations::depth_ndc_to_view_z | ||
|
|
||
| struct DebugBufferConfig { | ||
| opacity: f32, | ||
| mip_level: u32, | ||
| } | ||
|
|
||
| @group(1) @binding(0) var<uniform> config: DebugBufferConfig; | ||
|
|
||
| #ifdef DEBUG_DEPTH_PYRAMID | ||
| @group(1) @binding(1) var depth_pyramid_texture: texture_2d<f32>; | ||
| @group(1) @binding(2) var depth_pyramid_sampler: sampler; | ||
| #endif | ||
|
|
||
| @fragment | ||
| fn fragment(@builtin(position) frag_coord: vec4<f32>) -> @location(0) vec4<f32> { | ||
| let uv = frag_coord.xy / view.viewport.zw; | ||
| var output_color: vec4<f32> = vec4(0.0); | ||
|
|
||
| #ifdef DEBUG_DEPTH | ||
| #ifdef DEPTH_PREPASS | ||
| let depth = textureLoad(depth_prepass_texture, vec2<i32>(frag_coord.xy), 0); | ||
| // Linearize depth for visualization | ||
| let linearized_depth = -depth_ndc_to_view_z(depth); | ||
| // Use a reasonable range for visualization, e.g. 0 to 20 units | ||
| output_color = vec4(vec3(linearized_depth / 20.0), 1.0); | ||
| #else | ||
| output_color = vec4(1.0, 0.0, 1.0, 1.0); | ||
| #endif | ||
| #endif | ||
|
|
||
| #ifdef DEBUG_NORMAL | ||
| #ifdef NORMAL_PREPASS | ||
| let normal_sample = textureLoad(normal_prepass_texture, vec2<i32>(frag_coord.xy), 0); | ||
| output_color = vec4(normal_sample.xyz, 1.0); | ||
| #else | ||
| output_color = vec4(1.0, 0.0, 1.0, 1.0); | ||
| #endif | ||
| #endif | ||
|
|
||
| #ifdef DEBUG_MOTION_VECTORS | ||
| #ifdef MOTION_VECTOR_PREPASS | ||
| let motion_vector = textureLoad(motion_vector_prepass_texture, vec2<i32>(frag_coord.xy), 0).rg; | ||
| // These motion vectors are stored in a format where 1.0 represents full-screen movement. | ||
| // We use a power curve to amplify small movements while keeping them centered. | ||
| let mapped_motion = sign(motion_vector) * pow(abs(motion_vector), vec2(0.2)) * 0.5 + 0.5; | ||
| output_color = vec4(mapped_motion, 0.5, 1.0); | ||
| #else | ||
| output_color = vec4(1.0, 0.0, 1.0, 1.0); | ||
| #endif | ||
| #endif | ||
|
|
||
| #ifdef DEBUG_DEFERRED | ||
| #ifdef DEFERRED_PREPASS | ||
| let deferred = textureLoad(deferred_prepass_texture, vec2<i32>(frag_coord.xy), 0); | ||
| // Just show raw bits as colors for now | ||
| output_color = vec4(vec3(f32(deferred.x) / 255.0, f32(deferred.y) / 255.0, f32(deferred.z) / 255.0), 1.0); | ||
| #else | ||
| output_color = vec4(1.0, 0.0, 1.0, 1.0); | ||
| #endif | ||
| #endif | ||
|
|
||
| #ifdef DEBUG_DEPTH_PYRAMID | ||
| let depth_pyramid = textureSampleLevel(depth_pyramid_texture, depth_pyramid_sampler, uv, f32(config.mip_level)).r; | ||
| output_color = vec4(vec3(depth_pyramid), 1.0); | ||
| #endif | ||
|
|
||
| return vec4(output_color.rgb, output_color.a * config.opacity); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.