Unity Perlin Noise Bug?

I was testing Perlin noise and I think I found a bug / issue with it. For some reason this code :

float a = Mathf.PerlinNoise(16+i,16+j);

Works fine, but doing this :

float a = Mathf.PerlinNoise(16+i/j,16+j/i);

Does not work, as in it does not calculate it, and trying to debug.log the value doesn’t even call the debug function. I have no idea why this is not working. I am using Unity 4 ( latest ) and it is really starting to bug me

The whole function is :

	for( int i = 0;i<16;i++){
			for( int j = 0;j<16;j++){

				float Perlin1 = Mathf.PerlinNoise(((float)i+chunkPosX)/x_,((float)j+chunkPosZ)/z_);
				float Perlin2 = Mathf.PerlinNoise(((float)j+chunkPosZ)/z_,((float)i+chunkPosX)/x_);
				int y = (int)Mathf.Round(Perlin1*20*Perlin2);
				voxels[i,(int)y,j]=new Vox(voxelDatabase[1],1);
			}
		}
	}

According to the documentation on Unity’s website, both i and j need to be floating point values from 0 to 1. Have you tried,

float a = Mathf.PerlinNoise((float)i / 16.0f, (float)j / 16.0f);

Okay, You are declaring 2 ints in C#. Dividing ints will always result in ints… ie. whole integers… if you were running this on the primary thread it would likely be giving you errors telling you it requires floats

cast one of your int’s to a float and it should resolve the issue…

The reason the same method works in unityscript is because unityscript uses ambiguous variables, that become whatever they need to be… in this case, mathf.perlin noise requests a float, so the variables become floats…

as for whether or not it’s thread safe… i see no reason it wouldn’t be… but test it, unity will generally log an error something along the lines of…

!Thread::EqualsCurrentThreadID(m_MainThreadID)

if your using something that’s strictly not safe…
it’s just a fixed equation that returns a fixed result, it uses no variables outside it’s own scope… so you should be okay…

float a = Mathf.PerlinNoise(16+i/j,16+j/i);

Divide by zero?