finishing up 0.8

pull/177/head
Ben Hansen 3 years ago
parent 63e0d9c6b8
commit 9baae51fe3

@ -14,7 +14,7 @@ image = "0.23"
log = "0.4"
rayon = "1.4"
tobj = "2.0"
wgpu = { version = "0.8", features = ["trace"] }
wgpu = { version = "0.8", features = ["trace", "cross"] }
winit = "0.24"
[build-dependencies]

@ -19,6 +19,7 @@ pub struct ModelVertex {
normal: [f32; 3],
tangent: [f32; 3],
bitangent: [f32; 3],
padding: [u32; 2],
}
impl Vertex for ModelVertex {
@ -294,20 +295,18 @@ impl ModelLoader {
m.mesh.positions[i * 3],
m.mesh.positions[i * 3 + 1],
m.mesh.positions[i * 3 + 2],
]
.into(),
],
// tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1], 0.0]
tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1]]
.into(),
tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1]],
normal: [
m.mesh.normals[i * 3],
m.mesh.normals[i * 3 + 1],
m.mesh.normals[i * 3 + 2],
]
.into(),
],
// We'll calculate these later
tangent: [0.0; 3].into(),
bitangent: [0.0; 3].into(),
tangent: [0.0; 3],
bitangent: [0.0; 3],
padding: [0; 2],
}
})
.collect::<Vec<_>>();

@ -8,6 +8,7 @@ struct ModelVertex {
float nx; float ny; float nz;
float tx; float ty; float tz;
float bx; float by; float bz;
uint pad0; uint pad1;
};
layout(std430, set=0, binding=0) buffer SrcVertexBuffer {

@ -40,9 +40,11 @@ pub fn create_render_pipeline(
color_format: wgpu::TextureFormat,
depth_format: Option<wgpu::TextureFormat>,
vertex_layouts: &[wgpu::VertexBufferLayout],
vs_src: wgpu::ShaderModuleDescriptor,
fs_src: wgpu::ShaderModuleDescriptor,
mut vs_src: wgpu::ShaderModuleDescriptor,
mut fs_src: wgpu::ShaderModuleDescriptor,
) -> wgpu::RenderPipeline {
vs_src.flags &= wgpu::ShaderFlags::VALIDATION;
fs_src.flags &= wgpu::ShaderFlags::VALIDATION;
let vs_module = device.create_shader_module(&vs_src);
let fs_module = device.create_shader_module(&fs_src);

@ -6,6 +6,16 @@
Originally I wanted to wait until the WGSL spec fully stabilized, but due to some issues with the GLSL code, I've decided to switch over the code now. Why'll GLSL is supported by WebGPU, it's currently secondary to WGSL. I'll keep an example of how to use GLSL (and maybe add HLSL and Metal as well), but I'm going to use WGSL from now on.
### Shaderc has been removed
I've been thinking about doing this for a while now. Because shaderc is a c library, it often has to be redownloaded during builds. This has been slowing down my ability to add new content and maintain old content. I had been considering switching to naga earlier, but some of my shaders (notably the lighting ones) weren't compiling with naga as I was using features not available for compatibility reasons (`inverse` is not available in all languages targeting spirv).
Since I needed to make a bunch of changes to the code base to make the glsl, and because I wanted to switch the tutorial to WGSL anyways, I decided to bite the bullet and recode everything in WGSL and remove shaderc from the tutorials.
### Some of the showcase examples are broken
The `wgpu_glyph`, and `imgui-wgpu` crates currently depend on `wgpu` 0.7, which is causing the `pong` and `imgui-demo` to not compile. I decided to excluded them from the workspace until the underlying crates update to using `wgpu` 0.8. (Feel free to submit a issue or even PR when that happens!)
### Various API changes
* The `depth` field is now `depth_or_array_layers`

@ -1,5 +1,11 @@
# Basic Imgui Demo
<div class="warning">
This example is currently broken for 0.8. Some of the dependecies used are still on wgpu 0.7 which causes some dependency conflicts. Once the `imgui-wgpu` crate has been updated to use wgpu 0.8 I'll update the dependencies and remove this warning.
</div>
This is not an in depth guid on how to use Imgui. But here are some of the basics you'll need to get started. We'll need to import [imgui-rs](https://docs.rs/imgui), [imgui-wgpu](https://docs.rs/imgui-wgpu), and [imgui-winit-support](https://docs.rs/imgui-winit-support).
```toml

@ -1,5 +1,11 @@
# Pong
<div class="warning">
This example is currently broken for 0.8. Some of the dependecies used are still on wgpu 0.7 which causes some dependency conflicts. Once the `imgui-wgpu` crate has been updated to use wgpu 0.8 I'll update the dependencies and remove this warning.
</div>
![](./pong.png)
Practically the "Hello World!" of games. Pong has been remade thousands of times. I know Pong. You know Pong. We all know Pong. That being said, this time I wanted to put a little more effort than most people do. This showcase has a basic menu system, sounds, and different game states.

Loading…
Cancel
Save