コード例 #1
0
        /// <summary>
        /// Updates procedural textures.
        /// Array of float values for the texture is included as well as reference to the (this) object that the texture should be sent to.
        /// Public becasue PlanetManagerEditor needs to access this method to force updating of procedural textures.
        /// </summary>
        /// <param name="_textureName">Name of texture to be rebuilt (or "All")</param>
        public override void UpdateProceduralTexture(string _textureName)
        {
            if ((int)PlanetManager.DebugLevel > 1)
            {
                Debug.Log("GasPlanet.cs: UpdateProceduralTexture(" + _textureName + ")");
            }

            if (PlanetManager.TextureDetailMode == PlanetManager.TextureDetailModes.Progressive ||
                PlanetManager.TextureDetailMode == PlanetManager.TextureDetailModes.Progressive_Separate)
            {
                if (textureProgressiveStep == -1)
                {
                    SetDefaultProgressiveTextureLOD();
                }
            }

            if (_textureName == "All" || _textureName == "Maps")
            {
                _proceduralMaterialMaps = PlanetManager.Instance.GetUniqueProceduralMaterial(_dictionaryMaterials["gas"].GetPropertyMaterial(), gameObject, "gas");
                SetProceduralMaterialFloats("Maps", _proceduralMaterialMaps);
                _proceduralMaterialMaps.SetInputVector2Int("$outputsize", _lodGas + 4, _lodGas + 4);
                _proceduralMaterialMaps.RenderSync();
                _textureMaps          = _proceduralMaterialMaps.GetGeneratedTextures().ToList().Where(texture => texture.name.Contains("any")).FirstOrDefault();
                _textureCapNormal     = _proceduralMaterialMaps.GetGeneratedTextures().ToList().Where(texture => texture.name.Contains("CapNormal")).FirstOrDefault();
                _textureBodyNormal    = _proceduralMaterialMaps.GetGeneratedTextures().ToList().Where(texture => texture.name.Contains("BodyNormal")).FirstOrDefault();
                _texturePaletteLookup = _proceduralMaterialMaps.GetGeneratedTextures().ToList().Where(texture => texture.name.Contains("Palette_Diffuse")).FirstOrDefault();
                _material.SetTexture("_BodyTexture", _textureMaps);
                _material.SetTexture("_CapTexture", _textureMaps);
                _material.SetTexture("_BodyNormal", _textureBodyNormal);
                _material.SetTexture("_CapNormal", _textureCapNormal);
                _material.SetTexture("_PaletteLookup", _texturePaletteLookup);
            }

            // Start timer when rebuild of textures started
            _timerStartBuildingTextures = Time.realtimeSinceStartup;
        }
コード例 #2
0
    // Start is called before the first frame update
    void Start()
    {
        m_listSubstTextures = m_SubsGraphGO.GetGeneratedTextures();
        int i = 0;

        foreach (var tex in m_listSubstTextures)
        {
            string thisTex = tex.name.Substring(tex.name.LastIndexOf('-') + 2);
            Debug.Log("ThisTex CUT " + thisTex);
            Debug.Log("TEX " + tex.name);
            switch (thisTex)
            {
            case "baseColor":
                Debug.Log("Assigning BaseColor");
                objMat.SetTexture("_BaseMap", tex);
                break;

            case "normal":
                Debug.Log("Assigning normal");
                objMat.SetTexture("_BumpMap", tex);
                break;

            case "metallic":
                Debug.Log("Assigning metallic");
                objMat.SetTexture("_MetallicGlossMap", tex);
                break;

            case "ambientOcclusion":
                Debug.Log("Assigning AO");
                objMat.SetTexture("_OcclusionMap", tex);
                break;

            default:
                break;
            }
        }
    }