예제 #1
0
def loadDisneyEXR_multi_ref_shading(path, FEATURE_LIST):
    # time0 = time.time()

    prefix = path.split(".")[0]

    color_path = prefix + "_color.exr"
    diffuse_path = prefix + "_diffuse.exr"
    specular_path = prefix + "_specular.exr"
    texture_path = prefix + "_texture.exr"

    if "diffuse" in FEATURE_LIST:
        try:
            inFile = exr_utils.open(diffuse_path)
            diffuse = inFile.get_all()["default"]
            diffuse = _crop(diffuse, (1, 1), 128)
        except Exception:
            diffuse = np.zeros((128, 128, 3))
    if "specular" in FEATURE_LIST:
        try:
            inFile = exr_utils.open(specular_path)
            specular = inFile.get_all()["default"]
            specular = _crop(specular, (1, 1), 128)
        except Exception:
            specular = np.zeros((128, 128, 3))

    try:
        inFile = exr_utils.open(texture_path)
        texture = inFile.get_all()["default"]
        texture = _crop(texture, (1, 1), 128)
    except Exception:
        texture = np.zeros((128, 128, 3))

    if "diffuse" in FEATURE_LIST:
        diffuse[diffuse < 0.0] = 0.0
        diffuse = diffuse / (texture + 0.00316)
        diffuse = LogTransform(diffuse)
        color = diffuse
    if "specular" in FEATURE_LIST:
        specular[specular < 0.0] = 0.0
        specular = LogTransform(specular)
        color = specular
    return color
예제 #2
0
def loadDisneyEXR_feature_shading(path, FEATURE_LIST):
    # time0 = time.time()

    prefix = path.split(".")[0]

    # color_path = prefix + "_color.exr"
    variance_path = prefix + "_variance.exr"
    normal_path = prefix + "_normal.exr"
    depth_path = prefix + "_depth.exr"
    texture_path = prefix + "_texture.exr"
    visibility_path = prefix + "_visibility.exr"
    diffuse_path = prefix + "_diffuse.exr"
    specular_path = prefix + "_specular.exr"

    # inFile = exr_utils.open(variance_path)
    # variance = inFile.get_all()["default"]
    if "normal" in FEATURE_LIST:
        try:
            inFile = exr_utils.open(normal_path)
            normal = inFile.get_all()["default"]
            normal = _crop(normal, (1, 1), 128)
        except Exception:
            normal = np.zeros((128, 128, 3))

    if "depth" in FEATURE_LIST:
        try:
            inFile = exr_utils.open(depth_path)
            depth = inFile.get_all()["default"]
            depth = _crop(depth, (1, 1), 128)
        except Exception:
            depth = np.zeros((128, 128, 1))

    # if "albedo" in FEATURE_LIST:		//always load in albedo
    try:
        inFile = exr_utils.open(texture_path)
        texture = inFile.get_all()["default"]
        texture = _crop(texture, (1, 1), 128)
    except Exception:
        texture = np.zeros((128, 128, 3))

    if "visibility" in FEATURE_LIST:
        try:
            inFile = exr_utils.open(visibility_path)
            visibility = inFile.get_all()["default"]
            visibility = _crop(visibility, (1, 1), 128)
        except Exception:
            visibility = np.zeros((128, 128, 1))

    if "diffuse" in FEATURE_LIST:
        try:
            inFile = exr_utils.open(diffuse_path)
            diffuse = inFile.get_all()["default"]
            diffuse = _crop(diffuse, (1, 1), 128)
        except Exception:
            diffuse = np.zeros((128, 128, 3))

    if "specular" in FEATURE_LIST:
        try:
            inFile = exr_utils.open(specular_path)
            specular = inFile.get_all()["default"]
            specular = _crop(specular, (1, 1), 128)
        except Exception:
            specular = np.zeros((128, 128, 3))

    # variance = CalcRelVar( (1+ color.copy()) , variance, False, False, True )

    if "diffuse" in FEATURE_LIST:
        diffuse[diffuse < 0.0] = 0.0
        diffuse = diffuse / (texture + 0.00316)
        diffuse = LogTransform(diffuse)
        color = diffuse
    if "specular" in FEATURE_LIST:
        specular[specular < 0.0] = 0.0
        specular = LogTransform(specular)
        color = specular

    feature_tuple = ()
    if "normal" in FEATURE_LIST:
        normal = np.nan_to_num(normal)
        if "specular" in FEATURE_LIST:
            normal = (normal + 1.0) * 0.5
            normal = np.maximum(np.minimum(normal, 1.0), 0.0)
        feature_tuple += (normal, )
    if "depth" in FEATURE_LIST:
        # Normalize current frame depth to [0,1]
        maxDepth = np.max(depth)
        if maxDepth != 0:
            depth /= maxDepth
        feature_tuple += (depth, )
    if "albedo" in FEATURE_LIST:
        # texture = np.clip(texture,0.0,1.0)
        feature_tuple += (texture, )
    if "visibility" in FEATURE_LIST:
        feature_tuple += (visibility, )

    if len(feature_tuple) == 0:
        return color, np.zeros(color.shape)
    feautres = np.concatenate(feature_tuple, axis=2)  #

    return color, feautres
예제 #3
0
def loadDisneyEXR_ref(path):
    inFile = exr_utils.open(path)
    data = inFile.get_all()["default"]
    data = LogTransform(data)
    return data
예제 #4
0
def load_feature_mat_complete_tungsten_joint(path, FEATURE_LIST):

    prefix = os.path.splitext(path)[0]

    color_path = prefix + "_color.exr"
    variance_path = prefix + "_variance.exr"
    normal_path = prefix + "_normal.exr"
    depth_path = prefix + "_depth.exr"
    texture_path = prefix + "_albedo.exr"
    # visibility_path = prefix + "_visibility.exr"

    diffuse_path = prefix + "_diffuse.exr"
    specular_path = prefix + "_specular.exr"
    try:
        # inFile = exr_utils.open(color_path)
        # color = inFile.get_all()["default"]
        inFile = exr_utils.open(normal_path)
        normal = inFile.get_all()["default"]
        inFile = exr_utils.open(depth_path)
        depth = inFile.get_all()["default"]
        inFile = exr_utils.open(texture_path)
        texture = inFile.get_all()["default"]

        # inFile = exr_utils.open(visibility_path)
        # visibility = inFile.get_all()["default"]

        inFile = exr_utils.open(diffuse_path)
        diffuse = inFile.get_all()["default"]
        inFile = exr_utils.open(specular_path)
        specular = inFile.get_all()["default"]

    except Exception:
        print("Exception!!!!!" + prefix)
        return None, None, None, None

    # variance = CalcRelVar( (1+ color.copy()) , variance, False, False, True )
    # color[color < 0.0] = 0.0
    # color = LogTransform(color)
    diffuse[diffuse < 0.0] = 0.0
    diffuse = diffuse / (texture + 0.00316)
    diffuse = LogTransform(diffuse)
    specular[specular < 0.0] = 0.0
    specular = LogTransform(specular)
    normal = np.nan_to_num(normal)
    if "specular" in FEATURE_LIST:
        normal = (normal + 1.0) * 0.5
        normal = np.maximum(np.minimum(normal, 1.0), 0.0)
    # Normalize current frame depth to [0,1]
    maxDepth = np.max(depth)
    if maxDepth != 0:
        depth /= maxDepth

    #feature shut off
    # normal.fill(0.0)
    # # visibility.fill(0.0)
    # depth.fill(0.0)
    # texture.fill(0.0)

    # texture = np.clip(texture,0.0,1.0)

    # feautres = np.concatenate((variance,  normal, depth, texture, visibility), axis=2)
    feautres = np.concatenate((normal, depth, texture), axis=2)

    return diffuse, diffuse, specular, feautres
예제 #5
0
def load_reference_mat(path_ref, scene_name, path_feature=None):
    color_path = os.path.join(path_ref, scene_name)
    inFile = exr_utils.open(color_path)
    color = inFile.get_all()["default"]
    color = np.log(color + 1)
    return color