NS2 Material Guide - Choosing a Shader
Insane
Anomaly Join Date: 2002-05-13 Member: 605Members, Super Administrators, Forum Admins, NS1 Playtester, Forum Moderators, NS2 Developer, Constellation, NS2 Playtester, Squad Five Blue, NS2 Map Tester, Subnautica Developer, Pistachionauts, Future Perfect Developer
This isn't strictly "mapping" but as most of the texture artists seem to congregate in this forum I thought it was the best place for it. This post is a quick reference guide to choosing the correct shader for your NS2 materials. It assumes a basic working knowledge of modern texturing techniques (normal mapping and so on). NS2's material shaders are defined in .surface_shader files. These are XML files containing High Level Shader Language code. If you want to learn a little bit more about how the shaders themselves work, read this, or check out this in-depth video.
The "shader" parameter in your .material file is used to set a surface shader for that material. For each shader, I will describe what to use it for, and what texture maps it takes as an input.
MATERIAL FILE INPUTS
These are the values to set inside your .material file. Not all shaders require all of these values, and some have other, specialised values which will be covered individually.
"albedoMap" - Diffuse map.
"normalMap" - Normal map.
"specularMap" - Specular map.
"opacityMap" - Alpha map.
"emissiveMap" - Emissive/additive map.
LEVEL GEOMETRY
These shaders are intended for some materials that will be applied directly to world geometry by level designers. Note that these shaders look for a greyscale specular map in the alpha channel of the diffuse map. If you want your level texture to use an RGB specular map, use a Model_* shader.
"shaders/Level.surface_shader"
This is your basic level texture shader.
Inputs: diffuse map, normal map.
"shaders/Level_alpha.surface_shader"
This is for level textures requiring an alpha map. Use for materials like metal gratings, mesh screens etc.
Inputs: diffuse map, normal map, alpha map.
Note: Transparency is not fully implemented yet, and can only render 100% transparent or 100% opaque. Alpha maps should only use full black (0,0,0) or full white (255,255,255). For now, transparency can be "faked" using emissive maps.
"shaders/Level_emissive.surface_shader"
This for level textures requiring an emissive map, e.g. lights.
Inputs: diffuse map, normal map, emissive map.
MODELS
These shaders are intended in-game models, such as props and characters, as well as world geometry that requires an RGB specular map. You can also include a gloss map in the alpha channel of your specular map.
"shaders/Model.surface_shader"
This is your basic model shader.
Inputs: diffuse map, normal map, specular map.
"shaders/Model_alpha.surface_shader"
This is for models that also require alpha-mapped portions, for example foliage.
Inputs: diffuse map, normal map, specular map, alpha map.
Note: Transparency is not fully implemented yet, and can only render 100% transparent or 100% opaque. Alpha maps should only use full black (0,0,0) or full white (255,255,255). For now, transparency can be "faked" using emissive maps.
"shaders/Model_emissive.surface_shader"
This is for models requiring an emissive map, e.g. lights.
Inputs: diffuse map, normal map, specular map, emissive map.
"shaders/Model_emissive_alpha.surface_shader"
This is for models requiring both an alpha and emissive map.
Inputs: diffuse map, normal map, specular map, emissive map, alpha map.
DECALS
Use these for decal textures that the level designers "stamp" on top of existing geometry.
"shaders/Decal.surface_shader"
For general decal use.
Inputs: diffuse map, normal map, specular map, alpha map, endTime, scale.
"shaders/Decal_emissive.surface_shader"
For decals that also require an emissive map.
Inputs: diffuse map, normal map, specular map, emissive map, alpha map, endTime, scale.
Note that these shaders also take "endTime" and "scale" inputs. These are numerical values and are completely optional. They're used for animating decals such as bullet holes or blood spatter and aren't necessary if you're creating environment details.
VIEWMODELS
"shaders/ViewModel.surface_shader"
This is your basic view model shader.
Inputs: diffuse map, normal map, specular map.
"shaders/ViewModel_emissive.surface_shader"
This is for view models requiring an emissive map.
Inputs: diffuse map, normal map, specular map, emissive map.
MISCELLANEOUS
"shaders/Emissive.surface_shader"
This is for textures that use an emissive map only. Good for "faking" partial transparency e.g. glass textures.
Inputs: Emissive map.
"models/hologram.surface_shader"
For hologram effects. The flicker map is a texture that sets a flicker animation for varying the brightness. Just use "models/flicker.dds". Flicker speed controls how fast it flickers, xScroll and yScroll control the scrolling speed in each direction. Set these three values to zero for no flickering or scrolling.
Inputs: Emissive map. Flicker map, xScroll, yScroll, flicker speed.
"SURFACE" PARAMETER FOR MATERIALS
In the .material file you can set a "surface" parameter. This tells the game what effects to create for footsteps, bullet impacts etc. by specifying the kind of material the surface is made of. You can find a full list of possible values for this parameter in ns2/cinematics/materials.
The "shader" parameter in your .material file is used to set a surface shader for that material. For each shader, I will describe what to use it for, and what texture maps it takes as an input.
MATERIAL FILE INPUTS
These are the values to set inside your .material file. Not all shaders require all of these values, and some have other, specialised values which will be covered individually.
"albedoMap" - Diffuse map.
"normalMap" - Normal map.
"specularMap" - Specular map.
"opacityMap" - Alpha map.
"emissiveMap" - Emissive/additive map.
LEVEL GEOMETRY
These shaders are intended for some materials that will be applied directly to world geometry by level designers. Note that these shaders look for a greyscale specular map in the alpha channel of the diffuse map. If you want your level texture to use an RGB specular map, use a Model_* shader.
"shaders/Level.surface_shader"
This is your basic level texture shader.
Inputs: diffuse map, normal map.
"shaders/Level_alpha.surface_shader"
This is for level textures requiring an alpha map. Use for materials like metal gratings, mesh screens etc.
Inputs: diffuse map, normal map, alpha map.
Note: Transparency is not fully implemented yet, and can only render 100% transparent or 100% opaque. Alpha maps should only use full black (0,0,0) or full white (255,255,255). For now, transparency can be "faked" using emissive maps.
"shaders/Level_emissive.surface_shader"
This for level textures requiring an emissive map, e.g. lights.
Inputs: diffuse map, normal map, emissive map.
MODELS
These shaders are intended in-game models, such as props and characters, as well as world geometry that requires an RGB specular map. You can also include a gloss map in the alpha channel of your specular map.
"shaders/Model.surface_shader"
This is your basic model shader.
Inputs: diffuse map, normal map, specular map.
"shaders/Model_alpha.surface_shader"
This is for models that also require alpha-mapped portions, for example foliage.
Inputs: diffuse map, normal map, specular map, alpha map.
Note: Transparency is not fully implemented yet, and can only render 100% transparent or 100% opaque. Alpha maps should only use full black (0,0,0) or full white (255,255,255). For now, transparency can be "faked" using emissive maps.
"shaders/Model_emissive.surface_shader"
This is for models requiring an emissive map, e.g. lights.
Inputs: diffuse map, normal map, specular map, emissive map.
"shaders/Model_emissive_alpha.surface_shader"
This is for models requiring both an alpha and emissive map.
Inputs: diffuse map, normal map, specular map, emissive map, alpha map.
DECALS
Use these for decal textures that the level designers "stamp" on top of existing geometry.
"shaders/Decal.surface_shader"
For general decal use.
Inputs: diffuse map, normal map, specular map, alpha map, endTime, scale.
"shaders/Decal_emissive.surface_shader"
For decals that also require an emissive map.
Inputs: diffuse map, normal map, specular map, emissive map, alpha map, endTime, scale.
Note that these shaders also take "endTime" and "scale" inputs. These are numerical values and are completely optional. They're used for animating decals such as bullet holes or blood spatter and aren't necessary if you're creating environment details.
VIEWMODELS
"shaders/ViewModel.surface_shader"
This is your basic view model shader.
Inputs: diffuse map, normal map, specular map.
"shaders/ViewModel_emissive.surface_shader"
This is for view models requiring an emissive map.
Inputs: diffuse map, normal map, specular map, emissive map.
MISCELLANEOUS
"shaders/Emissive.surface_shader"
This is for textures that use an emissive map only. Good for "faking" partial transparency e.g. glass textures.
Inputs: Emissive map.
"models/hologram.surface_shader"
For hologram effects. The flicker map is a texture that sets a flicker animation for varying the brightness. Just use "models/flicker.dds". Flicker speed controls how fast it flickers, xScroll and yScroll control the scrolling speed in each direction. Set these three values to zero for no flickering or scrolling.
Inputs: Emissive map. Flicker map, xScroll, yScroll, flicker speed.
"SURFACE" PARAMETER FOR MATERIALS
In the .material file you can set a "surface" parameter. This tells the game what effects to create for footsteps, bullet impacts etc. by specifying the kind of material the surface is made of. You can find a full list of possible values for this parameter in ns2/cinematics/materials.
Comments
This was something I've had the intentions of doing myself... if I actually had the knowledge and time to do so :P
Maybe this should be a sticky thread with a collection of all information and tutorials on shaders, materials and textures?
Brian's shader system youtube tutorial would be a nice addition to that list.