Procedural Textures with Hash Functions
a year ago
- #hash-function
- #mathematical-patterns
- #game-development
- The author explores a simple hash function that maps (x, y) coordinates to colors, revealing complex and beautiful patterns.
- The hash function is defined as (c_x * x + c_y * y + c_xy * x * y + c_x^2 * x^2 + c_y^2 * y^2) mod m < τ * m.
- The function was initially developed for a game with a strict 2-bit color palette, requiring textures aligned perfectly to screen pixels.
- Different components of the hash function (like x^2 or x*y) produce varied patterns, such as repeating quadratic shapes or reciprocal curves.
- The author shares favorite patterns generated by tweaking coefficients and encourages readers to experiment with the provided hash playground.
- Potential applications include game textures or phone case designs, with examples shown from the author's game-jam project.