• Advertisement
Sign in to follow this  

Sine-based Tiled Procedural Bump

This topic is 649 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 !

Edited by fire67

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

@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 ?

Edited by lipsryme

Share this post


Link to post
Share on other sites

@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 :)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement