[Bf-extensions-cvs] [6e910cf2] master: The addon gets updated for Eevee/Cycles - part 4 - revision: A point source for both, Eevee and Cycles, is sufficient, no need to have an additional ball with emission for Cycles.

Clemens Barth noreply at git.blender.org
Thu Jan 20 15:02:30 CET 2022


Commit: 6e910cf217f037b5ea9c5c8128a7ef16b9d66318
Author: Clemens Barth
Date:   Thu Jan 20 15:01:18 2022 +0100
Branches: master
https://developer.blender.org/rBA6e910cf217f037b5ea9c5c8128a7ef16b9d66318

The addon gets updated for Eevee/Cycles - part 4 - revision: A point source
for both, Eevee and Cycles, is sufficient, no need to have an additional
ball with emission for Cycles.

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

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 13a5b19f..c3b0c150 100644
--- a/io_mesh_atomic/pdb_import.py
+++ b/io_mesh_atomic/pdb_import.py
@@ -629,53 +629,16 @@ def camera_light_source(use_camera,
         lamp_xyz_vec = object_center_vec + object_lamp_vec
         length = lamp_xyz_vec.length
 
-        # Eevee
-        # =====
-
         # As a lamp we use a point source.
-        lamp_data = bpy.data.lights.new(name="A_lamp_eevee", type="POINT")
+        lamp_data = bpy.data.lights.new(name="A_lamp", type="POINT")
         # 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 = 500000.0 * ( (length * length) / (58.0 * 58.0) )
-        lamp = bpy.data.objects.new("A_lamp_eevee", lamp_data)
+        lamp = bpy.data.objects.new("A_lamp", 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,
-                        # 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_cycles"
-
-        # See above.
-        strength = 5000.0 * ( (length * length) / (58.0 * 58.0) )
-
-        # Now, we create the material
-        lamp_material = bpy.data.materials.new(lamp.name)
-        lamp_material.use_nodes = True
-        # Create the emission Node.
-        material_output = lamp_material.node_tree.nodes.get('Material Output')
-        emission = lamp_material.node_tree.nodes.new('ShaderNodeEmission')
-        # Emission and strength values
-        emission.inputs['Strength'].default_value = strength
-        emission.inputs['Color'].default_value = (1.0, 1.0, 1.0, 1.0)
-        # The new material into the tree and link the material of the object
-        # with the new material.
-        lamp_material.node_tree.links.new(material_output.inputs[0], emission.outputs[0])
-        lamp.active_material = lamp_material
-
         # Some settings for the World: a bit ambient occlusion
         bpy.context.scene.world.light_settings.use_ambient_occlusion = True
         bpy.context.scene.world.light_settings.ao_factor = 0.1
diff --git a/io_mesh_atomic/xyz_import.py b/io_mesh_atomic/xyz_import.py
index 04da0a4b..3cd7185c 100644
--- a/io_mesh_atomic/xyz_import.py
+++ b/io_mesh_atomic/xyz_import.py
@@ -432,53 +432,16 @@ def camera_light_source(use_camera,
         lamp_xyz_vec = object_center_vec + object_lamp_vec
         length = lamp_xyz_vec.length
 
-        # Eevee
-        # =====
-
         # As a lamp we use a point source.
-        lamp_data = bpy.data.lights.new(name="A_lamp_eevee", type="POINT")
+        lamp_data = bpy.data.lights.new(name="A_lamp", type="POINT")
         # 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 = 500000.0 * ( (length * length) / (58.0 * 58.0) )
-        lamp = bpy.data.objects.new("A_lamp_eevee", lamp_data)
+        lamp = bpy.data.objects.new("A_lamp", 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,
-                        # 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"
-
-        # See above.
-        strength = 5000.0 * ( (length * length) / (58.0 * 58.0) )
-
-        # Now, we create the material
-        lamp_material = bpy.data.materials.new(lamp.name)
-        lamp_material.use_nodes = True
-        # Create the emission Node.
-        material_output = lamp_material.node_tree.nodes.get('Material Output')
-        emission = lamp_material.node_tree.nodes.new('ShaderNodeEmission')
-        # Emission and strength values
-        emission.inputs['Strength'].default_value = strength
-        emission.inputs['Color'].default_value = (1.0, 1.0, 1.0, 1.0)
-        # The new material into the tree and link the material of the object
-        # with the new material.
-        lamp_material.node_tree.links.new(material_output.inputs[0], emission.outputs[0])
-        lamp.active_material = lamp_material
-
         # Some settings for the World: a bit ambient occlusion
         bpy.context.scene.world.light_settings.use_ambient_occlusion = True
         bpy.context.scene.world.light_settings.ao_factor = 0.1



More information about the Bf-extensions-cvs mailing list