|
| | Material () |
| | Default constructor.
|
| |
| virtual | ~Material () |
| | Destructor.
|
| |
| std::unique_ptr< Core::Base > | clone () const override |
| |
| void | setInt (const std::string &key, int value) |
| | Sets an integer parameter.
|
| |
| void | setFloat (const std::string &key, float value) |
| | Sets a float parameter.
|
| |
| void | setVector2 (const std::string &key, const Infinity::Types::Math::Vector2 &value) |
| | Sets a 2D vector parameter.
|
| |
| void | setVector3 (const std::string &key, const Infinity::Types::Math::Vector3 &value) |
| | Sets a 3D vector parameter.
|
| |
| void | setVector4 (const std::string &key, const Infinity::Types::Math::Vector4 &value) |
| | Sets a 4D vector parameter.
|
| |
| void | setColor (const std::string &key, const Infinity::Types::Math::Vector4ub &value) |
| | Sets a color parameter (8-bit RGBA).
|
| |
| void | setTexture (const std::string &key, std::shared_ptr< const Containers::ArrayBase > texture) |
| | Sets a texture from a generic array base.
|
| |
| void | setTexture2DR (const std::string &key, const Containers::Array2D< uint8_t > &texture) |
| | Sets a single-channel 8-bit texture (R format).
|
| |
| void | setTexture2DRG (const std::string &key, const Containers::Array2D< Math::Vector2ub > &texture) |
| | Sets a two-channel 8-bit texture (RG format).
|
| |
| void | setTexture2DRGB (const std::string &key, const Containers::Array2D< Math::Vector3ub > &texture) |
| | Sets a three-channel 8-bit texture (RGB format).
|
| |
| void | setTexture2DRGBA (const std::string &key, const Containers::Array2D< Math::Vector4ub > &texture) |
| | Sets a four-channel 8-bit texture (RGBA format).
|
| |
| void | setTexture2DR_SFloat32 (const std::string &key, const Containers::Array2D< float > &texture) |
| | Sets a single-channel 32-bit float texture (R format, HDR).
|
| |
| void | setTexture2DRG_SFloat32 (const std::string &key, const Containers::Array2D< Math::Vector2 > &texture) |
| | Sets a two-channel 32-bit float texture (RG format, HDR).
|
| |
| void | setTexture2DRGB_SFloat32 (const std::string &key, const Containers::Array2D< Math::Vector3 > &texture) |
| | Sets a three-channel 32-bit float texture (RGB format, HDR).
|
| |
| void | setTexture2DRGBA_SFloat32 (const std::string &key, const Containers::Array2D< Math::Vector4 > &texture) |
| | Sets a four-channel 32-bit float texture (RGBA format, HDR).
|
| |
| int | getInt (const std::string &key) const |
| | Gets an integer parameter.
|
| |
| float | getFloat (const std::string &key) const |
| | Gets a float parameter.
|
| |
| Math::Vector2 | getVector2 (const std::string &key) const |
| | Gets a 2D vector parameter.
|
| |
| Math::Vector3 | getVector3 (const std::string &key) const |
| | Gets a 3D vector parameter.
|
| |
| Math::Vector4 | getVector4 (const std::string &key) const |
| | Gets a 4D vector parameter.
|
| |
| Math::Vector4ub | getColor (const std::string &key) const |
| | Gets a color parameter as 8-bit RGBA.
|
| |
| Math::Vector4ub | getColorRGBA (const std::string &key) const |
| | Gets a color parameter as 8-bit RGBA.
|
| |
| Math::Vector4 | getColorRGBAFloat (const std::string &key) const |
| | Gets a color parameter as normalized float RGBA.
|
| |
| bool | hasParam (const std::string &key) const |
| | Checks if a parameter exists.
|
| |
| bool | hasTexture (const std::string &key) const |
| | Checks if a texture parameter exists.
|
| |
| const Containers::ArrayBase & | getTexture (const std::string &key) const |
| | Gets a texture as generic ArrayBase reference.
|
| |
| const Containers::Array2D< uint8_t > & | getTexture2DR (const std::string &key) const |
| | Gets a single-channel 8-bit texture.
|
| |
| const Containers::Array2D< Math::Vector2ub > & | getTexture2DRG (const std::string &key) const |
| | Gets a two-channel 8-bit texture.
|
| |
| const Containers::Array2D< Math::Vector3ub > & | getTexture2DRGB (const std::string &key) const |
| | Gets a three-channel 8-bit texture.
|
| |
| const Containers::Array2D< Math::Vector4ub > & | getTexture2DRGBA (const std::string &key) const |
| | Gets a four-channel 8-bit texture.
|
| |
| const Containers::Array2D< float > & | getTexture2DR_SFloat32 (const std::string &key) const |
| | Gets a single-channel 32-bit float texture.
|
| |
| const Containers::Array2D< Math::Vector2 > & | getTexture2DRG_SFloat32 (const std::string &key) const |
| | Gets a two-channel 32-bit float texture.
|
| |
| const Containers::Array2D< Math::Vector3 > & | getTexture2DRGB_SFloat32 (const std::string &key) const |
| | Gets a three-channel 32-bit float texture.
|
| |
| const Containers::Array2D< Math::Vector4 > & | getTexture2DRGBA_SFloat32 (const std::string &key) const |
| | Gets a four-channel 32-bit float texture.
|
| |
| const Infinity::Types::TypeID & | typeId () const override |
| | Gets the TypeID for Material.
|
| |
| | Data () |
| |
| | Data (const Data &other) |
| |
| | Data (Data &&other) |
| |
| Data & | operator= (const Data &other) |
| |
| Data & | operator= (Data &&other) |
| |
| virtual | ~Data () |
| | Virtual destructor.
|
| |
| bool | hasProperty (const std::string &key) const |
| |
| template<typename T > |
| void | setProperty (const std::string &key, T &&value) |
| | Sets a typed property value.
|
| |
| template<typename T > |
| void | setProperty (const std::string &key, const T &value) |
| | Sets a typed property value.
|
| |
| void | setProperty (const std::string &key, PropertyValue &&value) |
| | Sets a typed property value.
|
| |
| const PropertyValue & | getProperty (const std::string &key) const |
| | Gets a property value without type checking.
|
| |
| template<typename T > |
| const T & | getProperty (const std::string &key) const |
| | Gets a typed property value.
|
| |
| void | removeProperty (const std::string &key) |
| |
| virtual | ~Base () |
| | Virtual destructor.
|
| |
| virtual std::istream & | legibleDataRead (std::istream &in) override |
| | Deserializes the object from a single-line text representation.
|
| |
| virtual std::ostream & | legibleDataWrite (std::ostream &out) const override |
| | Serializes the object to a single-line text representation.
|
| |
Shader configuration with parameters and textures for surface appearance.
Material defines the visual properties of rendered surfaces by specifying a shader and its associated parameters (uniforms and textures). It provides a type-safe interface for configuring shader inputs, supporting both scalar parameters (floats, vectors, colors) and texture data in various formats.
The material system enables:
- Shader-based rendering with customizable parameters
- Multiple texture channels (albedo, normal, roughness, metallic, etc.)
- Procedurally generated texture assignment
- Material variations for the same shader
- Support for both 8-bit and 32-bit float texture formats
- Parameter sharing via ImmutableMap
Materials reference shaders by name and store parameters in an ImmutableMap, allowing heterogeneous parameter types while maintaining type safety through the setter/getter methods.
Common use cases:
- Assigning materials to procedurally generated meshes
- Terrain material configuration with splatmaps
- Dynamic material parameter modification
- Texture-based surface properties
- PBR (Physically Based Rendering) workflows
- Custom shader parameter binding
- Note
- The shaderName must reference a shader known to the rendering system.
-
Texture formats support both LDR (8-bit) and HDR (32-bit float) data.
-
Parameters are stored by name and must match shader uniform names.
-
Use setTexture variants for different channel counts (R, RG, RGB, RGBA).
Example usage:
mat.
name =
"TerrainMaterial";
mat.
setVector3(
"tint", Vector3{0.8f, 0.7f, 0.6f});
mat.
setColor(
"baseColor", Vector4ub{200, 180, 160, 255});
Array2D<Vector4ub> albedoMap = generateAlbedoTexture(512, 512);
Array2D<Vector3ub> normalMap = generateNormalMap(512, 512);
Array2D<uint8_t> roughnessMap = generateRoughnessMap(512, 512);
terrainMat.shaderName = "terrain_multitexture";
terrainMat.setTexture2DRGBA("grassAlbedo", grassTexture);
terrainMat.setTexture2DRGBA("rockAlbedo", rockTexture);
terrainMat.setTexture2DRGBA("snowAlbedo", snowTexture);
terrainMat.setTexture2DR("splatmap", splatmapData);
terrainMat.setFloat("textureScale", 10.0f);
Array2D<Vector3> emissiveMap = generateEmissiveHDR(256, 256);
}
system->setIn("surface_material", std::move(mat));
Shader configuration with parameters and textures for surface appearance.
Definition Material.hpp:96
void setFloat(const std::string &key, float value)
Sets a float parameter.
void setTexture2DRGB_SFloat32(const std::string &key, const Containers::Array2D< Math::Vector3 > &texture)
Sets a three-channel 32-bit float texture (RGB format, HDR).
void setColor(const std::string &key, const Infinity::Types::Math::Vector4ub &value)
Sets a color parameter (8-bit RGBA).
std::string shaderName
Name of the shader to use for rendering.
Definition Material.hpp:119
void setTexture2DRGBA(const std::string &key, const Containers::Array2D< Math::Vector4ub > &texture)
Sets a four-channel 8-bit texture (RGBA format).
std::string name
Human-readable material name.
Definition Material.hpp:104
bool hasParam(const std::string &key) const
Checks if a parameter exists.
void setTexture2DRGB(const std::string &key, const Containers::Array2D< Math::Vector3ub > &texture)
Sets a three-channel 8-bit texture (RGB format).
void setVector3(const std::string &key, const Infinity::Types::Math::Vector3 &value)
Sets a 3D vector parameter.
float getFloat(const std::string &key) const
Gets a float parameter.
Material()
Default constructor.
void setTexture2DR(const std::string &key, const Containers::Array2D< uint8_t > &texture)
Sets a single-channel 8-bit texture (R format).