Use bitfieldExtract and distance in shaders.