Sine-based Tiled Procedural Bump

Started by
3 comments, last by fire67 7 years, 11 months ago

Hey everyone,

I am trying to implement this formula to generate bump but I am facing some issue. The result doesn't look the same it's much darker.

kUWt5.png

Here is my result (without same parameters) but it is much darker and I don't get why.

9GUF2.png

And here is the associated code.


// randx, randy and frequencies are array with some random values for each sin wave.
for (int x = 0; x < _width; ++x)
{
	for (int y = 0; y < _height; ++y)
	{
		float color = 0.0f;
		for (int i = 0; i < _iterations; ++i)
		{
			val += Mathf.Sin(Mathf.Sqrt(Mathf.Pow(x - randx[i], 2.0f) + Mathf.Pow(y - randy[i], 2.0f)) * 1.0f / (2.08f + 5.0f * frequencies[i]));
		}
		color /= (float)_iterations;
	}
}

Any idea why I am getting this result ?

Thanks a lot !

Advertisement

Your image contains negative values and when you visualize it naively they appear black. Bias it to between 0-1 and the results should be similar.

@fire67 do you think it's possible to share the code or at least show how you define the random values as I'm also not having an easy time with this ?

@fire67 do you think it's possible to share the code or at least show how you define the random values as I'm also not having an easy time with this ?

You could just supply them via a small constant buffer :)

.:vinterberg:.

@lipsryme, nothing really special about the random value. Just a random value generated between a range I can define in the editor. :)

This topic is closed to new replies.

Advertisement