Graphics Reference
In-Depth Information
BorderColor = new Color4(0, 0, 0, 0),
ComparisonFunction = Comparison.Never,
Filter = Filter.MinMagMipLinear,
MaximumAnisotropy = 16,
MaximumLod = float.MaxValue,
MinimumLod = 0,
MipLodBias = 0.0f
}));
8.
We can now implement the DoRender method to render our mesh. We will be
rendering the model's submeshes grouped by material, so we begin by iterating
the mesh's available materials. After retrieving the submeshes for the material,
we update the PerMaterialBuffer instance and then render the submesh
as shown in the following code:
// Draw sub-meshes grouped by material
for (var mIndx = 0; mIndx < mesh.Materials.Count; mIndx++)
{
// If the material buffer is assigned and submeshes
// user the material, update the PerMaterialBuffer
if (PerMaterialBuffer != null &&
subMeshesForMaterial.Length > 0)
{
... update material buffer
}
// For each sub-mesh
foreach (var subMesh in subMeshesForMaterial)
{
... render each sub-mesh
}
}
9.
We update the material buffer and assign any textures if PerMaterialBuffer is
assigned. If the first texture view is not null, we will set the HasTexture property of
the PerMaterial buffer to true .
// update the PerMaterialBuffer constant buffer
var material = new ConstantBuffers.PerMaterial()
{
Ambient = new Color4(mesh.Materials[mIndx].Ambient),
Diffuse = new Color4(mesh.Materials[mIndx].Diffuse),
Emissive = new Color4(mesh.Materials[mIndx].Emissive),
Specular = new Color4(mesh.Materials[mIndx].Specular),
SpecularPower = mesh.Materials[mIndx].SpecularPower,
UVTransform = mesh.Materials[mIndx].UVTransform,
};
 
Search WWH ::




Custom Search