This commit is contained in:
2021-01-26 18:12:12 -08:00
parent 77dcf1faf9
commit 9ebaece426
8 changed files with 12492 additions and 30 deletions

View File

@@ -1,21 +1,31 @@
use crate::ShadowUniforms;
use bytemuck::__core::mem;
use std::rc::Rc;
use bytemuck::__core::mem;
use crate::light::Light;
use crate::render::EntityUniforms;
/*
This will eventually be within an ECS...
So I will probably take the same approach that I did for tracer and have meta-data for rendering
held by the ECS, and a render system which will cycle through them and render
*/
struct Entity {
mx_world: cgmath::Matrix4<f32>,
rotation_speed: f32,
color: wgpu::Color,
vertex_buf: Rc<wgpu::Buffer>,
vertex_buf: Rc<wgpu::Buffer>, // Could probably tie this along with index & count to some resource handle in the renderer
index_buf: Rc<wgpu::Buffer>,
index_count: usize,
bind_group: wgpu::BindGroup,
bind_group: wgpu::BindGroup, // This is a little weird to have in the entity isn't it?
uniform_buf: wgpu::Buffer,
}
pub struct Runtime {
entities: Vec<Entity>, // This is going to be ECS'd
entities: Vec<Entity>,
// This is going to be ECS'd
lights: Vec<Light>, // ECS
}
@@ -27,8 +37,31 @@ impl Runtime {
{
// https://sotrh.github.io/learn-wgpu/beginner/tutorial5-textures/#the-bindgroup
// It appears like bindgroups are
// It appears like bindgroups are the shader input definitions
/*
But it is defined in multiples places...
` `
one of these in each pass
let bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
entries: &[
wgpu::BindGroupLayoutEntry {
The entities have one
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
layout: &local_bind_group_layout,
entries: &[wgpu::BindGroupEntry {
binding: 0,
resource: wgpu::BindingResource::Buffer(plane_uniform_buf.slice(..)),
}],
label: None,
});
*/
// Defines the Uniform buffer for the Vertex and Fragment shaders
let local_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {