Created
August 1, 2020 15:31
-
-
Save pferreir/35dff1b5ee2678f7e758b611e0ec4549 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use amethyst::renderer::{ | |
mtl::{TexAlbedo, TexEmission}, | |
pass::Base3DPassDef, | |
plugins::RenderBase3D, | |
rendy::{ | |
hal::pso::ShaderStageFlags, | |
mesh::{AsVertex, Normal, Position, TexCoord, VertexFormat}, | |
shader::SpirvShader | |
}, | |
skinning::JointCombined | |
}; | |
lazy_static::lazy_static! { | |
// These uses the precompiled shaders. | |
// These can be obtained using glslc.exe in the vulkan sdk. | |
static ref VERTEX: SpirvShader = SpirvShader::from_bytes( | |
include_bytes!("../shaders/compiled/pos_norm_tex_skin.vert.spv"), | |
ShaderStageFlags::VERTEX, | |
"main", | |
).unwrap(); | |
static ref VERTEX_SKINNED: SpirvShader = SpirvShader::from_bytes( | |
include_bytes!("../shaders/compiled/pos_norm_tex.vert.spv"), | |
ShaderStageFlags::VERTEX, | |
"main", | |
).unwrap(); | |
static ref FRAGMENT: SpirvShader = SpirvShader::from_bytes( | |
include_bytes!("../shaders/compiled/shaded.frag.spv"), | |
ShaderStageFlags::FRAGMENT, | |
"main", | |
).unwrap(); | |
} | |
#[derive(Debug)] | |
pub struct MyShaderPassDef; | |
impl Base3DPassDef for MyShaderPassDef { | |
const NAME: &'static str = "MyShader"; | |
type TextureSet = (TexAlbedo, TexEmission); | |
fn vertex_shader() -> &'static SpirvShader { | |
&VERTEX | |
} | |
fn vertex_skinned_shader() -> &'static SpirvShader { | |
&VERTEX_SKINNED | |
} | |
fn fragment_shader() -> &'static SpirvShader { | |
&FRAGMENT | |
} | |
fn base_format() -> Vec<VertexFormat> { | |
vec![Position::vertex(), Normal::vertex(), TexCoord::vertex()] | |
} | |
fn skinned_format() -> Vec<VertexFormat> { | |
vec![ | |
Position::vertex(), | |
Normal::vertex(), | |
TexCoord::vertex(), | |
JointCombined::vertex(), | |
] | |
} | |
} | |
pub type RenderMyShader = RenderBase3D<MyShaderPassDef>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment