Extracting util methods for generating textures on the fly.