4#ifndef GREM_GRAPHICS_3D_MODEL_3D_HPP
5#define GREM_GRAPHICS_3D_MODEL_3D_HPP
88 static_assert(
sizeof(shaderConfiguration.
vertexFlags) == 2);
89 static_assert(
sizeof(shaderConfiguration.
fragmentFlags) == 2);
94 [[no_unique_address]] std::hash<uint32_t> hasher;
367 template <
typename Constants,
typename Outputs,
typename... ExtraBuffers>
387 template <
typename Inputs,
typename Constants,
typename Outputs,
typename... ExtraBuffers>
404 template <
typename Constants,
typename Outputs,
typename... ExtraBuffers>
407 template <
typename F>
410 : function(std::forward<F>(function)) {}
416 template <
typename VS>
425 "Vertex shader's buffers do not match the shader pipeline set.");
429 return function(shaderConfiguration);
440 template <
typename Inputs,
typename Constants,
typename Outputs,
typename... ExtraBuffers>
443 template <
typename F>
446 : function(std::forward<F>(function)) {}
450 return fragmentShaderHandle;
453 template <
typename FS>
463 "Fragment shader's buffers do not match the shader pipeline set.");
467 return function(shaderConfiguration);
494 template <
typename VertexShaderConstants,
typename VertexShaderOutputs,
typename ExtraVertexShaderBuffers,
typename FragmentShaderConstants,
typename FragmentShaderOutputs,
495 typename ExtraFragmentShaderBuffers>
499 typename... ExtraFragmentShaderBuffers>
546 , vertexShaderSelector(std::
move(vertexShaderSelector))
547 , vertexShaderConstantsSelector(std::
move(vertexShaderConstantsSelector))
548 , fragmentShaderSelector(std::
move(fragmentShaderSelector))
549 , fragmentShaderConstantsSelector(std::
move(fragmentShaderConstantsSelector))
550 , shaderPipelineOptionsSelector(std::
move(shaderPipelineOptionsSelector)) {}
574 if (
const auto it = specializations.find(shaderConfiguration); it != specializations.end()) {
578 return specializations
579 .try_emplace(shaderConfiguration, *device, vertexShaderSelector(shaderConfiguration), vertexShaderConstantsSelector(shaderConfiguration),
580 fragmentShaderSelector(shaderConfiguration), fragmentShaderConstantsSelector(shaderConfiguration), shaderPipelineOptionsSelector(shaderConfiguration))
586 VertexShaderSelector vertexShaderSelector;
588 FragmentShaderSelector fragmentShaderSelector;
648 .FRAGMENT_HDR =
false,
672 .frontFace = shaderConfiguration.
frontFace,
700 GREM_API(graphics_3d)
721 GREM_API(graphics_3d)
746 explicit operator bool() const noexcept {
747 return m.
device !=
nullptr;
769 Node& node = m.nodes[nodeIndex];
835 m.nodes[nodeIndex].shaderConfiguration.materialType = newMaterialType;
847 m.nodes[nodeIndex].shaderConfiguration.frontFace = newFrontFace;
859 Node& node = m.nodes[nodeIndex];
860 if (newAlphaMasked) {
876 Node& node = m.nodes[nodeIndex];
877 if (newAlphaBlended) {
893 Node& node = m.nodes[nodeIndex];
894 if (newDoubleSided) {
917 return m.inverseBindPoseMatrixRange.begin;
927 return m.morphTargetValueRange.begin;
955 return m.staticJointCount;
973 return m.jointParentIndices;
992 return m.animationChannels;
1002 return m.keyframeInputTimePoints;
1012 return m.keyframeOutputValueData;
1024 if (
const auto it = m.animationMap.find(name); it != m.animationMap.end()) {
1041 return *animationIndex;
1043 throw std::out_of_range{
"Animation \"" +
String{name} +
"\" not found."};
1056 if (
static_cast<size_t>(index) >= m.animations.size()) {
1057 throw std::out_of_range{
"Invalid animation index."};
1066 .channels =
Span{m.animationChannels}.
subspan(animationChannelsBegin, animationChannelsEnd - animationChannelsBegin),
1067 .keyframeInputTimePoints = m.keyframeInputTimePoints,
1068 .keyframeOutputValueData = m.keyframeOutputValueData,
1109 if (
const auto it = m.jointMap.find(name); it != m.jointMap.end()) {
1128 throw std::out_of_range{
"Joint \"" +
String{name} +
"\" not found."};
1140 if (
const auto it = m.skinMap.find(name); it != m.skinMap.end()) {
1158 return *rootJointIndex;
1160 throw std::out_of_range{
"Skin \"" +
String{name} +
"\" not found."};
1170 return m.bindPoseBoundingBox;
1179 return m.bindPoseBoundingRadius;
1186 return Texture{
device, imageView, textureImageUploadOptions, textureSamplerOptions}.lock();
1213struct std::hash<
grem::graphics::Model3D::ShaderConfiguration> {
1215 return hasher(configuration);
#define GREM_ALWAYS_INLINE
Definition attributes.hpp:10
Definition ArrayList.hpp:27
Definition FunctionView.hpp:29
Definition HashMap.hpp:30
Optional value type that holds either a value or no value.
Definition Optional.hpp:58
Definition SharedPointer.hpp:65
constexpr detail::subspan_type_t< T, EXTENT, Offset, N > subspan() const
Definition Span.hpp:284
Definition fundamentals.hpp:109
Collection of GPU memory buffers to be read by a shader.
Definition buffers.hpp:580
UniformBuffer< Parameters, "Camera3DParameters"> ParameterBuffer
Shader buffer for 3D camera parameters.
Definition Camera3D.hpp:191
Persistent system managing the rendering context of a Window.
Definition Device.hpp:68
Compiled GPU fragment shader stage.
Definition shaders.hpp:1274
Generic abstraction of a GPU vertex array object and its associated buffers.
Definition Mesh.hpp:209
void setParameters(const Parameters &newParameters) noexcept
Upload new parameter values to the uniform buffer, overriding any previous contents.
Definition Mesh.hpp:475
Adapter for a function that selects which fragment shader to use for a given shader configuration.
Definition Model3D.hpp:441
GREM_ALWAYS_INLINE FragmentShaderSelectorBase(F &&function)
Definition Model3D.hpp:444
GREM_ALWAYS_INLINE FragmentShaderSelectorBase(const FS &fragmentShader)
Definition Model3D.hpp:454
GREM_ALWAYS_INLINE FragmentShaderSelectorBase(SharedPointer< FragmentShaderImplementation > fragmentShaderHandle)
Definition Model3D.hpp:448
GREM_ALWAYS_INLINE SharedPointer< FragmentShaderImplementation > operator()(const ShaderConfiguration &shaderConfiguration) const
Definition Model3D.hpp:466
Hasher for a ShaderConfiguration.
Definition Model3D.hpp:85
size_t operator()(const grem::graphics::Model3D::ShaderConfiguration &shaderConfiguration) const
Definition Model3D.hpp:87
ShaderPipelineSetBase(Device &device, VertexShaderSelector vertexShaderSelector, Function< VertexShaderConstants(const ShaderConfiguration &shaderConfiguration)> vertexShaderConstantsSelector, FragmentShaderSelector fragmentShaderSelector, Function< FragmentShaderConstants(const ShaderConfiguration &shaderConfiguration)> fragmentShaderConstantsSelector, Function< ShaderPipelineOptions(const ShaderConfiguration &shaderConfiguration)> shaderPipelineOptionsSelector)
Construct a shader pipeline set.
Definition Model3D.hpp:541
FragmentShaderSelectorBase< VertexShaderOutputs, FragmentShaderConstants, FragmentShaderOutputs, ExtraFragmentShaderBuffers... > FragmentShaderSelector
Adapter for a function that selects which fragment shader to use for a given shader configuration.
Definition Model3D.hpp:513
VertexShaderSelectorBase< VertexShaderConstants, VertexShaderOutputs, ExtraVertexShaderBuffers... > VertexShaderSelector
Adapter for a function that selects which vertex shader to use for a given shader configuration.
Definition Model3D.hpp:507
const ShaderPipeline & operator()(const ShaderConfiguration &shaderConfiguration)
Get the pipeline specialization corresponding to a specific mesh configuration.
Definition Model3D.hpp:573
Shader pipeline set for drawing 3D models.
Definition Model3D.hpp:496
Adapter for a function that selects which vertex shader to use for a given shader configuration.
Definition Model3D.hpp:405
GREM_ALWAYS_INLINE SharedPointer< VertexShaderImplementation > operator()(const ShaderConfiguration &shaderConfiguration) const
Definition Model3D.hpp:428
GREM_ALWAYS_INLINE VertexShaderSelectorBase(F &&function)
Definition Model3D.hpp:408
GREM_ALWAYS_INLINE VertexShaderSelectorBase(SharedPointer< VertexShaderImplementation > vertexShaderHandle)
Definition Model3D.hpp:412
GREM_ALWAYS_INLINE VertexShaderSelectorBase(const VS &vertexShader)
Definition Model3D.hpp:417
MaterialType
Material type that specifies how the material parameters should be interpreted when shading a mesh in...
Definition Model3D.hpp:73
@ UNLIT
The shader should use only the base color at full brightness.
Definition Model3D.hpp:75
@ METALLIC_ROUGHNESS
The shader should interpret the material according to the standard metallic-roughness model.
Definition Model3D.hpp:74
resource::Model::AnimationView getAnimationAtIndex(resource::Model::AnimationIndex index) const
Get the animation at a specific index.
Definition Model3D.hpp:1055
static constexpr auto DEFAULT_SHADER_PIPELINE_OPTIONS
Default 3D model graphics pipeline configuration.
Definition Model3D.hpp:668
void setNodeDoubleSided(size_t nodeIndex, bool newDoubleSided)
Set whether a node in the model is double-sided or not.
Definition Model3D.hpp:892
void setNodeFrontFace(size_t nodeIndex, FrontFace newFrontFace)
Set the winding order of the front-facing faces of a node in the model.
Definition Model3D.hpp:846
void setNodeMeshParameters(size_t nodeIndex, const Parameters &newParameters)
Set the mesh parameters of a node in the model.
Definition Model3D.hpp:768
ShaderPipelineSetBase< VertexShaderConstants, VertexShaderOutputs, meta::TypeList<>, FragmentShaderConstants, FragmentShaderOutputs, meta::TypeList<> > ShaderPipelineSet
Default shader pipeline set for drawing 3D models.
Definition Model3D.hpp:597
const resource::Model::Pose & getBindPose() const noexcept
Get the local bind pose of the model.
Definition Model3D.hpp:935
Model3D() noexcept=default
Construct an invalid model that must be reassigned before use.
resource::Model::AnimationView getAnimation(StringView name) const
Get the animation with a specific name.
Definition Model3D.hpp:1081
BufferSet< InverseBindPoseMatrixBuffer, MorphTargetValueBuffer > DataBuffers
Set of shader buffers related to the static data of 3D models.
Definition Model3D.hpp:325
StorageBuffer< InverseBindPoseMatrixFields, "Model3DInverseBindPoseMatrices"> InverseBindPoseMatrixBuffer
Shader buffer for 3D model inverse bind-pose matrices.
Definition Model3D.hpp:307
Optional< resource::Model::AnimationView > findAnimation(StringView name) const noexcept
Try to get the animation with a specific name.
Definition Model3D.hpp:1093
resource::Model::AnimationMap animationMap
Definition Model3D.hpp:1206
ArrayList< float > keyframeInputTimePoints
Definition Model3D.hpp:1199
Model3D & operator=(Model3D &&other) noexcept
Move assignment.
uint32_t getInverseBindPoseMatrixOffset() const noexcept
Get the inverse bind-pose matrix offset of the model.
Definition Model3D.hpp:916
Box< 3, float > bindPoseBoundingBox
Definition Model3D.hpp:1202
resource::Model::JointCount getJointCount() const noexcept
Get the number of joints in the model.
Definition Model3D.hpp:944
graphics::VertexShader< Mesh, Constants, Outputs, Camera3D::ParameterBuffer, DataBuffers, InstanceBuffers, ExtraBuffers... > VertexShaderBase
Vertex shader for drawing 3D models.
Definition Model3D.hpp:368
resource::Model::JointMap skinMap
Definition Model3D.hpp:1205
RangeAllocation< uint32_t > morphTargetValueRange
Definition Model3D.hpp:1194
void setNodeMaterialType(size_t nodeIndex, MaterialType newMaterialType)
Set how to interpret the material parameters of a node in the model when shading.
Definition Model3D.hpp:834
StorageBuffer< JointFields, "Model3DJoints"> JointBuffer
Shader buffer for 3D model joints.
Definition Model3D.hpp:337
resource::Model::MorphTargetWeightCount getMorphTargetWeightCount() const noexcept
Get the number of morph target weights of the model.
Definition Model3D.hpp:963
VertexShaderBase< VertexShaderConstants, VertexShaderOutputs > VertexShader
Default vertex shader for drawing 3D models.
Definition Model3D.hpp:373
resource::Model::JointIndex getSkinRootJointIndex(StringView name) const
Get the index of the root joint of a skin with a specific name.
Definition Model3D.hpp:1156
resource::Model::JointCount getStaticJointCount() const noexcept
Get the number of static joints in the model.
Definition Model3D.hpp:954
Optional< resource::Model::JointIndex > findJointIndex(StringView name) const noexcept
Find the index of a joint with a specific name.
Definition Model3D.hpp:1108
Renderer3D * renderer3D
Definition Model3D.hpp:1191
Optional< resource::Model::JointIndex > findSkinRootJointIndex(StringView name) const noexcept
Find the index of the root joint of a skin with a specific name.
Definition Model3D.hpp:1139
resource::Model::JointCount staticJointCount
Definition Model3D.hpp:1201
Span< const float > getKeyframeInputTimePoints() const noexcept
Get the input timepoints of the animation channel keyframes of the model.
Definition Model3D.hpp:1001
Device * device
Definition Model3D.hpp:1190
Model3D(Model3D &&other) noexcept
Move constructor.
Box< 3, float > getBindPoseBoundingBox() const noexcept
Get the local bounding box of the model in its bind pose.
Definition Model3D.hpp:1169
BufferSet< JointBuffer, MorphTargetWeightBuffer > InstanceBuffers
Set of shader buffers related to the dynamic data of 3D model instances.
Definition Model3D.hpp:355
float getBindPoseBoundingRadius() const noexcept
Get the local bounding radius of the model in its bind pose.
Definition Model3D.hpp:1178
StorageBuffer< MorphTargetWeightFields, "Model3DMorphTargetWeights"> MorphTargetWeightBuffer
Shader buffer for 3D model morph target weights.
Definition Model3D.hpp:350
static constexpr auto DEFAULT_FRAGMENT_SHADER_CONSTANTS
Default 3D model fragment shader constants.
Definition Model3D.hpp:646
ArrayList< resource::Model::AnimationChannel > animationChannels
Definition Model3D.hpp:1198
Optional< resource::Model::AnimationIndex > findAnimationIndex(StringView name) const noexcept
Find the index of an animation with a specific name.
Definition Model3D.hpp:1023
uint32_t getMorphTargetValueOffset() const noexcept
Get the morph target value offset of the model.
Definition Model3D.hpp:926
graphics::Mesh< Vertex, Index, Parameters, Instance > Mesh
Type of a single mesh of a 3D model.
Definition Model3D.hpp:234
Span< const resource::Model::AnimationChannel > getAnimationChannels() const noexcept
Get the animation channels of the model.
Definition Model3D.hpp:991
FragmentShaderBase< VertexShaderOutputs, FragmentShaderConstants, FragmentShaderOutputs > FragmentShader
Default fragment shader type for drawing 3D models.
Definition Model3D.hpp:393
static constexpr auto DEFAULT_VERTEX_SHADER_CONSTANTS
Default 3D model vertex shader constants.
Definition Model3D.hpp:628
void setNodeAlphaBlended(size_t nodeIndex, bool newAlphaBlended)
Set whether a node in the model is alpha blended or not.
Definition Model3D.hpp:875
Span< const Node > getNodes() const noexcept
Get the nodes of the model.
Definition Model3D.hpp:906
uint32_t Index
Data type used in the index buffer of a 3D model mesh.
Definition Model3D.hpp:187
Span< const resource::Model::Animation > getAnimations() const noexcept
Get the animations of the model.
Definition Model3D.hpp:981
resource::Model::Pose bindPose
Definition Model3D.hpp:1195
Span< const resource::Model::JointIndex > getJointParentIndices() const noexcept
Get the indices of the parent joints of each joint of the model.
Definition Model3D.hpp:972
ArrayList< resource::Model::Animation > animations
Definition Model3D.hpp:1197
RangeAllocation< uint32_t > inverseBindPoseMatrixRange
Definition Model3D.hpp:1193
resource::Model::JointIndex getJointIndex(StringView name) const
Get the index of a joint with a specific name.
Definition Model3D.hpp:1124
Model3D(const Model3D &other)
Copy constructor.
ArrayList< resource::Model::JointIndex > jointParentIndices
Definition Model3D.hpp:1196
resource::Model::JointMap jointMap
Definition Model3D.hpp:1204
Span< const byte > getKeyframeOutputValueData() const noexcept
Get the output values of the animation channel keyframes of the model.
Definition Model3D.hpp:1011
graphics::ShaderPipeline< Mesh > ShaderPipeline
Shader pipeline for drawing 3D models.
Definition Model3D.hpp:398
StorageBuffer< MorphTargetValueFields, "Model3DMorphTargetValues"> MorphTargetValueBuffer
Shader buffer for 3D model morph target values.
Definition Model3D.hpp:320
ArrayList< Node > nodes
Definition Model3D.hpp:1192
float bindPoseBoundingRadius
Definition Model3D.hpp:1203
Buffer< byte > keyframeOutputValueData
Definition Model3D.hpp:1200
graphics::FragmentShader< Mesh, Inputs, Constants, Outputs, Camera3D::ParameterBuffer, DataBuffers, InstanceBuffers, ExtraBuffers... > FragmentShaderBase
Fragment shader for drawing 3D models.
Definition Model3D.hpp:388
Model3D & operator=(const Model3D &other)
Copy assignment.
void setNodeAlphaMasked(size_t nodeIndex, bool newAlphaMasked)
Set whether a node in the model is alpha masked or not.
Definition Model3D.hpp:858
resource::Model::AnimationIndex getAnimationIndex(StringView name) const
Get the index of an animation with a specific name.
Definition Model3D.hpp:1039
Persistent system that provides 3D rendering capabilities.
Definition Renderer3D.hpp:120
Linked GPU shader pipeline.
Definition shaders.hpp:1508
GPU memory buffer containing an array of structs to be read by a shader program.
Definition buffers.hpp:493
Compiled GPU vertex shader stage.
Definition shaders.hpp:1060
Read-only non-owning view over a 2D image.
Definition Image.hpp:108
Definition concepts.hpp:141
Definition concepts.hpp:47
Definition concepts.hpp:35
Definition buffer_layouts.hpp:20
PrimitiveType
Graphical primitive type formed by mesh vertices, used in a ShaderPipelineOptions.
Definition shaders.hpp:290
@ TRIANGLES
Each consecutive triple of points forms an individual filled triangle.
Definition shaders.hpp:295
@ CULL_BACK_FACES
Discard back-facing faces.
Definition shaders.hpp:324
@ NONE
Ignore facing, don't cull primitives based on their winding order.
Definition shaders.hpp:319
FrontFace
Front face winding order used in a ShaderPipelineOptions.
Definition shaders.hpp:343
@ COUNTERCLOCKWISE
Consider faces with counterclockwise winding order to be front-facing.
Definition shaders.hpp:344
std::function< Signature > Function
Definition Function.hpp:14
vec< 4, float > vec4
Definition math.hpp:440
vec< 2, float > vec2
Definition math.hpp:438
GREM_ALWAYS_INLINE void lock(Lockable1 &lock1, Lockable2 &lock2, LockableN &... lockN)
Definition synchronization.hpp:1268
vec< 3, float > vec3
Definition math.hpp:439
constexpr auto move(input_range auto &&range, auto outputIterator)
Definition algorithms.hpp:669
vec< 4, uint8_t > u8vec4
Definition math.hpp:404
mat< 2, 2, float > mat2
Definition math.hpp:804
StringBase< char, std::char_traits< char >, std::allocator< char > > String
Definition String.hpp:17
constexpr detail::Matcher< V > match(V &&variant)
Choose a function overload to execute based on the active alternative of a variant.
Definition Variant.hpp:1922
vec< 4, u8norm > u8vec4norm
Definition math.hpp:464
mat< 4, 4, float > mat4
Definition math.hpp:806
StringViewBase< char, std::char_traits< char > > StringView
Definition StringView.hpp:16
Generic axis-aligned box shape with minimum and maximum extents in N-dimensional space.
Definition geometry.hpp:149
Definition RangeAllocator.hpp:35
static const BlendState ALPHA_BLENDING_PREMULTIPLIED
Blend state to use for pre-multiplied alpha blending using the standard "over" operator.
Definition shaders.hpp:391
Configuration options for a Model3D.
Definition Model3D.hpp:45
constexpr bool operator==(const Model3DOptions &other) const =default
Compare these options to another set of options for equality.
float maxTextureSamplerAnisotropy
Maximum level of anisotropic filtering to use when sampling material textures.
Definition Model3D.hpp:52
Struct of default fragment shader constants.
Definition Model3D.hpp:272
bool32_t FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_0
Definition Model3D.hpp:283
bool32_t FRAGMENT_HDR
Definition Model3D.hpp:273
bool32_t FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_0
Definition Model3D.hpp:277
bool32_t FRAGMENT_ALPHA_MASKED
Definition Model3D.hpp:274
bool32_t FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_1
Definition Model3D.hpp:284
bool32_t FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_1
Definition Model3D.hpp:280
bool32_t FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_0
Definition Model3D.hpp:279
bool32_t FRAGMENT_DOUBLE_SIDED
Definition Model3D.hpp:276
bool32_t FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_1
Definition Model3D.hpp:286
bool32_t FRAGMENT_ALPHA_BLENDED
Definition Model3D.hpp:275
bool32_t FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_0
Definition Model3D.hpp:285
bool32_t FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_1
Definition Model3D.hpp:282
bool32_t FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_0
Definition Model3D.hpp:281
bool32_t FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_1
Definition Model3D.hpp:278
Struct of fields output by the default fragment shader.
Definition Model3D.hpp:292
vec4 outputColor
Final fragment color.
Definition Model3D.hpp:293
Data layout for the attributes of a single instance of a 3D model mesh.
Definition Model3D.hpp:221
uint32_t instanceMorphTargetWeightOffset
Offset of the first morph target weight in the MorphTargetWeightBuffer.
Definition Model3D.hpp:227
vec3 instanceEmissiveFactor
Emissive factor to use when rendering.
Definition Model3D.hpp:224
uint32_t instanceInverseBindPoseMatrixOffset
Offset of the first matrix in the InverseBindPoseMatrixBuffer.
Definition Model3D.hpp:225
uint32_t instanceInstanceIdentifier
Instance identifier that may be used in shaders.
Definition Model3D.hpp:228
vec3 instanceEmissiveColor
Additive emissive color to use when rendering.
Definition Model3D.hpp:223
uint32_t instanceJointOffset
Offset of the first joint in the JointBuffer.
Definition Model3D.hpp:226
vec4 instanceTintColor
Multiplicative tint color to use when rendering.
Definition Model3D.hpp:222
Struct of shader fields representing the inverse bind matrix of a joint of a 3D model.
Definition Model3D.hpp:300
mat4 inverseBindPoseMatrix
Inverse bind-pose matrix of the joint.
Definition Model3D.hpp:301
Struct of shader fields representing a joint of a 3D model.
Definition Model3D.hpp:330
mat4 jointMatrix
Transformation matrix of the joint.
Definition Model3D.hpp:331
Struct of shader fields representing the value of a morph target of a 3D model.
Definition Model3D.hpp:313
float morphTargetValue
Value of the morph target.
Definition Model3D.hpp:314
Struct of shader fields representing the state of a morph target weight of a 3D model.
Definition Model3D.hpp:343
float morphTargetWeight
Weight of the morph target.
Definition Model3D.hpp:344
Node of a 3D model.
Definition Model3D.hpp:602
Mesh mesh
Mesh primitive of the node.
Definition Model3D.hpp:604
uint32_t inverseBindPoseMatrixOffset
Index of the node's skin's first inverse bind-pose matrix in the model's inverse bind-pose matrix arr...
Definition Model3D.hpp:610
Box< 3, float > boundingBox
Local bounding box of the node.
Definition Model3D.hpp:619
resource::Model::MorphTargetWeightIndex morphTargetWeightOffset
Index of the node's first morph target in the model's morph target weight array.
Definition Model3D.hpp:613
float boundingRadius
Local bounding radius of the node.
Definition Model3D.hpp:622
resource::Model::JointIndex jointIndex
Index of the model joint that the node is attached to.
Definition Model3D.hpp:616
ShaderConfiguration shaderConfiguration
Shader configuration of the node.
Definition Model3D.hpp:607
Parameters of a 3D model mesh.
Definition Model3D.hpp:192
vec2 meshNormalMapTextureOffset
Texture coordinate offset to use when sampling the normal map.
Definition Model3D.hpp:207
sampler2D meshEmissiveMap
Emissive texture used for emissive mapping.
Definition Model3D.hpp:202
sampler2D meshNormalMap
Normal texture used for normal mapping.
Definition Model3D.hpp:201
vec3 meshOcclusionRoughnessMetallicFactor
Occlusion strength (X), roughness factor (Y) and metallic factor (Z).
Definition Model3D.hpp:194
vec3 meshEmissiveFactor
Emissive factor.
Definition Model3D.hpp:196
vec2 meshOcclusionRoughnessMetallicMapTextureOffset
Texture coordinate offset to use when sampling the ORM map.
Definition Model3D.hpp:205
uint32_t meshMorphTargetStride
Size of each morph target, in number of floats.
Definition Model3D.hpp:213
mat2 meshEmissiveMapTextureBasis
Texture coordinate basis to use when sampling the emissive map.
Definition Model3D.hpp:210
float meshAlphaCutoff
Alpha cutoff value.
Definition Model3D.hpp:197
uint32_t meshMorphTargetCount
Number of morph targets.
Definition Model3D.hpp:212
vec4 meshBaseColorFactor
Base color factor.
Definition Model3D.hpp:193
sampler2D meshBaseColorMap
Base color texture used for diffuse shading.
Definition Model3D.hpp:199
vec2 meshEmissiveMapTextureOffset
Texture coordinate offset to use when sampling the emissive map.
Definition Model3D.hpp:209
vec2 meshBaseColorMapTextureOffset
Texture coordinate offset to use when sampling the base color map.
Definition Model3D.hpp:203
mat2 meshBaseColorMapTextureBasis
Texture coordinate basis to use when sampling the base color map.
Definition Model3D.hpp:204
uint32_t meshMorphTargetValueOffset
Offset of the first morph target in the MorphTargetValueBuffer.
Definition Model3D.hpp:211
float meshNormalScale
Normal scale.
Definition Model3D.hpp:195
mat2 meshNormalMapTextureBasis
Texture coordinate basis to use when sampling the normal map.
Definition Model3D.hpp:208
sampler2D meshOcclusionRoughnessMetallicMap
ORM texture used for specular shading.
Definition Model3D.hpp:200
float meshIndexOfRefraction
Index of refraction.
Definition Model3D.hpp:198
mat2 meshOcclusionRoughnessMetallicMapTextureBasis
Texture coordinate basis to use when sampling the ORM map.
Definition Model3D.hpp:206
Configuration options for shading a mesh instance of a 3D model.
Definition Model3D.hpp:81
PrimitiveType primitiveType
How to form primitives out of consecutive mesh vertices.
Definition Model3D.hpp:105
constexpr bool operator==(const ShaderConfiguration &other) const =default
Compare this configuration to another for equality.
resource::Model::VertexFlags vertexFlags
Vertex flags used by the shader, see VertexFlag.
Definition Model3D.hpp:115
FrontFace frontFace
The winding order of front-facing faces.
Definition Model3D.hpp:110
resource::Model::FragmentFlags fragmentFlags
Fragment flags used by the shader, see FragmentFlag.
Definition Model3D.hpp:120
MaterialType materialType
How to interpret the material parameters when shading.
Definition Model3D.hpp:100
Struct of default vertex shader constants.
Definition Model3D.hpp:239
bool32_t VERTEX_SKINNED
Definition Model3D.hpp:243
bool32_t VERTEX_MORPHED_COLOR
Definition Model3D.hpp:249
bool32_t VERTEX_MORPHED_POSITION
Definition Model3D.hpp:244
bool32_t VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_1
Definition Model3D.hpp:248
bool32_t VERTEX_MORPHED_NORMAL
Definition Model3D.hpp:245
bool32_t VERTEX_COLORED
Definition Model3D.hpp:242
bool32_t VERTEX_TEXTURED_ON_CHANNEL_1
Definition Model3D.hpp:241
bool32_t VERTEX_TEXTURED_ON_CHANNEL_0
Definition Model3D.hpp:240
bool32_t VERTEX_MORPHED_TANGENT
Definition Model3D.hpp:246
bool32_t VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_0
Definition Model3D.hpp:247
Struct of fields output by the default vertex shader.
Definition Model3D.hpp:255
vec4 fragmentTintColor
Tint color of the vertex.
Definition Model3D.hpp:263
float fragmentDepth
View-space depth of the vertex from the camera.
Definition Model3D.hpp:257
vec3 fragmentEmissiveFactor
Emissive factor of the vertex.
Definition Model3D.hpp:265
vec3 fragmentBitangent
World-space bitangent vector of the vertex.
Definition Model3D.hpp:260
uint32_t fragmentInstanceIdentifier
Instance identifier of the model instance.
Definition Model3D.hpp:266
vec2 fragmentTextureCoordinatesChannel0
Texture coordinates of the vertex on channel 0.
Definition Model3D.hpp:261
vec3 fragmentEmissiveColor
Emissive color of the vertex.
Definition Model3D.hpp:264
vec2 fragmentTextureCoordinatesChannel1
Texture coordinates of the vertex on channel 1.
Definition Model3D.hpp:262
vec3 fragmentPosition
World-space position of the vertex.
Definition Model3D.hpp:256
vec3 fragmentTangent
World-space tangent vector of the vertex.
Definition Model3D.hpp:259
vec3 fragmentNormal
World-space normal vector of the vertex.
Definition Model3D.hpp:258
Data layout for the attributes of a single vertex of a 3D model mesh.
Definition Model3D.hpp:137
iA2B10G10R10vec4norm vertexNormal
Unit vector (XYZ) pointing away from the vertex surface in the bind pose of the model.
Definition Model3D.hpp:147
vec2 vertexTextureCoordinatesChannel1
Texture UV coordinates that map to this vertex on channel 1.
Definition Model3D.hpp:164
u8vec4norm vertexJointWeights
Weights of the 4 joints that this vertex is skinned by.
Definition Model3D.hpp:179
iA2B10G10R10vec4norm vertexTangent
Unit vector (XYZ) pointing in some direction along the vertex surface in the bind pose of the model,...
Definition Model3D.hpp:154
vec3 vertexPosition
Bind-pose position relative to the origin of the model.
Definition Model3D.hpp:141
u8vec4norm vertexColor
Vertex tint color.
Definition Model3D.hpp:169
u8vec4 vertexJointIndices
Indices of the 4 joints that this vertex is skinned by.
Definition Model3D.hpp:174
vec2 vertexTextureCoordinatesChannel0
Texture UV coordinates that map to this vertex on channel 0.
Definition Model3D.hpp:159
Configuration of a graphics pipeline.
Definition shaders.hpp:428
Configuration options for a texture image upload.
Definition Texture.hpp:550
Configuration options for the sampler of a Texture.
Definition Texture.hpp:617
Reference to a sampler2D Texture that may be used as a parameter value type in a shader-read buffer.
Definition ParameterDescription.hpp:131
Non-owning read-only view over a set of animation channels and their associated data.
Definition Model.hpp:608
Animation of a model.
Definition Model.hpp:570
float minTimePoint
Start time of all animation channels.
Definition Model.hpp:572
AnimationChannelIndex animationChannelOffset
Index of the first animation channel.
Definition Model.hpp:583
float maxTimePoint
End time of all animation channels.
Definition Model.hpp:575
Local pose of a model.
Definition Model.hpp:733
HashMap< String, JointIndex, TransparentHash< StringView >, TransparentEqual< StringView > > JointMap
Map from name strings to joint indices.
Definition Model.hpp:587
Variant< resource::Image, resource::ImageView > Image
Image of a texture in a model.
Definition Model.hpp:284
uint16_t FragmentFlags
Set of FragmentFlag bits.
Definition Model.hpp:185
uint32_t MorphTargetWeightIndex
Offset of a morph target weight in the model's morph target weight array.
Definition Model.hpp:140
uint16_t VertexFlags
Set of VertexFlag bits.
Definition Model.hpp:168
uint32_t AnimationIndex
Offset of an animation in the model's animation array.
Definition Model.hpp:152
uint32_t JointIndex
Offset of a joint in the model's joint array.
Definition Model.hpp:148
@ FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_0
The base color map is sampled using texture coordinate channel 0.
Definition Model.hpp:192
@ FRAGMENT_ALPHA_MASKED
Fragments with alpha less than the alpha cutoff are discarded.
Definition Model.hpp:189
@ FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_0
The metallic/roughness map is sampled using texture coordinate channel 0.
Definition Model.hpp:194
@ FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_0
The emissive map is sampled using texture coordinate channel 0.
Definition Model.hpp:200
@ FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_1
The emissive map is sampled using texture coordinate channel 1.
Definition Model.hpp:201
@ FRAGMENT_ALPHA_BLENDED
Fragments are alpha blended.
Definition Model.hpp:190
@ FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_0
The normal map is sampled using texture coordinate channel 0.
Definition Model.hpp:198
@ FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_1
The metallic/roughness map is sampled using texture coordinate channel 1.
Definition Model.hpp:195
@ FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_1
The occlusion map is sampled using texture coordinate channel 1.
Definition Model.hpp:197
@ FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_1
The normal map is sampled using texture coordinate channel 1.
Definition Model.hpp:199
@ FRAGMENT_DOUBLE_SIDED
Fragments are double-sided.
Definition Model.hpp:191
@ FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_0
The occlusion map is sampled using texture coordinate channel 0.
Definition Model.hpp:196
@ FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_1
The base color map is sampled using texture coordinate channel 1.
Definition Model.hpp:193
@ VERTEX_COLORED
The vertex color component is used to tint the fragment color.
Definition Model.hpp:174
@ VERTEX_MORPHED_NORMAL
The vertex normal is morphed against the morph targets of the model using provided weights.
Definition Model.hpp:177
@ VERTEX_MORPHED_COLOR
The vertex color is morphed against the morph targets of the model using provided weights.
Definition Model.hpp:181
@ VERTEX_TEXTURED_ON_CHANNEL_1
Texture coordinate channel 1 is used to sample materials.
Definition Model.hpp:173
@ VERTEX_TEXTURED_ON_CHANNEL_0
Texture coordinate channel 0 is used to sample materials.
Definition Model.hpp:172
@ VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_1
Texture coordinate channel 1 is morphed against the morph targets of the model using provided weights...
Definition Model.hpp:180
@ VERTEX_MORPHED_TANGENT
The vertex tangent is morphed against the morph targets of the model using provided weights.
Definition Model.hpp:178
@ VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_0
Texture coordinate channel 0 is morphed against the morph targets of the model using provided weights...
Definition Model.hpp:179
@ VERTEX_MORPHED_POSITION
The vertex position is morphed against the morph targets of the model using provided weights.
Definition Model.hpp:176
@ VERTEX_SKINNED
The vertex joint components are used to skin the vertex over the model joints.
Definition Model.hpp:175
MorphTargetWeightIndex MorphTargetWeightCount
Number of morph target weights in a range within the model's morph target weight array.
Definition Model.hpp:141
JointIndex JointCount
Number of joints in a range within the model's joint array.
Definition Model.hpp:149
uint32_t AnimationChannelIndex
Offset of an animation channel in the model's animation channel array.
Definition Model.hpp:150
HashMap< String, AnimationIndex, TransparentHash< StringView >, TransparentEqual< StringView > > AnimationMap
Map from name strings to animation indices.
Definition Model.hpp:590
std::size_t operator()(const grem::graphics::Model3D::ShaderConfiguration &configuration) const
Definition Model3D.hpp:1214