2019-06-06 14:48:41 +00:00
|
|
|
use super::{
|
2020-10-21 21:05:25 +00:00
|
|
|
super::{Mesh, Pipeline, TgtColorFmt, TgtDepthStencilFmt, Tri, WinColorFmt},
|
2019-06-06 14:48:41 +00:00
|
|
|
Globals,
|
|
|
|
};
|
2019-05-06 08:22:47 +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-05-06 08:22:47 +00:00
|
|
|
};
|
2020-10-21 21:05:25 +00:00
|
|
|
use vek::*;
|
2019-05-06 08:22:47 +00:00
|
|
|
|
|
|
|
gfx_defines! {
|
|
|
|
vertex Vertex {
|
|
|
|
pos: [f32; 2] = "v_pos",
|
|
|
|
}
|
|
|
|
|
|
|
|
constant Locals {
|
2020-10-21 21:05:25 +00:00
|
|
|
proj_mat_inv: [[f32; 4]; 4] = "proj_mat_inv",
|
|
|
|
view_mat_inv: [[f32; 4]; 4] = "view_mat_inv",
|
2019-05-06 08:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pipeline pipe {
|
|
|
|
vbuf: gfx::VertexBuffer<Vertex> = (),
|
|
|
|
|
|
|
|
locals: gfx::ConstantBuffer<Locals> = "u_locals",
|
|
|
|
globals: gfx::ConstantBuffer<Globals> = "u_globals",
|
|
|
|
|
2020-10-21 21:05:25 +00:00
|
|
|
map: gfx::TextureSampler<[f32; 4]> = "t_map",
|
|
|
|
alt: gfx::TextureSampler<[f32; 2]> = "t_alt",
|
|
|
|
horizon: gfx::TextureSampler<[f32; 4]> = "t_horizon",
|
|
|
|
|
|
|
|
color_sampler: gfx::TextureSampler<<TgtColorFmt as gfx::format::Formatted>::View> = "src_color",
|
|
|
|
depth_sampler: gfx::TextureSampler<<TgtDepthStencilFmt as gfx::format::Formatted>::View> = "src_depth",
|
|
|
|
|
|
|
|
noise: gfx::TextureSampler<f32> = "t_noise",
|
2019-05-06 08:22:47 +00:00
|
|
|
|
2019-05-06 16:27:21 +00:00
|
|
|
tgt_color: gfx::RenderTarget<WinColorFmt> = "tgt_color",
|
2019-05-06 08:22:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-21 21:05:25 +00:00
|
|
|
impl Default for Locals {
|
|
|
|
fn default() -> Self { Self::new(Mat4::identity(), Mat4::identity()) }
|
|
|
|
}
|
|
|
|
|
2019-05-06 08:22:47 +00:00
|
|
|
impl Locals {
|
2020-10-21 21:05:25 +00:00
|
|
|
pub fn new(proj_mat_inv: Mat4<f32>, view_mat_inv: Mat4<f32>) -> Self {
|
|
|
|
Self {
|
|
|
|
proj_mat_inv: proj_mat_inv.into_col_arrays(),
|
|
|
|
view_mat_inv: view_mat_inv.into_col_arrays(),
|
|
|
|
}
|
|
|
|
}
|
2019-05-06 08:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct PostProcessPipeline;
|
|
|
|
|
|
|
|
impl Pipeline for PostProcessPipeline {
|
|
|
|
type Vertex = Vertex;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn create_mesh() -> Mesh<PostProcessPipeline> {
|
|
|
|
let mut mesh = Mesh::new();
|
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
mesh.push_tri(Tri::new(
|
|
|
|
Vertex { pos: [ 1.0, -1.0] },
|
|
|
|
Vertex { pos: [-1.0, 1.0] },
|
|
|
|
Vertex { pos: [-1.0, -1.0] },
|
|
|
|
));
|
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
mesh.push_tri(Tri::new(
|
|
|
|
Vertex { pos: [1.0, -1.0] },
|
|
|
|
Vertex { pos: [1.0, 1.0] },
|
|
|
|
Vertex { pos: [-1.0, 1.0] },
|
|
|
|
));
|
|
|
|
|
|
|
|
mesh
|
|
|
|
}
|