private MaterialPattern fromMaterial(Object value) {
        if (value instanceof Integer) {
            Integer material = (Integer) value;

            if (material > -1) {
                return new MaterialPattern(material);
            } else {
                logger.warning("Invalid material " + material + " (must be a positive material number)");
                return null;
            }

        } else if (value instanceof String) {
            String name = (String) value;

            if (materialDb == null) {
                logger.warning("Unknown material " + name + " (no material name database is in use)");
                return null;
            }

            MaterialPattern pattern = materialDb.getPattern(name);

            if (pattern == null) {
                logger.warning("Unknown material " + name + " (not recognized)");
                return null;
            }

            return pattern;
        } else {
            logger.warning("Unknown material (unknown data type)");
            return null;
        }
    }