forked from bevyengine/bevy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Globals and View structs into separate shaders (bevyengine#7512
) fixes bevyengine#6799 We should be able to reuse the `Globals` or `View` shader struct definitions from anywhere (including third party plugins) without needing to worry about defining unrelated shader defs. Also we'd like to refactor these structs to not be repeatedly defined. Refactor both `Globals` and `View` into separate importable shaders. Use the imports throughout. Co-Authored-By: Torstein Grindvik <52322338+torsteingrindvik@users.noreply.github.com>
- Loading branch information
1 parent
ea58451
commit 09591d3
Showing
10 changed files
with
69 additions
and
77 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#define_import_path bevy_render::globals | ||
|
||
struct Globals { | ||
// The time since startup in seconds | ||
// Wraps to 0 after 1 hour. | ||
time: f32, | ||
// The delta time since the previous frame in seconds | ||
delta_time: f32, | ||
// Frame count since the start of the app. | ||
// It wraps to zero when it reaches the maximum value of a u32. | ||
frame_count: u32, | ||
#ifdef SIXTEEN_BYTE_ALIGNMENT | ||
// WebGL2 structs must be 16 byte aligned. | ||
_webgl2_padding: f32 | ||
#endif | ||
}; |
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
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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#define_import_path bevy_render::globals | ||
|
||
struct Globals { | ||
// The time since startup in seconds | ||
// Wraps to 0 after 1 hour. | ||
time: f32, | ||
// The delta time since the previous frame in seconds | ||
delta_time: f32, | ||
// Frame count since the start of the app. | ||
// It wraps to zero when it reaches the maximum value of a u32. | ||
frame_count: u32, | ||
#ifdef SIXTEEN_BYTE_ALIGNMENT | ||
// WebGL2 structs must be 16 byte aligned. | ||
_webgl2_padding: f32 | ||
#endif | ||
}; |
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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#define_import_path bevy_render::view | ||
|
||
struct View { | ||
view_proj: mat4x4<f32>, | ||
inverse_view_proj: mat4x4<f32>, | ||
view: mat4x4<f32>, | ||
inverse_view: mat4x4<f32>, | ||
projection: mat4x4<f32>, | ||
inverse_projection: mat4x4<f32>, | ||
world_position: vec3<f32>, | ||
// viewport(x_origin, y_origin, width, height) | ||
viewport: vec4<f32>, | ||
}; |
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 |
---|---|---|
@@ -1,28 +1,4 @@ | ||
#define_import_path bevy_sprite::mesh2d_view_types | ||
|
||
struct View { | ||
view_proj: mat4x4<f32>, | ||
inverse_view_proj: mat4x4<f32>, | ||
view: mat4x4<f32>, | ||
inverse_view: mat4x4<f32>, | ||
projection: mat4x4<f32>, | ||
inverse_projection: mat4x4<f32>, | ||
world_position: vec3<f32>, | ||
// viewport(x_origin, y_origin, width, height) | ||
viewport: vec4<f32>, | ||
}; | ||
|
||
struct Globals { | ||
// The time since startup in seconds | ||
// Wraps to 0 after 1 hour. | ||
time: f32, | ||
// The delta time since the previous frame in seconds | ||
delta_time: f32, | ||
// Frame count since the start of the app. | ||
// It wraps to zero when it reaches the maximum value of a u32. | ||
frame_count: u32, | ||
#ifdef SIXTEEN_BYTE_ALIGNMENT | ||
// WebGL2 structs must be 16 byte aligned. | ||
_wasm_padding: f32 | ||
#endif | ||
} | ||
#import bevy_render::view | ||
#import bevy_render::globals |
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
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