2015-05-14 08:39:39 +08:00
|
|
|
// A "Material" file can contain one or more materials
|
2015-05-12 12:31:33 +08:00
|
|
|
material spaceship
|
|
|
|
{
|
2015-05-14 08:39:39 +08:00
|
|
|
// A Material contains one or more Techniques
|
|
|
|
// The first technique is going to be the default one.
|
|
|
|
// In this case, the default one is "unlit"
|
|
|
|
// A "Technique" describes how the material is going to be renderer
|
|
|
|
// Techniques could be:
|
|
|
|
// - How a Model is going to be renderer in high quality
|
|
|
|
// - or in low quality
|
|
|
|
// - or when using lights
|
|
|
|
// - or when not using lights
|
|
|
|
// - or to "outline" a model
|
|
|
|
// etc...
|
|
|
|
technique normal
|
2015-05-12 12:31:33 +08:00
|
|
|
{
|
2015-05-14 08:39:39 +08:00
|
|
|
// A technique can contain one or more passes
|
|
|
|
// A "Pass" describes the "draws" that will be needed
|
|
|
|
// in order to achieve the desired technique
|
|
|
|
// The 3 properties of the Passes are:
|
|
|
|
//
|
|
|
|
// renderState:
|
|
|
|
// resposinble for depth buffer, cullface, stencil, blending, etc.
|
|
|
|
// shader:
|
|
|
|
// responsible for the vertex and frag shaders, and its uniforms
|
|
|
|
// sampler:
|
|
|
|
// responsible for setting the texture and its parameters
|
2015-05-12 12:31:33 +08:00
|
|
|
pass 0
|
|
|
|
{
|
|
|
|
shader
|
|
|
|
{
|
|
|
|
vertexShader = Shaders3D/3d_position_tex.vert
|
|
|
|
fragmentShader = Shaders3D/3d_color_tex.frag
|
|
|
|
}
|
|
|
|
sampler 0
|
|
|
|
{
|
|
|
|
path = Sprite3DTest/boss.png
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-14 08:39:39 +08:00
|
|
|
// This is another technique. It "outlines" the model
|
|
|
|
// It has 3 passes in order to get the desired effect
|
2015-05-13 13:24:52 +08:00
|
|
|
technique outline
|
|
|
|
{
|
2015-05-14 08:39:39 +08:00
|
|
|
// 1st pass:
|
|
|
|
// creates a yellow outline of only the hull
|
|
|
|
pass outline
|
2015-05-13 13:24:52 +08:00
|
|
|
{
|
|
|
|
renderState
|
|
|
|
{
|
2015-05-14 01:24:32 +08:00
|
|
|
cullFace = true
|
|
|
|
cullFaceSide = BACK
|
|
|
|
depthTest = false
|
2015-05-13 13:24:52 +08:00
|
|
|
}
|
|
|
|
shader
|
|
|
|
{
|
|
|
|
vertexShader = Shaders3D/OutLine.vert
|
|
|
|
fragmentShader = Shaders3D/OutLine.frag
|
2015-05-14 01:24:32 +08:00
|
|
|
// Uniforms
|
|
|
|
OutLineColor = 1,1,0
|
|
|
|
OutlineWidth = 0.04
|
2015-05-13 13:24:52 +08:00
|
|
|
}
|
|
|
|
sampler 0
|
|
|
|
{
|
|
|
|
path = Sprite3DTest/boss.png
|
|
|
|
}
|
|
|
|
}
|
2015-05-14 08:39:39 +08:00
|
|
|
|
|
|
|
// 2nd pass:
|
|
|
|
// creates a blue outline of the borders
|
2015-05-13 13:24:52 +08:00
|
|
|
pass outline thick
|
|
|
|
{
|
|
|
|
renderState
|
|
|
|
{
|
2015-05-14 01:24:32 +08:00
|
|
|
cullFace = true
|
|
|
|
cullFaceSide = FRONT
|
|
|
|
depthTest = true
|
2015-05-13 13:24:52 +08:00
|
|
|
}
|
|
|
|
shader
|
|
|
|
{
|
|
|
|
vertexShader = Shaders3D/OutLine.vert
|
|
|
|
fragmentShader = Shaders3D/OutLine.frag
|
2015-05-14 01:24:32 +08:00
|
|
|
// Uniforms
|
|
|
|
OutLineColor = 0,0,1
|
|
|
|
OutlineWidth = 0.02
|
2015-05-13 13:24:52 +08:00
|
|
|
}
|
|
|
|
sampler 0
|
|
|
|
{
|
|
|
|
path = Sprite3DTest/boss.png
|
|
|
|
}
|
|
|
|
}
|
2015-05-14 08:39:39 +08:00
|
|
|
// 3rd pass
|
|
|
|
// Renders the model "normally"
|
|
|
|
// When a 'renderState' is not present it will use the default renderState
|
|
|
|
pass normal
|
2015-05-13 13:24:52 +08:00
|
|
|
{
|
|
|
|
shader
|
|
|
|
{
|
|
|
|
vertexShader = Shaders3D/3d_position_tex.vert
|
|
|
|
fragmentShader = Shaders3D/3d_color_tex.frag
|
|
|
|
}
|
|
|
|
sampler 0
|
|
|
|
{
|
|
|
|
path = Sprite3DTest/boss.png
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-05-14 08:39:39 +08:00
|
|
|
// Another technique:
|
|
|
|
// This one renders the model using the lights avaiable from the Scene
|
|
|
|
technique lit
|
|
|
|
{
|
|
|
|
pass 0
|
|
|
|
{
|
|
|
|
shader
|
|
|
|
{
|
|
|
|
// You can pass "compile time" variables to your shader using a 'defines'
|
|
|
|
defines = MAX_POINT_LIGHT_NUM 1;MAX_SPOT_LIGHT_NUM 1;MAX_DIRECTIONAL_LIGHT_NUM 1
|
|
|
|
vertexShader = Shaders3D/3d_position_normal_tex.vert
|
|
|
|
fragmentShader = Shaders3D/3d_color_normal_tex.frag
|
|
|
|
}
|
|
|
|
sampler 0
|
|
|
|
{
|
|
|
|
path = Sprite3DTest/boss.png
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-05-12 12:31:33 +08:00
|
|
|
}
|