Auburn / FastNoiseLite

Fast Portable Noise Library - C# C++ C Java HLSL GLSL JavaScript Rust Go

Home Page:http://auburn.github.io/FastNoiseLite/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

result of FNL_NOISE_CELLULAR in HLSL is not match the same in CPP

rfvtgbzxc opened this issue · comments

I used follwing parameters:
cpp:

FastNoiseLite noise;
noise.SetNoiseType(FastNoiseLite::NoiseType_Cellular);
noise.SetFrequency(0.02f);
PictureB aBmp(128, 128);
// Gather noise data
for (int y = 0; y < 128; y++)
{
	for (int x = 0; x < 128; x++)
	{
		aBmp.SetPixel(x,y,noise.GetNoise((float)x, (float)y)*255,0,0);
	}
}

HLSL:

fnl_state voronoiNoise = fnlCreateState();
voronoiNoise.noise_type = FNL_NOISE_CELLULAR;
voronoiNoise.frequency = 0.02f;
float sampledPixel = fnlGetNoise2D(voronoiNoise, tc.x * 100, tc.y *100);
return float4(sampledPixel, 0, 0, 1);

The texture coord is form 0 to 1, go through it. I mul it with 100 to match the size as the cpp one.

The result of cpp is as expectation, a noise like reflection on water suface. However in HLSL, there are only a little highlights scattering on the surface, other most field of the surface is black, which indicates the value after sampling is 0. The default noiseType, FNL_NOISE_OPENSIMPLEX2 in HLSL is running good. I tried to change the other parameters , simulating the setting in Readme.md of the homepage, but get the same result.

I use Directx11. The version of HLSL is 5.0 .