Example #1
0
        internal static void BindProxyGeometry(MyRenderableProxy proxy, MyRenderContext rc)
        {
            MyMeshBuffers buffers = proxy.Mesh.Buffers;

            rc.SetVertexBuffer(0, buffers.VB0);
            rc.SetVertexBuffer(1, buffers.VB1);

            if (proxy.InstancingEnabled && proxy.Instancing.VB != null)
            {
                rc.SetVertexBuffer(2, proxy.Instancing.VB);
            }
            rc.SetIndexBuffer(buffers.IB);
        }
        internal static void BindProxyGeometry(MyRenderableProxy proxy, MyRenderContext rc)
        {
            MyMeshBuffers buffers;

            if (proxy.Mesh != LodMeshId.NULL)
            {
                buffers = proxy.Mesh.Buffers;
            }
            else
            {
                buffers = proxy.MergedMesh.Buffers;
            }

            rc.SetVertexBuffer(0, buffers.VB0.Buffer, buffers.VB0.Stride);
            rc.SetVertexBuffer(1, buffers.VB1.Buffer, buffers.VB1.Stride);

            if (proxy.InstancingEnabled && proxy.Instancing.VB.Index != -1)
            {
                rc.SetVertexBuffer(2, proxy.Instancing.VB.Buffer, proxy.Instancing.VB.Stride);
            }
            rc.SetIndexBuffer(buffers.IB.Buffer, buffers.IB.Format);
        }
Example #3
0
        internal static void BindProxyGeometry(MyRenderableProxy proxy, MyRenderContext rc)
        {
            MyMeshBuffers buffers;
            
            if(proxy.Mesh != LodMeshId.NULL)
                buffers = proxy.Mesh.Buffers;
            else
                buffers = proxy.MergedMesh.Buffers;

            rc.SetVertexBuffer(0, buffers.VB0);
            rc.SetVertexBuffer(1, buffers.VB1);
            
            if (proxy.InstancingEnabled && proxy.Instancing.VB != null)
            {
                rc.SetVertexBuffer(2, proxy.Instancing.VB);

            }
            rc.SetIndexBuffer(buffers.IB);
        }
Example #4
0
        static void DrawInstanceComponent(MyInstanceComponent instanceComponent, List <MyHighlightDesc> highlightDescs)
        {
            MyRenderContext RC = MyRender11.RC;

            // common settings (combination of MyHighlightPass.cs and MyRenderingPass.cs):
            MyMapping mapping = MyMapping.MapDiscard(MyCommon.ProjectionConstants);
            Matrix    matrix  = MyRender11.Environment.Matrices.ViewProjectionAt0;

            matrix = Matrix.Transpose(matrix);
            mapping.WriteAndPosition(ref matrix);
            mapping.Unmap();

            RC.VertexShader.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants);
            RC.VertexShader.SetConstantBuffer(MyCommon.PROJECTION_SLOT, MyCommon.ProjectionConstants);
            RC.PixelShader.SetSamplers(0, MySamplerStateManager.StandardSamplers);
            RC.PixelShader.SetSrv(MyCommon.DITHER_8X8_SLOT, MyGeneratedTextureManager.Dithering8x8Tex);
            //RC.AllShaderStages.SetConstantBuffer(MyCommon.ALPHAMASK_VIEWS_SLOT, MyCommon.AlphamaskViewsConstants); // not used! Maybe impostors?
            RC.SetDepthStencilState(MyDepthStencilStateManager.WriteHighlightStencil, MyHighlight.HIGHLIGHT_STENCIL_MASK);
            RC.SetBlendState(null);
            RC.SetPrimitiveTopology(PrimitiveTopology.TriangleList);
            RC.SetRasterizerState(MyRasterizerStateManager.NocullRasterizerState);
            RC.SetScreenViewport();

            RC.PixelShader.SetConstantBuffer(4, MyCommon.HighlightConstants);


            MyLod lod = instanceComponent.GetHighlightLod();
            MyInstanceLodState stateId = MyInstanceLodState.Solid;
            float stateData            = 0;

            RC.SetIndexBuffer(lod.IB);
            RC.SetVertexBuffer(0, lod.VB0);

            IConstantBuffer objectCB = GetObjectCB(RC, instanceComponent, stateData);

            RC.VertexShader.SetConstantBuffer(MyCommon.OBJECT_SLOT, objectCB);
            RC.PixelShader.SetConstantBuffer(MyCommon.OBJECT_SLOT, objectCB);

            foreach (MyHighlightDesc desc in highlightDescs)
            {
                MyHighlightDesc descRef = desc;
                WriteHighlightConstants(ref descRef);

                if (string.IsNullOrEmpty(desc.SectionName))
                {
                    foreach (var part in lod.Parts)
                    {
                        DrawHighlightedPart(RC, part, stateId);
                    }
                }
                else
                {
                    if (lod.HighlightSections != null && lod.HighlightSections.ContainsKey(desc.SectionName))
                    {
                        foreach (var part in lod.HighlightSections[desc.SectionName].Parts)
                        {
                            DrawHighlightedPart(RC, part, stateId);
                        }
                    }
                }
            }
        }