rast/graphics/
shader.rs

1use nalgebra::Point3;
2
3use super::blending::Blendable;
4
5pub struct VertexContext<'a, U> {
6    pub vertex_id: usize,
7    pub instance_id: usize,
8    pub data: &'a U,
9}
10
11pub struct FragmentContext<'a, U, W> {
12    pub instance_id: usize,
13    pub position: Point3<f32>,
14
15    pub data: &'a U,
16    pub working: W,
17}
18
19pub struct VertexOutput<W> {
20    pub position: Point3<f32>,
21    pub data: W,
22}
23
24pub struct ProcessedVertexOutput<'a, W: ?Sized> {
25    pub data: &'a W,
26    pub weight: f32,
27}
28
29pub trait Shader {
30    type Uniform: Sync;
31    type Working: Blendable + Sync;
32
33    fn vertex_stage(&self, context: &VertexContext<Self::Uniform>) -> VertexOutput<Self::Working>;
34    fn fragment_stage(&self, context: &FragmentContext<Self::Uniform, Self::Working>) -> u32;
35}