[Bf-extensions-cvs] [7d11bb35] master: The addon gets updated for Eevee/Cycles - part 4: a point light source for Eevee is re-inserted (I forgot that this is needed for Eeve) and the transparency material properties of the vacancies when using Eevee have been changed: the cubes show now a nice transparency.

Clemens Barth noreply at git.blender.org
Sun Jan 16 10:33:17 CET 2022


Commit: 7d11bb351e580b738068c398f71d29d60244070a
Author: Clemens Barth
Date:   Sun Jan 16 10:29:13 2022 +0100
Branches: master
https://developer.blender.org/rBA7d11bb351e580b738068c398f71d29d60244070a

The addon gets updated for Eevee/Cycles - part 4: a point light source for
Eevee is re-inserted (I forgot that this is needed for Eeve) and the transparency
material properties of the vacancies when using Eevee have been changed: the
cubes show now a nice transparency.

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

M	io_mesh_atomic/pdb_import.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 4c2f92c7..ab1c63d0 100644
--- a/io_mesh_atomic/pdb_import.py
+++ b/io_mesh_atomic/pdb_import.py
@@ -628,18 +628,32 @@ def camera_light_source(use_camera,
         object_lamp_vec = Vector((lamp_dl,lamp_dy_right,lamp_dl))
         lamp_xyz_vec = object_center_vec + object_lamp_vec
 
+        # Eevee
+        # =====
+
+        # As a lamp we use a point source.
+        lamp_data = bpy.data.lights.new(name="A_lamp_eevee", type="POINT")
+        lamp_data.energy = 100000.0 # Watts
+        lamp = bpy.data.objects.new("A_lamp_eevee", lamp_data)
+        lamp.location = lamp_xyz_vec
+        bpy.context.collection.objects.link(lamp)
+
+        # Cycles
+        # ======
+
         # As a lamp we use a ball.
         bpy.ops.mesh.primitive_uv_sphere_add(
                         segments=64,
                         ring_count=64,
                         align='WORLD',
                         enter_editmode=False,
-                        location=lamp_xyz_vec,
+                        # We move the lamp below the point source from above.
+                        location=lamp_xyz_vec + Vector((0.0, 0.0, 1.5)),
                         rotation=(0, 0, 0))
         lamp = bpy.context.view_layer.objects.active
         # We put an 'A_' just that the lamp appears first in the outliner
         # tree
-        lamp.name = "A_lamp"
+        lamp.name = "A_lamp_cycles"
 
         # 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 5000.0 at a
@@ -1383,13 +1397,7 @@ def import_pdb(Ball_type,
                 # However, before we check if it is a vacancy.
                 # The vacancy is represented by a transparent cube.
                 if atom.name == "Vacancy":
-                    # Some properties for eevee.
-                    material.metallic = 0.8
-                    material.specular_intensity = 0.5
-                    material.roughness = 0.3
-                    material.blend_method = 'OPAQUE'
-                    material.show_transparent_back = False
-                    # Some properties for cycles
+                    # For cycles and eevee.
                     material.use_nodes = True
                     mat_P_BSDF = material.node_tree.nodes['Principled BSDF']
                     mat_P_BSDF.inputs['Metallic'].default_value = 0.1
@@ -1400,6 +1408,10 @@ def import_pdb(Ball_type,
                     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.5
+                    # Some additional stuff for eevee.
+                    material.blend_method = 'HASHED'
+                    material.shadow_method = 'HASHED'
+                    material.use_backface_culling = False
                 # The atom gets its properties.
                 atom.material = material
 
diff --git a/io_mesh_atomic/xyz_import.py b/io_mesh_atomic/xyz_import.py
index 16241c0e..d20c1730 100644
--- a/io_mesh_atomic/xyz_import.py
+++ b/io_mesh_atomic/xyz_import.py
@@ -431,13 +431,27 @@ def camera_light_source(use_camera,
         object_lamp_vec = Vector((lamp_dl,lamp_dy_right,lamp_dl))
         lamp_xyz_vec = object_center_vec + object_lamp_vec
 
+        # Eevee
+        # =====
+
+        # As a lamp we use a point source.
+        lamp_data = bpy.data.lights.new(name="A_lamp_eevee", type="POINT")
+        lamp_data.energy = 100000.0 # Watts
+        lamp = bpy.data.objects.new("A_lamp_eevee", lamp_data)
+        lamp.location = lamp_xyz_vec
+        bpy.context.collection.objects.link(lamp)
+
+        # Cycles
+        # ======
+
         # As a lamp we use a ball.
         bpy.ops.mesh.primitive_uv_sphere_add(
                         segments=64,
                         ring_count=64,
                         align='WORLD',
                         enter_editmode=False,
-                        location=lamp_xyz_vec,
+                        # We move the lamp below the point source from above.
+                        location=lamp_xyz_vec + Vector((0.0, 0.0, 1.5)),
                         rotation=(0, 0, 0))
         lamp = bpy.context.view_layer.objects.active
         # We put an 'A_' just that the lamp appears first in the outliner
@@ -527,13 +541,7 @@ def import_xyz(Ball_type,
                     # However, before we check if it is a vacancy
                     # The vacancy is represented by a transparent cube.
                     if atom.name == "Vacancy":
-                        # Some properties for eevee.
-                        material.metallic = 0.8
-                        material.specular_intensity = 0.5
-                        material.roughness = 0.3
-                        material.blend_method = 'OPAQUE'
-                        material.show_transparent_back = False
-                        # Some properties for cycles
+                        # For cycles and eevee.
                         material.use_nodes = True
                         mat_P_BSDF = material.node_tree.nodes['Principled BSDF']
                         mat_P_BSDF.inputs['Metallic'].default_value = 0.1
@@ -544,6 +552,10 @@ def import_xyz(Ball_type,
                         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.5
+                        # Some additional stuff for eevee.
+                        material.blend_method = 'HASHED'
+                        material.shadow_method = 'HASHED'
+                        material.use_backface_culling = False
                     # The atom gets its properties.
                     atom.material = material



More information about the Bf-extensions-cvs mailing list