You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
@group(0) @binding(0) var<uniform> view_proj_matrix: mat4x4<f32>; |
|
|
|
|
|
@group(1) @binding(0) var texture_sampler: sampler; |
|
@group(1) @binding(1) var model_texture: texture_2d<f32>; |
|
@group(1) @binding(2) var<uniform> model_matrix: mat4x4<f32>; |
|
@group(1) @binding(3) var<uniform> model_color: vec3<f32>; |
|
|
|
struct VertexInput { |
|
@location(0) position: vec3<f32>, |
|
@location(1) uv: vec2<f32>, |
|
}; |
|
|
|
struct VertexOutput { |
|
@builtin(position) position: vec4<f32>, |
|
@location(0) color: vec4<f32>, |
|
@location(1) frag_uv: vec2<f32>, |
|
}; |
|
|
|
struct FragmentOutput { |
|
@location(0) pixel_color: vec4<f32> |
|
}; |
|
|
|
@vertex fn vertex_main(in: VertexInput) -> VertexOutput { |
|
var out: VertexOutput; |
|
let mvp = model_matrix * view_proj_matrix; |
|
out.position = vec4<f32>(in.position, 1.0) * mvp; |
|
out.color = vec4<f32>(model_color, 1.0); |
|
out.frag_uv = in.uv; |
|
return out; |
|
} |
|
|
|
@fragment fn frag_main(in: VertexOutput) -> FragmentOutput { |
|
var out: FragmentOutput; |
|
let texture_color = textureSample(model_texture, texture_sampler, in.frag_uv); |
|
out.pixel_color = texture_color * in.color; |
|
return out; |
|
}
|
|
|