/*  #region Encode & Decode
         *
         * public override CfgEncoder Encode() => this.EncodeUnrecognized()
         *    .Add_Reference("mat", material)
         *    .Add_IfNotZero("texInd", selectedTexture)
         *    .Add_IfTrue("pv", usePreviewShader)
         *    .Add_IfTrue("colToV", colorToVertexColorOnMerge)
         *    .Add("tfs", materialsTextureFields);
         *
         * public override bool Decode(string tg, string data)
         * {
         *   switch (tg)
         *    {
         *        case "mat": data.Decode_Reference(ref material); break;
         *        case "texInd":  selectedTexture = data.ToInt(); break;
         *        case "pv": usePreviewShader = data.ToBool(); break;
         *        case "tfs": data.Decode_List(out materialsTextureFields); break;
         *        case "colToV": colorToVertexColorOnMerge = data.ToBool(); break;
         *        default: return false;
         *    }
         *    return true;
         * }
         #endregion*/

        public void SetTextureOnLastTarget(TextureMeta id)
        {
            if (painterTarget)
            {
                painterTarget.SetTextureOnMaterial(bufferParameterTarget, id.CurrentTexture(), material);
            }
        }
Exemplo n.º 2
0
        public override bool SetTextureOnMaterial(ShaderProperty.TextureValue field, TextureMeta id, PlaytimePainter painter)
        {
            var tex = id.CurrentTexture();

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

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

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

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

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

            return(true);
        }
Exemplo n.º 3
0
        public override bool SetTextureOnMaterial(ShaderProperty.TextureValue field, TextureMeta id, PlaytimePainter painter)
        {
            if (!CorrectField(field, painter))
            {
                return(false);
            }

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

            var tex = id.CurrentTexture();

            PainterDataAndConfig.TerrainHeight.GlobalValue = tex;
            return(true);
        }
Exemplo n.º 4
0
        public override bool SetTextureOnMaterial(ShaderProperty.TextureValue field, TextureMeta id, PlaytimePainter painter)
        {
            var tex = id.CurrentTexture();

            if (!painter.terrain || !field.Equals(PainterDataAndConfig.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

            PainterDataAndConfig.TerrainLight.GlobalValue = tex;



            return(true);
        }
Exemplo n.º 5
0
        public override bool SetTextureOnMaterial(ShaderProperty.TextureValue field, TextureMeta id, PlaytimePainter painter)
        {
            var tex = id.CurrentTexture();

            if (!painter.terrain)
            {
                return(false);
            }
            if (!field.HasUsageTag(PainterDataAndConfig.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);
        }
Exemplo n.º 6
0
 public RenderTexture Render(TextureMeta from, RenderTexture to) => Render(from.CurrentTexture(), to, Data.brushBufferCopy);