WIP shadowmapping
This commit is contained in:
parent
2fdae1a23a
commit
ac67a3d4de
9 changed files with 270 additions and 122 deletions
|
@ -1,43 +1,26 @@
|
|||
// Vertex shader
|
||||
#include globals.wgsl
|
||||
|
||||
struct Camera {
|
||||
view: mat4x4<f32>,
|
||||
proj: mat4x4<f32>,
|
||||
position: vec4<f32>,
|
||||
}
|
||||
@group(0) @binding(0)
|
||||
var<uniform> camera: Camera;
|
||||
|
||||
struct Light {
|
||||
position: vec3<f32>,
|
||||
color: vec3<f32>,
|
||||
}
|
||||
@group(1) @binding(0)
|
||||
var<uniform> light: Light;
|
||||
|
||||
struct VertexInput {
|
||||
struct LightVertexInput {
|
||||
@location(0) position: vec3<f32>,
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
struct LightVertexOutput {
|
||||
@builtin(position) clip_position: vec4<f32>,
|
||||
@location(0) color: vec3<f32>,
|
||||
};
|
||||
|
||||
@vertex
|
||||
fn vs_main(
|
||||
model: VertexInput,
|
||||
) -> VertexOutput {
|
||||
model: LightVertexInput,
|
||||
) -> LightVertexOutput {
|
||||
let scale = 10.0;
|
||||
var out: VertexOutput;
|
||||
var out: LightVertexOutput;
|
||||
out.clip_position = camera.proj * camera.view * vec4<f32>(model.position * scale + light.position, 1.0);
|
||||
out.color = light.color;
|
||||
out.color = light.color.xyz;
|
||||
return out;
|
||||
}
|
||||
|
||||
// Fragment shader
|
||||
|
||||
@fragment
|
||||
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
fn fs_main(in: LightVertexOutput) -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(in.color, 1.0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue