wgpu-renderer/res/shaders/globals.wgsl

54 lines
1.4 KiB
WebGPU Shading Language

// 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>,
matrices: array<mat4x4<f32>, 6>,
}
@group(1) @binding(0)
var<uniform> light: Light;
@group(1) @binding(1)
var<uniform> light_matrix_index: u32;
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>,
@location(4) world_position: vec4<f32>,
}
// Fragment shader
@group(1)@binding(2)
var t_light_depth: binding_array<texture_depth_2d>;
@group(1) @binding(3)
var s_light_depth: binding_array<sampler_comparison>;