mirror of
https://github.com/bevyengine/bevy
synced 2024-11-14 00:47:32 +00:00
83a358bf33
# Objective - The current shader code is misleading since it makes it look like a struct is passed to the bind group 0 but in reality only the color is passed. They just happen to have the exact same memory layout so wgsl doesn't complain and it works. - The struct is defined after the `impl Material` block which is backwards from pretty much every other usage of the `impl` block in bevy. ## Solution - Remove the unnecessary struct in the shader - move the impl block
14 lines
578 B
WebGPU Shading Language
14 lines
578 B
WebGPU Shading Language
#import bevy_pbr::forward_io::VertexOutput
|
|
// we can import items from shader modules in the assets folder with a quoted path
|
|
#import "shaders/custom_material_import.wgsl"::COLOR_MULTIPLIER
|
|
|
|
@group(1) @binding(0) var<uniform> material_color: vec4<f32>;
|
|
@group(1) @binding(1) var material_color_texture: texture_2d<f32>;
|
|
@group(1) @binding(2) var material_color_sampler: sampler;
|
|
|
|
@fragment
|
|
fn fragment(
|
|
mesh: VertexOutput,
|
|
) -> @location(0) vec4<f32> {
|
|
return material_color * textureSample(material_color_texture, material_color_sampler, mesh.uv) * COLOR_MULTIPLIER;
|
|
}
|