Irrlicht 3D Engine
irr::video::SMaterial Class Reference

Struct for holding parameters for a material renderer. More...

#include <SMaterial.h>

Public Member Functions

 SMaterial ()
 Default constructor. Creates a solid, lit material with white colors. More...
 
 SMaterial (const SMaterial &other)
 Copy constructor. More...
 
bool getFlag (E_MATERIAL_FLAG flag) const
 Gets the Material flag. More...
 
ITexturegetTexture (u32 i) const
 Gets the i-th texture. More...
 
core::matrix4getTextureMatrix (u32 i)
 Gets the texture transformation matrix for level i. More...
 
const core::matrix4getTextureMatrix (u32 i) const
 Gets the immutable texture transformation matrix for level i. More...
 
bool isTransparent () const
 
bool operator!= (const SMaterial &b) const
 Inequality operator. More...
 
SMaterialoperator= (const SMaterial &other)
 Assignment operator. More...
 
bool operator== (const SMaterial &b) const
 Equality operator. More...
 
void setFlag (E_MATERIAL_FLAG flag, bool value)
 Sets the Material flag to the given value. More...
 
void setTexture (u32 i, ITexture *tex)
 Sets the i-th texture. More...
 
void setTextureMatrix (u32 i, const core::matrix4 &mat)
 Sets the i-th texture transformation matrix. More...
 

Public Attributes

SColor AmbientColor
 How much ambient light (a global light) is reflected by this material. More...
 
u8 AntiAliasing
 Sets the antialiasing mode. More...
 
bool BackfaceCulling:1
 Is backface culling enabled? Default: true. More...
 
f32 BlendFactor
 Store the blend factors. More...
 
E_BLEND_OPERATION BlendOperation:4
 Store the blend operation of choice. More...
 
u8 ColorMask:4
 Defines the enabled color planes. More...
 
u8 ColorMaterial:3
 Defines the interpretation of vertex color in the lighting equation. More...
 
SColor DiffuseColor
 How much diffuse light coming from a light source is reflected by this material. More...
 
SColor EmissiveColor
 Light emitted by this material. Default is to emit no light. More...
 
bool FogEnable:1
 Is fog enabled? Default: false. More...
 
bool FrontfaceCulling:1
 Is frontface culling enabled? Default: false. More...
 
bool GouraudShading:1
 Flat or Gouraud shading? Default: true. More...
 
bool Lighting:1
 Will this material be lighted? Default: true. More...
 
E_MATERIAL_TYPE MaterialType
 Type of the material. Specifies how everything is blended together. More...
 
f32 MaterialTypeParam
 Free parameter, dependent on the material type. More...
 
f32 MaterialTypeParam2
 Second free parameter, dependent on the material type. More...
 
bool NormalizeNormals:1
 Should normals be normalized? More...
 
bool PointCloud:1
 Draw as point cloud or filled triangles? Default: false. More...
 
f32 PolygonOffsetDepthBias
 A constant z-buffer offset for a polygon/line/point. More...
 
E_POLYGON_OFFSET PolygonOffsetDirection:1
 DEPRECATED. Will be removed after Irrlicht 1.9. More...
 
u8 PolygonOffsetFactor:3
 DEPRECATED. Will be removed after Irrlicht 1.9. Please use PolygonOffsetDepthBias instead. More...
 
f32 PolygonOffsetSlopeScale
 Variable Z-Buffer offset based on the slope of the polygon. More...
 
f32 Shininess
 Value affecting the size of specular highlights. More...
 
SColor SpecularColor
 How much specular light (highlights from a light) is reflected. More...
 
SMaterialLayer TextureLayer [MATERIAL_MAX_TEXTURES]
 Texture layer array. More...
 
f32 Thickness
 Thickness of non-3dimensional elements such as lines and points. More...
 
bool UseMipMaps:1
 Shall mipmaps be used if available. More...
 
bool Wireframe:1
 Draw as wireframe or filled triangles? Default: false. More...
 
u8 ZBuffer
 Is the ZBuffer enabled? Default: ECFN_LESSEQUAL. More...
 
bool ZWriteEnable:1
 Is the zbuffer writable or is it read-only. Default: true. More...
 
E_ZWRITE_FINE_CONTROL ZWriteFineControl:1
 Give more control how the ZWriteEnable flag is interpreted. More...
 

Detailed Description

Struct for holding parameters for a material renderer.

Definition at line 286 of file SMaterial.h.

Constructor & Destructor Documentation

◆ SMaterial() [1/2]

irr::video::SMaterial::SMaterial ( )
inline

Default constructor. Creates a solid, lit material with white colors.

Definition at line 290 of file SMaterial.h.

◆ SMaterial() [2/2]

irr::video::SMaterial::SMaterial ( const SMaterial other)
inline

Copy constructor.

Parameters
otherMaterial to copy from.

Definition at line 306 of file SMaterial.h.

References irr::video::MATERIAL_MAX_TEXTURES_USED, and TextureLayer.

Member Function Documentation

◆ getFlag()

bool irr::video::SMaterial::getFlag ( E_MATERIAL_FLAG  flag) const
inline

◆ getTexture()

ITexture* irr::video::SMaterial::getTexture ( u32  i) const
inline

Gets the i-th texture.

Parameters
iThe desired level.
Returns
Texture for texture level i, if defined, else 0.

Definition at line 572 of file SMaterial.h.

References irr::video::MATERIAL_MAX_TEXTURES, irr::video::SMaterialLayer::Texture, and TextureLayer.

◆ getTextureMatrix() [1/2]

core::matrix4& irr::video::SMaterial::getTextureMatrix ( u32  i)
inline

Gets the texture transformation matrix for level i.

Parameters
iThe desired level. Must not be larger than MATERIAL_MAX_TEXTURES
Returns
Texture matrix for texture level i.

Definition at line 543 of file SMaterial.h.

References irr::video::SMaterialLayer::getTextureMatrix(), and TextureLayer.

◆ getTextureMatrix() [2/2]

const core::matrix4& irr::video::SMaterial::getTextureMatrix ( u32  i) const
inline

Gets the immutable texture transformation matrix for level i.

Parameters
iThe desired level.
Returns
Texture matrix for texture level i, or identity matrix for levels larger than MATERIAL_MAX_TEXTURES.

Definition at line 551 of file SMaterial.h.

References irr::video::SMaterialLayer::getTextureMatrix(), irr::core::IdentityMatrix, irr::video::MATERIAL_MAX_TEXTURES, and TextureLayer.

◆ isTransparent()

◆ operator!=()

◆ operator=()

◆ operator==()

bool irr::video::SMaterial::operator== ( const SMaterial b) const
inline

Equality operator.

Parameters
bMaterial to compare to.
Returns
True if the materials are equal, else false.

Definition at line 772 of file SMaterial.h.

◆ setFlag()

void irr::video::SMaterial::setFlag ( E_MATERIAL_FLAG  flag,
bool  value 
)
inline

Sets the Material flag to the given value.

Parameters
flagThe flag to be set.
valueThe new value for the flag.

Definition at line 591 of file SMaterial.h.

References AntiAliasing, BackfaceCulling, BlendOperation, ColorMask, ColorMaterial, irr::video::EAAM_OFF, irr::video::EAAM_SIMPLE, irr::video::EBO_ADD, irr::video::EBO_NONE, irr::video::ECM_DIFFUSE, irr::video::ECM_NONE, irr::video::ECP_ALL, irr::video::ECP_NONE, irr::video::EMF_ANISOTROPIC_FILTER, irr::video::EMF_ANTI_ALIASING, irr::video::EMF_BACK_FACE_CULLING, irr::video::EMF_BILINEAR_FILTER, irr::video::EMF_BLEND_FACTOR, irr::video::EMF_BLEND_OPERATION, irr::video::EMF_COLOR_MASK, irr::video::EMF_COLOR_MATERIAL, irr::video::EMF_FOG_ENABLE, irr::video::EMF_FRONT_FACE_CULLING, irr::video::EMF_GOURAUD_SHADING, irr::video::EMF_LIGHTING, irr::video::EMF_NORMALIZE_NORMALS, irr::video::EMF_POINTCLOUD, irr::video::EMF_POLYGON_OFFSET, irr::video::EMF_TEXTURE_WRAP, irr::video::EMF_TRILINEAR_FILTER, irr::video::EMF_USE_MIP_MAPS, irr::video::EMF_WIREFRAME, irr::video::EMF_ZBUFFER, irr::video::EMF_ZWRITE_ENABLE, irr::video::EPO_BACK, FogEnable, FrontfaceCulling, GouraudShading, Lighting, irr::video::MATERIAL_MAX_TEXTURES_USED, NormalizeNormals, PointCloud, PolygonOffsetDepthBias, PolygonOffsetDirection, PolygonOffsetFactor, PolygonOffsetSlopeScale, TextureLayer, irr::video::SMaterialLayer::TextureWrapU, irr::video::SMaterialLayer::TextureWrapV, irr::video::SMaterialLayer::TextureWrapW, UseMipMaps, Wireframe, ZBuffer, and ZWriteEnable.

Referenced by irr::scene::ISceneNode::setMaterialFlag().

◆ setTexture()

void irr::video::SMaterial::setTexture ( u32  i,
ITexture tex 
)
inline

Sets the i-th texture.

If i>=MATERIAL_MAX_TEXTURES this setting will be ignored.

Parameters
iThe desired level.
texTexture for texture level i.

Definition at line 581 of file SMaterial.h.

References irr::video::MATERIAL_MAX_TEXTURES, irr::video::SMaterialLayer::Texture, and TextureLayer.

Referenced by irr::scene::ISceneNode::setMaterialTexture().

◆ setTextureMatrix()

void irr::video::SMaterial::setTextureMatrix ( u32  i,
const core::matrix4 mat 
)
inline

Sets the i-th texture transformation matrix.

Parameters
iThe desired level.
matTexture matrix for texture level i.

Definition at line 562 of file SMaterial.h.

References irr::video::MATERIAL_MAX_TEXTURES, irr::video::SMaterialLayer::setTextureMatrix(), and TextureLayer.

Member Data Documentation

◆ AmbientColor

SColor irr::video::SMaterial::AmbientColor

How much ambient light (a global light) is reflected by this material.

The default is full white, meaning objects are completely globally illuminated. Reduce this if you want to see diffuse or specular light effects.

Definition at line 372 of file SMaterial.h.

Referenced by operator!=(), and operator=().

◆ AntiAliasing

u8 irr::video::SMaterial::AntiAliasing

Sets the antialiasing mode.

Values are chosen from E_ANTI_ALIASING_MODE. Default is EAAM_SIMPLE, i.e. simple multi-sample anti-aliasing.

Definition at line 439 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ BackfaceCulling

bool irr::video::SMaterial::BackfaceCulling

Is backface culling enabled? Default: true.

Definition at line 519 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ BlendFactor

f32 irr::video::SMaterial::BlendFactor

Store the blend factors.

textureBlendFunc/textureBlendFuncSeparate functions should be used to write properly blending factors to this parameter. If you use EMT_ONETEXTURE_BLEND type for this material, this field should be equal to MaterialTypeParam.

Definition at line 464 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), isTransparent(), operator!=(), and operator=().

◆ BlendOperation

E_BLEND_OPERATION irr::video::SMaterial::BlendOperation

Store the blend operation of choice.

Values to be chosen from E_BLEND_OPERATION.

Definition at line 458 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), isTransparent(), operator!=(), operator=(), and setFlag().

◆ ColorMask

u8 irr::video::SMaterial::ColorMask

Defines the enabled color planes.

Values are defined as or'ed values of the E_COLOR_PLANE enum. Only enabled color planes will be rendered to the current render target. Typical use is to disable all colors when rendering only to depth or stencil buffer, or using Red and Green for Stereo rendering.

Definition at line 446 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ ColorMaterial

u8 irr::video::SMaterial::ColorMaterial

Defines the interpretation of vertex color in the lighting equation.

Values should be chosen from E_COLOR_MATERIAL. When lighting is enabled, vertex color can be used instead of the material values for light modulation. This allows to easily change e.g. the diffuse light behavior of each face. The default, ECM_DIFFUSE, will result in a very similar rendering as with lighting turned off, just with light shading.

Definition at line 454 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ DiffuseColor

SColor irr::video::SMaterial::DiffuseColor

How much diffuse light coming from a light source is reflected by this material.

The default is full white.

Definition at line 376 of file SMaterial.h.

Referenced by operator!=(), and operator=().

◆ EmissiveColor

SColor irr::video::SMaterial::EmissiveColor

Light emitted by this material. Default is to emit no light.

Definition at line 379 of file SMaterial.h.

Referenced by operator!=(), and operator=().

◆ FogEnable

bool irr::video::SMaterial::FogEnable

Is fog enabled? Default: false.

Definition at line 525 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ FrontfaceCulling

bool irr::video::SMaterial::FrontfaceCulling

Is frontface culling enabled? Default: false.

Definition at line 522 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ GouraudShading

bool irr::video::SMaterial::GouraudShading

Flat or Gouraud shading? Default: true.

Definition at line 506 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ Lighting

bool irr::video::SMaterial::Lighting

Will this material be lighted? Default: true.

Definition at line 509 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ MaterialType

E_MATERIAL_TYPE irr::video::SMaterial::MaterialType

Type of the material. Specifies how everything is blended together.

Definition at line 366 of file SMaterial.h.

Referenced by isTransparent(), operator!=(), operator=(), and irr::scene::ISceneNode::setMaterialType().

◆ MaterialTypeParam

f32 irr::video::SMaterial::MaterialTypeParam

Free parameter, dependent on the material type.

Mostly ignored, used for example in EMT_PARALLAX_MAP_SOLID and EMT_TRANSPARENT_ALPHA_CHANNEL.

Definition at line 421 of file SMaterial.h.

Referenced by operator!=(), and operator=().

◆ MaterialTypeParam2

f32 irr::video::SMaterial::MaterialTypeParam2

Second free parameter, dependent on the material type.

Mostly ignored.

Definition at line 425 of file SMaterial.h.

Referenced by operator!=(), and operator=().

◆ NormalizeNormals

bool irr::video::SMaterial::NormalizeNormals

Should normals be normalized?

Always use this if the mesh lit and scaled. Default: false

Definition at line 529 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ PointCloud

bool irr::video::SMaterial::PointCloud

Draw as point cloud or filled triangles? Default: false.

Definition at line 503 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ PolygonOffsetDepthBias

f32 irr::video::SMaterial::PolygonOffsetDepthBias

A constant z-buffer offset for a polygon/line/point.

The range of the value is driver specific. On OpenGL you get units which are multiplied by the smallest value that is guaranteed to produce a resolvable offset. On D3D9 you can pass a range between -1 and 1. But you should likely divide it by the range of the depthbuffer. Like dividing by 65535.0 for a 16 bit depthbuffer. Thought it still might produce too large of a bias. Some article (https://aras-p.info/blog/2008/06/12/depth-bias-and-the-power-of-deceiving-yourself/) recommends multiplying by 2.0*4.8e-7 (and strangely on both 16 bit and 24 bit).

Definition at line 485 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ PolygonOffsetDirection

E_POLYGON_OFFSET irr::video::SMaterial::PolygonOffsetDirection

DEPRECATED. Will be removed after Irrlicht 1.9.

Flag defining the direction the polygon offset is applied to. Can be to front or to back, specified by values from E_POLYGON_OFFSET.

Definition at line 476 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), operator!=(), operator=(), and setFlag().

◆ PolygonOffsetFactor

u8 irr::video::SMaterial::PolygonOffsetFactor

DEPRECATED. Will be removed after Irrlicht 1.9. Please use PolygonOffsetDepthBias instead.

Factor specifying how far the polygon offset should be made. Specifying 0 disables the polygon offset. The direction is specified separately. The factor can be from 0 to 7. Note: This probably never worked on Direct3D9 (was coded for D3D8 which had different value ranges)

Definition at line 471 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ PolygonOffsetSlopeScale

f32 irr::video::SMaterial::PolygonOffsetSlopeScale

Variable Z-Buffer offset based on the slope of the polygon.

For polygons looking flat at a camera you could use 0 (for example in a 2D game) But in most cases you will have polygons rendered at a certain slope. The driver will calculate the slope for you and this value allows to scale that slope. The complete polygon offset is: PolygonOffsetSlopeScale*slope + PolygonOffsetDepthBias A good default here is to use 1.f if you want to push the polygons away from the camera and -1.f to pull them towards the camera.

Definition at line 494 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), operator!=(), operator=(), and setFlag().

◆ Shininess

f32 irr::video::SMaterial::Shininess

Value affecting the size of specular highlights.

A value of 20 is common. If set to 0, no specular highlights are being used. To activate, simply set the shininess of a material to a value in the range [0.5;128]:

sceneNode->getMaterial(0).Shininess = 20.0f;

You can change the color of the highlights using

sceneNode->getMaterial(0).SpecularColor.set(255,255,255,255);

The specular color of the dynamic lights (SLight::SpecularColor) will influence the the highlight color too, but they are set to a useful value by default when creating the light scene node. Here is a simple example on how to use specular highlights:

// load and display mesh
scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(
smgr->getMesh("data/faerie.md2"));
node->setMaterialTexture(0, driver->getTexture("data/Faerie2.pcx")); // set diffuse texture
node->setMaterialFlag(video::EMF_LIGHTING, true); // enable dynamic lighting
node->getMaterial(0).Shininess = 20.0f; // set size of specular highlights
// add white light
scene::ILightSceneNode* light = smgr->addLightSceneNode(0,
core::vector3df(5,5,5), video::SColorf(1.0f, 1.0f, 1.0f));

Definition at line 416 of file SMaterial.h.

Referenced by operator!=(), and operator=().

◆ SpecularColor

SColor irr::video::SMaterial::SpecularColor

How much specular light (highlights from a light) is reflected.

The default is to reflect white specular light. See SMaterial::Shininess on how to enable specular lights.

Definition at line 384 of file SMaterial.h.

Referenced by operator!=(), and operator=().

◆ TextureLayer

◆ Thickness

f32 irr::video::SMaterial::Thickness

Thickness of non-3dimensional elements such as lines and points.

Definition at line 428 of file SMaterial.h.

Referenced by operator!=(), and operator=().

◆ UseMipMaps

bool irr::video::SMaterial::UseMipMaps

Shall mipmaps be used if available.

Sometimes, disabling mipmap usage can be useful. Default: true

Definition at line 533 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ Wireframe

bool irr::video::SMaterial::Wireframe

Draw as wireframe or filled triangles? Default: false.

The user can access a material flag using

material.Wireframe=true

or

material.setFlag(EMF_WIREFRAME, true);

Definition at line 500 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ ZBuffer

u8 irr::video::SMaterial::ZBuffer

Is the ZBuffer enabled? Default: ECFN_LESSEQUAL.

If you want to disable depth test for this material just set this parameter to ECFN_DISABLED. Values are from E_COMPARISON_FUNC.

Definition at line 434 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ ZWriteEnable

bool irr::video::SMaterial::ZWriteEnable

Is the zbuffer writable or is it read-only. Default: true.

This flag is forced to false if the MaterialType is a transparent type and the scene parameter ALLOW_ZWRITE_ON_TRANSPARENT is not set. If you set this parameter to true, make sure that ZBuffer value is other than ECFN_DISABLED

Definition at line 516 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

◆ ZWriteFineControl

E_ZWRITE_FINE_CONTROL irr::video::SMaterial::ZWriteFineControl

Give more control how the ZWriteEnable flag is interpreted.

Note that there is also the global flag AllowZWriteOnTransparent which when set acts like all materials have set EZI_ALLOW_ON_TRANSPARENT.

Definition at line 538 of file SMaterial.h.

Referenced by operator!=(), and operator=().


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