[Bf-extensions-cvs] [30129110] master: Update/bug removal of the 'Utility panel' - part 1: the functions in the section 'Change atom shape' got updated for eevee and cycles. There are also a few adjustments of the values of both importers (PDB and XYZ).

Clemens Barth noreply at git.blender.org
Sun Jan 16 22:08:14 CET 2022


Commit: 3012911034aa279bafe10f3a547896bbf2777aca
Author: Clemens Barth
Date:   Sun Jan 16 22:01:17 2022 +0100
Branches: master
https://developer.blender.org/rBA3012911034aa279bafe10f3a547896bbf2777aca

Update/bug removal of the 'Utility panel' - part 1: the functions in the
section 'Change atom shape' got updated for eevee and cycles.
There are also a few adjustments of the values of both importers
(PDB and XYZ).

===================================================================

M	io_mesh_atomic/pdb_import.py
M	io_mesh_atomic/utility_panel.py
M	io_mesh_atomic/xyz_import.py

===================================================================

diff --git a/io_mesh_atomic/pdb_import.py b/io_mesh_atomic/pdb_import.py
index d340d82b..13a5b19f 100644
--- a/io_mesh_atomic/pdb_import.py
+++ b/io_mesh_atomic/pdb_import.py
@@ -637,7 +637,7 @@ def camera_light_source(use_camera,
         # We now determine the emission strength of the lamp. Note that the
         # intensity depends on 1/r^2. For this we use a value of 100000.0 at a
         # distance of 58. This value was determined manually inside Blender.
-        lamp_data.energy = 100000.0 * ( (length * length) / (58.0 * 58.0) )
+        lamp_data.energy = 500000.0 * ( (length * length) / (58.0 * 58.0) )
         lamp = bpy.data.objects.new("A_lamp_eevee", lamp_data)
         lamp.location = lamp_xyz_vec
         bpy.context.collection.objects.link(lamp)
diff --git a/io_mesh_atomic/utility_panel.py b/io_mesh_atomic/utility_panel.py
index 1b5ea235..9aba4e42 100644
--- a/io_mesh_atomic/utility_panel.py
+++ b/io_mesh_atomic/utility_panel.py
@@ -355,26 +355,30 @@ def modify_objects(action_type,
 
         bpy.context.view_layer.objects.active = None
 
-    # Replace atom objects
+    # Change the  atom objects
     if action_type == "ATOM_REPLACE_OBJ" and "STICK" not in atom.name.upper():
 
         scn = bpy.context.scene.atom_blend
 
-        new_material = draw_obj_material(scn.replace_objs_material,
-                                         atom.active_material)
+        material = atom.active_material
+        new_material = draw_obj_material(scn.replace_objs_material, material)
 
         # Special object (like halo, etc.)
         if scn.replace_objs_special != '0':
-            new_atom = draw_obj_special(scn.replace_objs_special, atom)
+            atom = draw_obj_special(scn.replace_objs_special, atom)
         # Standard geometrical objects
         else:
             # If the atom shape shall not be changed, then:
             if scn.replace_objs == '0':
                 atom.active_material = new_material
-                #return {'FINISHED'}
             # If the atom shape shall change, then:
             else:
-                new_atom = draw_obj(scn.replace_objs, atom, new_material)
+                atom = draw_obj(scn.replace_objs, atom, new_material)
+
+        # If the atom is the representative ball of a dupliverts structure,
+        # then make it invisible.
+        if atom.parent != None:
+            atom.hide_set(True)
 
     # Default shapes and colors for atoms
     if action_type == "ATOM_DEFAULT_OBJ" and "STICK" not in atom.name.upper():
@@ -444,7 +448,6 @@ def separate_atoms(scn):
         # Do not hide the object!
         obj_dupli.hide_set(False)
 
-
     bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
     bpy.context.view_layer.objects.active = mesh
 
@@ -452,51 +455,80 @@ def separate_atoms(scn):
 # Prepare a new material
 def draw_obj_material(material_type, material):
 
+    mat_P_BSDF_default = material.node_tree.nodes['Principled BSDF']
+    default_color = mat_P_BSDF_default.inputs['Base Color'].default_value
+
     if material_type == '0': # Unchanged
         material_new = material
     if material_type == '1': # Normal
+        # We create again the 'normal' material. Why? It's because the old
+        # one could have been deleted by the user during the course of the
+        # user's work in Blender ... .
         material_new = bpy.data.materials.new(material.name + "_normal")
+        material_new.use_nodes = True
+        mat_P_BSDF = material_new.node_tree.nodes['Principled BSDF']
+        mat_P_BSDF.inputs['Base Color'].default_value = default_color
+        mat_P_BSDF.inputs['Metallic'].default_value = 0.0
+        mat_P_BSDF.inputs['Specular'].default_value = 0.5
+        mat_P_BSDF.inputs['Roughness'].default_value = 0.5
+        mat_P_BSDF.inputs['Clearcoat Roughness'].default_value = 0.03
+        mat_P_BSDF.inputs['IOR'].default_value = 1.45
+        mat_P_BSDF.inputs['Transmission'].default_value = 0.0
+        mat_P_BSDF.inputs['Transmission Roughness'].default_value = 0.0
+        mat_P_BSDF.inputs['Alpha'].default_value = 1.0
+        # Some additional stuff for eevee.
+        material_new.blend_method = 'OPAQUE'
+        material_new.shadow_method = 'OPAQUE'
     if material_type == '2': # Transparent
         material_new = bpy.data.materials.new(material.name + "_transparent")
-        material_new.metallic = 0.8
-        material_new.specular_intensity = 0.5
-        material_new.roughness = 0.3
-        material_new.blend_method = 'OPAQUE'
-        material_new.show_transparent_back = False
-        # Some properties for cycles
         material_new.use_nodes = True
         mat_P_BSDF = material_new.node_tree.nodes['Principled BSDF']
-        mat_P_BSDF.inputs['Metallic'].default_value = 0.1
+        mat_P_BSDF.inputs['Base Color'].default_value = default_color
+        mat_P_BSDF.inputs['Metallic'].default_value = 0.0
+        mat_P_BSDF.inputs['Specular'].default_value = 0.15
         mat_P_BSDF.inputs['Roughness'].default_value = 0.2
-        mat_P_BSDF.inputs['Transmission'].default_value = 0.9
-        mat_P_BSDF.inputs['IOR'].default_value = 0.8
+        mat_P_BSDF.inputs['Clearcoat Roughness'].default_value = 0.37
+        mat_P_BSDF.inputs['IOR'].default_value = 1.45
+        mat_P_BSDF.inputs['Transmission'].default_value = 0.8
+        mat_P_BSDF.inputs['Transmission Roughness'].default_value = 0.0
+        mat_P_BSDF.inputs['Alpha'].default_value = 0.4
+        # Some additional stuff for eevee.
+        material_new.blend_method = 'HASHED'
+        material_new.shadow_method = 'HASHED'
+        material_new.use_backface_culling = False
     if material_type == '3': # Reflecting
         material_new = bpy.data.materials.new(material.name + "_reflecting")
-        material_new.metallic = 0.5
-        material_new.specular_intensity = 0.5
-        material_new.roughness = 0.0
-        material_new.blend_method = 'OPAQUE'
-        # Some properties for cycles
         material_new.use_nodes = True
         mat_P_BSDF = material_new.node_tree.nodes['Principled BSDF']
-        mat_P_BSDF.inputs['Metallic'].default_value = 0.95
+        mat_P_BSDF.inputs['Base Color'].default_value = default_color
+        mat_P_BSDF.inputs['Metallic'].default_value = 0.7
+        mat_P_BSDF.inputs['Specular'].default_value = 0.15
         mat_P_BSDF.inputs['Roughness'].default_value = 0.1
+        mat_P_BSDF.inputs['Clearcoat Roughness'].default_value = 0.5
+        mat_P_BSDF.inputs['IOR'].default_value = 0.8
         mat_P_BSDF.inputs['Transmission'].default_value = 0.0
-        mat_P_BSDF.inputs['IOR'].default_value = 1.0
+        mat_P_BSDF.inputs['Transmission Roughness'].default_value = 0.0
+        mat_P_BSDF.inputs['Alpha'].default_value = 1.0
+        # Some additional stuff for eevee.
+        material_new.blend_method = 'OPAQUE'
+        material_new.shadow_method = 'OPAQUE'
     if material_type == '4': # Transparent + reflecting
         material_new = bpy.data.materials.new(material.name + "_trans+refl")
-        material_new.metallic = 0.3
-        material_new.specular_intensity = 0.5
-        material_new.roughness = 0.3
-        material_new.blend_method = 'OPAQUE'
-        material_new.show_transparent_back = False
-        # Some properties for cycles
         material_new.use_nodes = True
         mat_P_BSDF = material_new.node_tree.nodes['Principled BSDF']
+        mat_P_BSDF.inputs['Base Color'].default_value = default_color
         mat_P_BSDF.inputs['Metallic'].default_value = 0.5
-        mat_P_BSDF.inputs['Roughness'].default_value = 0.2
-        mat_P_BSDF.inputs['Transmission'].default_value = 0.5
-        mat_P_BSDF.inputs['IOR'].default_value = 0.8
+        mat_P_BSDF.inputs['Specular'].default_value = 0.15
+        mat_P_BSDF.inputs['Roughness'].default_value = 0.05
+        mat_P_BSDF.inputs['Clearcoat Roughness'].default_value = 0.37
+        mat_P_BSDF.inputs['IOR'].default_value = 1.45
+        mat_P_BSDF.inputs['Transmission'].default_value = 0.6
+        mat_P_BSDF.inputs['Transmission Roughness'].default_value = 0.0
+        mat_P_BSDF.inputs['Alpha'].default_value = 0.6
+        # Some additional stuff for eevee.
+        material_new.blend_method = 'HASHED'
+        material_new.shadow_method = 'HASHED'
+        material_new.use_backface_culling = False
 
     # Always, when the material is changed, a new name is created. Note that
     # this makes sense: Imagine, an other object uses the same material as the
diff --git a/io_mesh_atomic/xyz_import.py b/io_mesh_atomic/xyz_import.py
index d50cacff..04da0a4b 100644
--- a/io_mesh_atomic/xyz_import.py
+++ b/io_mesh_atomic/xyz_import.py
@@ -440,7 +440,7 @@ def camera_light_source(use_camera,
         # We now determine the emission strength of the lamp. Note that the
         # intensity depends on 1/r^2. For this we use a value of 100000.0 at a
         # distance of 58. This value was determined manually inside Blender.
-        lamp_data.energy = 100000.0 * ( (length * length) / (58.0 * 58.0) )
+        lamp_data.energy = 500000.0 * ( (length * length) / (58.0 * 58.0) )
         lamp = bpy.data.objects.new("A_lamp_eevee", lamp_data)
         lamp.location = lamp_xyz_vec
         bpy.context.collection.objects.link(lamp)



More information about the Bf-extensions-cvs mailing list