GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
Model3D.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Ivar Härnqvist
2// SPDX-License-Identifier: MIT
3
4#ifndef GREM_GRAPHICS_3D_MODEL_3D_HPP
5#define GREM_GRAPHICS_3D_MODEL_3D_HPP
6
8
25#include <GREM/core/math.hpp>
32
33#include <cstddef> // std::size_t
34#include <functional> // std::hash
35#include <utility> // std::move, std::forward
36
37namespace grem::graphics {
38
39class Device; // Forward declaration, to avoid including Device.hpp.
40class Renderer3D; // Forward declaration, to avoid a circular include of Renderer3D.hpp.
41
53
61 [[nodiscard]] constexpr bool operator==(const Model3DOptions& other) const = default;
62};
63
67class Model3D {
68public:
73 enum class MaterialType : uint8_t {
75 UNLIT = 1,
76 };
77
85 class Hash {
86 public:
87 [[nodiscard]] size_t operator()(const grem::graphics::Model3D::ShaderConfiguration& shaderConfiguration) const {
88 static_assert(sizeof(shaderConfiguration.vertexFlags) == 2);
89 static_assert(sizeof(shaderConfiguration.fragmentFlags) == 2);
90 return hasher(static_cast<uint32_t>(shaderConfiguration.vertexFlags << 16) | shaderConfiguration.fragmentFlags);
91 }
92
93 private:
94 [[no_unique_address]] std::hash<uint32_t> hasher;
95 };
96
101
106
111
116
121
129 [[nodiscard]] constexpr bool operator==(const ShaderConfiguration& other) const = default;
130 };
131
181
187 using Index = uint32_t;
188
215
230
235
251
268
288
295
303
308
316
320 using MorphTargetValueBuffer = StorageBuffer<MorphTargetValueFields, "Model3DMorphTargetValues">;
321
326
333
337 using JointBuffer = StorageBuffer<JointFields, "Model3DJoints">;
338
346
350 using MorphTargetWeightBuffer = StorageBuffer<MorphTargetWeightFields, "Model3DMorphTargetWeights">;
351
356
367 template <typename Constants, typename Outputs, typename... ExtraBuffers>
369
374
387 template <typename Inputs, typename Constants, typename Outputs, typename... ExtraBuffers>
389
394
399
404 template <typename Constants, typename Outputs, typename... ExtraBuffers>
406 public:
407 template <typename F>
410 : function(std::forward<F>(function)) {}
411
413 : function(
414 [vertexShaderHandle = std::move(vertexShaderHandle)](const ShaderConfiguration&) -> SharedPointer<VertexShaderImplementation> { return vertexShaderHandle; }) {}
415
416 template <typename VS>
417 GREM_ALWAYS_INLINE VertexShaderSelectorBase(const VS& vertexShader) requires(requires {
419 })
420 : function([vertexShaderHandle = vertexShader.lock()](const ShaderConfiguration&) -> SharedPointer<VertexShaderImplementation> { return vertexShaderHandle; }) {
421 static_assert(same_as<typename VS::mesh_type, Mesh>, "Vertex shader's' mesh type does not match the shader pipeline set.");
422 static_assert(same_as<typename VS::constants_type, Constants>, "Vertex shader's constants do not match the shader pipeline set.");
423 static_assert(same_as<typename VS::outputs_type, Outputs>, "Vertex shader's outputs do not match the shader pipeline set.");
424 static_assert(meta::type_list_starts_with_v<typename VertexShaderBase<Constants, Outputs, ExtraBuffers...>::buffer_types, typename VS::buffer_types>,
425 "Vertex shader's buffers do not match the shader pipeline set.");
426 }
427
429 return function(shaderConfiguration);
430 }
431
432 private:
434 };
435
440 template <typename Inputs, typename Constants, typename Outputs, typename... ExtraBuffers>
442 public:
443 template <typename F>
446 : function(std::forward<F>(function)) {}
447
449 : function([fragmentShaderHandle = std::move(fragmentShaderHandle)](const ShaderConfiguration&) -> SharedPointer<FragmentShaderImplementation> {
450 return fragmentShaderHandle;
451 }) {}
452
453 template <typename FS>
454 GREM_ALWAYS_INLINE FragmentShaderSelectorBase(const FS& fragmentShader) requires(requires {
456 })
457 : function([fragmentShaderHandle = fragmentShader.lock()](const ShaderConfiguration&) -> SharedPointer<FragmentShaderImplementation> { return fragmentShaderHandle; }) {
458 static_assert(same_as<typename FS::mesh_type, Mesh>, "Fragment shader's' mesh type does not match the shader pipeline set.");
459 static_assert(same_as<typename FS::inputs_type, Inputs>, "Fragment shader's outputs do not match the shader pipeline set.");
460 static_assert(same_as<typename FS::constants_type, Constants>, "Fragment shader's constants do not match the shader pipeline set.");
461 static_assert(same_as<typename FS::outputs_type, Outputs>, "Fragment shader's outputs do not match the shader pipeline set.");
462 static_assert(meta::type_list_starts_with_v<typename FragmentShaderBase<Inputs, Constants, Outputs, ExtraBuffers...>::buffer_types, typename FS::buffer_types>,
463 "Fragment shader's buffers do not match the shader pipeline set.");
464 }
465
467 return function(shaderConfiguration);
468 }
469
470 private:
472 };
473
494 template <typename VertexShaderConstants, typename VertexShaderOutputs, typename ExtraVertexShaderBuffers, typename FragmentShaderConstants, typename FragmentShaderOutputs,
495 typename ExtraFragmentShaderBuffers>
497
498 template <typename VertexShaderConstants, typename VertexShaderOutputs, typename... ExtraVertexShaderBuffers, typename FragmentShaderConstants, typename FragmentShaderOutputs,
499 typename... ExtraFragmentShaderBuffers>
501 meta::TypeList<ExtraFragmentShaderBuffers...>> {
502 public:
508
514
541 ShaderPipelineSetBase(Device& device, VertexShaderSelector vertexShaderSelector,
542 Function<VertexShaderConstants(const ShaderConfiguration& shaderConfiguration)> vertexShaderConstantsSelector, FragmentShaderSelector fragmentShaderSelector,
543 Function<FragmentShaderConstants(const ShaderConfiguration& shaderConfiguration)> fragmentShaderConstantsSelector,
544 Function<ShaderPipelineOptions(const ShaderConfiguration& shaderConfiguration)> shaderPipelineOptionsSelector)
545 : device(&device)
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)) {}
551
573 [[nodiscard]] const ShaderPipeline& operator()(const ShaderConfiguration& shaderConfiguration) {
574 if (const auto it = specializations.find(shaderConfiguration); it != specializations.end()) {
575 [[likely]];
576 return it->second;
577 }
578 return specializations
579 .try_emplace(shaderConfiguration, *device, vertexShaderSelector(shaderConfiguration), vertexShaderConstantsSelector(shaderConfiguration),
580 fragmentShaderSelector(shaderConfiguration), fragmentShaderConstantsSelector(shaderConfiguration), shaderPipelineOptionsSelector(shaderConfiguration))
581 .first->second;
582 }
583
584 private:
585 Device* device;
586 VertexShaderSelector vertexShaderSelector;
587 Function<VertexShaderConstants(const ShaderConfiguration& shaderConfiguration)> vertexShaderConstantsSelector;
588 FragmentShaderSelector fragmentShaderSelector;
589 Function<FragmentShaderConstants(const ShaderConfiguration& shaderConfiguration)> fragmentShaderConstantsSelector;
590 Function<ShaderPipelineOptions(const ShaderConfiguration& shaderConfiguration)> shaderPipelineOptionsSelector;
592 };
593
598
624
628 static constexpr auto DEFAULT_VERTEX_SHADER_CONSTANTS = [](const Model3D::ShaderConfiguration& shaderConfiguration) noexcept -> VertexShaderConstants {
630 .VERTEX_TEXTURED_ON_CHANNEL_0 = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_TEXTURED_ON_CHANNEL_0) != 0,
631 .VERTEX_TEXTURED_ON_CHANNEL_1 = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_TEXTURED_ON_CHANNEL_1) != 0,
632 .VERTEX_COLORED = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_COLORED) != 0,
633 .VERTEX_SKINNED = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_SKINNED) != 0,
634 .VERTEX_MORPHED_POSITION = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_MORPHED_POSITION) != 0,
635 .VERTEX_MORPHED_NORMAL = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_MORPHED_NORMAL) != 0,
636 .VERTEX_MORPHED_TANGENT = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_MORPHED_TANGENT) != 0,
637 .VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_0 = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_0) != 0,
638 .VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_1 = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_1) != 0,
639 .VERTEX_MORPHED_COLOR = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_MORPHED_COLOR) != 0,
640 };
641 };
642
646 static constexpr auto DEFAULT_FRAGMENT_SHADER_CONSTANTS = [](const Model3D::ShaderConfiguration& shaderConfiguration) noexcept -> FragmentShaderConstants {
648 .FRAGMENT_HDR = false,
649 .FRAGMENT_ALPHA_MASKED = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_ALPHA_MASKED) != 0,
650 .FRAGMENT_ALPHA_BLENDED = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_ALPHA_BLENDED) != 0,
651 .FRAGMENT_DOUBLE_SIDED = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_DOUBLE_SIDED) != 0,
652 .FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_0 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_0) != 0,
653 .FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_1 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_1) != 0,
654 .FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_0 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_0) != 0,
655 .FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_1 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_1) != 0,
656 .FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_0 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_0) != 0,
657 .FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_1 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_1) != 0,
658 .FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_0 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_0) != 0,
659 .FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_1 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_1) != 0,
660 .FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_0 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_0) != 0,
661 .FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_1 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_1) != 0,
662 };
663 };
664
668 static constexpr auto DEFAULT_SHADER_PIPELINE_OPTIONS = [](const Model3D::ShaderConfiguration& shaderConfiguration) noexcept -> ShaderPipelineOptions {
670 .primitiveType = shaderConfiguration.primitiveType,
672 .frontFace = shaderConfiguration.frontFace,
673 .blendState = ((shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_ALPHA_BLENDED) != 0)
676 };
677 };
678
682 Model3D() noexcept = default;
683
700 GREM_API(graphics_3d)
701 Model3D(Device& device, Renderer3D& renderer3D, const resource::Model& model, const Model3DOptions& options = {},
703 loadTextureDefault);
704
721 GREM_API(graphics_3d)
722 Model3D(Device& device, Renderer3D& renderer3D, resource::Model&& model, const Model3DOptions& options = {},
724 loadTextureDefault);
725
727 GREM_API(graphics_3d) ~Model3D();
728
730 GREM_API(graphics_3d) Model3D(const Model3D& other);
731
733 GREM_API(graphics_3d) Model3D(Model3D&& other) noexcept;
734
736 GREM_API(graphics_3d) Model3D& operator=(const Model3D& other);
737
739 GREM_API(graphics_3d) Model3D& operator=(Model3D&& other) noexcept;
740
746 explicit operator bool() const noexcept {
747 return m.device != nullptr;
748 }
749
768 void setNodeMeshParameters(size_t nodeIndex, const Parameters& newParameters) {
769 Node& node = m.nodes[nodeIndex];
770 node.mesh.setParameters(newParameters);
771
772 if (newParameters.meshBaseColorMap) {
775 }
778 }
779 } else {
780 node.shaderConfiguration.fragmentFlags &= ~resource::Model::FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_0;
781 node.shaderConfiguration.fragmentFlags &= ~resource::Model::FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_1;
782 }
783
784 if (newParameters.meshOcclusionRoughnessMetallicMap) {
788 }
792 }
793 } else {
794 node.shaderConfiguration.fragmentFlags &= ~resource::Model::FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_0;
795 node.shaderConfiguration.fragmentFlags &= ~resource::Model::FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_1;
796 node.shaderConfiguration.fragmentFlags &= ~resource::Model::FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_0;
797 node.shaderConfiguration.fragmentFlags &= ~resource::Model::FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_1;
798 }
799
800 if (newParameters.meshNormalMap) {
803 }
806 }
807 } else {
808 node.shaderConfiguration.fragmentFlags &= ~resource::Model::FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_0;
809 node.shaderConfiguration.fragmentFlags &= ~resource::Model::FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_1;
810 }
811
812 if (newParameters.meshEmissiveMap) {
815 }
818 }
819 } else {
820 node.shaderConfiguration.fragmentFlags &= ~resource::Model::FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_0;
821 node.shaderConfiguration.fragmentFlags &= ~resource::Model::FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_1;
822 }
823 }
824
834 void setNodeMaterialType(size_t nodeIndex, MaterialType newMaterialType) {
835 m.nodes[nodeIndex].shaderConfiguration.materialType = newMaterialType;
836 }
837
846 void setNodeFrontFace(size_t nodeIndex, FrontFace newFrontFace) {
847 m.nodes[nodeIndex].shaderConfiguration.frontFace = newFrontFace;
848 }
849
858 void setNodeAlphaMasked(size_t nodeIndex, bool newAlphaMasked) {
859 Node& node = m.nodes[nodeIndex];
860 if (newAlphaMasked) {
862 } else {
863 node.shaderConfiguration.fragmentFlags &= ~resource::Model::FRAGMENT_ALPHA_MASKED;
864 }
865 }
866
875 void setNodeAlphaBlended(size_t nodeIndex, bool newAlphaBlended) {
876 Node& node = m.nodes[nodeIndex];
877 if (newAlphaBlended) {
879 } else {
880 node.shaderConfiguration.fragmentFlags &= ~resource::Model::FRAGMENT_ALPHA_BLENDED;
881 }
882 }
883
892 void setNodeDoubleSided(size_t nodeIndex, bool newDoubleSided) {
893 Node& node = m.nodes[nodeIndex];
894 if (newDoubleSided) {
896 } else {
897 node.shaderConfiguration.fragmentFlags &= ~resource::Model::FRAGMENT_DOUBLE_SIDED;
898 }
899 }
900
906 [[nodiscard]] Span<const Node> getNodes() const noexcept {
907 return m.nodes;
908 }
909
916 [[nodiscard]] uint32_t getInverseBindPoseMatrixOffset() const noexcept {
917 return m.inverseBindPoseMatrixRange.begin;
918 }
919
926 [[nodiscard]] uint32_t getMorphTargetValueOffset() const noexcept {
927 return m.morphTargetValueRange.begin;
928 }
929
935 [[nodiscard]] const resource::Model::Pose& getBindPose() const noexcept {
936 return m.bindPose;
937 }
938
944 [[nodiscard]] resource::Model::JointCount getJointCount() const noexcept {
945 return static_cast<resource::Model::JointCount>(m.bindPose.localJoints.size());
946 }
947
954 [[nodiscard]] resource::Model::JointCount getStaticJointCount() const noexcept {
955 return m.staticJointCount;
956 }
957
964 return static_cast<resource::Model::MorphTargetWeightCount>(m.bindPose.localMorphTargetWeights.size());
965 }
966
973 return m.jointParentIndices;
974 }
975
982 return m.animations;
983 }
984
992 return m.animationChannels;
993 }
994
1001 [[nodiscard]] Span<const float> getKeyframeInputTimePoints() const noexcept {
1002 return m.keyframeInputTimePoints;
1003 }
1004
1011 [[nodiscard]] Span<const byte> getKeyframeOutputValueData() const noexcept {
1012 return m.keyframeOutputValueData;
1013 }
1014
1024 if (const auto it = m.animationMap.find(name); it != m.animationMap.end()) {
1025 return it->second;
1026 }
1027 return {};
1028 }
1029
1040 if (const Optional<resource::Model::AnimationIndex> animationIndex = findAnimationIndex(name)) {
1041 return *animationIndex;
1042 }
1043 throw std::out_of_range{"Animation \"" + String{name} + "\" not found."};
1044 }
1045
1056 if (static_cast<size_t>(index) >= m.animations.size()) {
1057 throw std::out_of_range{"Invalid animation index."};
1058 }
1059 const resource::Model::Animation& animation = m.animations[index];
1060 const resource::Model::AnimationChannelIndex animationChannelsBegin = animation.animationChannelOffset;
1061 const resource::Model::AnimationChannelIndex animationChannelsEnd =
1062 (index + 1 < m.animations.size()) ? m.animations[index + 1].animationChannelOffset : static_cast<resource::Model::AnimationChannelIndex>(m.animationChannels.size());
1064 .minTimePoint = animation.minTimePoint,
1065 .maxTimePoint = animation.maxTimePoint,
1066 .channels = Span{m.animationChannels}.subspan(animationChannelsBegin, animationChannelsEnd - animationChannelsBegin),
1067 .keyframeInputTimePoints = m.keyframeInputTimePoints,
1068 .keyframeOutputValueData = m.keyframeOutputValueData,
1069 };
1070 }
1071
1084
1094 if (const Optional<resource::Model::AnimationIndex> animationIndex = findAnimationIndex(name)) {
1095 return getAnimationAtIndex(*animationIndex);
1096 }
1097 return {};
1098 }
1099
1109 if (const auto it = m.jointMap.find(name); it != m.jointMap.end()) {
1110 return it->second;
1111 }
1112 return {};
1113 }
1114
1125 if (const Optional<resource::Model::JointIndex> jointIndex = findJointIndex(name)) {
1126 return *jointIndex;
1127 }
1128 throw std::out_of_range{"Joint \"" + String{name} + "\" not found."};
1129 }
1130
1140 if (const auto it = m.skinMap.find(name); it != m.skinMap.end()) {
1141 return it->second;
1142 }
1143 return {};
1144 }
1145
1157 if (const Optional<resource::Model::JointIndex> rootJointIndex = findSkinRootJointIndex(name)) {
1158 return *rootJointIndex;
1159 }
1160 throw std::out_of_range{"Skin \"" + String{name} + "\" not found."};
1161 }
1162
1169 [[nodiscard]] Box<3, float> getBindPoseBoundingBox() const noexcept {
1170 return m.bindPoseBoundingBox;
1171 }
1172
1178 [[nodiscard]] float getBindPoseBoundingRadius() const noexcept {
1179 return m.bindPoseBoundingRadius;
1180 }
1181
1182private:
1183 [[nodiscard]] static SharedPointer<TextureImplementation> loadTextureDefault(Device& device, const resource::Model::Image& image,
1184 const TextureImageUploadOptions& textureImageUploadOptions, const TextureSamplerOptions& textureSamplerOptions) {
1185 const resource::ImageView imageView = match(image)([&](const auto& img) -> resource::ImageView { return img; });
1186 return Texture{device, imageView, textureImageUploadOptions, textureSamplerOptions}.lock();
1187 }
1188
1189 struct {
1190 Device* device = nullptr;
1207 } m;
1208};
1209
1210} // namespace grem::graphics
1211
1212template <>
1213struct std::hash<grem::graphics::Model3D::ShaderConfiguration> {
1214 [[nodiscard]] std::size_t operator()(const grem::graphics::Model3D::ShaderConfiguration& configuration) const {
1215 return hasher(configuration);
1216 }
1217
1218private:
1219 [[no_unique_address]] grem::graphics::Model3D::ShaderConfiguration::Hash hasher;
1220};
1221
1222#endif
#define GREM_ALWAYS_INLINE
Definition attributes.hpp:10
Definition ArrayList.hpp:27
Definition Buffer.hpp:28
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
Definition Span.hpp:146
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
Definition aliases.hpp:16
constexpr bool type_list_starts_with_v
Whether a specialization of meta::TypeList starts with the types in another type list.
Definition metaprogramming.hpp:629
Definition Window.hpp:15
Definition aliases.hpp:9
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
Definition math.hpp:474
Compile-time list of types.
Definition metaprogramming.hpp:347
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