diff options
Diffstat (limited to 'release/scripts/startup/bl_operators/object_quick_effects.py')
-rw-r--r-- | release/scripts/startup/bl_operators/object_quick_effects.py | 130 |
1 files changed, 50 insertions, 80 deletions
diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py index 24323b1554e..70334fb0f23 100644 --- a/release/scripts/startup/bl_operators/object_quick_effects.py +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -364,88 +364,38 @@ class QuickSmoke(Operator): # Setup material - # Cycles - if context.scene.render.use_shading_nodes or context.render.use_shading_nodes: - bpy.ops.object.material_slot_add() - - mat = bpy.data.materials.new("Smoke Domain Material") - obj.material_slots[0].material = mat - - # Make sure we use nodes - mat.use_nodes = True - - # Set node variables and clear the default nodes - tree = mat.node_tree - nodes = tree.nodes - links = tree.links - - nodes.clear() + # Cycles and Eevee + bpy.ops.object.material_slot_add() - # Create shader nodes + mat = bpy.data.materials.new("Smoke Domain Material") + obj.material_slots[0].material = mat - # Material output - node_out = nodes.new(type='ShaderNodeOutputMaterial') - node_out.location = grid_location(6, 1) + # Make sure we use nodes + mat.use_nodes = True - # Add Principled Volume - node_principled = nodes.new(type='ShaderNodeVolumePrincipled') - node_principled.location = grid_location(4, 1) - links.new(node_principled.outputs["Volume"], - node_out.inputs["Volume"]) + # Set node variables and clear the default nodes + tree = mat.node_tree + nodes = tree.nodes + links = tree.links - node_principled.inputs["Density"].default_value = 5.0 + nodes.clear() - if self.style in {'FIRE', 'BOTH'}: - node_principled.inputs["Blackbody Intensity"].default_value = 1.0 + # Create shader nodes - # Blender Internal - else: - # create a volume material with a voxel data texture for the domain - bpy.ops.object.material_slot_add() - - mat = bpy.data.materials.new("Smoke Domain Material") - obj.material_slots[0].material = mat - mat.type = 'VOLUME' - mat.volume.density = 0 - mat.volume.density_scale = 5 - mat.volume.step_size = 0.1 - - tex = bpy.data.textures.new("Smoke Density", 'VOXEL_DATA') - tex.voxel_data.domain_object = obj - tex.voxel_data.interpolation = 'TRICUBIC_BSPLINE' - - tex_slot = mat.texture_slots.add() - tex_slot.texture = tex - tex_slot.texture_coords = 'ORCO' - tex_slot.use_map_color_emission = False - tex_slot.use_map_density = True - tex_slot.use_map_color_reflection = True - - # for fire add a second texture for flame emission - mat.volume.emission_color = Vector((0.0, 0.0, 0.0)) - tex = bpy.data.textures.new("Flame", 'VOXEL_DATA') - tex.voxel_data.domain_object = obj - tex.voxel_data.smoke_data_type = 'SMOKEFLAME' - tex.voxel_data.interpolation = 'TRICUBIC_BSPLINE' - tex.use_color_ramp = True + # Material output + node_out = nodes.new(type='ShaderNodeOutputMaterial') + node_out.location = grid_location(6, 1) - tex_slot = mat.texture_slots.add() - tex_slot.texture = tex - tex_slot.texture_coords = 'ORCO' + # Add Principled Volume + node_principled = nodes.new(type='ShaderNodeVolumePrincipled') + node_principled.location = grid_location(4, 1) + links.new(node_principled.outputs["Volume"], + node_out.inputs["Volume"]) - # add color ramp for flame color - ramp = tex.color_ramp - # dark orange - elem = ramp.elements.new(0.333) - elem.color = (0.2, 0.03, 0.0, 1.0) + node_principled.inputs["Density"].default_value = 5.0 - # yellow glow - elem = ramp.elements.new(0.666) - elem.color = (1, 0.65, 0.25, 1.0) - - mat.texture_slots[1].use_map_density = True - mat.texture_slots[1].use_map_emission = True - mat.texture_slots[1].emission_factor = 5 + if self.style in {'FIRE', 'BOTH'}: + node_principled.inputs["Blackbody Intensity"].default_value = 1.0 return {'FINISHED'} @@ -547,13 +497,33 @@ class QuickFluid(Operator): mat = bpy.data.materials.new("Fluid Domain Material") obj.material_slots[0].material = mat - mat.specular_intensity = 1 - mat.specular_hardness = 100 - mat.use_transparency = True - mat.alpha = 0.0 - mat.transparency_method = 'RAYTRACE' - mat.raytrace_transparency.ior = 1.33 - mat.raytrace_transparency.depth = 4 + # Make sure we use nodes + mat.use_nodes = True + + # Set node variables and clear the default nodes + tree = mat.node_tree + nodes = tree.nodes + links = tree.links + + nodes.clear() + + # Create shader nodes + + # Material output + node_out = nodes.new(type='ShaderNodeOutputMaterial') + node_out.location = grid_location(6, 1) + + # Add Glass + node_glass = nodes.new(type='ShaderNodeBsdfGlass') + node_glass.location = grid_location(4, 1) + links.new(node_glass.outputs["BSDF"], node_out.inputs["Surface"]) + node_glass.inputs["IOR"].default_value = 1.33 + + # Add Absorption + node_absorption = nodes.new(type='ShaderNodeVolumeAbsorption') + node_absorption.location = grid_location(4, 2) + links.new(node_absorption.outputs["Volume"], node_out.inputs["Volume"]) + node_absorption.inputs["Color"].default_value = (0.8, 0.9, 1.0, 1.0) if self.start_baking: bpy.ops.fluid.bake('INVOKE_DEFAULT') |