Skip to content
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

Fix post_processing example on webgl2 #9361

Merged
merged 2 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assets/shaders/post_processing.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ var screen_texture: texture_2d<f32>;
var texture_sampler: sampler;
struct PostProcessSettings {
intensity: f32,
#ifdef SIXTEEN_BYTE_ALIGNMENT
// WebGL2 structs must be 16 byte aligned.
_webgl2_padding: vec3<f32>
#endif
}
@group(0) @binding(2)
var<uniform> settings: PostProcessSettings;
Expand Down
10 changes: 8 additions & 2 deletions examples/shader/post_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl FromWorld for PostProcessPipeline {
ty: BindingType::Buffer {
ty: bevy::render::render_resource::BufferBindingType::Uniform,
has_dynamic_offset: false,
min_binding_size: None,
min_binding_size: Some(PostProcessSettings::min_size()),
rparrett marked this conversation as resolved.
Show resolved Hide resolved
},
count: None,
},
Expand Down Expand Up @@ -338,6 +338,9 @@ impl FromWorld for PostProcessPipeline {
#[derive(Component, Default, Clone, Copy, ExtractComponent, ShaderType)]
struct PostProcessSettings {
intensity: f32,
// WebGL2 structs must be 16 byte aligned.
#[cfg(feature = "webgl2")]
_webgl2_padding: Vec3,
rparrett marked this conversation as resolved.
Show resolved Hide resolved
}

/// Set up a simple 3D scene
Expand All @@ -359,7 +362,10 @@ fn setup(
},
// Add the setting to the camera.
// This component is also used to determine on which camera to run the post processing effect.
PostProcessSettings { intensity: 0.02 },
PostProcessSettings {
intensity: 0.02,
..default()
},
));

// cube
Expand Down