From 4d10cb46d9152ed7892772e04ae2d7e3f4c2d3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vil=C3=A9m=20Duha?= Date: Sat, 4 Jan 2020 14:11:49 +0100 Subject: BlenderKit: update several material attributes This will enable to search for procedural assets and filter heavy assets for EEVEE --- blenderkit/__init__.py | 9 +++++++++ blenderkit/asset_inspector.py | 32 +++++++++++++++++++++----------- blenderkit/upload.py | 3 +++ 3 files changed, 33 insertions(+), 11 deletions(-) (limited to 'blenderkit') diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py index 1eccfa4d..db8d1bf4 100644 --- a/blenderkit/__init__.py +++ b/blenderkit/__init__.py @@ -489,6 +489,14 @@ class BlenderKitCommonUploadProps(object): default="PUBLIC", ) + is_procedural: BoolProperty(name="Procedural", + description="Asset is procedural - has no texture.", + default=True + ) + node_count: IntProperty(name="Node count", description="Total nodes in the asset", default=0) + texture_count: IntProperty(name="Node count", description="Total nodes in the asset", default=0) + total_megapixels: IntProperty(name="Node count", description="Total nodes in the asset", default=0) + # is_private: BoolProperty(name="Asset is Private", # description="If not marked private, your asset will go into the validation process automatically\n" # "Private assets are limited by quota.", @@ -621,6 +629,7 @@ class BlenderKitMaterialUploadProps(PropertyGroup, BlenderKitCommonUploadProps): description="shaders used in asset, autofilled", default="", ) + is_free: BoolProperty(name="Free for Everyone", description="You consent you want to release this asset as free for everyone", default=True, update=update_free diff --git a/blenderkit/asset_inspector.py b/blenderkit/asset_inspector.py index 73e6c09a..e5d1d5cf 100644 --- a/blenderkit/asset_inspector.py +++ b/blenderkit/asset_inspector.py @@ -33,31 +33,41 @@ RENDER_OBTYPES = ['MESH', 'CURVE', 'SURFACE', 'METABALL', 'TEXT'] def check_material(props, mat): e = bpy.context.scene.render.engine shaders = [] + textures = [] + props.texture_count = 0 + props.node_count = 0 + props.total_megapixels = 0 + props.is_procedural = True + if e == 'CYCLES': if mat.node_tree is not None: checknodes = mat.node_tree.nodes[:] while len(checknodes) > 0: n = checknodes.pop() + props.node_count += 1 if n.type == 'GROUP': # dive deeper here. checknodes.extend(n.node_tree.nodes) if len(n.outputs) == 1 and n.outputs[0].type == 'SHADER' and n.type != 'GROUP': if n.type not in shaders: shaders.append(n.type) if n.type == 'TEX_IMAGE': - mattype = 'image based' - if n.image is not None: - - maxres = max(n.image.size[0], n.image.size[1]) - - props.texture_resolution_max = max(props.texture_resolution_max, maxres) - minres = min(n.image.size[0], n.image.size[1]) + if n.image is not None: + mattype = 'image based' + props.is_procedural = False + if n.image not in textures: + textures.append(n.image) + props.texture_count += 1 + props.total_megapixels += (n.image.size[0] * n.image.size[1]) - if props.texture_resolution_min == 0: - props.texture_resolution_min = minres - else: - props.texture_resolution_min = min(props.texture_resolution_min, minres) + maxres = max(n.image.size[0], n.image.size[1]) + props.texture_resolution_max = max(props.texture_resolution_max, maxres) + minres = min(n.image.size[0], n.image.size[1]) + if props.texture_resolution_min == 0: + props.texture_resolution_min = minres + else: + props.texture_resolution_min = min(props.texture_resolution_min, minres) props.shaders = '' for s in shaders: diff --git a/blenderkit/upload.py b/blenderkit/upload.py index 001c6211..4b02d321 100644 --- a/blenderkit/upload.py +++ b/blenderkit/upload.py @@ -377,6 +377,9 @@ def get_upload_data(self, context, asset_type): "animated": props.animated, "purePbr": props.pbr, "textureSizeMeters": props.texture_size_meters, + "procedural": props.is_procedural, + "nodeCount": props.node_count, + "textureCount": props.texture_count, } -- cgit v1.2.3