예제 #1
0
        public void Generate(RenderTexture targetRt)
        {
            GFoliageDistributionMapGeneratorParams param = GTextureToolParams.Instance.TreeDistribution;

            GCommon.FillTexture(targetRt, Color.clear);

            List <Vector2> pos = new List <Vector2>();

            if (param.Terrain != null &&
                param.Terrain.TerrainData != null &&
                param.Terrain.TerrainData.Foliage.Trees != null &&
                param.Terrain.TerrainData.Foliage.Trees.Prototypes.Count != 0)
            {
                GetTreePosition(param, pos);
                Draw(targetRt, param, pos);
            }
            if (param.Terrain != null &&
                param.Terrain.TerrainData != null &&
                param.Terrain.TerrainData.Foliage.Grasses != null &&
                param.Terrain.TerrainData.Foliage.Grasses.Prototypes.Count != 0)
            {
                GGrassPatch[] patches = param.Terrain.TerrainData.Foliage.GrassPatches;
                for (int i = 0; i < patches.Length; ++i)
                {
                    GetGrassPosition(param, patches[i], pos);
                    Draw(targetRt, param, pos);
                }
            }
        }
예제 #2
0
        public void Generate(RenderTexture targetRt)
        {
            GBlendMapGeneratorParams param = GTextureToolParams.Instance.Blend;

            RenderTexture bg = new RenderTexture(targetRt);

            GCommon.CopyToRT(targetRt, bg);

            GCommon.FillTexture(targetRt, Color.black);
            for (int i = 0; i < param.Layers.Count; ++i)
            {
                GBlendLayer l = param.Layers[i];
                Mat.SetTexture("_Background", bg);
                Mat.SetTexture("_Foreground", l.Texture);
                Mat.SetFloat("_Number", l.Number);
                Mat.SetVector("_Vector", l.Vector);
                Mat.SetInt("_Ops", (int)l.BlendOps);
                Mat.SetFloat("_LerpFactor", l.LerpFactor);
                Mat.SetTexture("_LerpMask", l.LerpMask);
                Mat.SetInt("_Saturate", l.Saturate ? 1 : 0);

                GCommon.DrawQuad(targetRt, GCommon.FullRectUvPoints, Mat, (int)l.DataSource);
                GCommon.CopyToRT(targetRt, bg);
            }

            bg.Release();
            GUtilities.DestroyObject(bg);
        }
        public void Generate(RenderTexture targetRt)
        {
            GHeightMapFromMeshGeneratorParams param = GTextureToolParams.Instance.HeightMapFromMesh;

            if (param.SrcMesh == null)
            {
                GCommon.FillTexture(targetRt, Color.black);
            }
            else
            {
                try
                {
                    SetUp(param, targetRt);
                    Render(param, targetRt);
                }
                catch (System.Exception e)
                {
                    Debug.Log(e);
                }
                finally
                {
                    CleanUp();
                }
            }
        }
예제 #4
0
        public void Generate(RenderTexture targetRt)
        {
            GNormalMapGeneratorParams param = GTextureToolParams.Instance.NormalMap;
            Color defaultColor = param.Space == GNormalMapSpace.Local ? new Color(0.5f, 1, 0.5f, 1) : new Color(0.5f, 0.5f, 1, 1);

            if (param.Terrain == null || param.Terrain.TerrainData == null)
            {
                GCommon.FillTexture(targetRt, defaultColor);
            }
            else
            {
                if (param.Mode == GNormalMapMode.Sharp)
                {
                    RenderSharpNormalMap(param, targetRt);
                }
                else if (param.Mode == GNormalMapMode.Interpolated)
                {
                    RenderInterpolatedNormalMap(param, targetRt);
                }
                else if (param.Mode == GNormalMapMode.PerPixel)
                {
                    RenderPerPixelNormalMap(param, targetRt);
                }
                else
                {
                    GCommon.FillTexture(targetRt, defaultColor);
                }
            }
        }
예제 #5
0
        public void Generate(RenderTexture targetRt)
        {
            GColorMapGeneratorParams param = GTextureToolParams.Instance.ColorMap;

            if (param.Terrain == null || param.Terrain.TerrainData == null)
            {
                GCommon.FillTexture(targetRt, Color.black);
            }
            else
            {
                RenderColorMap(param.Terrain, targetRt);
            }
        }
        public void Generate(RenderTexture targetRt)
        {
            GSteepnessMapGeneratorParams param = GTextureToolParams.Instance.Steepness;

            if (param.Terrain == null || param.Terrain.TerrainData == null)
            {
                GCommon.FillTexture(targetRt, Color.clear);
            }
            else
            {
                GNormalMapGeneratorParams normalMapParam = new GNormalMapGeneratorParams();
                normalMapParam.Terrain = param.Terrain;
                normalMapParam.Space   = GNormalMapSpace.Local;
                normalMapParam.Mode    = param.Mode;

                RenderTexture       normalMap = new RenderTexture(targetRt);
                GNormalMapGenerator gen       = new GNormalMapGenerator();
                if (param.Mode == GNormalMapMode.Sharp)
                {
                    gen.RenderSharpNormalMap(normalMapParam, normalMap);
                }
                else if (param.Mode == GNormalMapMode.Interpolated)
                {
                    gen.RenderInterpolatedNormalMap(normalMapParam, normalMap);
                }
                else if (param.Mode == GNormalMapMode.PerPixel)
                {
                    gen.RenderPerPixelNormalMap(normalMapParam, normalMap);
                }

                Mat.SetTexture("_BumpMap", normalMap);
                GCommon.DrawQuad(targetRt, GCommon.FullRectUvPoints, Mat, 0);

                normalMap.Release();
                GUtilities.DestroyObject(normalMap);
            }
        }