Groups a shader program with textures and surface parameters.
More...
#include <kmaterial.h>
Groups a shader program with textures and surface parameters.
A material is assigned to a kObject (and optionally its children) via kObject::setMaterial(). The renderer queries the material for the shader to bind, the texture list to upload, and the surface colour/PBR values to pass as uniforms.
◆ kMaterial()
| kemena::kMaterial::kMaterial |
( |
| ) |
|
Constructs a material with default surface parameters and no shader.
◆ ~kMaterial()
| virtual kemena::kMaterial::~kMaterial |
( |
| ) |
|
|
virtual |
Destroys the material.
Does not free the shader or textures; ownership of those resources remains with the caller.
◆ addTexture()
| void kemena::kMaterial::addTexture |
( |
kTexture * | texture | ) |
|
Appends a texture to the material's texture list.
- Parameters
-
| texture | Texture to add; ownership is not transferred. |
◆ getAmbientColor()
| kVec3 kemena::kMaterial::getAmbientColor |
( |
| ) |
|
Returns the ambient colour.
- Returns
- RGB ambient colour.
◆ getCullBack()
| bool kemena::kMaterial::getCullBack |
( |
| ) |
|
Returns which face is culled when single-sided rendering is on.
- Returns
- true if back faces are culled; false if front faces are culled.
◆ getDiffuseColor()
| kVec3 kemena::kMaterial::getDiffuseColor |
( |
| ) |
|
Returns the diffuse colour.
- Returns
- RGB diffuse colour.
◆ getMetallic()
| float kemena::kMaterial::getMetallic |
( |
| ) |
|
Returns the PBR metallic factor.
- Returns
- Metallic value.
◆ getRoughness()
| float kemena::kMaterial::getRoughness |
( |
| ) |
|
Returns the PBR roughness factor.
- Returns
- Roughness value.
◆ getShader()
| kShader * kemena::kMaterial::getShader |
( |
| ) |
|
Returns the assigned shader.
- Returns
- Pointer to the shader, or nullptr if none is set.
◆ getShininess()
| float kemena::kMaterial::getShininess |
( |
| ) |
|
Returns the Phong shininess exponent.
- Returns
- Shininess value.
◆ getSingleSided()
| bool kemena::kMaterial::getSingleSided |
( |
| ) |
|
Returns whether face culling is enabled.
- Returns
- true if single-sided rendering is active.
◆ getSpecularColor()
| kVec3 kemena::kMaterial::getSpecularColor |
( |
| ) |
|
Returns the specular colour.
- Returns
- RGB specular colour.
◆ getTexture()
| kTexture * kemena::kMaterial::getTexture |
( |
int | index | ) |
|
Returns a texture by index.
- Parameters
-
| index | Zero-based index into the texture list. |
- Returns
- Pointer to the texture, or nullptr if index is out of range.
◆ getTextures()
| std::vector< kTexture * > kemena::kMaterial::getTextures |
( |
| ) |
|
Returns all textures attached to this material.
- Returns
- Copy of the internal texture vector.
◆ getTransparent()
Returns the transparency blending mode.
- Returns
- Current transparency type.
◆ getUvTiling()
| kVec2 kemena::kMaterial::getUvTiling |
( |
| ) |
|
Returns the UV tiling factor.
- Returns
- UV tiling (U, V).
◆ setAmbientColor()
| void kemena::kMaterial::setAmbientColor |
( |
kVec3 | color | ) |
|
Sets the ambient colour.
- Parameters
-
| color | RGB ambient colour (0..1 per channel). |
◆ setDiffuseColor()
| void kemena::kMaterial::setDiffuseColor |
( |
kVec3 | color | ) |
|
Sets the diffuse colour.
- Parameters
-
◆ setMetallic()
| void kemena::kMaterial::setMetallic |
( |
float | value | ) |
|
Sets the PBR metallic factor.
- Parameters
-
| value | Metallic value in the range [0, 1]. |
◆ setRoughness()
| void kemena::kMaterial::setRoughness |
( |
float | value | ) |
|
Sets the PBR roughness factor.
- Parameters
-
| value | Roughness value in the range [0, 1]. |
◆ setShader()
| void kemena::kMaterial::setShader |
( |
kShader * | newShader | ) |
|
Assigns a compiled shader to this material.
- Parameters
-
| newShader | Pointer to the shader program; must outlive the material. |
◆ setShininess()
| void kemena::kMaterial::setShininess |
( |
float | value | ) |
|
Sets the Phong shininess exponent.
- Parameters
-
| value | Shininess exponent (higher = tighter highlights). |
◆ setSingleSided()
| void kemena::kMaterial::setSingleSided |
( |
bool | newSingleSided, |
|
|
bool | newCullBack = true ) |
Configures face culling for this material.
- Parameters
-
| newSingleSided | true to enable face culling. |
| newCullBack | true to cull back faces; false to cull front faces. |
◆ setSpecularColor()
| void kemena::kMaterial::setSpecularColor |
( |
kVec3 | color | ) |
|
Sets the specular colour.
- Parameters
-
| color | RGB specular colour. |
◆ setTransparent()
Sets the transparency blending mode.
- Parameters
-
| type | Transparency type (none, alpha blend, etc.). |
◆ setUvTiling()
| void kemena::kMaterial::setUvTiling |
( |
kVec2 | newTiling | ) |
|
Sets the UV tiling factor applied to all texture coordinates.
- Parameters
-
| newTiling | Tiling multiplier (U, V). |
The documentation for this class was generated from the following file: