protected override void DrawOverride(IDeviceContextHolder contextHolder, ICamera camera, SpecialRenderMode mode)
        {
            if (mode == SpecialRenderMode.Shadow)
            {
                if (_pntgObject == null)
                {
                    _pntgObject = new TrianglesRenderableObject <InputLayouts.VerticePNTG>("",
                                                                                           InputLayouts.VerticePNTG.Convert(OriginalNode.Vertices), Indices);
                    _pntgObject.Draw(contextHolder, camera, SpecialRenderMode.InitializeOnly);

                    _txNormal     = contextHolder.Get <INormalsNormalTexturesProvider>().GetTexture(contextHolder, OriginalNode.MaterialId);
                    _txNormalView = _txNormal?.Item1.Resource ?? contextHolder.GetFlatNmTexture();
                }

                if (_materialDepth == null)
                {
                    return;
                }
                _materialDepth.PrepareAo(contextHolder, _txNormalView, _txNormal?.Item2 ?? 1f);
                _pntgObject.SetBuffers(contextHolder);
                _materialDepth.SetMatricesAo(ParentMatrix);
                _materialDepth.DrawAo(contextHolder, Indices.Length);
            }
            else
            {
                if (mode != SpecialRenderMode.Simple)
                {
                    return;
                }
                if (!_material.Prepare(contextHolder, mode))
                {
                    return;
                }

                if (_materialDepth != null)
                {
                    if (!_txAlphaSet)
                    {
                        _txAlphaSet  = true;
                        _txAlpha     = contextHolder.TryToGet <IAlphaTexturesProvider>()?.GetTexture(contextHolder, OriginalNode.MaterialId);
                        _txAlphaView = _txAlpha?.Item1.Resource;
                    }

                    if (_txAlpha != null)
                    {
                        _materialDepth.PrepareShadow(_txAlphaView, _txAlphaView == null ? -1f : _txAlpha.Item2);
                    }
                    else
                    {
                        _materialDepth.PrepareShadow(null, -1f);
                    }
                }

                base.DrawOverride(contextHolder, camera, mode);

                _material.SetMatrices(ParentMatrix, camera);
                _material.Draw(contextHolder, Indices.Length, mode);
            }
        }
Example #2
0
        protected override void DrawOverride(IDeviceContextHolder contextHolder, ICamera camera, SpecialRenderMode mode)
        {
            if (!_material.Prepare(contextHolder, mode))
            {
                return;
            }
            base.DrawOverride(contextHolder, camera, mode);

            _material.SetMatrices(Transform * ParentMatrix, camera);
            _material.Draw(contextHolder, Indices.Length, mode);
        }