Procedural Textures with Hash Functions
I'm the sort of person who gets very excited when simple rules create complex behaviour. The other day, I needed a simple hash function that maps ( 𝑥 , 𝑦 ) coordinates to a colour, and found a straightforward equation that ended up being astoundingly rich. Hence this post; to talk about and play with this function. TL;DR: The boolean predicate ( 𝑐 𝑥 𝑥 + 𝑐 𝑦 𝑦 + 𝑐 𝑥 𝑦 𝑥 𝑦 + 𝑐 𝑥 2 𝑥 2 + 𝑐 𝑦 2 𝑦 2 ) mod 𝑚 < 𝜏 𝑚 , is richly varied and beautiful. For example, varying 𝑐 𝑥 𝑦 with the other parameters fixed: For the rest of this post, we'll try to unpick the function. If you'd prefer to play with it yourself, check out the hash playground. I was trying to make a game that obeyed a 2-bit colour palette. With a strict interpretation of the rules, this means no interpolation or antialiasing — the pixels onscreen should only be one of 4 colours. So I needed textures that could align perfectly to the screen. The not-at-all novel solution: Hash the (x, y) screen-space
Procedural textures with hash functions Procedural textures with hash functions and Hash Playground I'm the sort of person who gets very excited when simple rules create complex behaviour. The other day, I needed a simple hash function that maps $(x, y)$ coordinates to a colour, and found a straightforward equation that ended up being astoundingly rich. Hence this post; to talk about and play with this function. TL;DR: The boolean predicate $(c_x \, x + c_y \, y + c_{xy} \, x \, y + c_{x^2} \, x^2 + c_{y^2} \, y^2)$ $\mathrm{mod} \, m < \tau \, m$, is richly varied and beautiful. For example,
Explore this link on the map →saved by
related reading
- Paper Shaders – Ultra-fast zero-dependency shadersshaders.paper.design
- The Book of Shaders: Fractal Brownian Motionthebookofshaders.com
- Poline — Esoteric Color Palette Generation Librarymeodai.github.io
- Shadersshaders.com
- Hash function - Wikipediaen.wikipedia.org
- GitHub - josephmiclaus/p5.grain: Conveniently add film grain, seamless texture overlays, and manipulate pixels to achieve nostalgic and artistic effects in p5.js sketches and artworks. · GitHubgithub.com
- ZK-Friendly Hash Functions | Zellic — Researchzellic.io
- JAPANESE GRADIENTS [FOR UI]™japanesegradientsforui.com
- Gradientor - A minimalist, beautiful Radial Background Generatorgradientor.app
- Khroma - The AI color tool for designerskhroma.co
- Khroma - The AI color tool for designerskhroma.co
- Image to Mesh Gradientphotogradient.com