2023-01-29 18:57:29 +02:00
|
|
|
// Vertex shader
|
|
|
|
|
|
|
|
struct CameraUniform {
|
|
|
|
view: mat4x4<f32>,
|
|
|
|
proj: mat4x4<f32>,
|
|
|
|
position: vec4<f32>,
|
|
|
|
}
|
|
|
|
@group(0) @binding(0)
|
|
|
|
var<uniform> camera: CameraUniform;
|
|
|
|
|
|
|
|
struct Light {
|
|
|
|
position: vec3<f32>,
|
|
|
|
color: vec4<f32>,
|
2023-01-30 00:40:50 +02:00
|
|
|
matrices: array<mat4x4<f32>, 6>,
|
2023-01-29 18:57:29 +02:00
|
|
|
}
|
|
|
|
@group(1) @binding(0)
|
|
|
|
var<uniform> light: Light;
|
|
|
|
|
2023-11-05 00:16:34 +02:00
|
|
|
// Needs to be 16 bytes in WebGL
|
|
|
|
struct LightMatrixIndex {
|
|
|
|
value: u32,
|
|
|
|
_padding: u32,
|
|
|
|
_padding1: u32,
|
|
|
|
_padding2: u32,
|
|
|
|
}
|
2023-04-14 23:24:48 +03:00
|
|
|
@group(1) @binding(1)
|
2023-11-05 00:16:34 +02:00
|
|
|
var<uniform> light_matrix_index: LightMatrixIndex;
|
2023-04-14 23:24:48 +03:00
|
|
|
|
2023-01-29 18:57:29 +02:00
|
|
|
struct VertexInput {
|
|
|
|
@location(0) position: vec3<f32>,
|
|
|
|
@location(1) tex_coords: vec2<f32>,
|
|
|
|
@location(2) normal: vec3<f32>,
|
|
|
|
@location(3) tangent: vec3<f32>,
|
|
|
|
@location(4) bitangent: vec3<f32>,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct InstanceInput {
|
|
|
|
@location(5) model_matrix_0: vec4<f32>,
|
|
|
|
@location(6) model_matrix_1: vec4<f32>,
|
|
|
|
@location(7) model_matrix_2: vec4<f32>,
|
|
|
|
@location(8) model_matrix_3: vec4<f32>,
|
|
|
|
@location(9) normal_matrix_0: vec3<f32>,
|
|
|
|
@location(10) normal_matrix_1: vec3<f32>,
|
|
|
|
@location(11) normal_matrix_2: vec3<f32>,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct VertexOutput {
|
|
|
|
@builtin(position) clip_position: vec4<f32>,
|
|
|
|
@location(0) tex_coords: vec2<f32>,
|
|
|
|
@location(1) tangent_position: vec3<f32>,
|
|
|
|
@location(2) tangent_light_position: vec3<f32>,
|
|
|
|
@location(3) tangent_view_position: vec3<f32>,
|
2023-01-30 00:40:50 +02:00
|
|
|
@location(4) world_position: vec4<f32>,
|
2023-01-29 18:57:29 +02:00
|
|
|
}
|