Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ##### BEGIN LICENSE BLOCK #####
- #
- # Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)
- #
- # This work is licensed under the Creative Commons
- # Attribution-NonCommercial-NoDerivatives 4.0 International License.
- #
- # To view a copy of this license,
- # visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
- #
- # ##### END LICENSE BLOCK #####
- bl_info = {
- "name": "INSTAMIST",
- "author": "Darkfall",
- "version": (1, 0),
- "blender": (2, 90, 1),
- "location": "View3D > N > INSTA-MIST",
- "description": "Adds Mist to your scene along with arranging the compositor",
- "warning": "",
- "doc_url": "",
- "category": "Add Mist",
- }
- import bpy
- from bpy.types import Panel, Operator
- def mist_comp_action(context):
- tree = context.scene.node_tree
- comp_node = tree.nodes.get('Composite')
- comp_node.location = (700, 0)
- viewer_node = tree.nodes.new('CompositorNodeViewer')
- viewer_node.location = (700, 200)
- render_layer_node = tree.nodes.get('Render Layers')
- render_layer_node.location = (-200, 0)
- mix_node = tree.nodes.new('CompositorNodeMixRGB')
- mix_node.location = (500, 0)
- mix_node.blend_type = 'ADD'
- mix_node.use_clamp = True
- mix2_node = tree.nodes.new('CompositorNodeMixRGB')
- mix2_node.location = (300, 0)
- mix2_node.blend_type = 'MULTIPLY'
- mix2_node.use_clamp = True
- cr_node = tree.nodes.new('CompositorNodeValToRGB')
- cr_node.location = (0, 0)
- cr_node.color_ramp.elements[0].color = (0.2, 0.2, 0.2, 1)
- cr_node.color_ramp.elements.new(position= 0.27)
- link = tree.links.new
- link(mix_node.outputs[0], viewer_node.inputs[0])
- link(mix_node.outputs[0], comp_node.inputs[0])
- link(mix2_node.outputs[0], mix_node.inputs[1])
- link(cr_node.outputs[0], mix2_node.inputs[1])
- link(render_layer_node.outputs[0], mix_node.inputs[2])
- link(render_layer_node.outputs[3], cr_node.inputs[0])
- return {'FINISHED'}
- class INSTAMIST_PT_main_panel(Panel):
- bl_label = "INSTA-MIST"
- bl_idname = "INSTAMIST_PT_main_panel"
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- bl_category = "INSTA-MIST"
- def draw(self, context):
- layout = self.layout
- scene = context.scene
- layout.operator("instamist.add_mist_operator")
- class INSTAMIST_PT_sub_panel(Panel):
- bl_label = "INSTA-MIST Options"
- bl_idname = "INSTAMIST_PT_sub_panel"
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- bl_category = "INSTA-MIST"
- bl_parent_id = 'INSTAMIST_PT_main_panel'
- @classmethod
- def poll(cls, context):
- return (context.scene.view_layers["View Layer"].use_pass_mist == True
- )
- def draw(self, context):
- layout = self.layout
- scene = context.scene
- world = scene.world.mist_settings
- layout.prop(world, "start")
- layout.prop(world, "depth")
- layout.prop(world, "falloff")
- class INSTAMIST_OT_add_mist(Operator):
- bl_label = "Enable/Disable Mist"
- bl_idname = "instamist.add_mist_operator"
- def execute(self, context):
- scene = context.scene
- camera = bpy.data.cameras['Camera']
- vl = scene.view_layers["View Layer"]
- tree = scene.node_tree
- if vl.use_pass_mist == False:
- vl.use_pass_mist = True
- camera.show_mist = True
- if scene.use_nodes == False:
- scene.use_nodes = True
- mist_comp_action(context)
- elif vl.use_pass_mist == True:
- vl.use_pass_mist = False
- camera.show_mist = False
- mix1 = tree.nodes.remove(tree.nodes.get('Mix'))
- mix2 = tree.nodes.remove(tree.nodes.get('Mix.001'))
- cr = tree.nodes.remove(tree.nodes.get('ColorRamp'))
- comp_node = tree.nodes.get('Composite')
- viewer_node = tree.nodes.get('Viewer')
- render_layer_node = tree.nodes.get('Render Layers')
- tree.links.new(render_layer_node.outputs[0], comp_node.inputs[0])
- tree.links.new(render_layer_node.outputs[0], viewer_node.inputs[0])
- return {'FINISHED'}
- classes = [INSTAMIST_PT_main_panel, INSTAMIST_OT_add_mist, INSTAMIST_PT_sub_panel]
- def register():
- for cls in classes:
- bpy.utils.register_class(cls)
- def unregister():
- for cls in classes:
- bpy.utils.unregister_class(cls)
- if __name__ == "__main__":
- register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement