Пример #1
0
        /**
         * Prepare the renderer for the rendering.
         */
        public void InitRenderer(FoliagePainter painter, FoliageDataRuntime dataToRender, List <FoliageType> foliageTypes)
        {
            m_FoliageData = dataToRender;

            foreach (FoliageType type in foliageTypes)
            {
                FoliageTypeUtilities.BuildDataRuntime(painter, type, m_Settings.m_WindTransform);
            }

            UpdateFoliageTypes(foliageTypes);
        }
Пример #2
0
        /** Called in case that we need to set the volatile data for a billboard batch material or something like that */
        public void UpdateValues()
        {
            // Update all billboard distances
            if (m_IsSpeedTreeType)
            {
                FoliageTypeSpeedTreeData speedTreeData = m_RuntimeData.m_SpeedTreeData;
                Material billboardMaterialBatch        = m_RuntimeData.m_SpeedTreeData.m_BillboardMaterial;

                if (billboardMaterialBatch != null)
                {
                    billboardMaterialBatch.SetFloat("CRITIAS_MaxFoliageTypeDistance", m_RenderInfo.m_MaxDistance);
                    billboardMaterialBatch.SetFloat("CRITIAS_MaxFoliageTypeDistanceSqr", m_RenderInfo.m_MaxDistance * m_RenderInfo.m_MaxDistance);

                    billboardMaterialBatch.SetVectorArray("_UVVert_U", speedTreeData.m_VertBillboardU);
                    billboardMaterialBatch.SetVectorArray("_UVVert_V", speedTreeData.m_VertBillboardV);

                    billboardMaterialBatch.SetVector("_UVHorz_U", speedTreeData.m_VertBillboardU[0]);
                    billboardMaterialBatch.SetVector("_UVHorz_V", speedTreeData.m_VertBillboardV[0]);

                    billboardMaterialBatch.SetColor("_HueVariation", m_RenderInfo.m_Hue);
                    billboardMaterialBatch.SetColor("_Color", m_RenderInfo.m_Color);
                }

                // Update the hue variation
                if (m_IsGrassType)
                {
                    m_RuntimeData.m_LODDataGrass.m_Material.SetColor("_HueVariation", m_RenderInfo.m_Hue);
                    m_RuntimeData.m_LODDataGrass.m_Material.SetColor("_Color", m_RenderInfo.m_Color);
                }
                else
                {
                    for (int i = 0; i < m_RuntimeData.m_LODDataTree.Length; i++)
                    {
                        for (int m = 0; m < m_RuntimeData.m_LODDataTree[i].m_Materials.Length; m++)
                        {
                            m_RuntimeData.m_LODDataTree[i].m_Materials[m].SetColor("_Color", m_RenderInfo.m_Color);
                        }
                    }
                }
            }

            // Update all LOD distances
            if (IsGrassType == false)
            {
                LODGroup grp  = m_Prefab.GetComponent <LODGroup>();
                LOD[]    lods = grp != null?grp.GetLODs() : null;

                FoliageTypeUtilities.UpdateDistancesLOD(m_RuntimeData.m_LODDataTree, lods, m_RenderInfo.m_MaxDistance, IsSpeedTreeType);
            }
        }