2023-01-29 18:57:29 +02:00
|
|
|
// Vertex shader
|
|
|
|
|
|
|
|
struct CameraUniform {
|
|
|
|
view: mat4x4<f32>,
|
|
|
|
proj: mat4x4<f32>,
|
2023-11-08 21:35:53 +02:00
|
|
|
inv_view_proj: mat4x4<f32>,
|
2023-01-29 18:57:29 +02:00
|
|
|
position: vec4<f32>,
|
2023-11-09 21:04:59 +02:00
|
|
|
planes: vec4<f32>,
|
2023-01-29 18:57:29 +02:00
|
|
|
}
|
|
|
|
@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
|
|
|
}
|
2023-11-10 19:38:12 +02:00
|
|
|
@group(0) @binding(1)
|
2023-01-29 18:57:29 +02:00
|
|
|
var<uniform> light: Light;
|
|
|
|
|
2023-11-05 02:27:38 +02:00
|
|
|
struct GlobalUniforms {
|
2023-11-08 21:35:53 +02:00
|
|
|
time: f32,
|
2023-11-05 02:27:38 +02:00
|
|
|
light_matrix_index: u32,
|
|
|
|
use_shadowmaps: u32,
|
2023-11-08 21:35:53 +02:00
|
|
|
_padding: u32,
|
2023-11-05 00:16:34 +02:00
|
|
|
}
|
2023-11-10 19:38:12 +02:00
|
|
|
@group(0) @binding(2)
|
2023-11-05 02:27:38 +02:00
|
|
|
var<uniform> global_uniforms: GlobalUniforms;
|
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
|
|
|
}
|