/// <summary>
 /// Adds a shadow caster filter for rendering only meshes that can cast shadows.
 /// </summary>
 /// <param name="modelRenderer">The model renderer.</param>
 /// <returns>ModelRenderer.</returns>
 public static ModelRenderer AddShadowCasterFilter(this ModelRenderer modelRenderer)
 {
     modelRenderer.AcceptPrepareMeshForRendering.Add((model, mesh) => mesh.Parameters.Get(LightingKeys.CastShadows));
     modelRenderer.AcceptRenderMesh.Add((context, renderMesh) => renderMesh.Parameters.Get(LightingKeys.CastShadows));
     modelRenderer.AppendDebugName("ShadowMapCaster");
     return(modelRenderer);
 }
 /// <summary>
 /// Adds an opaque filter for rendering meshes which are opaque.
 /// </summary>
 /// <param name="modelRenderer">The model renderer.</param>
 /// <returns>ModelRenderer.</returns>
 public static ModelRenderer AddOpaqueFilter(this ModelRenderer modelRenderer)
 {
     modelRenderer.AcceptPrepareMeshForRendering.Add((model, mesh) => !IsTransparent(mesh));
     modelRenderer.AcceptRenderMesh.Add((context, renderMesh) => !IsTransparent(renderMesh.Mesh));
     modelRenderer.AppendDebugName("Opaque");
     return(modelRenderer);
 }
        // TODO: Add support for OR combination of filters

        /// <summary>
        /// Adds a transparent filter for rendering meshes which are transparent.
        /// </summary>
        /// <param name="modelRenderer">The model renderer.</param>
        /// <returns>ModelRenderer.</returns>
        public static ModelRenderer AddTransparentFilter(this ModelRenderer modelRenderer)
        {
            modelRenderer.AcceptPrepareMeshForRendering.Add((model, mesh) => IsTransparent(mesh));
            modelRenderer.AcceptRenderMesh.Add((context, effectMesh) => IsTransparent(effectMesh.Mesh));
            modelRenderer.AppendDebugName("Transparent");
            return(modelRenderer);
        }
 /// <summary>
 /// Adds a layer filter for rendering meshes only on the context active layers.
 /// </summary>
 /// <param name="modelRenderer">The model renderer.</param>
 /// <returns>ModelRenderer.</returns>
 public static ModelRenderer AddContextActiveLayerFilter(this ModelRenderer modelRenderer)
 {
     modelRenderer.AcceptRenderMesh.Add((context, renderMesh) => (context.Parameters.Get(RenderingParameters.ActiveRenderLayer) & renderMesh.Parameters.Get(RenderingParameters.RenderLayer)) != RenderLayers.RenderLayerNone);
     modelRenderer.AppendDebugName("Active Layer");
     return(modelRenderer);
 }
 /// <summary>
 /// Adds a layer filter for rendering meshes only on the specified layer.
 /// </summary>
 /// <param name="modelRenderer">The model renderer.</param>
 /// <param name="activelayers">The activelayers.</param>
 /// <returns>ModelRenderer.</returns>
 public static ModelRenderer AddLayerFilter(this ModelRenderer modelRenderer, RenderLayers activelayers)
 {
     modelRenderer.AcceptRenderMesh.Add((context, renderMesh) => (renderMesh.Parameters.Get(RenderingParameters.RenderLayer) & activelayers) != RenderLayers.RenderLayerNone);
     modelRenderer.AppendDebugName("Layer " + activelayers);
     return(modelRenderer);
 }