Skip to content

Commit

Permalink
Merge branch 'main' into move_hide_to_entity
Browse files Browse the repository at this point in the history
  • Loading branch information
cornerfarmer committed Dec 12, 2023
2 parents 02b685c + 2eea80d commit 9863096
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
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
10 changes: 8 additions & 2 deletions blenderproc/python/utility/InstallUtility.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
from typing import Union, Tuple

if version_info.major == 3:
from urllib.request import urlretrieve
from urllib.request import urlretrieve, build_opener, install_opener
from urllib.error import URLError
else:
from urllib import urlretrieve
from urllib import urlretrieve, build_opener, install_opener
import contextlib

# pylint: disable=wrong-import-position
Expand Down Expand Up @@ -126,6 +126,12 @@ def make_sure_blender_is_installed(custom_blender_path: str, blender_install_pat
url = used_url + ".zip"
else:
raise RuntimeError(f"This system is not supported yet: {platform}")

# setting the default header, else the server does not allow the download
opener = build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
install_opener(opener)

try:
try:
# pylint: disable=import-outside-toplevel
Expand Down
2 changes: 1 addition & 1 deletion blenderproc/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
""" Define the current BlenderProc version. """
__version__ = '2.6.1'
__version__ = '2.6.2'
4 changes: 4 additions & 0 deletions change_log.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

# Version History

## Version 2.6.2 6th December 2023

- Fixes blender download

## Version 2.6.1 26th August 2023

- Fixes pyrender usage on windows, EGL / headless rendering is now only used on linux
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

0 comments on commit 9863096

Please sign in to comment.