/// <summary>Bind blend states for alpha blending</summary>
        public static void BindMaterialTextureBlendStates(MyRenderContext rc, MyFileTextureEnum textures)
        {
            textures &= ~MyFileTextureEnum.ALPHAMASK;
            switch (textures)
            {
            case MyFileTextureEnum.COLOR_METAL:
                rc.SetBlendState(MyBlendStateManager.BlendDecalNormal);
                break;

            case MyFileTextureEnum.NORMALMAP_GLOSS:
                rc.SetBlendState(MyBlendStateManager.BlendDecalColor);
                break;

            case MyFileTextureEnum.COLOR_METAL | MyFileTextureEnum.NORMALMAP_GLOSS:
                rc.SetBlendState(MyBlendStateManager.BlendDecalNormalColor);
                break;

            case MyFileTextureEnum.COLOR_METAL | MyFileTextureEnum.NORMALMAP_GLOSS | MyFileTextureEnum.EXTENSIONS:
                rc.SetBlendState(MyBlendStateManager.BlendDecalNormalColorExt);
                break;

            default:
                throw new Exception("Unknown texture bundle type");
            }
        }
Example #2
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);
                        }
                    }
                }
            }
        }
Example #3
0
 /// <summary>Bind blend states for alpha blending</summary>
 public static void BindMaterialTextureBlendStates(MyRenderContext rc, MyFileTextureEnum textures)
 {
     textures &= ~MyFileTextureEnum.ALPHAMASK;
     switch (textures)
     {
         case MyFileTextureEnum.COLOR_METAL:
             rc.SetBlendState(MyBlendStateManager.BlendDecalNormal);
             break;
         case MyFileTextureEnum.NORMALMAP_GLOSS:
             rc.SetBlendState(MyBlendStateManager.BlendDecalColor);
             break;
         case MyFileTextureEnum.COLOR_METAL | MyFileTextureEnum.NORMALMAP_GLOSS:
             rc.SetBlendState(MyBlendStateManager.BlendDecalNormalColor);
             break;
         case MyFileTextureEnum.COLOR_METAL | MyFileTextureEnum.NORMALMAP_GLOSS | MyFileTextureEnum.EXTENSIONS:
             rc.SetBlendState(MyBlendStateManager.BlendDecalNormalColorExt);
             break;
         default:
             throw new Exception("Unknown texture bundle type");
     }
 }