Skip to content

Instantly share code, notes, and snippets.

@qpfiffer
Created July 27, 2011 05:18
Show Gist options
  • Select an option

  • Save qpfiffer/1108730 to your computer and use it in GitHub Desktop.

Select an option

Save qpfiffer/1108730 to your computer and use it in GitHub Desktop.
Streaky Concrete
public static void modConcrete(ref Texture2D modify, GraphicsDevice gDevice, Random tRandom)
{
if (modify == null)
throw new Exception("Null texture.");
//float colorFloat = (float)(tRandom.Next(25, 75)) / 255.0f;
//Color bgColor = new Color(colorFloat, colorFloat, colorFloat, 1.0f);
Color setColor;
simplexCarmody simC = new simplexCarmody(tRandom);
double noise = 0f;
Color[] texData = new Color[(modify.Width * modify.Height)];
for (int y = 0; y < modify.Height; y++)
{
//noise = (simC.noise(y * 2, y * 8, 5) + 1) * 5;
noise += (simC.noise(y * 2, y * 3, 5) + 1) * 0.25f;
noise = (noise - (int)noise) * 1f;
// Octave 3: Streak
//noise += simC.noise(x, y * 100, 5) * 0.7f;
for (int x = 0; x < modify.Width; x++)
{
double tempNoise = noise;
// Octave 2: Fine noise
tempNoise += simC.noise(x * 200, y * 200, 5) * 0.5f;
// Adjust range to [0, 1]
tempNoise = (tempNoise + 1) / 2;
int red = (int)(tempNoise * 55);
int green = (int)(tempNoise * 55);
int blue = (int)(tempNoise * 55);
if (red > 255) red = 255;
else if (red < 0) red = 0;
if (green > 255) green = 255;
else if (green < 0) green = 0;
if (blue > 255) blue = 255;
else if (blue < 0) blue = 0;
setColor = new Color(red, green, blue);
texData[y * modify.Width + x] = setColor;
}
}
modify.SetData<Color>(texData);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment