2019-06-06 14:48:41 +00:00
|
|
|
use super::{
|
|
|
|
super::{util::arr_to_mat, Pipeline, TgtColorFmt, TgtDepthFmt},
|
2019-09-25 12:00:00 +00:00
|
|
|
Globals, Light, Shadow,
|
2019-06-06 14:48:41 +00:00
|
|
|
};
|
2019-01-13 20:53:55 +00:00
|
|
|
use gfx::{
|
2020-02-01 20:39:39 +00:00
|
|
|
self, gfx_constant_struct_meta, gfx_defines, gfx_impl_struct_meta, gfx_pipeline,
|
|
|
|
gfx_pipeline_inner, gfx_vertex_struct_meta,
|
2019-01-13 20:53:55 +00:00
|
|
|
};
|
|
|
|
use vek::*;
|
|
|
|
|
|
|
|
gfx_defines! {
|
|
|
|
vertex Vertex {
|
|
|
|
pos: [f32; 3] = "v_pos",
|
2019-01-14 14:18:58 +00:00
|
|
|
norm: [f32; 3] = "v_norm",
|
2019-01-13 20:53:55 +00:00
|
|
|
col: [f32; 3] = "v_col",
|
|
|
|
bone_idx: u8 = "v_bone_idx",
|
|
|
|
}
|
|
|
|
|
|
|
|
constant Locals {
|
|
|
|
model_mat: [[f32; 4]; 4] = "model_mat",
|
2019-05-13 13:58:01 +00:00
|
|
|
model_col: [f32; 4] = "model_col",
|
2019-01-13 20:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constant BoneData {
|
|
|
|
bone_mat: [[f32; 4]; 4] = "bone_mat",
|
|
|
|
}
|
|
|
|
|
|
|
|
pipeline pipe {
|
|
|
|
vbuf: gfx::VertexBuffer<Vertex> = (),
|
|
|
|
|
|
|
|
locals: gfx::ConstantBuffer<Locals> = "u_locals",
|
|
|
|
globals: gfx::ConstantBuffer<Globals> = "u_globals",
|
|
|
|
bones: gfx::ConstantBuffer<BoneData> = "u_bones",
|
2019-07-21 15:04:36 +00:00
|
|
|
lights: gfx::ConstantBuffer<Light> = "u_lights",
|
2019-09-25 12:00:00 +00:00
|
|
|
shadows: gfx::ConstantBuffer<Shadow> = "u_shadows",
|
2019-01-13 20:53:55 +00:00
|
|
|
|
2019-11-17 22:41:00 +00:00
|
|
|
noise: gfx::TextureSampler<f32> = "t_noise",
|
|
|
|
|
2019-01-13 20:53:55 +00:00
|
|
|
tgt_color: gfx::RenderTarget<TgtColorFmt> = "tgt_color",
|
|
|
|
tgt_depth: gfx::DepthTarget<TgtDepthFmt> = gfx::preset::depth::LESS_EQUAL_WRITE,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Vertex {
|
2019-01-14 14:18:58 +00:00
|
|
|
pub fn new(pos: Vec3<f32>, norm: Vec3<f32>, col: Rgb<f32>, bone_idx: u8) -> Self {
|
2019-01-13 20:53:55 +00:00
|
|
|
Self {
|
|
|
|
pos: pos.into_array(),
|
|
|
|
col: col.into_array(),
|
2019-01-14 14:18:58 +00:00
|
|
|
norm: norm.into_array(),
|
2019-01-13 20:53:55 +00:00
|
|
|
bone_idx,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn with_bone_idx(mut self, bone_idx: u8) -> Self {
|
|
|
|
self.bone_idx = bone_idx;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Locals {
|
2019-05-13 13:58:01 +00:00
|
|
|
pub fn new(model_mat: Mat4<f32>, col: Rgba<f32>) -> Self {
|
2019-01-13 20:53:55 +00:00
|
|
|
Self {
|
2019-03-02 03:48:30 +00:00
|
|
|
model_mat: arr_to_mat(model_mat.into_col_array()),
|
2019-05-13 13:58:01 +00:00
|
|
|
model_col: col.into_array(),
|
2019-01-13 20:53:55 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-13 13:58:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Locals {
|
2020-02-01 20:39:39 +00:00
|
|
|
fn default() -> Self { Self::new(Mat4::identity(), Rgba::broadcast(1.0)) }
|
2019-01-13 20:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl BoneData {
|
|
|
|
pub fn new(bone_mat: Mat4<f32>) -> Self {
|
|
|
|
Self {
|
|
|
|
bone_mat: arr_to_mat(bone_mat.into_col_array()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-01 20:39:39 +00:00
|
|
|
pub fn default() -> Self { Self::new(Mat4::identity()) }
|
2019-01-13 20:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct FigurePipeline;
|
|
|
|
|
|
|
|
impl Pipeline for FigurePipeline {
|
|
|
|
type Vertex = Vertex;
|
|
|
|
}
|