Esempio n. 1
0
    private void OnDrawGizmos()
    {
        if (!debug || terrainFaces == null)
        {
            return;
        }
        foreach (TerrainFace tf in terrainFaces)
        {
            foreach (Chunk chunk in tf.GetVisibleChunks())
            {
                Gizmos.color = Color.Lerp(Color.red, Color.green, (float)chunk.detailLevel / (lods.Length - 1));
                float elevation = noiseGenerator.GetNoise3D(chunk.position.normalized);
                Gizmos.DrawSphere(chunk.position.normalized * (1 + elevation) * radius, Mathf.Lerp((lods.Length - 1) / 2, 0.5f, (float)chunk.detailLevel / (lods.Length - 1)));

                Gizmos.color = Color.red;
                chunk.GetNeighbourLOD();
                foreach (byte b in chunk.neighbours)
                {
                    if (b == 1)
                    {
                        Gizmos.DrawWireCube(chunk.position.normalized * (1 + elevation) * radius, Vector3.one * Mathf.Lerp((lods.Length - 1) / 2, 0.5f, (float)chunk.detailLevel / (lods.Length - 1)));
                    }
                }
            }
        }
    }
Esempio n. 2
0
    private void OnDrawGizmos()
    {
        if (!debug)
        {
            return;
        }
        if (!enabled)
        {
            return;
        }

        Gizmos.color = Color.green;
        PBSNoiseGenerator NoiseGenerator = planet.noiseGenerator;

        foreach (Vector3 point in scorerPoints)
        {
            float elevation = NoiseGenerator.GetNoise3D(point);
            elevation = Mathf.Clamp(elevation, 0, 1);
            if (float.IsNaN(elevation))
            {
                elevation = 0;
            }
            Gizmos.DrawWireSphere(point * (1 + elevation) * planet.radius, 1.0f);
        }
    }
Esempio n. 3
0
    public override float GetNoise3D(Vector3 vector)
    {
        if (inputModule == null)
        {
            return(0.0f);
        }

        return((inputModule.GetNoise3D(vector) * scale) + bias);
    }
Esempio n. 4
0
    public override float GetNoise3D(Vector3 vector)
    {
        float elevation = noiseGenerator.GetNoise3D(vector);

        if (float.IsInfinity(elevation) || float.IsNaN(elevation))
        {
            elevation = 1f;
        }
        return(Mathf.Clamp(elevation, 0, 1.0f));
    }
    public override float GetNoise3D(Vector3 vector)
    {
        if (inputModule == null || warpModule == null)
        {
            return(0.0f);
        }

        Vector3 q = new Vector3(warpModule.GetNoise3D(vector), warpModule.GetNoise3D(vector + new Vector3(Iteration1XOffset, Iteration1YOffset, Iteration1ZOffset)), warpModule.GetNoise3D(vector + new Vector3(Iteration1XOffset + 0.5f, Iteration1YOffset + 0.5f, Iteration1ZOffset + 2.4f)));

        if (WarpIterations == WarpIterationsType.One)
        {
            return(inputModule.GetNoise3D(vector + new Vector3((Multiplier * q.x), (Multiplier * q.y), (Multiplier * q.z))));
        }

        Vector3 r = new Vector3(warpModule.GetNoise3D(vector + new Vector3((Multiplier * q).x + Iteration2XOffset1, (Multiplier * q).y + Iteration2YOffset1, (Multiplier * q).z + Iteration2ZOffset1)),
                                warpModule.GetNoise3D(vector + new Vector3((Multiplier * q).x + Iteration2XOffset2, (Multiplier * q).y + Iteration2YOffset2, (Multiplier * q).z + Iteration2ZOffset2)),
                                warpModule.GetNoise3D(vector + new Vector3((Multiplier * q).x + 3.4f + Iteration2XOffset2, (Multiplier * q).y + Iteration2YOffset2 + 4.6f, (Multiplier * q).z + Iteration2ZOffset2 + 2.3f)));

        return(inputModule.GetNoise3D(vector + new Vector3(Multiplier * r.x, Multiplier * r.y, Multiplier * r.z)));
    }
    public override float GetNoise3D(Vector3 vector)
    {
        if (inputModule1 == null || inputModule2 == null)
        {
            return(0.0f);
        }

        float modifier = 1.0f;

        if (maskModule != null)
        {
            float mask = maskModule.GetNoise3D(vector);
            if (mask >= threshold)
            {
                modifier = mask;
            }
            else
            {
                return(inputModule1.GetNoise3D(vector));
            }
        }

        return(modifier * (inputModule1.GetNoise3D(vector) + inputModule2.GetNoise3D(vector)));
    }
Esempio n. 7
0
    public override float GetNoise3D(Vector3 vector)
    {
        if (inputModule1 == null && inputModule2 == null && selectModule == null)
        {
            return(0.0f);
        }

        float control = selectModule.GetNoise3D(vector);

        if (interpolationType != SelectInterpType.None)
        {
            // outside lower falloff bound
            if (control <= (threshold - falloff))
            {
                return(inputModule2.GetNoise3D(vector));
            }
            // outside upper falloff bound
            else if (control >= (threshold + falloff))
            {
                return(inputModule1.GetNoise3D(vector));
            }
            // otherwise must be inside the threshold bounds, so smooth it
            else
            {
                switch (interpolationType)
                {
                case SelectInterpType.CircularIn:
                    return(Interpolation.InterpCircularIn(inputModule2.GetNoise3D(vector), inputModule1.GetNoise3D(vector), (control - (threshold - falloff) / (2.0f * falloff))));

                case SelectInterpType.CircularInOut:
                    return(Interpolation.InterpCircularInOut(inputModule2.GetNoise3D(vector), inputModule1.GetNoise3D(vector), (control - (threshold - falloff) / (2.0f * falloff))));

                case SelectInterpType.CircularOut:
                    return(Interpolation.InterpCircularOut(inputModule2.GetNoise3D(vector), inputModule1.GetNoise3D(vector), (control - (threshold - falloff) / (2.0f * falloff))));

                case SelectInterpType.ExponentialIn:
                    return(Interpolation.InterpExpoIn(inputModule2.GetNoise3D(vector), inputModule1.GetNoise3D(vector), (control - (threshold - falloff) / (2.0f * falloff))));

                case SelectInterpType.ExponentialInOut:
                    return(Interpolation.InterpExpoInOut(inputModule2.GetNoise3D(vector), inputModule1.GetNoise3D(vector), (control - (threshold - falloff) / (2.0f * falloff))));

                case SelectInterpType.ExponentialOut:
                    return(Interpolation.InterpExpoOut(inputModule2.GetNoise3D(vector), inputModule1.GetNoise3D(vector), (control - (threshold - falloff) / (2.0f * falloff))));

                case SelectInterpType.SineIn:
                    return(Interpolation.InterpSinIn(inputModule2.GetNoise3D(vector), inputModule1.GetNoise3D(vector), (control - (threshold - falloff) / (2.0f * falloff))));

                case SelectInterpType.SineInOut:
                    return(Interpolation.InterpSinInOut(inputModule2.GetNoise3D(vector), inputModule1.GetNoise3D(vector), (control - (threshold - falloff) / (2.0f * falloff))));

                case SelectInterpType.SineOut:
                    return(Interpolation.InterpSinOut(inputModule2.GetNoise3D(vector), inputModule1.GetNoise3D(vector), (control - (threshold - falloff) / (2.0f * falloff))));

                case SelectInterpType.Step:
                    return(Interpolation.InterpStep(inputModule2.GetNoise3D(vector), inputModule1.GetNoise3D(vector), (control - (threshold - falloff) / (2.0f * falloff)), numSteps));

                case SelectInterpType.Linear:
                    return(Mathf.Lerp(inputModule2.GetNoise3D(vector), inputModule1.GetNoise3D(vector), (control - (threshold - falloff) / (2.0f * falloff))));
                }
            }
        }

        // If there's no interpolation, easy mode
        if (control > threshold)
        {
            return(inputModule1.GetNoise3D(vector));
        }
        else
        {
            return(inputModule2.GetNoise3D(vector));
        }
    }