1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use super::base_3d::*;
use crate::{mtl::FullTextureSet, skinning::JointCombined};
use rendy::{
    mesh::{AsVertex, Normal, Position, Tangent, TexCoord, VertexFormat},
    shader::SpirvShader,
};

/// Implementation of `Base3DPassDef` for Physically-based (PBR) rendering pass.
#[derive(Debug)]
pub struct PbrPassDef;
impl Base3DPassDef for PbrPassDef {
    const NAME: &'static str = "Pbr";
    type TextureSet = FullTextureSet;
    fn vertex_shader() -> &'static SpirvShader {
        &super::POS_NORM_TANG_TEX_VERTEX
    }
    fn vertex_skinned_shader() -> &'static SpirvShader {
        &super::POS_NORM_TANG_TEX_SKIN_VERTEX
    }
    fn fragment_shader() -> &'static SpirvShader {
        &super::PBR_FRAGMENT
    }
    fn base_format() -> Vec<VertexFormat> {
        vec![
            Position::vertex(),
            Normal::vertex(),
            Tangent::vertex(),
            TexCoord::vertex(),
        ]
    }
    fn skinned_format() -> Vec<VertexFormat> {
        vec![
            Position::vertex(),
            Normal::vertex(),
            Tangent::vertex(),
            TexCoord::vertex(),
            JointCombined::vertex(),
        ]
    }
}

/// Describes a Physically-based (PBR) 3d Pass with lighting
pub type DrawPbrDesc<B> = DrawBase3DDesc<B, PbrPassDef>;
/// Draws a Physically-based (PBR) 3d Pass with lighting
pub type DrawPbr<B> = DrawBase3D<B, PbrPassDef>;
/// Describes a Physically-based (PBR) 3d Pass with lighting and transparency
pub type DrawPbrTransparentDesc<B> = DrawBase3DTransparentDesc<B, PbrPassDef>;
/// Draws a Physically-based (PBR) 3d Pass with lighting and transparency
pub type DrawPbrTransparent<B> = DrawBase3DTransparent<B, PbrPassDef>;