示例#1
0
        private bool GenerateAreas()
        {
#if UNITY_EDITOR
            SgtHelper.MakeTextureReadable(texture);
            SgtHelper.MakeTextureTruecolor(texture);
#endif
            if (texture != null && splats != null)
            {
                splatCount = splats.Count;
                size       = new int2(texture.width, texture.height);

                SgtHelper.UpdateNativeArray(ref weights, size.x * size.y * splatCount);

                tempColors.Clear();

                foreach (var splat in splats)
                {
                    tempColors.Add(splat.Color);
                }

                var data = texture.GetRawTextureData <byte>();
                var offS = SgtHelper.GetStride(texture.format);
                var offR = SgtHelper.GetOffset(texture.format, 0);
                var offG = SgtHelper.GetOffset(texture.format, 1);
                var offB = SgtHelper.GetOffset(texture.format, 2);

                for (var y = 0; y < size.y; y++)
                {
                    for (var x = 0; x < size.x; x++)
                    {
                        var index = x + y * size.x;
                        var r     = data[index * offS + offR];
                        var g     = data[index * offS + offG];
                        var b     = data[index * offS + offB];

                        for (var s = 0; s < splatCount; s++)
                        {
                            weights[index * splatCount + s] = GetDistance(tempColors[s], r, g, b);
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
示例#2
0
        protected override int BeginQuads()
        {
            SgtHelper.BeginRandomSeed(Seed);

            sourceTex2D = SourceTex as Texture2D;

            if (sourceTex2D != null && Samples > 0)
            {
#if UNITY_EDITOR
                SgtHelper.MakeTextureReadable(sourceTex2D);
                SgtHelper.MakeTextureTruecolor(sourceTex2D);
#endif
                halfSize = Size * 0.5f;

                return(StarCount);
            }

            return(0);
        }
示例#3
0
        protected override int BeginQuads()
        {
            SgtHelper.BeginRandomSeed(seed);

            if (starColors == null)
            {
                starColors = SgtHelper.CreateGradient(Color.white);
            }

            sourceTex2D = sourceTex as Texture2D;

            if (sourceTex2D != null && samples > 0)
            {
#if UNITY_EDITOR
                SgtHelper.MakeTextureReadable(sourceTex2D);
                SgtHelper.MakeTextureTruecolor(sourceTex2D);
#endif
                halfSize = size * 0.5f;

                return(starCount);
            }

            return(0);
        }