How do youse use a float2 to generate cellular noise?

I’m using the Unity.Mathematics package for noise samples. I’m trying to generate biomes using cellular noise. Originally I’ve been doing something like:

        foreach (Biome m_biome in WorldGeneration.Instance.biomes)
        {
            if (biomeNoise > m_biome.minNoiseValue && biomeNoise <= m_biome.maxNoiseValue)
            {
                biome = m_biome;
            }
        }

where I generate a biome based on a certain float value returned by a noise function. However, when trying to use cellular noise, a float2 gets returned, and I have no idea what to do with it. There aren’t too many examples using the Mathematics package, so I’m a bitt confused on what I should do here.

@5argon wrote a great blog mentioning this and showing examples:

You can pick which component you want to use.

Yes, I want to use cellular noise, but even this article doesn’t really explain what to do with the float2 value.

It shows the result of using x (F1) and y (F2). It’s your pick which one looks like the kind of noise that you want to use.

1 Like

oh, so something like

foreach (Biome m_biome in WorldGeneration.Instance.biomes)
        {
            if (biomeNoise.x > m_biome.minNoiseValue && biomeNoise.x <= m_biome.maxNoiseValue)
            {
                biome = m_biome;
            }
        }

where biomeNoise is the float2 value?

1 Like

Pretty much! You can also extract the x component and make the local variable just a float and stuff like that to keep things simple.

1 Like

Thanks for the help :slight_smile:

1 Like