How to write a Material File

From Iris2

Jump to: navigation, search
(Created page with 'Material Templates // see http://www.ogre3d.org/docs/manual/manual_28.html#SEC145 // can be used by // import * from "material-templates.material" // --------------- THESE ARE…')
(Import the materia-templates.material)
 
Line 1: Line 1:
-
Material Templates
+
=Editing the File=
 +
==Import the materia-templates.material==
-
// see http://www.ogre3d.org/docs/manual/manual_28.html#SEC145
+
Open a file and rename it to the name of the material in your mesh file. For example "basefloortile.material" for the "respective basefloortile.mesh".
-
// can be used by
+
-
// import * from "material-templates.material"
+
-
// --------------- THESE ARE THE ATLAS STANDARD MATERIALS ----------------------
+
Begin the file with the following file without the slashes. The slashes are normally for comments.
-
// MESH BASE MATERIAL TEMPLATE
+
-
material atlas_base
+
-
{
+
-
receive_shadows off
+
-
technique default
 
-
{
 
-
pass
 
-
{
 
-
lighting on
 
-
ambient vertexcolour
+
<pre>import * from "material-templates.material"</pre>
-
diffuse vertexcolour
+
-
+
-
texture_unit MainTexture
+
-
{
+
-
filtering anisotropic
+
-
max_anisotropy 8
+
-
texture checker.png
+
-
texture_alias MainTexture
+
-
tex_address_mode clamp
+
-
}
+
-
}
+
-
}
+
-
}
+
-
// MESH BASE ALPHA MATERIAL TEMPLATE
 
-
material atlas_base_alpha : atlas_base
 
-
{
 
-
technique default
 
-
{
 
-
pass Decal
 
-
{
 
-
lighting on
 
-
ambient vertexcolour
+
This will import the templates and the artist does not have to type very much.
-
diffuse vertexcolour
+
-
alpha_rejection greater_equal 128
+
==Defining the Template and Texture==
-
alpha_to_coverage on
+
 
-
}
+
Then type this and replace the "diffuse_template" with your chosen template and "tex_basefloortile.png" with the texture which you want to use.
-
}
+
 
 +
<pre>
 +
material basefloortile : diffuse_template
 +
{
 +
  set_texture_alias ambient_tex tex_basefloortile.png
 +
  set_texture_alias diffuse_tex tex_basefloortile.png
}
}
 +
</pre>
-
// --------------- THESE ARE THE STANDARD NON-ATLAS MATERIALS ----------------------
+
Diffuse is the texture for normal light and ambient is what happens if there is no light.
-
material diffuse_template
+
-
{
+
-
receive_shadows off
+
-
technique default
+
=Templates=
-
{
+
-
pass Decal
+
-
{
+
-
lighting on
+
-
ambient vertexcolour
+
==diffuse_template==
-
diffuse vertexcolour
+
-
+
-
texture_unit
+
-
{
+
-
filtering anisotropic
+
-
max_anisotropy 8
+
-
texture checker.png
+
-
texture_alias diffuse_tex
+
-
tex_address_mode clamp
+
-
}
+
-
}
+
-
}
+
-
}
+
-
// MESH BASE ALPHA MATERIAL TEMPLATE
+
For normal Tiles without transparency but still having their own shadow.
-
material diffuse_template_alpha : diffuse_template
+
-
{
+
-
technique default
+
-
{
+
-
pass Decal
+
-
{
+
-
lighting on
+
-
ambient vertexcolour
+
==diffuse_template_alpha==
-
diffuse vertexcolour
+
-
alpha_rejection greater_equal 128
+
This is good for tiles with transparent textures but still having shadows.
-
alpha_to_coverage on
+
-
}
+
-
}
+
-
}
+
-
material diffuse_template_foliage : diffuse_template
+
:Advantage: Does not need a lot of performance
-
{
+
:Disadvantage Not so nice frames and is good for everything with transparency
-
technique default
+
-
{
+
-
pass Decal
+
-
{
+
-
lighting on
+
-
ambient vertexcolour
+
==diffuse_template_sceneblend==
-
diffuse vertexcolour
+
-
cull_hardware none
+
You can take that if the object should not have shadows but still is alpha transparent.
-
cull_software none
+
-
+
-
alpha_rejection greater_equal 128
+
-
alpha_to_coverage on
+
-
texture_unit
+
: Advantage: It has very nice frames. Good for grasses.
-
{
+
: Disadvantage: No real "Tiefensortierung". It is only apparent if you look at it and another mesh also having sceneblend.
-
filtering anisotropic
+
-
max_anisotropy 8
+
-
texture checker.png
+
-
texture_alias diffuse_tex
+
-
tex_address_mode wrap
+
-
}
+
-
}
+
-
}
+
-
}
+
-
material diffuse_template_sceneblend : diffuse_template
+
==diffuse_template_foliage==
-
{
+
-
technique default
+
-
{
+
-
pass Decal
+
-
{
+
-
lighting on
+
-
ambient vertexcolour
+
For objects having models and is alpha transparent.
-
diffuse vertexcolour
+
-
cull_hardware none
+
: Advantage: Object has shadows
-
cull_software none
+
: Disadvantage: Object unfortunately does not have nice frames. Good for flowers and trees.Objekt hat nicht so schöne Ränder (geeignet für Blumen oder Bäume)
-
scene_blend alpha_blend
+
=Beware=
-
depth_write off
+
 
-
depth_check on
+
To test the meshes, material and texture by taking a look on it with the help of [http://www.ogre3d.org/tikiwiki/Ogre+Meshy Ogre Meshy]. You have to copy the "material-templates.material" in the same folder.
-
}
+
 
-
}
+
=Links=
-
}
+
 
 +
[http://www.ogre3d.org/tikiwiki/Materials Tutorials]

Current revision as of 16:01, 19 December 2011

Personal tools