Ejemplo n.º 1
0
        protected override void ProcessPipelineState(RenderContext context, RenderNodeReference renderNodeReference, ref RenderNode renderNode, RenderObject renderObject, PipelineStateDescription pipelineState)
        {
            var renderMesh = (RenderMesh)renderObject;
            var drawData   = renderMesh.ActiveMeshDraw;

            pipelineState.InputElements = PrepareInputElements(pipelineState, drawData);
            pipelineState.PrimitiveType = drawData.PrimitiveType;

            // Prepare each sub render feature
            foreach (var renderFeature in RenderFeatures)
            {
                renderFeature.ProcessPipelineState(context, renderNodeReference, ref renderNode, renderObject, pipelineState);
            }
        }
Ejemplo n.º 2
0
 public abstract bool IsVisible(RenderObject renderObject, RenderView renderView, RenderViewStage renderViewStage);
Ejemplo n.º 3
0
 /// <summary>
 ///   Does any changes required to the pipeline state by this render feature.
 /// </summary>
 /// <param name="context">Context object providing access to information and services.</param>
 /// <param name="renderNodeReference"></param>
 /// <param name="renderNode"></param>
 /// <param name="renderObject"></param>
 /// <param name="pipelineState"></param>
 public virtual void ProcessPipelineState(RenderContext context, RenderNodeReference renderNodeReference, ref RenderNode renderNode, RenderObject renderObject, PipelineStateDescription pipelineState)
 {
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Removes a <see cref="RenderObject"/> from the rendering.
        /// </summary>
        /// <param name="renderObject"></param>
        public void RemoveRenderObject(RenderObject renderObject)
        {
            var renderFeature = renderObject.RenderFeature;

            renderFeature?.RemoveRenderObject(renderObject);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Implemented by subclasses to reset effect dependent data.
 /// </summary>
 protected virtual void InvalidateEffectPermutation(RenderObject renderObject, RenderEffect renderEffect)
 {
 }
Ejemplo n.º 6
0
        public override void Process(RenderNodeReference renderNodeReference, ref RenderNode renderNode, RenderObject renderObject, PipelineStateDescription pipelineState)
        {
            var output        = renderNode.RenderStage.Output;
            var isMultisample = output.MultisampleCount != MultisampleCount.None;
            var renderMesh    = (RenderMesh)renderObject;

            // Make object in transparent stage use AlphaBlend and DepthRead
            if (renderNode.RenderStage == TransparentRenderStage)
            {
                pipelineState.BlendState        = renderMesh.MaterialPass.BlendState ?? BlendStates.AlphaBlend;
                pipelineState.DepthStencilState = DepthStencilStates.DepthRead;
                if (isMultisample)
                {
                    pipelineState.BlendState.AlphaToCoverageEnable = renderMesh.MaterialPass.AlphaToCoverage ?? true;
                }
            }

            var cullMode = pipelineState.RasterizerState.CullMode;

            // Apply material cull mode
            var cullModeOverride = renderMesh.MaterialInfo.CullMode;

            // No override, or already two-sided?
            if (cullModeOverride.HasValue && cullMode != CullMode.None)
            {
                if (cullModeOverride.Value == CullMode.None)
                {
                    // Override to two-sided
                    cullMode = CullMode.None;
                }
                else if (cullModeOverride.Value == cullMode)
                {
                    // No or double flipping
                    cullMode = CullMode.Back;
                }
                else
                {
                    // Single flipping
                    cullMode = CullMode.Front;
                }
            }

            // Flip faces when geometry is inverted
            if (renderMesh.IsScalingNegative)
            {
                if (cullMode == CullMode.Front)
                {
                    cullMode = CullMode.Back;
                }
                else if (cullMode == CullMode.Back)
                {
                    cullMode = CullMode.Front;
                }
            }

            pipelineState.RasterizerState.CullMode = cullMode;

            if (isMultisample)
            {
                pipelineState.RasterizerState.MultisampleCount         = output.MultisampleCount;
                pipelineState.RasterizerState.MultisampleAntiAliasLine = true;
            }

            pipelineState.RasterizerState.ScissorTestEnable = output.ScissorTestEnable;
        }
Ejemplo n.º 7
0
 public abstract void Process(RenderObject renderObject);
Ejemplo n.º 8
0
 public override void Process(RenderNodeReference renderNodeReference, ref RenderNode renderNode, RenderObject renderObject, PipelineStateDescription pipelineState)
 {
     if (renderNode.RenderStage == RenderStage)
     {
         pipelineState.RasterizerState = RasterizerStates.Wireframe;
     }
 }
Ejemplo n.º 9
0
 public override void Process(RenderNodeReference renderNodeReference, ref RenderNode renderNode, RenderObject renderObject, PipelineStateDescription pipelineState)
 {
     // Objects in the shadow map render stage disable culling and depth clip
     if (renderNode.RenderStage == ShadowMapRenderStage)
     {
         pipelineState.RasterizerState = new RasterizerStateDescription(CullMode.None)
         {
             DepthClipEnable = DepthClipping
         };
     }
 }
Ejemplo n.º 10
0
 public abstract void Process(RenderNodeReference renderNodeReference, ref RenderNode renderNode, RenderObject renderObject, PipelineStateDescription pipelineState);