39 lines
852 B
WebGPU Shading Language
39 lines
852 B
WebGPU Shading Language
|
struct InstanceInput {
|
||
|
@location(2) transform_matrix_0: vec4<f32>,
|
||
|
@location(3) transform_matrix_1: vec4<f32>,
|
||
|
@location(4) transform_matrix_2: vec4<f32>,
|
||
|
@location(5) transform_matrix_3: vec4<f32>,
|
||
|
};
|
||
|
|
||
|
// Vertex shader
|
||
|
|
||
|
struct VertexInput {
|
||
|
@location(0) position: vec3<f32>,
|
||
|
}
|
||
|
|
||
|
struct VertexOutput {
|
||
|
@builtin(position) clip_position: vec4<f32>,
|
||
|
}
|
||
|
|
||
|
@vertex
|
||
|
fn vertex_shader_main(
|
||
|
model: VertexInput,
|
||
|
instance: InstanceInput,
|
||
|
) -> VertexOutput {
|
||
|
let transform_matrix = mat4x4<f32>(
|
||
|
instance.transform_matrix_0,
|
||
|
instance.transform_matrix_1,
|
||
|
instance.transform_matrix_2,
|
||
|
instance.transform_matrix_3,
|
||
|
);
|
||
|
|
||
|
var out: VertexOutput;
|
||
|
out.clip_position = transform_matrix * vec4<f32>(model.position, 1.0);
|
||
|
return out;
|
||
|
}
|
||
|
|
||
|
|
||
|
@fragment
|
||
|
fn fragment_shader_main(in: VertexOutput) -> @location(0) vec4<f32> {
|
||
|
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||
|
}
|