encode and decode visibility buffer