GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::graphics::Model3D Class Reference

Container for a set of 3D triangle mesh nodes stored on the GPU. More...

#include <GREM/graphics_3d/Model3D.hpp>

Classes

struct  ShaderConfiguration
 Configuration options for shading a mesh instance of a 3D model. More...
struct  Vertex
 Data layout for the attributes of a single vertex of a 3D model mesh. More...
struct  Parameters
 Parameters of a 3D model mesh. More...
struct  Instance
 Data layout for the attributes of a single instance of a 3D model mesh. More...
struct  VertexShaderConstants
 Struct of default vertex shader constants. More...
struct  VertexShaderOutputs
 Struct of fields output by the default vertex shader. More...
struct  FragmentShaderConstants
 Struct of default fragment shader constants. More...
struct  FragmentShaderOutputs
 Struct of fields output by the default fragment shader. More...
struct  InverseBindPoseMatrixFields
 Struct of shader fields representing the inverse bind matrix of a joint of a 3D model. More...
struct  MorphTargetValueFields
 Struct of shader fields representing the value of a morph target of a 3D model. More...
struct  JointFields
 Struct of shader fields representing a joint of a 3D model. More...
struct  MorphTargetWeightFields
 Struct of shader fields representing the state of a morph target weight of a 3D model. More...
class  VertexShaderSelectorBase
 Adapter for a function that selects which vertex shader to use for a given shader configuration. More...
class  FragmentShaderSelectorBase
 Adapter for a function that selects which fragment shader to use for a given shader configuration. More...
class  ShaderPipelineSetBase
 Shader pipeline set for drawing 3D models. More...
class  ShaderPipelineSetBase< VertexShaderConstants, VertexShaderOutputs, meta::TypeList< ExtraVertexShaderBuffers... >, FragmentShaderConstants, FragmentShaderOutputs, meta::TypeList< ExtraFragmentShaderBuffers... > >
struct  Node
 Node of a 3D model. More...

Public Types

enum class  MaterialType : uint8_t { METALLIC_ROUGHNESS = 0 , UNLIT = 1 }
 Material type that specifies how the material parameters should be interpreted when shading a mesh instance of a 3D model. More...
using Index = uint32_t
 Data type used in the index buffer of a 3D model mesh.
using Mesh = graphics::Mesh<Vertex, Index, Parameters, Instance>
 Type of a single mesh of a 3D model.
using InverseBindPoseMatrixBuffer = StorageBuffer<InverseBindPoseMatrixFields, "Model3DInverseBindPoseMatrices">
 Shader buffer for 3D model inverse bind-pose matrices.
using MorphTargetValueBuffer = StorageBuffer<MorphTargetValueFields, "Model3DMorphTargetValues">
 Shader buffer for 3D model morph target values.
using DataBuffers = BufferSet<InverseBindPoseMatrixBuffer, MorphTargetValueBuffer>
 Set of shader buffers related to the static data of 3D models.
using JointBuffer = StorageBuffer<JointFields, "Model3DJoints">
 Shader buffer for 3D model joints.
using MorphTargetWeightBuffer = StorageBuffer<MorphTargetWeightFields, "Model3DMorphTargetWeights">
 Shader buffer for 3D model morph target weights.
using InstanceBuffers = BufferSet<JointBuffer, MorphTargetWeightBuffer>
 Set of shader buffers related to the dynamic data of 3D model instances.
template<typename Constants, typename Outputs, typename... ExtraBuffers>
using VertexShaderBase = graphics::VertexShader<Mesh, Constants, Outputs, Camera3D::ParameterBuffer, DataBuffers, InstanceBuffers, ExtraBuffers...>
 Vertex shader for drawing 3D models.
using VertexShader = VertexShaderBase<VertexShaderConstants, VertexShaderOutputs>
 Default vertex shader for drawing 3D models.
template<typename Inputs, typename Constants, typename Outputs, typename... ExtraBuffers>
using FragmentShaderBase = graphics::FragmentShader<Mesh, Inputs, Constants, Outputs, Camera3D::ParameterBuffer, DataBuffers, InstanceBuffers, ExtraBuffers...>
 Fragment shader for drawing 3D models.
using FragmentShader = FragmentShaderBase<VertexShaderOutputs, FragmentShaderConstants, FragmentShaderOutputs>
 Default fragment shader type for drawing 3D models.
using ShaderPipeline = graphics::ShaderPipeline<Mesh>
 Shader pipeline for drawing 3D models.
using ShaderPipelineSet = ShaderPipelineSetBase<VertexShaderConstants, VertexShaderOutputs, meta::TypeList<>, FragmentShaderConstants, FragmentShaderOutputs, meta::TypeList<>>
 Default shader pipeline set for drawing 3D models.

Public Member Functions

 Model3D () noexcept=default
 Construct an invalid model that must be reassigned before use.
 Model3D (Device &device, Renderer3D &renderer3D, const resource::Model &model, const Model3DOptions &options={}, FunctionView< SharedPointer< TextureImplementation >(Device &, const resource::Model::Image &, const TextureImageUploadOptions &, const TextureSamplerOptions &)> loadTexture=loadTextureDefault)
 Construct a model from loaded model data.
 Model3D (Device &device, Renderer3D &renderer3D, resource::Model &&model, const Model3DOptions &options={}, FunctionView< SharedPointer< TextureImplementation >(Device &, const resource::Model::Image &, const TextureImageUploadOptions &, const TextureSamplerOptions &)> loadTexture=loadTextureDefault)
 Construct a model from loaded model data.
 ~Model3D ()
 Destructor.
 Model3D (const Model3D &other)
 Copy constructor.
 Model3D (Model3D &&other) noexcept
 Move constructor.
Model3D & operator= (const Model3D &other)
 Copy assignment.
Model3D & operator= (Model3D &&other) noexcept
 Move assignment.
 operator bool () const noexcept
 Check if the model has a value.
void setNodeMeshParameters (size_t nodeIndex, const Parameters &newParameters)
 Set the mesh parameters of a node in the model.
void setNodeMaterialType (size_t nodeIndex, MaterialType newMaterialType)
 Set how to interpret the material parameters of a node in the model when shading.
void setNodeFrontFace (size_t nodeIndex, FrontFace newFrontFace)
 Set the winding order of the front-facing faces of a node in the model.
void setNodeAlphaMasked (size_t nodeIndex, bool newAlphaMasked)
 Set whether a node in the model is alpha masked or not.
void setNodeAlphaBlended (size_t nodeIndex, bool newAlphaBlended)
 Set whether a node in the model is alpha blended or not.
void setNodeDoubleSided (size_t nodeIndex, bool newDoubleSided)
 Set whether a node in the model is double-sided or not.
Span< const Node > getNodes () const noexcept
 Get the nodes of the model.
uint32_t getInverseBindPoseMatrixOffset () const noexcept
 Get the inverse bind-pose matrix offset of the model.
uint32_t getMorphTargetValueOffset () const noexcept
 Get the morph target value offset of the model.
const resource::Model::Pose & getBindPose () const noexcept
 Get the local bind pose of the model.
resource::Model::JointCount getJointCount () const noexcept
 Get the number of joints in the model.
resource::Model::JointCount getStaticJointCount () const noexcept
 Get the number of static joints in the model.
resource::Model::MorphTargetWeightCount getMorphTargetWeightCount () const noexcept
 Get the number of morph target weights of the model.
Span< const resource::Model::JointIndex > getJointParentIndices () const noexcept
 Get the indices of the parent joints of each joint of the model.
Span< const resource::Model::Animation > getAnimations () const noexcept
 Get the animations of the model.
Span< const resource::Model::AnimationChannel > getAnimationChannels () const noexcept
 Get the animation channels of the model.
Span< const float > getKeyframeInputTimePoints () const noexcept
 Get the input timepoints of the animation channel keyframes of the model.
Span< const byte > getKeyframeOutputValueData () const noexcept
 Get the output values of the animation channel keyframes of the model.
Optional< resource::Model::AnimationIndex > findAnimationIndex (StringView name) const noexcept
 Find the index of an animation with a specific name.
resource::Model::AnimationIndex getAnimationIndex (StringView name) const
 Get the index of an animation with a specific name.
resource::Model::AnimationView getAnimationAtIndex (resource::Model::AnimationIndex index) const
 Get the animation at a specific index.
resource::Model::AnimationView getAnimation (StringView name) const
 Get the animation with a specific name.
Optional< resource::Model::AnimationView > findAnimation (StringView name) const noexcept
 Try to get the animation with a specific name.
Optional< resource::Model::JointIndex > findJointIndex (StringView name) const noexcept
 Find the index of a joint with a specific name.
resource::Model::JointIndex getJointIndex (StringView name) const
 Get the index of a joint with a specific name.
Optional< resource::Model::JointIndex > findSkinRootJointIndex (StringView name) const noexcept
 Find the index of the root joint of a skin with a specific name.
resource::Model::JointIndex getSkinRootJointIndex (StringView name) const
 Get the index of the root joint of a skin with a specific name.
Box< 3, float > getBindPoseBoundingBox () const noexcept
 Get the local bounding box of the model in its bind pose.
float getBindPoseBoundingRadius () const noexcept
 Get the local bounding radius of the model in its bind pose.

Static Public Attributes

static constexpr auto DEFAULT_VERTEX_SHADER_CONSTANTS
 Default 3D model vertex shader constants.
static constexpr auto DEFAULT_FRAGMENT_SHADER_CONSTANTS
 Default 3D model fragment shader constants.
static constexpr auto DEFAULT_SHADER_PIPELINE_OPTIONS
 Default 3D model graphics pipeline configuration.

Detailed Description

Container for a set of 3D triangle mesh nodes stored on the GPU.

Member Typedef Documentation

◆ Index

Data type used in the index buffer of a 3D model mesh.

Meets the requirements of the grem::graphics::mesh_index concept.

◆ Mesh

Type of a single mesh of a 3D model.

◆ InverseBindPoseMatrixBuffer

Shader buffer for 3D model inverse bind-pose matrices.

◆ MorphTargetValueBuffer

Shader buffer for 3D model morph target values.

◆ DataBuffers

Set of shader buffers related to the static data of 3D models.

◆ JointBuffer

Shader buffer for 3D model joints.

◆ MorphTargetWeightBuffer

Shader buffer for 3D model morph target weights.

◆ InstanceBuffers

Set of shader buffers related to the dynamic data of 3D model instances.

◆ VertexShaderBase

template<typename Constants, typename Outputs, typename... ExtraBuffers>
using grem::graphics::Model3D::VertexShaderBase = graphics::VertexShader<Mesh, Constants, Outputs, Camera3D::ParameterBuffer, DataBuffers, InstanceBuffers, ExtraBuffers...>

Vertex shader for drawing 3D models.

Template Parameters
Constantsuser-defined aggregate type of external constants that are declared in the shader.
Outputsuser-defined aggregate type of fields that are declared in the shader and passed to the next pipeline stage.
ExtraBufferslist of buffers that the shader reads from in addition to the required 3D model buffers.

◆ VertexShader

◆ FragmentShaderBase

template<typename Inputs, typename Constants, typename Outputs, typename... ExtraBuffers>
using grem::graphics::Model3D::FragmentShaderBase = graphics::FragmentShader<Mesh, Inputs, Constants, Outputs, Camera3D::ParameterBuffer, DataBuffers, InstanceBuffers, ExtraBuffers...>

Fragment shader for drawing 3D models.

Template Parameters
Inputsuser-defined aggregate type of fields that are passed into the shader from the previous pipeline stage.
Constantsuser-defined aggregate type of external constants that are declared in the shader.
Outputsuser-defined aggregate type of fields that are declared in the shader and passed to the next pipeline stage.
ExtraBufferslist of buffers that the shader reads from in addition to the required 3D model buffers.

◆ FragmentShader

◆ ShaderPipeline

Shader pipeline for drawing 3D models.

◆ ShaderPipelineSet

Member Enumeration Documentation

◆ MaterialType

enum class grem::graphics::Model3D::MaterialType : uint8_t
strong

Material type that specifies how the material parameters should be interpreted when shading a mesh instance of a 3D model.

Enumerator
METALLIC_ROUGHNESS 

The shader should interpret the material according to the standard metallic-roughness model.

UNLIT 

The shader should use only the base color at full brightness.

Constructor & Destructor Documentation

◆ Model3D() [1/5]

grem::graphics::Model3D::Model3D ( )
defaultnoexcept

Construct an invalid model that must be reassigned before use.

◆ Model3D() [2/5]

grem::graphics::Model3D::Model3D ( Device & device,
Renderer3D & renderer3D,
const resource::Model & model,
const Model3DOptions & options = {},
FunctionView< SharedPointer< TextureImplementation >(Device &, const resource::Model::Image &, const TextureImageUploadOptions &, const TextureSamplerOptions &)> loadTexture = loadTextureDefault )

Construct a model from loaded model data.

Parameters
devicedevice to create the model for. Must outlive the model.
renderer3Drenderer to create the model for. Must be associated with the given device. Must outlive the model.
modeldata to create the model from.
optionsmodel options, see Model3DOptions.
loadTexturefunction to use to load the textures from the images provided by the model. Defaults to creating a new texture.
Exceptions
graphics::Erroron failure to create the model.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ Model3D() [3/5]

grem::graphics::Model3D::Model3D ( Device & device,
Renderer3D & renderer3D,
resource::Model && model,
const Model3DOptions & options = {},
FunctionView< SharedPointer< TextureImplementation >(Device &, const resource::Model::Image &, const TextureImageUploadOptions &, const TextureSamplerOptions &)> loadTexture = loadTextureDefault )

Construct a model from loaded model data.

Parameters
devicedevice to create the model for. Must outlive the model.
renderer3Drenderer to create the model for. Must be associated with the given device. Must outlive the model.
modeldata to create the model from.
optionsmodel options, see Model3DOptions.
loadTexturefunction to use to load the textures from the images provided by the model. Defaults to creating a new texture.
Exceptions
graphics::Erroron failure to create the model.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ ~Model3D()

grem::graphics::Model3D::~Model3D ( )

Destructor.

◆ Model3D() [4/5]

grem::graphics::Model3D::Model3D ( const Model3D & other)

Copy constructor.

◆ Model3D() [5/5]

grem::graphics::Model3D::Model3D ( Model3D && other)
noexcept

Move constructor.

Member Function Documentation

◆ operator=() [1/2]

Model3D & grem::graphics::Model3D::operator= ( const Model3D & other)

Copy assignment.

◆ operator=() [2/2]

Model3D & grem::graphics::Model3D::operator= ( Model3D && other)
noexcept

Move assignment.

◆ operator bool()

grem::graphics::Model3D::operator bool ( ) const
inlineexplicitnoexcept

Check if the model has a value.

Returns
true if the model has a value, false otherwise.

◆ setNodeMeshParameters()

void grem::graphics::Model3D::setNodeMeshParameters ( size_t nodeIndex,
const Parameters & newParameters )
inline

Set the mesh parameters of a node in the model.

Parameters
nodeIndexindex of the node whose parameters to update. Must be a valid node index.
newParametersnew parameter values to set.
Exceptions
graphics::Erroron failure to set the parameters.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Note
The shape of the new parameters will also affect the node's shader configuration.
Warning
The given morph target parameters must be valid for the model and the current morph configuration of the mesh.

◆ setNodeMaterialType()

void grem::graphics::Model3D::setNodeMaterialType ( size_t nodeIndex,
MaterialType newMaterialType )
inline

Set how to interpret the material parameters of a node in the model when shading.

Parameters
nodeIndexindex of the node to update. Must be a valid node index.
newMaterialTypenew material type to set.
Note
This affects the node's shader configuration.

◆ setNodeFrontFace()

void grem::graphics::Model3D::setNodeFrontFace ( size_t nodeIndex,
FrontFace newFrontFace )
inline

Set the winding order of the front-facing faces of a node in the model.

Parameters
nodeIndexindex of the node to update. Must be a valid node index.
newFrontFacenew front face to set.
Note
This affects the node's shader configuration.

◆ setNodeAlphaMasked()

void grem::graphics::Model3D::setNodeAlphaMasked ( size_t nodeIndex,
bool newAlphaMasked )
inline

Set whether a node in the model is alpha masked or not.

Parameters
nodeIndexindex of the node to update. Must be a valid node index.
newAlphaMaskednew alpha masked state to set.
Note
This affects the fragment flags of the node's shader configuration.

◆ setNodeAlphaBlended()

void grem::graphics::Model3D::setNodeAlphaBlended ( size_t nodeIndex,
bool newAlphaBlended )
inline

Set whether a node in the model is alpha blended or not.

Parameters
nodeIndexindex of the node to update. Must be a valid node index.
newAlphaBlendednew alpha blended state to set.
Note
This affects the fragment flags of the node's shader configuration.

◆ setNodeDoubleSided()

void grem::graphics::Model3D::setNodeDoubleSided ( size_t nodeIndex,
bool newDoubleSided )
inline

Set whether a node in the model is double-sided or not.

Parameters
nodeIndexindex of the node to update. Must be a valid node index.
newDoubleSidednew double-sided state to set.
Note
This affects the fragment flags of the node's shader configuration.

◆ getNodes()

Span< const Node > grem::graphics::Model3D::getNodes ( ) const
inlinenodiscardnoexcept

Get the nodes of the model.

Returns
a read-only view over the nodes of the model.

◆ getInverseBindPoseMatrixOffset()

uint32_t grem::graphics::Model3D::getInverseBindPoseMatrixOffset ( ) const
inlinenodiscardnoexcept

Get the inverse bind-pose matrix offset of the model.

Returns
the index of the first inverse bind-pose matrix of the model in the device that the model was created for.

◆ getMorphTargetValueOffset()

uint32_t grem::graphics::Model3D::getMorphTargetValueOffset ( ) const
inlinenodiscardnoexcept

Get the morph target value offset of the model.

Returns
the index of the first floating-point value of the model's morph targets in the device that the model was created for.

◆ getBindPose()

const resource::Model::Pose & grem::graphics::Model3D::getBindPose ( ) const
inlinenodiscardnoexcept

Get the local bind pose of the model.

Returns
the bind pose of the model.

◆ getJointCount()

resource::Model::JointCount grem::graphics::Model3D::getJointCount ( ) const
inlinenodiscardnoexcept

Get the number of joints in the model.

Returns
the number of joints in the model.

◆ getStaticJointCount()

resource::Model::JointCount grem::graphics::Model3D::getStaticJointCount ( ) const
inlinenodiscardnoexcept

Get the number of static joints in the model.

Returns
the number of unskinned joints at the beginning of the model's joint array.

◆ getMorphTargetWeightCount()

resource::Model::MorphTargetWeightCount grem::graphics::Model3D::getMorphTargetWeightCount ( ) const
inlinenodiscardnoexcept

Get the number of morph target weights of the model.

Returns
the number of morph target weights of the model.

◆ getJointParentIndices()

Span< const resource::Model::JointIndex > grem::graphics::Model3D::getJointParentIndices ( ) const
inlinenodiscardnoexcept

Get the indices of the parent joints of each joint of the model.

Returns
the parent indices of each joint of the model.

◆ getAnimations()

Span< const resource::Model::Animation > grem::graphics::Model3D::getAnimations ( ) const
inlinenodiscardnoexcept

Get the animations of the model.

Returns
a read-only view over the array of animations of the model.

◆ getAnimationChannels()

Span< const resource::Model::AnimationChannel > grem::graphics::Model3D::getAnimationChannels ( ) const
inlinenodiscardnoexcept

Get the animation channels of the model.

Returns
a read-only view over the array of animation channels of the model.

◆ getKeyframeInputTimePoints()

Span< const float > grem::graphics::Model3D::getKeyframeInputTimePoints ( ) const
inlinenodiscardnoexcept

Get the input timepoints of the animation channel keyframes of the model.

Returns
a read-only view over the array of input timepoints of the animation channel keyframes of the model.

◆ getKeyframeOutputValueData()

Span< const byte > grem::graphics::Model3D::getKeyframeOutputValueData ( ) const
inlinenodiscardnoexcept

Get the output values of the animation channel keyframes of the model.

Returns
a read-only view over the bytes of the array of output values of the animation channel keyframes of the model.

◆ findAnimationIndex()

Optional< resource::Model::AnimationIndex > grem::graphics::Model3D::findAnimationIndex ( StringView name) const
inlinenodiscardnoexcept

Find the index of an animation with a specific name.

Parameters
namename of the animation to search for.
Returns
the index of the given animation in the model's animation array, or an empty optional if the animation wasn't found.

◆ getAnimationIndex()

resource::Model::AnimationIndex grem::graphics::Model3D::getAnimationIndex ( StringView name) const
inlinenodiscard

Get the index of an animation with a specific name.

Parameters
namename of the animation to search for.
Returns
the index of the given animation in the model's animation array.
Exceptions
std::out_of_rangeif the given animation wasn't found.

◆ getAnimationAtIndex()

resource::Model::AnimationView grem::graphics::Model3D::getAnimationAtIndex ( resource::Model::AnimationIndex index) const
inlinenodiscard

Get the animation at a specific index.

Parameters
indexindex of the animation to get.
Returns
a non-owning read-only view over the given animation.
Exceptions
std::out_of_rangeif the given index is out of range.

◆ getAnimation()

resource::Model::AnimationView grem::graphics::Model3D::getAnimation ( StringView name) const
inlinenodiscard

Get the animation with a specific name.

Parameters
namename of the animation to search for.
Returns
a non-owning read-only view over the given animation.
Exceptions
std::out_of_rangeif the animation was not found.

◆ findAnimation()

Optional< resource::Model::AnimationView > grem::graphics::Model3D::findAnimation ( StringView name) const
inlinenodiscardnoexcept

Try to get the animation with a specific name.

Parameters
namename of the animation to search for.
Returns
a non-owning read-only view over the given animation, or an empty optional if the animation wasn't found.

◆ findJointIndex()

Optional< resource::Model::JointIndex > grem::graphics::Model3D::findJointIndex ( StringView name) const
inlinenodiscardnoexcept

Find the index of a joint with a specific name.

Parameters
namename of the joint to search for.
Returns
the index of the given joint in the model's joint array, or an empty optional if the joint wasn't found.

◆ getJointIndex()

resource::Model::JointIndex grem::graphics::Model3D::getJointIndex ( StringView name) const
inlinenodiscard

Get the index of a joint with a specific name.

Parameters
namename of the joint to search for.
Returns
the index of the given joint in the model's joint array.
Exceptions
std::out_of_rangeif the given joint wasn't found.

◆ findSkinRootJointIndex()

Optional< resource::Model::JointIndex > grem::graphics::Model3D::findSkinRootJointIndex ( StringView name) const
inlinenodiscardnoexcept

Find the index of the root joint of a skin with a specific name.

Parameters
namename of the skin whose root joint to search for.
Returns
the index of the root joint of the given skin in the model's joint array, or an empty optional if the skin wasn't found.

◆ getSkinRootJointIndex()

resource::Model::JointIndex grem::graphics::Model3D::getSkinRootJointIndex ( StringView name) const
inlinenodiscard

Get the index of the root joint of a skin with a specific name.

Parameters
namename of the skin whose root joint to search for.
Returns
the index of the root joint of the given skin in the model's joint array.
Exceptions
std::out_of_rangeif the given skin wasn't found.

◆ getBindPoseBoundingBox()

Box< 3, float > grem::graphics::Model3D::getBindPoseBoundingBox ( ) const
inlinenodiscardnoexcept

Get the local bounding box of the model in its bind pose.

Returns
the axis-aligned bounding box of the model, relative to its origin.

◆ getBindPoseBoundingRadius()

float grem::graphics::Model3D::getBindPoseBoundingRadius ( ) const
inlinenodiscardnoexcept

Get the local bounding radius of the model in its bind pose.

Returns
the maximum vertex position distance from the model origin.

Member Data Documentation

◆ DEFAULT_VERTEX_SHADER_CONSTANTS

auto grem::graphics::Model3D::DEFAULT_VERTEX_SHADER_CONSTANTS
staticconstexpr
Initial value:
= [](const Model3D::ShaderConfiguration& shaderConfiguration) noexcept -> VertexShaderConstants {
.VERTEX_TEXTURED_ON_CHANNEL_0 = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_TEXTURED_ON_CHANNEL_0) != 0,
.VERTEX_TEXTURED_ON_CHANNEL_1 = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_TEXTURED_ON_CHANNEL_1) != 0,
.VERTEX_COLORED = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_COLORED) != 0,
.VERTEX_SKINNED = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_SKINNED) != 0,
.VERTEX_MORPHED_POSITION = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_MORPHED_POSITION) != 0,
.VERTEX_MORPHED_NORMAL = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_MORPHED_NORMAL) != 0,
.VERTEX_MORPHED_TANGENT = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_MORPHED_TANGENT) != 0,
.VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_0 = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_0) != 0,
.VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_1 = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_1) != 0,
.VERTEX_MORPHED_COLOR = (shaderConfiguration.vertexFlags & resource::Model::VERTEX_MORPHED_COLOR) != 0,
};
}
Configuration options for shading a mesh instance of a 3D model.
Definition Model3D.hpp:81
Struct of default vertex shader constants.
Definition Model3D.hpp:239
@ 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

Default 3D model vertex shader constants.

◆ DEFAULT_FRAGMENT_SHADER_CONSTANTS

auto grem::graphics::Model3D::DEFAULT_FRAGMENT_SHADER_CONSTANTS
staticconstexpr
Initial value:
= [](const Model3D::ShaderConfiguration& shaderConfiguration) noexcept -> FragmentShaderConstants {
.FRAGMENT_HDR = false,
.FRAGMENT_ALPHA_MASKED = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_ALPHA_MASKED) != 0,
.FRAGMENT_ALPHA_BLENDED = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_ALPHA_BLENDED) != 0,
.FRAGMENT_DOUBLE_SIDED = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_DOUBLE_SIDED) != 0,
.FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_0 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_0) != 0,
.FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_1 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_1) != 0,
.FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_0 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_0) != 0,
.FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_1 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_1) != 0,
.FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_0 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_0) != 0,
.FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_1 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_1) != 0,
.FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_0 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_0) != 0,
.FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_1 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_1) != 0,
.FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_0 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_0) != 0,
.FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_1 = (shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_1) != 0,
};
}
Struct of default fragment shader constants.
Definition Model3D.hpp:272
@ 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

Default 3D model fragment shader constants.

◆ DEFAULT_SHADER_PIPELINE_OPTIONS

auto grem::graphics::Model3D::DEFAULT_SHADER_PIPELINE_OPTIONS
staticconstexpr
Initial value:
= [](const Model3D::ShaderConfiguration& shaderConfiguration) noexcept -> ShaderPipelineOptions {
.primitiveType = shaderConfiguration.primitiveType,
.faceCullingMode = ((shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_DOUBLE_SIDED) != 0) ? FaceCullingMode::NONE : FaceCullingMode::CULL_BACK_FACES,
.frontFace = shaderConfiguration.frontFace,
.blendState = ((shaderConfiguration.fragmentFlags & resource::Model::FRAGMENT_ALPHA_BLENDED) != 0)
};
}
Optional value type that holds either a value or no value.
Definition Optional.hpp:58
FaceCullingMode
Face culling mode used in a ShaderPipelineOptions.
Definition shaders.hpp:315
@ 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
Definition Window.hpp:15
Blend state used in a ShaderPipelineOptions.
Definition shaders.hpp:389
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 of a graphics pipeline.
Definition shaders.hpp:428

Default 3D model graphics pipeline configuration.

◆ device

Device* grem::graphics::Model3D::device = nullptr

◆ renderer3D

Renderer3D* grem::graphics::Model3D::renderer3D = nullptr

◆ nodes

ArrayList<Node> grem::graphics::Model3D::nodes {}

◆ inverseBindPoseMatrixRange

RangeAllocation<uint32_t> grem::graphics::Model3D::inverseBindPoseMatrixRange {}

◆ morphTargetValueRange

RangeAllocation<uint32_t> grem::graphics::Model3D::morphTargetValueRange {}

◆ bindPose

resource::Model::Pose grem::graphics::Model3D::bindPose {}

◆ jointParentIndices

ArrayList<resource::Model::JointIndex> grem::graphics::Model3D::jointParentIndices {}

◆ animations

ArrayList<resource::Model::Animation> grem::graphics::Model3D::animations {}

◆ animationChannels

ArrayList<resource::Model::AnimationChannel> grem::graphics::Model3D::animationChannels {}

◆ keyframeInputTimePoints

ArrayList<float> grem::graphics::Model3D::keyframeInputTimePoints {}

◆ keyframeOutputValueData

Buffer<byte> grem::graphics::Model3D::keyframeOutputValueData {}

◆ staticJointCount

resource::Model::JointCount grem::graphics::Model3D::staticJointCount = 0

◆ bindPoseBoundingBox

Box<3, float> grem::graphics::Model3D::bindPoseBoundingBox {}

◆ bindPoseBoundingRadius

float grem::graphics::Model3D::bindPoseBoundingRadius = 0.0f

◆ jointMap

resource::Model::JointMap grem::graphics::Model3D::jointMap {}

◆ skinMap

resource::Model::JointMap grem::graphics::Model3D::skinMap {}

◆ animationMap

resource::Model::AnimationMap grem::graphics::Model3D::animationMap {}

The documentation for this class was generated from the following file: