[Bf-extensions-cvs] [a142d867] master: initial commit hdri shortcut by Nikos_prinio T50366 T51145
meta-androcto
noreply at git.blender.org
Sat Apr 22 02:46:45 CEST 2017
Commit: a142d8675d603fca126ce046ff29571bd9c0d377
Author: meta-androcto
Date: Sat Apr 22 10:46:20 2017 +1000
Branches: master
https://developer.blender.org/rBACa142d8675d603fca126ce046ff29571bd9c0d377
initial commit hdri shortcut by Nikos_prinio T50366 T51145
===================================================================
A lighting_hdri_shortcut/__init__.py
===================================================================
diff --git a/lighting_hdri_shortcut/__init__.py b/lighting_hdri_shortcut/__init__.py
new file mode 100644
index 00000000..8a028776
--- /dev/null
+++ b/lighting_hdri_shortcut/__init__.py
@@ -0,0 +1,647 @@
+# 2015 Nicolas Priniotakis (Nikos) - nikos at easy-logging.net
+#
+# This work is free. You can redistribute it and/or modify it under the
+# terms of the Do What The Fuck You Want To Public License, Version 2,
+# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
+
+bl_info = {
+ "name": "HDRI lighting Shortcut",
+ "author": "Nicolas Priniotakis (Nikos)",
+ "version": (1, 3, 2, 0),
+ "blender": (2, 7, 6, 0),
+ "api": 44539,
+ "category": "Material",
+ "location": "Properties > World",
+ "description": "Easy setup for HDRI global lightings",
+ "warning": "",
+ "wiki_url": "",
+ "tracker_url": "", }
+
+import bpy
+from bpy.types import Operator, AddonPreferences
+import getpass
+import os
+
+global nodes, folder_path, pref, img_path, real_HDR, adjustments
+global node_coo, node_map, node_rgb, node_add, node_sat, node_env, node_math, node_math_add, node_bkgnd, node_out, node_light_path, node_rflx_math, node_rflx_math_add
+
+real_HDR = False
+adjustments = False
+img_path = None
+
+# ----------------- functions --------------------
+
+
+def img_exists(img):
+ for index, i in enumerate(bpy.data.images):
+ if i.name == img:
+ return True
+ return False
+
+
+def img_index(img):
+ for index, i in enumerate(bpy.data.images):
+ if i.name == img:
+ return index
+ return None
+
+
+def current_bkgnd():
+ nodes = bpy.context.scene.world.node_tree.nodes
+ for node in nodes:
+ if node.name == "ENVIRONMENT":
+ return node.image.name
+
+
+def node_exists(n):
+ nodes = bpy.context.scene.world.node_tree.nodes
+ for node in nodes:
+ if node.name == n:
+ return True
+ return False
+
+
+def node_attrib():
+ global node_coo, node_map, node_rgb, node_add, node_sat, node_env, node_math, node_math_add, node_bkgnd, node_out, node_light_path, node_reflexion, node_rflx_math, node_rflx_math_add
+ global node_blur_noise, node_blur_coordinate, node_blur_mix_1, node_blur_mix_2, node_blur_math_sub, node_blur_math_add
+ nodes = bpy.context.scene.world.node_tree.nodes
+ try:
+ for node in nodes:
+ if node.name == 'COORDINATE':
+ node_coo = node
+ if node.name == 'MAPPING':
+ node_map = node
+ if node.name == 'COMBINE':
+ node_rgb = node
+ if node.name == 'RGB_ADD':
+ node_add = node
+ if node.name == 'SATURATION':
+ node_sat = node
+ if node.name == 'ENVIRONMENT':
+ node_env = node
+ if node.name == 'HLS_MATH':
+ node_math = node
+ if node.name == 'HLS_MATH_ADD':
+ node_math_add = node
+ if node.name == 'BACKGROUND':
+ node_bkgnd = node
+ if node.name == 'OUTPUT':
+ node_out = node
+ if node.name == "LIGHT_PATH":
+ node_light_path = node
+ if node.name == 'REFLEXION':
+ node_reflexion = node
+ if node.name == "RFLX_MATH":
+ node_rflx_math = node
+ if node.name == "RFLX_MATH_ADD":
+ node_rflx_math_add = node
+ if node.name == "BLUR_NOISE":
+ node_blur_noise = node
+ if node.name == "BLUR_COORDINATE":
+ node_blur_coordinate = node
+ if node.name == "BLUR_MIX_1":
+ node_blur_mix_1 = node
+ if node.name == "BLUR_MIX_2":
+ node_blur_mix_2 = node
+ if node.name == "BLUR_MATH_ADD":
+ node_blur_math_add = node
+ if node.name == "BLUR_MATH_SUB":
+ node_blur_math_sub = node
+ except:
+ pass
+
+
+def node_tree_ok():
+ try:
+ current_world = bpy.context.scene.world
+ if current_world.name == "HDRI Lighting Shortcut":
+ if node_exists("COORDINATE"):
+ if node_exists("MAPPING"):
+ if node_exists("COMBINE"):
+ if node_exists("RGB_ADD"):
+ if node_exists("SATURATION"):
+ if node_exists("ENVIRONMENT"):
+ if node_exists("BACKGROUND"):
+ if node_exists("LIGHT_PATH"):
+ if node_exists('REFLEXION'):
+ if node_exists('RFLX_MATH'):
+ if node_exists('RFLX_MATH_ADD'):
+ if node_exists('HLS_MATH'):
+ if node_exists('HLS_MATH_ADD'):
+ if node_exists('REF_MIX'):
+ if node_exists('BLUR_NOISE'):
+ if node_exists('BLUR_COORDINATE'):
+ if node_exists('BLUR_MIX_1'):
+ if node_exists('BLUR_MIX_2'):
+ if node_exists('BLUR_MATH_ADD'):
+ if node_exists('BLUR_MATH_SUB'):
+ if node_exists("OUTPUT"):
+ node_attrib()
+ return True
+ except:
+ pass
+ return False
+
+
+def update_mirror(self, context):
+ global node_env
+ try:
+ if self.mirror == True:
+ node_env.projection = 'MIRROR_BALL'
+ else:
+ node_env.projection = 'EQUIRECTANGULAR'
+ except:
+ pass
+
+
+def update_orientation(self, context):
+ try:
+ node_map.rotation[2] = self.orientation
+ #node_map.rotation[2] = (self.orientation * 0.0174533)
+ except:
+ pass
+
+
+def update_sat(self, context):
+ try:
+ node_sat.inputs[1].default_value = self.sat
+ except:
+ pass
+
+
+def update_hue(self, context):
+ try:
+ node_sat.inputs[0].default_value = self.hue
+ except:
+ pass
+
+
+def update_strength(self, context):
+ try:
+ node_math_add.inputs[1].default_value = self.light_strength
+ if bpy.context.scene.adjustments_prop == False:
+ node_rflx_math_add.inputs[1].default_value = self.light_strength
+ self.reflexion = self.light_strength
+ except:
+ pass
+
+
+def update_main_strength(self, context):
+ try:
+ node_math.inputs[1].default_value = self.main_light_strength
+ except:
+ pass
+
+
+def update_visible(self, context):
+ cam = self.world.cycles_visibility
+ if self.visible == True:
+ cam.camera = True
+ else:
+ cam.camera = False
+ try:
+ self.light_strength += 0 # dirty trick to force the viewport to update
+ except:
+ pass
+
+
+def update_reflexion(self, context):
+ try:
+ node_rflx_math_add.inputs[1].default_value = self.reflexion
+ except:
+ pass
+
+
+def reset():
+ self = bpy.context.scene
+ self.visible = True
+ self.adjustments_prop = False
+ self.mirror = False
+ self.world.cycles_visibility.camera = False
+ self.light_strength = 0.5
+ self.main_light_strength = 0.1
+ self.orientation = 0.0
+ self.adjustments_color = (0, 0, 0)
+ self.sat = 1
+ self.hue = 0.5
+ self.reflexion = 0.5
+ self.mirror = False
+
+
+def apply_parameters():
+ scene = bpy.context.scene
+ node_rgb.inputs[0].default_value = scene.adjustments_color[0]
+ node_rgb.inputs[1].default_value = scene.adjustments_color[1]
+ node_rgb.inputs[2].default_value = scene.adjustments_color[2]
+ node_math_add.inputs[1].default_value = scene.light_strength
+ node_math.inputs[1].default_value = scene.main_light_strength
+ node_sat.inputs[1].default_value = scene.sat
+ node_sat.inputs[0].default_value = scene.hue
+ node_rflx_math_add.inputs[1].default_value = scene.reflexion
+
+ if scene.mirror == True:
+ node_env.projection = 'MIRROR_BALL'
+ else:
+ node_env.projection = 'EQUIRECTANGULAR'
+
+
+def clear_node_tree():
+ nodes = bpy.context.scene.world.node_tree.nodes
+ for node in nodes:
+ try:
+ nodes.remove(node)
+ except:
+ pass
+
+
+def update_adjustments(self, context):
+ global adjustments
+ if self.adjustments_prop == True:
+ adjustments = True
+ else:
+ adjustments = False
+ self.adjustments_color = (0, 0, 0)
+ self.sat = 1
+ self.hue = .5
+ self.reflexion = self.light_strength
+ self.mirror = False
+
+
+def node_tree_exists(world_name):
+ for w in bpy.data.worlds:
+ if w.name == world_name:
+ return True
+ return False
+
+
+def world_num(world_name):
+ for index, w in enumerate(bpy.data.worlds):
+ if w.name == world_name:
+ return index
+
+
+def setup(img_path):
+ global node_coo, node_map, node_rgb, node_add, node_sat, node_env, node_math, node_math_add, node_bkgnd, node_out, node_light_path, node_reflexion, node_rflx_math, node_rflx_math_add
+ global node_blur_noise, node_blur_coordinate, node_blur_mix_1, node_blur_mix_2, node_blur_math_sub, node_blur_math_add
+ bpy.context.area.type = 'NODE_EDITOR'
+ bpy.context.scene.render.engine = 'CYCLES'
+ bpy.context.space_data.tree_type = 'ShaderNodeTree'
+ bpy.context.space_data.shader_type = 'WORLD'
+ tre
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list