Mainly, this new material would be compatible with the current one. It simply adds two new methods to ISceneNode: setTextureFlag() and setTextureBlend(), which allows to define the blend mode and flags for each texture layer individually, instead of using a global setMaterialType which affects the whole material. ISceneNode::setMaterialType() would be rewritten so, for the user, it will be exactly like it currently is, but internally, it should call different combinations of setTextureFlag() and setTextureType() to match the given material type.
It would be something like this:
void ISceneNode::setMaterialType(video::E_MATERIAL_TYPE newType)
This is the same method as we currently have. This would simply be a fast way of defining material types without worrying about the individual blend modes of each texture layer. Internally, this method should call the appropiate texture flag and blend modes to match the specified type.
void ISceneNode::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue)
Also the same as the current method. Sets some flags which affects the whole material, like wireframe, cull mode, light & fog sensitivity, etc.
You would need to add EMF_VERTEX_ALPHA to tell the material that you want to use the vertex alpha defined in the mesh.
void ISceneNode::setTextureFlag(s32 textureLayer, video::E_TEXTURE_FLAG flag, bool newvalue)
This new method would be used to set the flags for the specified texture layer in the material. The values would be:
ETF_ALPHA_MAP The texture will be drawn transparent based on the alpha map contained. If the texture were loaded from a file format which does not support alpha information, an alpha channel should be generated based on the color info (darker=more transparent).
ETF_MASKED The parts of the texture which match the color of the mask defined in the texture will be drawn transparent.
ETF_SPHERE_MAP The texture will be used as a sphere map
void ISceneNode::setTextureBlend(s32 textureLayer, video::E_TEXTURE_BLEND blendMode)
This set the blend mode of one texture layer over the layer which is below it. For texture layer 0, it will define how it will blend over the background.
ETB_SOLID Texture will overwrite the layer below. Have in mind that if the layer uses ETF_ALPHA_MAP, the layer below it (or the background in the caseof layer 0) will still be visible.
ETB_ADD The layer will be added to the one below it (or the background).
ETB_MODULATE The color values of this layer will be multiplied with the one below it. Standard blend mode used for lightmaps.
ETB_MODULATE_2X Same as above, but multiplies by 2 the color values, giving brighter lightmaps.
ETB_MODULATE_4X Same as above, but multiplies by 4 the color values, giving much brighter lightmaps.
ETB_NORMAL The layer will be blended wiith the one below it using normal mapping. The layer below should contain the diffuse texture.
Probably more texture flags & blend modes should be added to these ones, I am not sure, but this gives a general idea of what would be a better material system for IrrLicht.
What do you think? (specially you, Niko
