1use luminance::pipeline::TextureBinding;
4use luminance::pixel::NormUnsigned;
5use luminance::shader::Uniform;
6use luminance::texture::Dim3;
7use luminance_derive::{Semantics, UniformInterface, Vertex};
8
9#[derive(Copy, Clone, Debug, Semantics)]
10pub enum VertexSemantics {
11 #[sem(name = "co", repr = "[f32; 2]", wrapper = "VPosition")]
12 VPosition,
13
14 #[sem(name = "position", repr = "[f32; 2]", wrapper = "IPosition")]
15 IPosition,
16 #[sem(name = "rotation", repr = "f32", wrapper = "IRotation")]
17 IRotation,
18 #[sem(name = "scale", repr = "[f32; 2]", wrapper = "IScale")]
19 IScale,
20 #[sem(name = "color", repr = "[f32; 4]", wrapper = "IColor")]
21 IColor,
22 #[sem(name = "sheet", repr = "f32", wrapper = "ISheet")]
23 ISheet,
24 #[sem(name = "uv", repr = "[f32; 4]", wrapper = "IUV")]
25 IUV,
26
27 #[sem(name = "spawn", repr = "f32", wrapper = "PSpawn")]
28 PSpawn,
29 #[sem(name = "lifetime", repr = "f32", wrapper = "PLifetime")]
30 PLifetime,
31 #[sem(name = "velocity", repr = "[f32; 2]", wrapper = "PVelocity")]
32 PVelocity,
33 #[sem(name = "acceleration", repr = "[f32; 2]", wrapper = "PAcceleration")]
34 PAcceleration,
35 #[sem(name = "drag", repr = "f32", wrapper = "PDrag")]
36 PDrag,
37
38 #[sem(name = "angle_info", repr = "[f32; 3]", wrapper = "PAngleInfo")]
39 PAngleInfo,
40
41 #[sem(name = "scale_extrems", repr = "[f32; 4]", wrapper = "PScaleExtremes")]
42 PScaleExtremes,
43
44 #[sem(name = "start_color", repr = "[f32; 4]", wrapper = "PStartColor")]
45 PStartColor,
46 #[sem(name = "end_color", repr = "[f32; 4]", wrapper = "PEndColor")]
47 PEndColor,
48}
49
50#[repr(C)]
53#[derive(Vertex, Copy, Clone, PartialEq, Debug)]
54#[vertex(sem = "VertexSemantics")]
55pub struct Vertex {
56 pub position: VPosition,
57}
58
59#[repr(C)]
62#[derive(Vertex, Copy, Clone, PartialEq, Debug)]
63#[vertex(sem = "VertexSemantics", instanced = "true")]
64pub struct Instance {
65 pub position: IPosition,
66 pub rotation: IRotation,
67 pub scale: IScale,
68 pub color: IColor,
69 pub sheet: ISheet,
70 pub uv: IUV,
71}
72
73#[repr(C)]
76#[derive(Vertex, Copy, Clone, PartialEq)]
77#[vertex(sem = "VertexSemantics", instanced = "true")]
78pub struct Particle {
79 pub spawn: PSpawn,
80 pub lifetime: PLifetime,
81 pub position: IPosition,
82 pub velocity: PVelocity,
83 pub acceleration: PAcceleration,
84 pub drag: PDrag,
85
86 pub angle_info: PAngleInfo,
87
88 pub scale_extremes: PScaleExtremes,
89
90 pub start_color: PStartColor,
91 pub end_color: PEndColor,
92
93 pub sheet: ISheet,
94 pub uv: IUV,
95}
96
97#[derive(Debug, UniformInterface)]
100pub struct ShaderInterface {
101 #[uniform(unbound)]
102 pub t: Uniform<f32>,
103
104 pub view: Uniform<[[f32; 4]; 4]>,
105
106 pub tex: Uniform<TextureBinding<Dim3, NormUnsigned>>,
107}