Reorganised: renderer;
This commit is contained in:
parent
905d05bc39
commit
afaad0ae0d
16 changed files with 1310 additions and 1170 deletions
|
|
@ -1,9 +1,10 @@
|
|||
use crate::render::{MaterialProperties, Texture};
|
||||
use crate::render::{Texture};
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use glam::camera::lh::proj::directx::perspective;
|
||||
use glam::{Affine3A, EulerRot, Mat3A, Mat4, Vec3, Vec4};
|
||||
use wgpu::util::DeviceExt;
|
||||
use wgpu::{Device, Queue};
|
||||
use crate::render::instance::material::MaterialProperties;
|
||||
|
||||
pub(crate) struct Eye {
|
||||
pub(crate) frame: Affine3A,
|
||||
|
|
@ -16,6 +17,7 @@ pub(crate) struct Eye {
|
|||
pub(crate) camera_buffer: wgpu::Buffer,
|
||||
pub(crate) layout: wgpu::BindGroupLayout,
|
||||
pub(crate) group: wgpu::BindGroup,
|
||||
pub sky_pipeline: wgpu::RenderPipeline,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
|
@ -49,7 +51,7 @@ impl Eye {
|
|||
bytemuck::cast_slice(&[self.environment]),
|
||||
);
|
||||
}
|
||||
pub(crate) fn new(device: &Device, width: u32, height: u32, skybox: Texture) -> Eye {
|
||||
pub(crate) fn new(device: &Device, config: &wgpu::SurfaceConfiguration, width: u32, height: u32, skybox: Texture) -> Eye {
|
||||
let camera_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some("Camera Buffer"),
|
||||
contents: bytemuck::cast_slice(&[
|
||||
|
|
@ -116,6 +118,51 @@ impl Eye {
|
|||
label: Some("eye_bind_group_layout"),
|
||||
});
|
||||
|
||||
let shader = device.create_shader_module(wgpu::include_wgsl!("sky.wgsl"));
|
||||
|
||||
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||
label: Some("Render Pipeline Layout"),
|
||||
bind_group_layouts: &[Some(&layout)],
|
||||
immediate_size: 0,
|
||||
});
|
||||
|
||||
//todo: use a pipeline cache!
|
||||
let sky_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||
label: Some("Sky Pipeline"),
|
||||
layout: Some(&pipeline_layout),
|
||||
vertex: wgpu::VertexState {
|
||||
module: &shader,
|
||||
entry_point: Some("vs_sky"),
|
||||
compilation_options: Default::default(),
|
||||
buffers: &[],
|
||||
},
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: &shader,
|
||||
entry_point: Some("fs_sky"),
|
||||
compilation_options: Default::default(),
|
||||
targets: &[Some(wgpu::ColorTargetState {
|
||||
// 4.
|
||||
format: config.format,
|
||||
blend: Some(wgpu::BlendState::REPLACE),
|
||||
write_mask: wgpu::ColorWrites::ALL,
|
||||
})],
|
||||
}),
|
||||
primitive: wgpu::PrimitiveState {
|
||||
front_face: wgpu::FrontFace::Cw,
|
||||
..Default::default()
|
||||
},
|
||||
depth_stencil: Some(wgpu::DepthStencilState {
|
||||
format: wgpu::TextureFormat::Depth32Float,
|
||||
depth_write_enabled: Some(false),
|
||||
depth_compare: Some(wgpu::CompareFunction::LessEqual),
|
||||
stencil: wgpu::StencilState::default(),
|
||||
bias: wgpu::DepthBiasState::default(),
|
||||
}),
|
||||
multisample: wgpu::MultisampleState::default(),
|
||||
multiview_mask: None,
|
||||
cache: None,
|
||||
});
|
||||
|
||||
let group = Eye::bind_group(&layout, device, &camera_buffer, &environment_buffer, skybox);
|
||||
|
||||
Eye {
|
||||
|
|
@ -129,6 +176,7 @@ impl Eye {
|
|||
layout,
|
||||
environment,
|
||||
environment_buffer,
|
||||
sky_pipeline,
|
||||
}
|
||||
}
|
||||
fn bind_group(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue