
# Objective assets v2 broke custom shader imports. fix them ## Solution store handles of any file dependencies in the `Shader` to avoid them being immediately dropped. also added a use into the `shader_material` example so that it'll be harder to break support in future.
19 lines
625 B
WebGPU Shading Language
19 lines
625 B
WebGPU Shading Language
#import bevy_pbr::mesh_vertex_output MeshVertexOutput
|
|
// we can import items from shader modules in the assets folder with a quoted path
|
|
#import "shaders/custom_material_import.wgsl" COLOR_MULTIPLIER
|
|
|
|
struct CustomMaterial {
|
|
color: vec4<f32>,
|
|
};
|
|
|
|
@group(1) @binding(0) var<uniform> material: CustomMaterial;
|
|
@group(1) @binding(1) var base_color_texture: texture_2d<f32>;
|
|
@group(1) @binding(2) var base_color_sampler: sampler;
|
|
|
|
@fragment
|
|
fn fragment(
|
|
mesh: MeshVertexOutput,
|
|
) -> @location(0) vec4<f32> {
|
|
return material.color * textureSample(base_color_texture, base_color_sampler, mesh.uv) * COLOR_MULTIPLIER;
|
|
}
|