Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ccmaterials): Skip transparent cc materials per default #1004

Merged
merged 3 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion blenderproc/python/loader/CCMaterialLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

def load_ccmaterials(folder_path: str = "resources/cctextures", used_assets: list = None, preload: bool = False,
fill_used_empty_materials: bool = False, add_custom_properties: dict = None,
use_all_materials: bool = False) -> List[Material]:
use_all_materials: bool = False, skip_transparent_materials: bool = True) -> List[Material]:
""" This method loads all textures obtained from https://ambientCG.com, use the script
(scripts/download_cc_textures.py) to download all the textures to your pc.

Expand All @@ -29,6 +29,7 @@ def load_ccmaterials(folder_path: str = "resources/cctextures", used_assets: lis
:param add_custom_properties: A dictionary of materials and the respective properties.
:param use_all_materials: If this is false only a selection of probably useful textures is used. This excludes \
some see through texture and non tileable texture.
:param skip_transparent_materials: If set to true, all materials with transparent portions are skipped.
:return: a list of all loaded materials, if preload is active these materials do not contain any textures yet
and have to be filled before rendering (by calling this function again, no need to save the prior
returned list)
Expand Down Expand Up @@ -87,6 +88,10 @@ def load_ccmaterials(folder_path: str = "resources/cctextures", used_assets: lis
normal_image_path = base_image_path.replace("Color", "NormalGL")
displacement_image_path = base_image_path.replace("Color", "Displacement")

# All transparent materials have an opacity image. Skip them, if desired.
if skip_transparent_materials and os.path.exists(alpha_image_path):
continue

# if the material was already created it only has to be searched
if fill_used_empty_materials:
new_mat = MaterialLoaderUtility.find_cc_material_by_name(asset, add_custom_properties)
Expand Down
2 changes: 1 addition & 1 deletion tests/testLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_cc_material_loader(self):
materials = bproc.loader.load_ccmaterials(folder_path=cc_texture_folder,
used_assets=["metal", "wood", "fabric"])

list_of_some_textures = ["Metal001", "Fabric006", "Wood039"]
list_of_some_textures = ["Metal001", "Fabric004", "Wood039"]

for material in materials:
if material.get_name() in list_of_some_textures:
Expand Down
Loading