private void AddPlaneVisual3D(Point3D centerPosition, System.Windows.Media.Media3D.Material material, Size planeSize, bool isBillboard)
        {
            PlaneVisual3D planeVisual3D;

            if (isBillboard)
            {
                planeVisual3D = new BillboardVisual3D(); // BillboardVisual3D is defined in this sample and is the same as PlaneVisual3D but when BillboardVisual3D is there, we know that it needs to be aligned with the camera on each camera change
            }
            else
            {
                planeVisual3D = new PlaneVisual3D();
            }

            planeVisual3D.CenterPosition  = centerPosition;
            planeVisual3D.Size            = planeSize;
            planeVisual3D.Normal          = new Vector3D(0, 0, 1);
            planeVisual3D.HeightDirection = new Vector3D(0, 1, 0);
            planeVisual3D.Material        = material;

            if (!isBillboard)
            {
                planeVisual3D.BackMaterial = material;
            }

            SemiTransparentRootVisual3D.Children.Add(planeVisual3D);
        }
        private void SetMaterialsDXAttributes(System.Windows.Media.Media3D.Material wpfMaterial)
        {
            if (wpfMaterial == null)
            {
                return;
            }

            // Texture_AlphaClipThreshold attribute description:
            // This attribute can be set to a float value between 0 and 1.
            // When set to a float value that is bigger then 0, then alpha clipping is enabled.
            // This means that pixels with alpha color values below this value will be clipped (not rendered and their depth will not be written to depth buffer).
            // When alpha clipping is disabled (this attribute is not set or is set to 0) this means that also pixels with alpha value 0 are fully processed (they are not visible but its depth value is still written so objects that are rendered afterwards and are behind the pixel will not be visible).

            // Texture_UseAlphaToCoverage  attribute description:
            // When set to true, then the texture is rendered with using CommonStates.AlphaToCoverage blend state that can be used to render
            // textures with transparent and semi-transparent pixels and does not require objects to be sorted by their camera distance.
            //
            // When using alpha-to-coverage then the graphics card determines if the pixel is transparent or opaque based on the color's alpha value
            // (when alpha is less the 0.5 then pixel is fully transparent; otherwise the pixel is fully opaque).
            //
            // What is more, when using MSAA (multi-sample anti-aliasing) then the level of transparency can be defined more accurately with making some sub-pixel samples transparent and some opaque
            // (for example when using 8 x MSAA then each pixel's color is calculated with combining 8 sub-pixel samples; when alpha-to-coverage is enabled and alpha value is 0.25 (=2/8) then 2 of the samples will be transparent and 6 will be opaque).
            // This way it is possible to create smoother transitions from fully transparent to fully opaque regions.
            // This technique does not produce as accurate results as standard alpha blending, but a big advantage is that it does not require objects to be sorted (and rendered) from those that are farthest away to those that are closest to the camera (and the results are still very good for some use cases - especially when the textures has small transitions from transparent to opaque).

            // NOTE:
            // Texture_AlphaClipThreshold and Texture_UseAlphaToCoverage DXAttributes are read
            // only when the material is initialized by the DXEngine. Changes after initialization are not read.
            //
            // It is possible to enable both alpha-to-coverage and alpha clipping. But this is not needed.

            bool isAlphaToCoverageEnabled = AlphaToCoverageRadioButton.IsChecked ?? false;
            bool isAlphaClippingEnabled   = AlphaClippingRadioButton.IsChecked ?? false;

            if (isAlphaClippingEnabled)
            {
                float alphaClippingThreshold = GetAlphaClippingThreshold();
                wpfMaterial.SetDXAttribute(DXAttributeType.Texture_AlphaClipThreshold, alphaClippingThreshold);

                // When using DXEngine's StandardMaterial, you can change alpha-clip threshold with setting its AlphaClipThreshold value.
                // This field is provided with the IDiffuseTextureMaterial interface that StandardMaterial implements.
                // For example:
                //var standardMaterial = new StandardMaterial()
                //{
                //    // ... set other properties
                //    AlphaClipThreshold = alphaClippingThreshold
                //};
            }

            if (isAlphaToCoverageEnabled)
            {
                wpfMaterial.SetDXAttribute(DXAttributeType.Texture_UseAlphaToCoverage, true);

                // To alpha-to-coverage in DXEngine's StandardMaterial, set its TextureBlendState value to AlphaToCoverage blend state.
                // This field is provided with the IDiffuseTextureMaterial interface that StandardMaterial implements.
                // For example:
                //var standardMaterial = new StandardMaterial()
                //{
                //    // ... set other properties
                //    DiffuseTextures = new ShaderResourceView[] { textureShaderResourceView },
                //    TextureBlendState = MainDXViewportView.DXScene.DXDevice.CommonStates.AlphaToCoverage
                //};
            }
        }