BlenderKit: update several material attributes
This will enable to search for procedural assets and filter heavy assets for EEVEE
This commit is contained in:
parent
37085aeb2f
commit
4d10cb46d9
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
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])
|
||||
|
||||
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)
|
||||
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:
|
||||
|
|
|
@ -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,
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue