2021-07-29 18:05:19 +00:00
|
|
|
struct PointLight {
|
|
|
|
position : vec4<f32>;
|
2022-01-19 18:11:17 +00:00
|
|
|
}
|
2021-07-29 18:05:19 +00:00
|
|
|
|
|
|
|
struct PointLights {
|
2022-01-20 22:11:07 +00:00
|
|
|
values : array<PointLight>;
|
2022-01-19 18:11:17 +00:00
|
|
|
}
|
2021-07-29 18:05:19 +00:00
|
|
|
|
|
|
|
struct Uniforms {
|
|
|
|
worldView : mat4x4<f32>;
|
|
|
|
proj : mat4x4<f32>;
|
|
|
|
numPointLights : u32;
|
|
|
|
color_source : u32;
|
|
|
|
color : vec4<f32>;
|
2022-01-19 18:11:17 +00:00
|
|
|
}
|
2021-07-29 18:05:19 +00:00
|
|
|
|
2022-01-19 22:46:57 +00:00
|
|
|
@binding(0) @group(0) var<uniform> uniforms : Uniforms;
|
2021-07-29 18:05:19 +00:00
|
|
|
|
2022-01-19 22:46:57 +00:00
|
|
|
@binding(1) @group(0) var<storage, read> pointLights : PointLights;
|
2021-07-29 18:05:19 +00:00
|
|
|
|
2022-01-19 22:46:57 +00:00
|
|
|
@binding(2) @group(0) var mySampler : sampler;
|
2021-07-29 18:05:19 +00:00
|
|
|
|
2022-01-19 22:46:57 +00:00
|
|
|
@binding(3) @group(0) var myTexture : texture_2d<f32>;
|
2021-07-29 18:05:19 +00:00
|
|
|
|
|
|
|
struct FragmentInput {
|
2022-01-19 22:46:57 +00:00
|
|
|
@builtin(position)
|
2021-07-29 18:05:19 +00:00
|
|
|
position : vec4<f32>;
|
2022-01-19 22:46:57 +00:00
|
|
|
@location(0)
|
2021-07-29 18:05:19 +00:00
|
|
|
view_position : vec4<f32>;
|
2022-01-19 22:46:57 +00:00
|
|
|
@location(1)
|
2021-07-29 18:05:19 +00:00
|
|
|
normal : vec4<f32>;
|
2022-01-19 22:46:57 +00:00
|
|
|
@location(2)
|
2021-07-29 18:05:19 +00:00
|
|
|
uv : vec2<f32>;
|
2022-01-19 22:46:57 +00:00
|
|
|
@location(3)
|
2021-07-29 18:05:19 +00:00
|
|
|
color : vec4<f32>;
|
2022-01-19 18:11:17 +00:00
|
|
|
}
|
2021-07-29 18:05:19 +00:00
|
|
|
|
|
|
|
struct FragmentOutput {
|
2022-01-19 22:46:57 +00:00
|
|
|
@location(0)
|
2021-07-29 18:05:19 +00:00
|
|
|
color : vec4<f32>;
|
2022-01-19 18:11:17 +00:00
|
|
|
}
|
2021-07-29 18:05:19 +00:00
|
|
|
|
|
|
|
fn getColor(fragment : FragmentInput) -> vec4<f32> {
|
|
|
|
var color : vec4<f32>;
|
|
|
|
if ((uniforms.color_source == 0u)) {
|
|
|
|
color = fragment.color;
|
2022-01-04 20:06:49 +00:00
|
|
|
} else if ((uniforms.color_source == 1u)) {
|
2021-07-29 18:05:19 +00:00
|
|
|
color = fragment.normal;
|
|
|
|
color.a = 1.0;
|
2022-01-04 20:06:49 +00:00
|
|
|
} else if ((uniforms.color_source == 2u)) {
|
2021-07-29 18:05:19 +00:00
|
|
|
color = uniforms.color;
|
2022-01-04 20:06:49 +00:00
|
|
|
} else if ((uniforms.color_source == 3u)) {
|
2021-07-29 18:05:19 +00:00
|
|
|
color = textureSample(myTexture, mySampler, fragment.uv);
|
|
|
|
}
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
2022-01-19 22:46:57 +00:00
|
|
|
@stage(fragment)
|
2021-07-29 18:05:19 +00:00
|
|
|
fn main(fragment : FragmentInput) -> FragmentOutput {
|
|
|
|
var output : FragmentOutput;
|
|
|
|
output.color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
2021-10-22 00:21:44 +00:00
|
|
|
_ = uniforms;
|
|
|
|
_ = mySampler;
|
|
|
|
_ = myTexture;
|
|
|
|
_ = &(pointLights);
|
2021-07-29 18:05:19 +00:00
|
|
|
return output;
|
|
|
|
}
|