# Sine-based Tiled Procedural Bump

## 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.

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

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 on other sites

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

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628382
• Total Posts
2982367

• 10
• 9
• 15
• 24
• 11