Move all resources into res folder
This commit is contained in:
parent
2fb1a1dc7c
commit
4723cf513a
4 changed files with 3 additions and 3 deletions
Binary file not shown.
Before Width: | Height: | Size: 28 KiB |
BIN
src/pikachu.png
BIN
src/pikachu.png
Binary file not shown.
Before Width: | Height: | Size: 44 KiB |
|
@ -1,49 +0,0 @@
|
|||
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>;
|
||||
};
|
||||
|
||||
struct CameraUniform {
|
||||
view_proj: mat4x4<f32>;
|
||||
};
|
||||
[[group(1), binding(0)]]
|
||||
var<uniform> camera: CameraUniform;
|
||||
|
||||
struct VertexInput {
|
||||
[[location(0)]] position: vec3<f32>;
|
||||
[[location(1)]] tex_coords: vec2<f32>;
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
[[builtin(position)]] clip_position: vec4<f32>;
|
||||
[[location(0)]] tex_coords: vec2<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn vs_main(
|
||||
model: VertexInput,
|
||||
instance: InstanceInput,
|
||||
) -> VertexOutput {
|
||||
let model_matrix = mat4x4<f32>(
|
||||
instance.model_matrix_0,
|
||||
instance.model_matrix_1,
|
||||
instance.model_matrix_2,
|
||||
instance.model_matrix_3,
|
||||
);
|
||||
var out: VertexOutput;
|
||||
out.tex_coords = model.tex_coords;
|
||||
out.clip_position = camera.view_proj * model_matrix * vec4<f32>(model.position, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
var t_diffuse: texture_2d<f32>;
|
||||
[[group(0), binding(1)]]
|
||||
var s_diffuse: sampler;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn fs_main(in: VertexOutput) -> [[location(0)]] vec4<f32> {
|
||||
return textureSample(t_diffuse, s_diffuse, in.tex_coords);
|
||||
}
|
|
@ -149,7 +149,7 @@ impl State {
|
|||
label: Some("texture_bind_group_layout"),
|
||||
});
|
||||
|
||||
let diffuse_bytes = include_bytes!("happy-tree.png");
|
||||
let diffuse_bytes = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/res/images/happy-tree.png"));
|
||||
let diffuse_texture =
|
||||
Texture::from_bytes(&device, &queue, diffuse_bytes, "happy-tree.png")
|
||||
.unwrap();
|
||||
|
@ -169,7 +169,7 @@ impl State {
|
|||
label: Some("diffuse_bind_group"),
|
||||
});
|
||||
|
||||
let diffuse_bytes_pikachu = include_bytes!("pikachu.png");
|
||||
let diffuse_bytes_pikachu = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/res/images/pikachu.png"));
|
||||
let diffuse_texture_pikachu = Texture::from_bytes(
|
||||
&device,
|
||||
&queue,
|
||||
|
@ -196,7 +196,7 @@ impl State {
|
|||
|
||||
let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor {
|
||||
label: Some("Shader"),
|
||||
source: wgpu::ShaderSource::Wgsl(include_str!("shader.wgsl").into()),
|
||||
source: wgpu::ShaderSource::Wgsl(include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/res/shaders/main.wgsl")).into()),
|
||||
});
|
||||
|
||||
let camera = Camera {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue