I might implement or develop this myself if there’s no way of doing this, but even for eevee my files are becoming too huge to load fast, it would be great to have a solid overview much like the grey one now that displays the colors of the materials, without any other specs loading.
You can set a color under ‘viewport display’ for both objects and materials, and then choose which one to use under the solid shading settings.
1 Like
Here’s a python snippet to setup the viewport color of all materials according to the main color of their shader tree. Works well only with simple materials though since it will just fetch the first instance of a shader node and derive the viewport color from it. You can copy/paste it in the text editor and run it once to override all material viewport colors.
import bpy
class ColorViewport:
def __init__(self, diffuse_color, metallic, roughness) -> None:
self.diffuse_color = diffuse_color
self.metallic = metallic
self.roughness = roughness
def update_viewport_color(material: bpy.types.Material) -> None:
color_viewport = get_main_color(material)
if color_viewport is not None:
for key, value in color_viewport.__dict__.items():
setattr(material, key, value)
def get_main_color(material: bpy.types.Material):
if not material.use_nodes:
return None
nodes = material.node_tree.nodes
for node in nodes:
if isinstance(node, bpy.types.ShaderNodeBsdfPrincipled):
return ColorViewport(
diffuse_color=node.inputs[0].default_value,
metallic=node.inputs[6].default_value,
roughness=node.inputs[9].default_value,
)
elif isinstance(node, (bpy.types.ShaderNodeBsdfDiffuse, bpy.types.ShaderNodeBsdfGlossy)):
return ColorViewport(
diffuse_color=node.inputs[0].default_value,
metallic=0,
roughness=node.inputs[1].default_value,
)
elif isinstance(node, (bpy.types.ShaderNodeEmission, bpy.types.ShaderNodeBsdfTransparent)):
return ColorViewport(
diffuse_color=node.inputs[0].default_value,
metallic=0,
roughness=0.4,
)
if __name__ == "__main__":
for mat in bpy.data.materials:
update_viewport_color(mat)
4 Likes
This one helped a lot thank you all for the support!
1 Like