diff options
Diffstat (limited to 'src/textures.c')
| -rw-r--r-- | src/textures.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/textures.c b/src/textures.c index 665e5447..e228b356 100644 --- a/src/textures.c +++ b/src/textures.c @@ -611,6 +611,8 @@ Image ImageCopy(Image image) newImage.height = image.height; newImage.mipmaps = image.mipmaps; newImage.format = image.format; + + //if (image.mipmaps > 1) ImageMipmaps(&newImage); } return newImage; @@ -823,6 +825,8 @@ void ImageFormat(Image *image, int newFormat) } free(pixels); + + //if (image->mipmaps > 1) ImageMipmaps(image); } else TraceLog(LOG_WARNING, "Image data format is compressed, can not be converted"); } @@ -1688,7 +1692,7 @@ Image GenImageWhiteNoise(int width, int height, float factor) } // Generate image: perlin noise -Image GenImagePerlinNoise(int width, int height, float scale) +Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale) { Color *pixels = (Color *)malloc(width*height*sizeof(Color)); @@ -1696,13 +1700,18 @@ Image GenImagePerlinNoise(int width, int height, float scale) { for (int x = 0; x < width; x++) { - float nx = (float)x*scale/(float)width; - float ny = (float)y*scale/(float)height; + float nx = (float)(x + offsetX)*scale/(float)width; + float ny = (float)(y + offsetY)*scale/(float)height; - // we need to translate the data from [-1; 1] to [0; 1] - float p = (stb_perlin_fbm_noise3(nx, ny, 1.0f, 2.0f, 0.5f, 6, 0, 0, 0) + 1.0f) / 2.0f; + // Typical values to start playing with: + // lacunarity = ~2.0 -- spacing between successive octaves (use exactly 2.0 for wrapping output) + // gain = 0.5 -- relative weighting applied to each successive octave + // octaves = 6 -- number of "octaves" of noise3() to sum + + // NOTE: We need to translate the data from [-1..1] to [0..1] + float p = (stb_perlin_fbm_noise3(nx, ny, 1.0f, 2.0f, 0.5f, 6, 0, 0, 0) + 1.0f)/2.0f; - int intensity = (int)(p * 255.0f); + int intensity = (int)(p*255.0f); pixels[y*width + x] = (Color){intensity, intensity, intensity, 255}; } } |
