示例#1
0
        protected override void RecordCommandsInternal(ref MyRenderableProxy_2 proxy, int instanceIndex, int sectionIndex)
        {
            RC.SetSRVs(ref proxy.ObjectSRVs);
            RC.BindVertexData(ref proxy.VertexData);

            Stats.Meshes++;

            if (instanceIndex == -1)
            {
                RC.BindShaders(proxy.HighlightShaders.MultiInstance);
                for (int it = 0; it < proxy.Submeshes.Length; it++)
                {
                    MyDrawSubmesh_2 submesh = proxy.Submeshes[it];
                    DrawSubmesh(ref proxy, ref submesh, sectionIndex);
                }
            }
            else
            {
                RC.BindShaders(proxy.HighlightShaders.SingleInstance);
                MyDrawSubmesh_2 submesh;
                if (sectionIndex == -1)
                {
                    submesh = proxy.Submeshes[instanceIndex];
                }
                else
                {
                    submesh = proxy.SectionSubmeshes[instanceIndex][sectionIndex];
                }

                DrawSubmesh(ref proxy, ref submesh, instanceIndex);
            }
        }
示例#2
0
        protected override void RecordCommandsInternal(ref MyRenderableProxy_2 proxy, int instanceIndex, int sectionIndex)
        {
            MyRenderUtils.SetSrvs(RC, ref proxy.ObjectSrvs);

            Stats.Draws++;

            if (instanceIndex == -1)
            {
                MyRenderUtils.BindShaderBundle(RC, proxy.HighlightShaders.MultiInstance);
                for (int it = 0; it < proxy.Submeshes.Length; it++)
                {
                    MyDrawSubmesh_2 submesh = proxy.Submeshes[it];
                    DrawSubmesh(ref proxy, ref submesh, sectionIndex);
                }
            }
            else
            {
                MyRenderUtils.BindShaderBundle(RC, proxy.HighlightShaders.SingleInstance);
                MyDrawSubmesh_2 submesh;
                if (sectionIndex == -1)
                {
                    submesh = proxy.Submeshes[instanceIndex];
                }
                else
                {
                    submesh = proxy.SectionSubmeshes[instanceIndex][sectionIndex];
                }

                DrawSubmesh(ref proxy, ref submesh, instanceIndex);
            }
        }
示例#3
0
        private void DrawSubmesh(ref MyRenderableProxy_2 proxy, ref MyDrawSubmesh_2 submesh, int instanceIndex)
        {
            var material = MyMaterials1.ProxyPool.Data[submesh.MaterialId.Index];

            RC.MoveConstants(ref material.MaterialConstants);
            RC.SetConstants(ref material.MaterialConstants, MyCommon.MATERIAL_SLOT);
            RC.SetSRVs(ref material.MaterialSRVs);

            MyMergeInstancingConstants constants = new MyMergeInstancingConstants();

            constants.InstanceIndex = instanceIndex;
            constants.StartIndex    = submesh.Start;
            SetProxyConstants(ref proxy, constants);

            if (proxy.InstanceCount == 0)
            {
                switch (submesh.DrawCommand)
                {
                case MyDrawCommandEnum.DrawIndexed:
                    RC.DeviceContext.DrawIndexed(submesh.Count, submesh.Start, submesh.BaseVertex);
                    break;

                case MyDrawCommandEnum.Draw:
                    RC.DeviceContext.Draw(submesh.Count, submesh.Start);
                    break;

                default:
                    break;
                }
            }
            else
            {
                switch (submesh.DrawCommand)
                {
                case MyDrawCommandEnum.DrawIndexed:
                    RC.DeviceContext.DrawIndexedInstanced(submesh.Count, proxy.InstanceCount, submesh.Start, submesh.BaseVertex, proxy.StartInstance);
                    break;

                case MyDrawCommandEnum.Draw:
                    RC.DeviceContext.DrawInstanced(submesh.Count, proxy.InstanceCount, submesh.Start, proxy.StartInstance);
                    break;

                default:
                    break;
                }
            }

            Stats.Submeshes++;
        }
示例#4
0
        /// <returns>Actor full mesh indices count</returns>
        private void UpdateActorSubmeshes(ref MyRenderableProxy_2 proxy, MyActor actor, int actorIndex, int indexOffset)
        {
            MyRenderableComponent component      = actor.GetRenderable();
            MyRenderableProxy     proxy1         = component.Lods[0].RenderableProxies[0];
            MyDrawSubmesh_2       sectionSubmesh = proxy.Submeshes[0];

            MyDrawSubmesh_2[] sectionSubmeshes = new MyDrawSubmesh_2[proxy1.SectionSubmeshes.Length];
            proxy.SectionSubmeshes[actorIndex] = sectionSubmeshes;
            for (int it = 0; it < proxy1.SectionSubmeshes.Length; it++)
            {
                MyDrawSubmesh sectionSubmesh1 = proxy1.SectionSubmeshes[it];
                sectionSubmesh.Count = sectionSubmesh1.IndexCount;
                sectionSubmesh.Start = indexOffset + sectionSubmesh1.StartIndex;
                sectionSubmeshes[it] = sectionSubmesh;
            }
        }
        /// <returns>Actor full mesh indices count</returns>
        private void UpdateActorSubmeshes(ref MyRenderableProxy_2 proxy, MyActor actor, int actorIndex, int indexOffset)
        {
            MyRenderableComponent component = actor.GetRenderable();
            MyRenderableProxy proxy1 = component.Lods[0].RenderableProxies[0];
            MyDrawSubmesh_2 sectionSubmesh = proxy.Submeshes[0];

            MyDrawSubmesh_2[] sectionSubmeshes = new MyDrawSubmesh_2[proxy1.SectionSubmeshes.Length];
            proxy.SectionSubmeshes[actorIndex] = sectionSubmeshes;
            for (int it = 0; it < proxy1.SectionSubmeshes.Length; it++)
            {
                MyDrawSubmesh sectionSubmesh1 = proxy1.SectionSubmeshes[it];
                sectionSubmesh.Count = sectionSubmesh1.IndexCount;
                sectionSubmesh.Start = indexOffset + sectionSubmesh1.StartIndex;
                sectionSubmeshes[it] = sectionSubmesh;
            }
        }
示例#6
0
        private void DrawSubmesh(ref MyRenderableProxy_2 proxy, ref MyDrawSubmesh_2 submesh, int instanceIndex)
        {
            var material = MyMaterials1.ProxyPool.Data[submesh.MaterialId.Index];
            MyRenderUtils.MoveConstants(RC, ref material.MaterialConstants);
            MyRenderUtils.SetConstants(RC, ref material.MaterialConstants, MyCommon.MATERIAL_SLOT);
            MyRenderUtils.SetSrvs(RC, ref material.MaterialSrvs);

            MyMergeInstancingConstants constants = new MyMergeInstancingConstants();
            constants.InstanceIndex = instanceIndex;
            constants.StartIndex = submesh.Start;
            SetProxyConstants(ref proxy, constants);

            if (proxy.InstanceCount == 0)
            {
                switch (submesh.DrawCommand)
                {
                    case MyDrawCommandEnum.DrawIndexed:
                        RC.DrawIndexed(submesh.Count, submesh.Start, submesh.BaseVertex);
                        break;
                    case MyDrawCommandEnum.Draw:
                        RC.Draw(submesh.Count, submesh.Start);
                        break;
                    default:
                        break;
                }
            }
            else
            {
                switch (submesh.DrawCommand)
                {
                    case MyDrawCommandEnum.DrawIndexed:
                        RC.DrawIndexedInstanced(submesh.Count, proxy.InstanceCount, submesh.Start, submesh.BaseVertex, proxy.StartInstance);
                        break;
                    case MyDrawCommandEnum.Draw:
                        RC.DrawInstanced(submesh.Count, proxy.InstanceCount, submesh.Start, proxy.StartInstance);
                        break;
                    default:
                        break;
                }
            }

            Stats.Submeshes++;
        }