Since my bachelor thesis topic was approved I’ve been working on this project nearly every day. I made progress. Not as much as I wished for, but anyway. Basically I am now able to load and correctly display collada models using a variety of material properties. Since there are so many possible permutations of material properties (diffuse color or map, ambient color or map, specular color or map etc.) and other factors (light sources) I realized that it was way too much work to write a shader for each combination. Even using an approach like XNA’s BasicEffect which offers an array of varying vertex and pixel shaders to deal with quite a few combinations is not what I wanted to do. Instead I decided to write a shader generator, which generates and compiles a shader on demand depending on the needed material properties and other factors like lights, animation yes/no, which type of animation, mesh instancing yes/no and so on.
Creating this obviously took most of the time so far, but as I’m nearly finished with it I’m happy. It supports any combination of all supported features. One of the basic design decisions was to map all possible features with a class hierarchy. The following class diagram shows basically all supported material properties at the time being:
One of the advantages of a class hierachie is that I can use object oriented features for defining material properties, as for example inheritance. Also every material property has a well defined interface which can be used by my shader generator to generate the needed HLSL code. Each material property contains, among other things, a structure called “ShaderInstructions” containing basic information like the HLSL type. Also there is an interface called IShaderDefaultValue which can be implemented to define a default value for single value properties like textures, colors or float values.
Other than that support for one ambient light and multiple directional lights is implemented. Other types of lights are yet on the to-do list. But the next important point I am going to implement is animation. I’m going to implement “Mesh Morph Animation” and “Skinned Mesh Animation”. I hope to complete these features within the next week.
Yesterday and today I mostly worked on different normal mapping types. I successfully implemented simple Dot3 Bump Mapping and Parallax Mapping, which is shown in the next screenshot.
I also tried to implement Relief Mapping (a.k.a. Steep Parallax Mapping). Unfortunately that didn’t work too well. I hope that I will be able to fix it at some point, but right now animation is of a higher priority.
Leave a Reply