public override bool SetTextureOnMaterial(ShaderProperty.TextureValue field, TextureMeta id)
        {
            var tex = id.CurrentTexture();

            if (!painter.terrain)
            {
                return(false);
            }

            if (!field.HasUsageTag(PainterShaderVariables.TERRAIN_CONTROL_TEXTURE))
            {
                return(false);
            }

            var no = field.NameForDisplayPEGI()[0].CharToInt();

            if (no == 0)
            {
                PainterShaderVariables.TerrainControlMain.GlobalValue = tex;
            }

            painter.terrain.terrainData.alphamapTextures[no] = id.texture2D;

            return(true);
        }
        public override bool SetTextureOnMaterial(ShaderProperty.TextureValue field, TextureMeta id)
        {
            if (!CorrectField(field, painter))
            {
                return(false);
            }

            if (id != null && id.texture2D)
            {
                painter.terrainHeightTexture = id.texture2D;
            }

            var tex = id.CurrentTexture();

            PainterShaderVariables.TerrainHeight.GlobalValue = tex;
            return(true);
        }
        public override bool SetTextureOnMaterial(ShaderProperty.TextureValue field, TextureMeta id)
        {
            var tex = id.CurrentTexture();

            if (!painter.terrain)
            {
                return(false);
            }
            if (!field.HasUsageTag(PainterShaderVariables.TERRAIN_SPLAT_DIFFUSE))
            {
                return(false);
            }
            var no = field.NameForDisplayPEGI()[0].CharToInt();

            painter.terrain.SetSplashPrototypeTexture(id.texture2D, no);
            if (tex.GetType() != typeof(Texture2D))
            {
                Debug.Log("Can only use Texture2D for Splat Prototypes. If using regular terrain may not see changes.");
            }
            else
            {
#if UNITY_EDITOR
                var texImporter = ((Texture2D)tex).GetTextureImporter();
                if (texImporter == null)
                {
                    return(true);
                }
                var needReimport = texImporter.WasClamped();
                needReimport |= texImporter.HadNoMipmaps();

                if (needReimport)
                {
                    texImporter.SaveAndReimport();
                }
#endif
            }
            return(true);
        }
示例#4
0
        public override bool SetTextureOnMaterial(ShaderProperty.TextureValue field, TextureMeta id)
        {
            var tex = id.CurrentTexture();

            if (!painter.terrain || !field.Equals(PainterShaderVariables.TerrainLight))
            {
                return(false);
            }

            FindMergingTerrain(painter);
            if (mergingTerrain && id != null)
            {
                mergingTerrain.lightTexture = id.texture2D;
            }

#if UNITY_EDITOR
            var t2D = tex as Texture2D;

            if (t2D)
            {
                var importer = (t2D).GetTextureImporter();
                if (importer != null)
                {
                    var needReimport = importer.WasClamped();
                    needReimport |= importer.HadNoMipmaps();

                    if (needReimport)
                    {
                        importer.SaveAndReimport();
                    }
                }
            }
#endif

            PainterShaderVariables.TerrainLight.GlobalValue = tex;

            return(true);
        }