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.
UnsignedInt lightOffset
Light offset.
UnsignedInt lightCount
Light 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.

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)

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 the PhongGL::PhongGL(Flags, UnsignedInt, UnsignedInt, UnsignedInt) constructor, 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 is enabled as well, this value is added to the ID coming from the PhongGL::ObjectId attribute.

UnsignedInt 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.

UnsignedInt 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 0xffffffffu.

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