Пример #1
0
 public override void Process(RenderNodeReference renderNodeReference, ref RenderNode renderNode, RenderObject renderObject, PipelineStateDescription pipelineState)
 {
     if (renderNode.RenderStage == RenderStage)
     {
         pipelineState.RasterizerState = RasterizerStates.Wireframe;
     }
 }
Пример #2
0
        internal RenderNodeReference CreateRenderNode(RenderObject renderObject, RenderView renderView, ViewObjectNodeReference renderPerViewNode, RenderStage renderStage)
        {
            var renderNode = new RenderNode(renderObject, renderView, renderPerViewNode, renderStage);

            // Create view node
            var index  = RenderNodes.Add(renderNode);
            var result = new RenderNodeReference(index);

            return(result);
        }
Пример #3
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
         };
     }
 }
 public override void Process(RenderNodeReference renderNodeReference, ref RenderNode renderNode, RenderObject renderObject, PipelineStateDescription pipelineState)
 {
     // Disable culling and depth clip
     if (renderNode.RenderStage == VoxelRenderStage)
     {
         pipelineState.RasterizerState = new RasterizerStateDescription(CullMode.None)
         {
             DepthClipEnable = DepthClipping
         };
         pipelineState.DepthStencilState.DepthBufferEnable      = false;
         pipelineState.DepthStencilState.DepthBufferWriteEnable = false;
         pipelineState.DepthStencilState.StencilEnable          = false;
         pipelineState.DepthStencilState.StencilWriteMask       = 0;
         pipelineState.DepthStencilState.StencilMask            = 0;
         pipelineState.BlendState.RenderTarget0.BlendEnable     = false;
         pipelineState.BlendState.IndependentBlendEnable        = false;
     }
 }
Пример #5
0
 /// <summary>
 /// Do any changes required to the pipeline state.
 /// </summary>
 /// <param name="context"></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)
 {
 }
        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);
            }
        }
Пример #7
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 = renderMesh.TransparentWriteDepth ? DepthStencilStates.Default : 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;
        }
Пример #8
0
        protected override void ProcessPipelineState(RenderContext context, RenderNodeReference renderNodeReference, ref RenderNode renderNode, RenderObject renderObject, PipelineStateDescription pipelineState)
        {
            var renderMesh = (RenderMesh)renderObject;
            var drawData   = renderMesh.ActiveMeshDraw;

            if (drawData is StagedMeshDraw smd && smd.VertexBuffers == null)
            {
                smd.performStage(context.GraphicsDevice, smd);
            }

            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);
            }
        }
Пример #9
0
 public abstract void Process(RenderNodeReference renderNodeReference, ref RenderNode renderNode, RenderObject renderObject, PipelineStateDescription pipelineState);