コード例 #1
0
    public override void Process(uint seed)
    {
        int splatMap = TerrainMeta.SplatMap.res;

        Parallel.For(0, splatMap, (int z) => {
            for (int i = 0; i < splatMap; i++)
            {
                GenerateCliffSplat.Process(i, z);
            }
        });
    }
コード例 #2
0
    public override void Process(uint seed)
    {
        int splatres = TerrainMeta.SplatMap.res;

        Parallel.For(0, splatres, (Action <int>)(z =>
        {
            for (int x = 0; x < splatres; ++x)
            {
                GenerateCliffSplat.Process(x, z);
            }
        }));
    }
コード例 #3
0
    protected override void ApplySplat(Matrix4x4 localToWorld, Matrix4x4 worldToLocal)
    {
        if (this.Radius == 0f)
        {
            this.Radius = this.extents.x;
        }
        bool flag  = base.ShouldSplat(1);
        bool flag1 = base.ShouldSplat(2);
        bool flag2 = base.ShouldSplat(4);
        bool flag3 = base.ShouldSplat(8);
        bool flag4 = base.ShouldSplat(16);
        bool flag5 = base.ShouldSplat(32);
        bool flag6 = base.ShouldSplat(64);
        bool flag7 = base.ShouldSplat(128);

        if (!flag && !flag1 && !flag2 && !flag3 && !flag4 && !flag5 && !flag6 && !flag7)
        {
            return;
        }
        TextureData textureDatum  = new TextureData(this.splatmap0);
        TextureData textureDatum1 = new TextureData(this.splatmap1);
        Vector3     vector32      = localToWorld.MultiplyPoint3x4(this.offset + new Vector3(-this.Radius, 0f, -this.Radius));
        Vector3     vector33      = localToWorld.MultiplyPoint3x4(this.offset + new Vector3(this.Radius, 0f, -this.Radius));
        Vector3     vector34      = localToWorld.MultiplyPoint3x4(this.offset + new Vector3(-this.Radius, 0f, this.Radius));
        Vector3     vector35      = localToWorld.MultiplyPoint3x4(this.offset + new Vector3(this.Radius, 0f, this.Radius));

        TerrainMeta.SplatMap.ForEachParallel(vector32, vector33, vector34, vector35, (int x, int z) => {
            GenerateCliffSplat.Process(x, z);
            float single     = TerrainMeta.SplatMap.Coordinate(z);
            Vector3 vector3  = new Vector3(TerrainMeta.DenormalizeX(TerrainMeta.SplatMap.Coordinate(x)), 0f, TerrainMeta.DenormalizeZ(single));
            Vector3 vector31 = worldToLocal.MultiplyPoint3x4(vector3) - this.offset;
            float single1    = Noise.Billow(vector3.x, vector3.z, 4, 0.005f, 0.25f * this.Fade, 2f, 0.5f);
            float single2    = Mathf.InverseLerp(this.Radius, this.Radius - this.Fade + single1, vector31.Magnitude2D());
            if (single2 == 0f)
            {
                return;
            }
            Vector4 interpolatedVector = textureDatum.GetInterpolatedVector((vector31.x + this.extents.x) / this.size.x, (vector31.z + this.extents.z) / this.size.z);
            Vector4 vector4            = textureDatum1.GetInterpolatedVector((vector31.x + this.extents.x) / this.size.x, (vector31.z + this.extents.z) / this.size.z);
            if (!flag)
            {
                interpolatedVector.x = 0f;
            }
            if (!flag1)
            {
                interpolatedVector.y = 0f;
            }
            if (!flag2)
            {
                interpolatedVector.z = 0f;
            }
            if (!flag3)
            {
                interpolatedVector.w = 0f;
            }
            if (!flag4)
            {
                vector4.x = 0f;
            }
            if (!flag5)
            {
                vector4.y = 0f;
            }
            if (!flag6)
            {
                vector4.z = 0f;
            }
            if (!flag7)
            {
                vector4.w = 0f;
            }
            TerrainMeta.SplatMap.SetSplatRaw(x, z, interpolatedVector, vector4, single2);
        });
    }
コード例 #4
0
    protected override void ApplySplat(Matrix4x4 localToWorld, Matrix4x4 worldToLocal)
    {
        if ((double)this.Radius == 0.0)
        {
            this.Radius = (float)this.extents.x;
        }
        bool should0 = this.ShouldSplat(1);
        bool should1 = this.ShouldSplat(2);
        bool should2 = this.ShouldSplat(4);
        bool should3 = this.ShouldSplat(8);
        bool should4 = this.ShouldSplat(16);
        bool should5 = this.ShouldSplat(32);
        bool should6 = this.ShouldSplat(64);
        bool should7 = this.ShouldSplat(128);

        if (!should0 && !should1 && (!should2 && !should3) && (!should4 && !should5 && (!should6 && !should7)))
        {
            return;
        }
        TextureData splat0data = new TextureData(this.splatmap0);
        TextureData splat1data = new TextureData(this.splatmap1);

        TerrainMeta.SplatMap.ForEachParallel(((Matrix4x4) ref localToWorld).MultiplyPoint3x4(Vector3.op_Addition(this.offset, new Vector3(-this.Radius, 0.0f, -this.Radius))), ((Matrix4x4) ref localToWorld).MultiplyPoint3x4(Vector3.op_Addition(this.offset, new Vector3(this.Radius, 0.0f, -this.Radius))), ((Matrix4x4) ref localToWorld).MultiplyPoint3x4(Vector3.op_Addition(this.offset, new Vector3(-this.Radius, 0.0f, this.Radius))), ((Matrix4x4) ref localToWorld).MultiplyPoint3x4(Vector3.op_Addition(this.offset, new Vector3(this.Radius, 0.0f, this.Radius))), (Action <int, int>)((x, z) =>
        {
            GenerateCliffSplat.Process(x, z);
            float normZ = TerrainMeta.SplatMap.Coordinate(z);
            float normX = TerrainMeta.SplatMap.Coordinate(x);
            Vector3 vector3_1;
            ((Vector3) ref vector3_1).\u002Ector(TerrainMeta.DenormalizeX(normX), 0.0f, TerrainMeta.DenormalizeZ(normZ));
            Vector3 vector3_2 = Vector3.op_Subtraction(((Matrix4x4) ref worldToLocal).MultiplyPoint3x4(vector3_1), this.offset);
            float opacity     = Mathf.InverseLerp(this.Radius, this.Radius - this.Fade + Noise.Billow((float)vector3_1.x, (float)vector3_1.z, 4, 0.005f, 0.25f * this.Fade, 2f, 0.5f), Vector3Ex.Magnitude2D(vector3_2));
            if ((double)opacity == 0.0)
            {
                return;
            }
            Vector4 interpolatedVector1 = splat0data.GetInterpolatedVector((float)((vector3_2.x + this.extents.x) / this.size.x), (float)((vector3_2.z + this.extents.z) / this.size.z));
            Vector4 interpolatedVector2 = splat1data.GetInterpolatedVector((float)((vector3_2.x + this.extents.x) / this.size.x), (float)((vector3_2.z + this.extents.z) / this.size.z));
            if (!should0)
            {
                interpolatedVector1.x = (__Null)0.0;
            }
            if (!should1)
            {
                interpolatedVector1.y = (__Null)0.0;
            }
            if (!should2)
            {
                interpolatedVector1.z = (__Null)0.0;
            }
            if (!should3)
            {
                interpolatedVector1.w = (__Null)0.0;
            }
            if (!should4)
            {
                interpolatedVector2.x = (__Null)0.0;
            }
            if (!should5)
            {
                interpolatedVector2.y = (__Null)0.0;
            }
            if (!should6)
            {
                interpolatedVector2.z = (__Null)0.0;
            }
            if (!should7)
            {
                interpolatedVector2.w = (__Null)0.0;
            }
            TerrainMeta.SplatMap.SetSplatRaw(x, z, interpolatedVector1, interpolatedVector2, opacity);
        }));
    }
コード例 #5
0
    protected override void ApplySplat(Matrix4x4 localToWorld, Matrix4x4 worldToLocal)
    {
        if (Radius == 0f)
        {
            Radius = extents.x;
        }
        bool should0 = ShouldSplat(1);
        bool should1 = ShouldSplat(2);
        bool should2 = ShouldSplat(4);
        bool should3 = ShouldSplat(8);
        bool should4 = ShouldSplat(16);
        bool should5 = ShouldSplat(32);
        bool should6 = ShouldSplat(64);
        bool should7 = ShouldSplat(128);

        if (!should0 && !should1 && !should2 && !should3 && !should4 && !should5 && !should6 && !should7)
        {
            return;
        }
        TextureData splat0data = new TextureData(splatmap0.Get());
        TextureData splat1data = new TextureData(splatmap1.Get());
        Vector3     v          = localToWorld.MultiplyPoint3x4(offset + new Vector3(0f - Radius, 0f, 0f - Radius));
        Vector3     v2         = localToWorld.MultiplyPoint3x4(offset + new Vector3(Radius, 0f, 0f - Radius));
        Vector3     v3         = localToWorld.MultiplyPoint3x4(offset + new Vector3(0f - Radius, 0f, Radius));
        Vector3     v4         = localToWorld.MultiplyPoint3x4(offset + new Vector3(Radius, 0f, Radius));

        TerrainMeta.SplatMap.ForEachParallel(v, v2, v3, v4, delegate(int x, int z)
        {
            GenerateCliffSplat.Process(x, z);
            float normZ   = TerrainMeta.SplatMap.Coordinate(z);
            float normX   = TerrainMeta.SplatMap.Coordinate(x);
            Vector3 point = new Vector3(TerrainMeta.DenormalizeX(normX), 0f, TerrainMeta.DenormalizeZ(normZ));
            Vector3 v5    = worldToLocal.MultiplyPoint3x4(point) - offset;
            float num     = Mathf.InverseLerp(Radius, Radius - Fade, v5.Magnitude2D());
            if (num != 0f)
            {
                Vector4 interpolatedVector  = splat0data.GetInterpolatedVector((v5.x + extents.x) / size.x, (v5.z + extents.z) / size.z);
                Vector4 interpolatedVector2 = splat1data.GetInterpolatedVector((v5.x + extents.x) / size.x, (v5.z + extents.z) / size.z);
                if (!should0)
                {
                    interpolatedVector.x = 0f;
                }
                if (!should1)
                {
                    interpolatedVector.y = 0f;
                }
                if (!should2)
                {
                    interpolatedVector.z = 0f;
                }
                if (!should3)
                {
                    interpolatedVector.w = 0f;
                }
                if (!should4)
                {
                    interpolatedVector2.x = 0f;
                }
                if (!should5)
                {
                    interpolatedVector2.y = 0f;
                }
                if (!should6)
                {
                    interpolatedVector2.z = 0f;
                }
                if (!should7)
                {
                    interpolatedVector2.w = 0f;
                }
                TerrainMeta.SplatMap.SetSplatRaw(x, z, interpolatedVector, interpolatedVector2, num);
            }
        });
    }