Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
material.hpp
Go to the documentation of this file.
1
8
9
#pragma once
10
#include "
core_types.hpp
"
11
#include "
data.hpp
"
12
#include "
shader.hpp
"
13
14
namespace
assets {
15
16
enum class
BlendMode : uint8_t {
17
opaque,
18
alpha,
19
additive,
20
multiply,
21
};
22
23
enum class
CullMode : uint8_t {
24
none,
25
front,
26
back,
27
};
28
33
struct
MaterialSettings
{
34
BlendMode blend_mode = BlendMode::opaque;
35
bool
depth_test =
true
;
36
bool
depth_write =
true
;
37
CullMode cull_mode = CullMode::back;
38
};
39
49
class
TOAST_API Material :
public
Data {
50
public
:
51
explicit
Material(
const
toml::table& table,
Handle<Schema>
schema = {});
52
~Material()
override
;
53
54
[[nodiscard]]
55
auto
type()
const
-> std::string_view
override
{
56
return
"material"
;
57
}
58
59
[[nodiscard]]
60
auto
serialize(
SaveMode
mode)
const
-> std::vector<uint8_t>
override
;
61
62
void
reload
(
const
toml::table& table)
override
;
63
64
[[nodiscard]]
65
auto
name
()
const
-> std::string;
66
67
[[nodiscard]]
68
virtual
auto
shaders()
const
->
const
std::vector<Handle<Shader>>&;
69
70
[[nodiscard]]
71
virtual
auto
settings()
const
->
MaterialSettings
;
72
76
[[nodiscard]]
77
virtual
auto
value
(std::string_view key)
const
->
const
DataValue
*;
78
82
[[nodiscard]]
83
virtual
auto
rootMaterial
() -> Material* {
84
return
this
;
85
}
86
87
private
:
88
mutable
std::vector<Handle<Shader>> m_shader_handles;
89
mutable
bool
m_shaders_dirty =
true
;
90
};
91
}
assets::DataValue
Typed value for TOML files.
Definition
data_value.hpp:50
assets::Handle
Type-safe smart pointer for assets.
Definition
core_types.hpp:149
assets::Material::rootMaterial
virtual auto rootMaterial() -> Material *
The material owning the render pass, instances return their parent.
Definition
material.hpp:83
assets::Material::reload
void reload(const toml::table &table) override
Re-parses the asset contents in place.
Definition
material.cpp:32
assets::Material::name
auto name() const -> std::string
Display name of the material.
Definition
material.cpp:37
assets::Material::value
virtual auto value(std::string_view key) const -> const DataValue *
Looks up a shader parameter value by name.
Definition
material.cpp:112
core_types.hpp
Base types for the asset system.
assets::SaveMode
SaveMode
Definition
core_types.hpp:25
data.hpp
Typed data asset backed by schema-driven TOML.
shader.hpp
Slang shader source asset, compiled to SPIR-V by the renderer's ShaderCache.
assets::MaterialSettings
Fixed-function pipeline state carried by the material's [settings] block.
Definition
material.hpp:33
engine
src
toast
assets
material.hpp
Generated by
1.17.0