44 lines
1.2 KiB
WebGPU Shading Language
44 lines
1.2 KiB
WebGPU Shading Language
#import bevy_pbr::{
|
|
mesh_functions,
|
|
forward_io::{VertexOutput, Vertex}
|
|
}
|
|
|
|
// struct Vertex {
|
|
// @builtin(instance_index) instance_index: u32,
|
|
// @location(0) position: vec3<f32>,
|
|
// @location(1) normal: vec3<f32>,
|
|
// @location(2) color: vec4<f32>,
|
|
// }
|
|
|
|
// struct VertexOutput {
|
|
// @builtin(position) position: vec4<f32>,
|
|
// @location(0) world_position: vec4<f32>,
|
|
// @location(1) @interpolate(flat) world_normal: vec3<f32>,
|
|
// @location(2) @interpolate(flat) color: vec4<f32>,
|
|
// @location(3) @interpolate(flat) instance_index: u32,
|
|
// }
|
|
|
|
@vertex
|
|
fn vertex(vert: Vertex) -> VertexOutput {
|
|
var out: VertexOutput;
|
|
|
|
let mesh_world_from_local = mesh_functions::get_world_from_local(vert.instance_index);
|
|
|
|
out.world_normal = mesh_functions::mesh_normal_local_to_world(
|
|
vert.normal,
|
|
vert.instance_index
|
|
);
|
|
|
|
out.world_position = mesh_functions::mesh_position_local_to_world(mesh_world_from_local, vec4<f32>(vert.position, 1.0));
|
|
out.position = position_world_to_clip(out.world_position.xyz);
|
|
|
|
out.instance_index = vert.instance_index;
|
|
out.color = vert.color;
|
|
|
|
return out
|
|
}
|
|
|
|
// @fragment
|
|
// fn fragment(
|
|
// vertex_outpu
|
|
// ) |