Features:
- Works with existing material system.
- Easy to use with custom shaders.
- Supports user defined conditional fallbacks.
- SMaterial can now contain application defined data(very handy for passing data to custom material renderers).
Download:
Source Zip
Usage Example:
Code: Select all
IMaterialSystem *matsys = VideoDriver->getMaterialSystem();
SMaterial material;
//this will try load a material from "Path/prettybirdy.irrmaterial".
//If it fails it wil create a default material with the image file.
matsys->loadMaterial(&material,"Path/prettybirdy.png");
Code: Select all
<!--example.irrmaterial-->
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<material>
<!--this is a material fallback.
It takes the format of:
<material_renderer_name [systemparam ="[{<,<=,>,>=,!}]intvalue" ...]>
...
</<material_renderer_name>
System params ares set by the caller to control loading of materials. When reading
material files the material system tests these parameters. If one fails (or
if the material type isn't supported by hardware) this fallback is skipped.-->
<parallaxmap_solid renderer_d3d = "1" graphic_level = "2">
<!--
This is a material attribute. The format is identical to value written out with irr::io::IAttributes.
Only the following types are supported: float,bool,int,color,colorf,vector3d,position,matrix.
-->
<float name = "Shininess" value = "1.0"/>
<!--
These set the textures for the materials layers.
arguments:
layer : can be a number specifying the layer or a mnemonic name.
file : The filename to load. Can also specify a Named texture by prefixing the name with a $ symbol.
create_normal_map: if set to true. the material system will convert this texture into a normal map upon loading.
amplitude: When create_normal_map is true this float specifies the height multiplier used. It defaults to 1.
nomipmaps: if set to true no mipmaps will be created.
noalpha: if set to true the alpha channel will be ignored when loading.
-->
<texture layer = "base" file = "Path\example.png">
<!--You can set some texture layer specific attributes here. only the following attributes are supported-->
<vector3d name = "translation" value = "1 1 0"/>
<vector3d name = "rotation" value = "1 1 0"/>
<vector3d name = "scale" value = "1 1 0"/>
<bool name = "BilinearFilter" value = "false"/>
<bool name = "AnisotropicFilter" value = "false"/>
<bool name = "TrilinearFilter" value = "false"/>
<int name = "TextureWrap" value = "0"/>
</texture>
<!--if you don't need to specify texture attributes, this format is valid too-->
<texture layer = "parallaxmap" file = "Path\example_height.png" create_normal_map = "true" amplitude = "9"/>
</parallaxmap_solid>
<normalmap_solid renderer_d3d = "1" graphic_level = "<=1">
<texture layer = "base" file = "Path\example.png"/>
<texture layer = "normalmap" file = "Path\example_height.png" create_normal_map = "true" amplitude = "9"/>
</normalmap_solid>
<!--This material fallback uses a named texture instead of a file.-->
<solid>
<texture layer = "base" file = "$NamedTexture"/>
</solid>
</material>