public void MarkOneCascade(int numCascade, IDepthStencil depthStencil, Matrix worldToProjection,
                                   ICascadeShadowMapSlice slice)
        {
            MyRenderContext RC = MyRender11.RC;

            RC.SetVertexBuffer(0, m_vertexBuffer);
            RC.SetIndexBuffer(m_indexBuffer);
            RC.SetInputLayout(m_inputLayout);
            RC.SetViewport(0, 0, MyRender11.ResolutionI.X, MyRender11.ResolutionI.Y);
            RC.SetDepthStencilState(MyDepthStencilStateManager.MarkIfInsideCascadeOld[numCascade], 0xf - numCascade);
            RC.SetRasterizerState(MyRasterizerStateManager.NocullRasterizerState);
            RC.SetPrimitiveTopology(PrimitiveTopology.TriangleList);

            MyMapping mapping            = MyMapping.MapDiscard(m_markerConstantBuffer);
            Matrix    shadowToProjection = slice.MatrixShadowToWorldAt0Space * worldToProjection;

            shadowToProjection = Matrix.Transpose(shadowToProjection);
            mapping.WriteAndPosition(ref shadowToProjection);
            mapping.Unmap();
            RC.VertexShader.SetConstantBuffer(6, m_markerConstantBuffer);
            RC.VertexShader.Set(m_vsMarker);

            RC.PixelShader.SetSrv(0, depthStencil.SrvDepth);
            //RC.PixelShader.SetSrv(1, depthStencil.SrvStencil);
            RC.PixelShader.Set(m_psMarker);

            RC.SetRtv(depthStencil, MyDepthStencilAccess.DepthReadOnly);

            RC.DrawIndexed(36, 0, 0);
        }
Example #2
0
        // returned value - is there anything to draw?
        public bool Finalize(MyRenderContext RC, out IVertexBuffer vbInstances)
        {
            vbInstances = m_vbInstances;
            if (m_validElements == 0)
            {
                return(false);
            }

            MyMapping mappingVb = MyMapping.MapDiscard(RC, vbInstances);

            mappingVb.WriteAndPosition(m_vbData, m_validElements);
            mappingVb.Unmap();
            return(true);
        }
        public void UpdateEntry(int voxelMaterialId, ref MyVoxelMaterialEntry entry)
        {
            MyRenderProxy.Assert(voxelMaterialId < MAX_ENTRIES);
            MyRenderProxy.Assert(Cb != null);
            MyRenderProxy.Assert(MyRenderProxy.RenderThread.SystemThread == System.Threading.Thread.CurrentThread);

            if (m_needsUpdate[voxelMaterialId])
            {
                m_entries[voxelMaterialId] = entry;
                MyMapping mapping = MyMapping.MapDiscard(Cb);
                for (int i = 0; i < MAX_ENTRIES; i++)
                {
                    mapping.WriteAndPosition(ref m_entries[i]);
                }
                mapping.Unmap();
                m_needsUpdate[voxelMaterialId] = false;
            }
        }