• Much more documentation of this system is needed. I could easily go in depth on this and take up 5+ pages in the process. Hopefully there is more documentation to come on this later. 
  • Materials store information about how an object will render, which shader it will use, and which shader parameters it will receive from the engine. This makes it very easy to write a shader and know the data will get to your shader.
  • Let’s take a look at Terrain.qsm as an example:
    • <material effect="Terrain">
      • This is where the material references the shader (.fx) file. The Sample game’s terrain uses Terrain.fx.
    • <sampler semantic="TEXTURE_MAP">../Images/TerrainMaps/mapLargeTerrain</sampler>
      • Which texture your terrain will use to multi-texture splat textures onto the terrain. “Sampler semantic” means that TEXTURE_MAP will be a texture sampler in the effects file.
    • <variable_matrix semantic="WORLDVIEWPROJECTION"varID="WorldViewProjection"/>
      • variable_matrix semantic means that WorldViewProjection will be a Matrix (float4x4) in the effects file.
    • The same concept applies to all standard semantic types.
    • CAUTION: Don’t forget to set your .qsm file to compile. Once you have it in the project, right click on the file, and set ‘Build Action’ to compile.
  • So why are Materials useful?
    • The word “Material” sort of gives away the answer. You could have many different materials all using the same shader type. For example, if the shaders job is just to light a textured object with ambient and specular lighting, that is fine, but what if you want a wooden Entity to be shown more dully lit than a shiny metal object you shouldn’t have to write different shaders that do that for you, and you don’t want to hard-code different values in the code for all of your different types, so you simply define these values in the Material that you want on the Entity.
    • In addition to material types, the material describes which shader parameters you’ll need, so it is an easy way to register for those paramaters, after which time the shader can automatically make use of them.

Last edited Jan 7, 2012 at 5:04 PM by LordIkon, version 3

Comments

No comments yet.