Esempio n. 1
0
        public bool CreateGBuffer(MyMwmData mwmData, int lodNum, ref HashSet <string> setMaterialNames)
        {
            UniqueId = MyManagers.IDGenerator.GBufferLods.Generate();
            LodNum   = lodNum;

            IB  = MyManagers.ModelBuffers.GetOrCreateIB(mwmData);
            VB0 = MyManagers.ModelBuffers.GetOrCreateVB0(mwmData);
            VB1 = MyManagers.ModelBuffers.GetOrCreateVB1(mwmData);
            VertexInputComponents = MyManagers.ModelBuffers.CreateStandardVertexInputComponents(mwmData);
            m_instanceMaterialsStrategy.Init();

            BoundingBox = mwmData.BoundindBox;

            HighlightSections = null;
            Parts             = new List <MyPart>();
            GlassParts        = null;

            int offset = 0;

            foreach (var mwmPartInfo in mwmData.PartInfos)
            {
                // Making of parts is connected to the creating index buffer. It will worth to do it much more connected in future
                int    indicesCount = mwmPartInfo.m_indices.Count;
                string materialName = mwmPartInfo.GetMaterialName();
                if (mwmPartInfo.Technique != MyMeshDrawTechnique.GLASS)
                {
                    MyMeshDrawTechnique technique        = mwmPartInfo.Technique;
                    string             cmFilepath        = MyMwmUtils.GetColorMetalTexture(mwmPartInfo, mwmData.MwmContentPath);
                    string             ngFilepath        = MyMwmUtils.GetNormalGlossTexture(mwmPartInfo, mwmData.MwmContentPath);
                    string             extFilepath       = MyMwmUtils.GetExtensionTexture(mwmPartInfo, mwmData.MwmContentPath);
                    string             alphamaskFilepath = MyMwmUtils.GetAlphamaskTexture(mwmPartInfo, mwmData.MwmContentPath);
                    MyStandardMaterial material          = MyManagers.Materials.GetOrCreateStandardMaterial(materialName, technique, cmFilepath, ngFilepath, extFilepath, alphamaskFilepath);

                    MyPart part = new MyPart();
                    part.InitForGBuffer(this, materialName, mwmData.MwmContentPath, mwmPartInfo, material, offset, indicesCount, 0);
                    Parts.Add(part);
                }
                else
                {
                    MyGlassMaterial glassMaterial = MyManagers.Materials.GetGlassMaterial(materialName);

                    MyPart part = new MyPart();
                    part.InitForGlass(this, mwmPartInfo.GetMaterialName(), glassMaterial, mwmPartInfo.Technique, offset, indicesCount, 0);
                    if (GlassParts == null)
                    {
                        GlassParts = new List <MyPart>();
                    }
                    GlassParts.Add(part); // glass parts are rendered by different pipeline than the regular "solid" geometry
                }
                offset += indicesCount;

                setMaterialNames.Add(materialName);
            }

            return(true);
        }
Esempio n. 2
0
        public MyGlassMaterial GetGlassMaterial(string materialName)
        {
            MyRenderProxy.Assert(!string.IsNullOrEmpty(materialName));

            if (!m_glassMaterials.ContainsKey(materialName))
            {
                MyTransparentMaterial oldTransparentMaterial = MyTransparentMaterials.GetMaterial(materialName);
                string  textureFilepath = oldTransparentMaterial.Texture;
                Vector4 color           = oldTransparentMaterial.Color;
                float   reflectivity    = oldTransparentMaterial.Reflectivity;

                MyGlassMaterial glassMaterial = new MyGlassMaterial(materialName, textureFilepath, color, reflectivity);
                m_glassMaterials.Add(materialName, glassMaterial);
            }
            return(m_glassMaterials[materialName]);
        }
Esempio n. 3
0
        public void InitForGlass(MyLod parent, string name, MyGlassMaterial glassMaterial, MyMeshDrawTechnique technique, int startIndex, int indicesCount, int startVertex)
        {
            m_shaderBundles = new MyShaderBundle[(int)4];  // the support for glass is enabled only for 2 techniques
            m_shaderBundles[(int)MyInstanceLodState.Solid] = MyManagers.ShaderBundles.GetShaderBundle(MyRenderPassType.Glass,
                                                                                                      technique,
                                                                                                      MyInstanceLodState.Solid,
                                                                                                      false,
                                                                                                      false,
                                                                                                      false);

            m_shaderBundles[(int)MyInstanceLodState.Transition] = MyManagers.ShaderBundles.GetShaderBundle(MyRenderPassType.Glass,
                                                                                                           technique,
                                                                                                           MyInstanceLodState.Transition,
                                                                                                           false,
                                                                                                           false,
                                                                                                           false);
            m_shaderBundles[(int)MyInstanceLodState.Hologram] = MyManagers.ShaderBundles.GetShaderBundle(MyRenderPassType.Glass,
                                                                                                         Technique,
                                                                                                         MyInstanceLodState.Hologram,
                                                                                                         false,
                                                                                                         false,
                                                                                                         false);
            m_shaderBundles[(int)MyInstanceLodState.Dithered] = MyManagers.ShaderBundles.GetShaderBundle(MyRenderPassType.Glass,
                                                                                                         Technique,
                                                                                                         MyInstanceLodState.Dithered,
                                                                                                         false,
                                                                                                         false,
                                                                                                         false);
            Parent                      = parent;
            Name                        = name;
            Technique                   = technique;
            StandardMaterial            = null;
            GlassMaterial               = glassMaterial;
            InstanceMaterialOffsetInLod = -1; // <- not used so far
            StartIndex                  = startIndex;
            IndicesCount                = indicesCount;
            StartVertex                 = startVertex;
        }