use ombre::prelude::*; // Display shader, for rendering a backbuffer to the frontbuffer. pub mod display { use super::*; // No uniforms used. pub type Uniforms = (); pub const fn source() -> gfx::ShaderSource<'static> { gfx::ShaderSource { vertex: include_str!("shaders/display/vertex.glsl"), fragment: include_str!("shaders/display/fragment.glsl"), geometry: None, } } pub const fn description() -> gfx::ShaderDescriptor<'static> { gfx::ShaderDescriptor { textures: &["backbuffer"], uniforms: gfx::UniformBlockLayout { uniforms: &[] }, } } } /// Constant shader, for gizmos and other UI components. #[allow(dead_code)] pub mod constant { use super::*; #[repr(C)] pub struct Uniforms { pub model: Transform3D, pub view: Transform3D, pub proj: Transform3D, } unsafe impl bytes::Packed for Uniforms {} pub const fn source() -> gfx::ShaderSource<'static> { gfx::ShaderSource { vertex: include_str!("shaders/mvp/vertex.glsl"), fragment: include_str!("shaders/constant/fragment.glsl"), geometry: None, } } pub const fn attributes() -> [gfx::VertexAttribute; 2] { [ gfx::VertexAttribute::new("position", gfx::VertexFormat::Float3), gfx::VertexAttribute::new("color", gfx::VertexFormat::Float4), ] } pub const fn description() -> gfx::ShaderDescriptor<'static> { gfx::ShaderDescriptor { textures: &[], uniforms: gfx::UniformBlockLayout { uniforms: &[ gfx::UniformDescriptor { name: "model", kind: gfx::UniformKind::Mat4, arity: 1, }, gfx::UniformDescriptor { name: "view", kind: gfx::UniformKind::Mat4, arity: 1, }, gfx::UniformDescriptor { name: "proj", kind: gfx::UniformKind::Mat4, arity: 1, }, ], }, } } } /// The default shader. /// This is a Blinn/Cook-Torance shader with some additional capabilities. pub mod default { use super::*; #[repr(C)] pub struct Uniforms { pub model: Transform3D, pub view: Transform3D, pub proj: Transform3D, pub light: Vector3D, pub window_size: Size, pub enable_tomemap: u32, pub render_mode: u32, pub interaction_mode: u32, pub object_id: u32, pub vertex_hovered: i32, } unsafe impl bytes::Packed for Uniforms {} pub const fn source() -> gfx::ShaderSource<'static> { gfx::ShaderSource { vertex: include_str!("shaders/blinn/vertex.glsl"), fragment: include_str!("shaders/blinn/fragment.glsl"), geometry: Some(include_str!("shaders/blinn/geometry.glsl")), } } pub const fn attributes() -> [gfx::VertexAttribute; 7] { [ gfx::VertexAttribute::new("position", gfx::VertexFormat::Float3), gfx::VertexAttribute::new("color", gfx::VertexFormat::Float4), gfx::VertexAttribute::new("normal", gfx::VertexFormat::Float3), gfx::VertexAttribute::new("uv", gfx::VertexFormat::Float2), gfx::VertexAttribute::new("opacity", gfx::VertexFormat::Float1), gfx::VertexAttribute::new("polygon", gfx::VertexFormat::Int1), gfx::VertexAttribute::new("selected", gfx::VertexFormat::Float1), ] } pub const fn description() -> gfx::ShaderDescriptor<'static> { gfx::ShaderDescriptor { textures: &["diffuseSampler", "specularSampler"], uniforms: gfx::UniformBlockLayout { uniforms: &[ gfx::UniformDescriptor { name: "model", kind: gfx::UniformKind::Mat4, arity: 1, }, gfx::UniformDescriptor { name: "view", kind: gfx::UniformKind::Mat4, arity: 1, }, gfx::UniformDescriptor { name: "proj", kind: gfx::UniformKind::Mat4, arity: 1, }, gfx::UniformDescriptor { name: "light", kind: gfx::UniformKind::Float3, arity: 1, }, gfx::UniformDescriptor { name: "windowSize", kind: gfx::UniformKind::Float2, arity: 1, }, gfx::UniformDescriptor { name: "enableTonemap", kind: gfx::UniformKind::UInt1, arity: 1, }, gfx::UniformDescriptor { name: "renderMode", kind: gfx::UniformKind::UInt1, arity: 1, }, gfx::UniformDescriptor { name: "interactionMode", kind: gfx::UniformKind::UInt1, arity: 1, }, gfx::UniformDescriptor { name: "objectId", kind: gfx::UniformKind::UInt1, arity: 1, }, gfx::UniformDescriptor { name: "vertexHovered", kind: gfx::UniformKind::Int1, arity: 1, }, ], }, } } }