Magnum::Shaders::PhongDrawUniform struct new in Git master

Per-draw uniform for Phong shaders.

Together with the generic TransformationUniform3D contains parameters that are specific to each draw call. Texture transformation, if needed, is supplied separately in a TextureTransformationUniform; material-related properties are expected to be shared among multiple draw calls and thus are provided in a separate PhongMaterialUniform structure, referenced by materialId.

Constructors, destructors, conversion operators

PhongDrawUniform(DefaultInitT = DefaultInit) explicit constexpr noexcept
Construct with default parameters.
PhongDrawUniform(NoInitT) explicit noexcept
Construct without initializing the contents.

Public variables

Matrix3x4 normalMatrix
Normal matrix.
UnsignedShort materialId
Material ID.
UnsignedInt objectId
Object ID.
UnsignedShort lightOffset
Light offset.
UnsignedShort lightCount
Light count.
UnsignedShort jointOffset
Joint offset.
UnsignedShort perInstanceJointCount
Per-instance joint count.

Convenience setters

Provided to allow the use of method chaining for populating a structure in a single expression, otherwise equivalent to accessing the fields directly. Also guaranteed to provide backwards compatibility when packing of the actual fields changes.

auto setNormalMatrix(const Matrix3x3& matrix) -> PhongDrawUniform&
Set the normalMatrix field.
auto setMaterialId(UnsignedInt id) -> PhongDrawUniform&
Set the materialId field.
auto setObjectId(UnsignedInt id) -> PhongDrawUniform&
Set the objectId field.
auto setLightOffsetCount(UnsignedInt offset, UnsignedInt count) -> PhongDrawUniform&
Set the lightOffset and lightCount fields.
auto setJointOffset(UnsignedInt offset) -> PhongDrawUniform&
Set the jointOffset field.
auto setPerInstanceJointCount(UnsignedInt count) -> PhongDrawUniform&
Set the perInstanceJointCount field.

Function documentation

PhongDrawUniform& Magnum::Shaders::PhongDrawUniform::setNormalMatrix(const Matrix3x3& matrix)

Set the normalMatrix field.

Returns Reference to self (for method chaining)

The matrix is expanded to Matrix3x4, with the bottom row being zeros.

PhongDrawUniform& Magnum::Shaders::PhongDrawUniform::setMaterialId(UnsignedInt id)

Set the materialId field.

Returns Reference to self (for method chaining)

PhongDrawUniform& Magnum::Shaders::PhongDrawUniform::setObjectId(UnsignedInt id)

Set the objectId field.

Returns Reference to self (for method chaining)

PhongDrawUniform& Magnum::Shaders::PhongDrawUniform::setLightOffsetCount(UnsignedInt offset, UnsignedInt count)

Set the lightOffset and lightCount fields.

Returns Reference to self (for method chaining)

PhongDrawUniform& Magnum::Shaders::PhongDrawUniform::setJointOffset(UnsignedInt offset)

Set the jointOffset field.

Returns Reference to self (for method chaining)

PhongDrawUniform& Magnum::Shaders::PhongDrawUniform::setPerInstanceJointCount(UnsignedInt count)

Set the perInstanceJointCount field.

Returns Reference to self (for method chaining)

Variable documentation

Matrix3x4 Magnum::Shaders::PhongDrawUniform::normalMatrix

Normal matrix.

Default value is an identity matrix. The bottom row is unused and acts only as a padding to match uniform buffer packing rules.

If PhongGL::Flag::InstancedTransformation is enabled, the per-instance normal matrix coming from the PhongGL::NormalMatrix attribute is applied first, before this one.

UnsignedShort Magnum::Shaders::PhongDrawUniform::materialId

Material ID.

References a particular material from a PhongMaterialUniform array. Useful when a UBO with more than one material is supplied or in a multi-draw scenario. Should be less than the material count passed to PhongGL::Configuration::setMaterialCount(), if material count is 1, this field is assumed to be 0 and isn't even read by the shader. Default value is 0, meaning the first material gets used.

UnsignedInt Magnum::Shaders::PhongDrawUniform::objectId

Object ID.

Unlike materialId, this index is used only for the object ID framebuffer output, not to access any other uniform data. Default value is 0.

Used only if PhongGL::Flag::ObjectId is enabled, ignored otherwise. If PhongGL::Flag::InstancedObjectId and/or PhongGL::Flag::ObjectIdTexture is enabled as well, this value is added to the ID coming from the PhongGL::ObjectId attribute and/or the texture.

UnsignedShort Magnum::Shaders::PhongDrawUniform::lightOffset

Light offset.

References the first light in the PhongLightUniform array. Should be less than the light count passed to PhongGL constructor. Default value is 0.

Used only if PhongGL::Flag::LightCulling is enabled, otherwise light offset is implicitly 0.

UnsignedShort Magnum::Shaders::PhongDrawUniform::lightCount

Light count.

Specifies how many lights after the lightOffset are used from the PhongLightUniform array. Gets clamped by the shader so it's together with lightOffset not larger than the light count passed to PhongGL constructor. Default value is 0xffffu.

Used only if PhongGL::Flag::LightCulling is enabled, otherwise light count is implicitly PhongGL::lightCount().

UnsignedShort Magnum::Shaders::PhongDrawUniform::jointOffset

Joint offset.

Offset added to joint IDs in the PhongGL::JointIds and PhongGL::SecondaryJointIds attributes. Useful when a UBO with joint matrices for more than one skin is supplied or in a multi-draw scenario. Should be less than the joint count passed to PhongGL::Configuration::setJointCount(). Default value is 0, meaning no offset is added to joint IDs.

UnsignedShort Magnum::Shaders::PhongDrawUniform::perInstanceJointCount

Per-instance joint count.

Offset added to joint IDs in the PhongGL::JointIds and PhongGL::SecondaryJointIds atttributes in instanced draws. Should be less than the joint count passed to PhongGL::Configuration::setJointCount(). Default value is 0, meaning every instance will use the same joint matrices, setting it to a non-zero value causes the joint IDs to be interpreted as gl_InstanceID*count + jointId.