Graphics Reference
In-Depth Information
How it works…
The Visual Studio graphics content pipeline uses [VSInstallDir]\Common7\IDE\
Extensions\Microsoft\VsGraphics\vsgraphics.exe to display models/scenes
and also to compile them into objects ready for consumption in your application at runtime.
Unfortunately, Microsoft has only provided MSBuild targets for C++ projects; however,
with a few tweaks of the original MSBuild target files (also located in the same directory),
we can now do the same for our C# projects.
The compiled mesh object file structure may include multiple vertex buffers, index buffers,
submeshes, materials, texture references, the pixel shaders used, bones, and animations.
The exact binary file layout is shown within the comments in the Common\Mesh.cs class file.
The mesh class uses a BinaryReader instance and some helpful extension methods to load
the CMO file.
The MeshContentTask method supports compiling Autodesk FBX ( .fbx ),
Collada ( .dae ), and Wavefront ( .obj ), to compile mesh objects ( .CMO ).
Our mesh renderer is now available to manage the rendering tasks for the mesh object's
vertex and index buffers, materials, and textures. This renderer simply iterates the available
materials, updating the material buffer and then for each submesh that uses this material,
it loads the appropriate vertex and index buffers.
Currently, our solution is grouping materials that are used within a single mesh and its
submeshes. For a full-engine implementation, it would be more likely that materials are
shared between different meshes and therefore it would be necessary to correctly group
multiple meshes that use a material.
You can open the FBX file within Visual Studio and play with the material settings to see
how they affect the final render. At this point, it is also worth trying to use models that
include textures.
There's more…
You will find two more content pipeline MSBuild targets that have been converted to work with
C# projects in the downloaded code: one for compiling images ( ImageContentTask ) and one
for compiling shader graphs (the .dgls files) to shader byte code ( ShaderGraphContentTask ).
 
Search WWH ::




Custom Search