Exemplo n.º 1
0
        public void GetHighlightLod(int i, out MyLod lod, out MyInstanceLodState stateId, out float stateData)
        {
            int lodNum;

            m_lodStrategy.GetLod(MyPassIdResolver.DefaultGBufferPassId, i, out lodNum, out stateId, out stateData);
            lod = Models.HighlightModel.GetLod(lodNum);
        }
Exemplo n.º 2
0
        public void GetLod(int passId, int i, out MyLod lod, out MyInstanceLodState stateId, out float stateData)
        {
            int lodNum;

            m_lodStrategy.GetLod(passId, i, out lodNum, out stateId, out stateData);
            if (passId == 0)
            {
                lod = Models.StandardModel.GetLod(lodNum);
            }
            else
            {
                lod = Models.DepthModel.GetLod(lodNum);
            }
        }
Exemplo n.º 3
0
        void IDrawableGroupStrategy.Fill(int bufferOffset, MyInstanceComponent instance, MyLod lod, int multiTransformI, int instanceMaterialOffsetInData, MyInstanceLodState state, float stateData)
        {
            MyVbConstantElement element = new MyVbConstantElement
            {
                //WorldMatrixRow0 = new Vector4(matrix.M11, matrix.M12, matrix.M13, matrix.M14),
                //WorldMatrixRow1 = new Vector4(matrix.M21, matrix.M22, matrix.M23, matrix.M24),
                //WorldMatrixRow2 = new Vector4(matrix.M31, matrix.M32, matrix.M33, matrix.M34),
            };

            //Much faster approach than naive:
            instance.GetMatrixCols(multiTransformI,
                                   out element.WorldMatrixRow0,
                                   out element.WorldMatrixRow1,
                                   out element.WorldMatrixRow2);

            m_vbData[bufferOffset] = element;

            m_validElements++;
        }
Exemplo n.º 4
0
        void IDrawableGroupStrategy.Fill(int bufferOffset, MyInstanceComponent instance, MyLod lod, int multiTransformI, int instanceMaterialOffsetInData, MyInstanceLodState state, float stateData)
        {
            HalfVector4 packedColorMultEmissivity = MyInstanceMaterial.Default.PackedColorMultEmissivity;

            if (instanceMaterialOffsetInData != -1) // if instance material is defined
            {
                MyInstanceMaterial instanceMaterial = instance.GetInstanceMaterial(instanceMaterialOffsetInData);
                packedColorMultEmissivity = instanceMaterial.PackedColorMultEmissivity;
            }
            else
            {
                packedColorMultEmissivity = instance.GlobalColorMultEmissivity;
            }

            HalfVector4 packedKeyColorDithering = instance.KeyColor.ToHalfVector4();
            HalfVector4 dithering = new HalfVector4();

            dithering.PackedValue = (ulong)HalfUtils.Pack(stateData);
            packedKeyColorDithering.PackedValue = packedKeyColorDithering.PackedValue | dithering.PackedValue << 48;

            MyVbConstantElement element = new MyVbConstantElement
            {
                //WorldMatrixRow0 = new Vector4(matrix.M11, matrix.M12, matrix.M13, matrix.M14),
                //WorldMatrixRow1 = new Vector4(matrix.M21, matrix.M22, matrix.M23, matrix.M24),
                //WorldMatrixRow2 = new Vector4(matrix.M31, matrix.M32, matrix.M33, matrix.M34),
                KeyColorDithering   = packedKeyColorDithering,
                ColorMultEmissivity = packedColorMultEmissivity,
            };

            // much faster approach than naive:
            instance.GetMatrixCols(multiTransformI,
                                   out element.WorldMatrixRow0,
                                   out element.WorldMatrixRow1,
                                   out element.WorldMatrixRow2);

            m_vbData[bufferOffset] = element;

            m_validElements++;
        }
Exemplo n.º 5
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);
                        }
                    }
                }
            }
        }