Last active
October 15, 2021 08:09
-
-
Save dreisicht/3d9c619521c0587374ad84e66d6aed7c to your computer and use it in GitHub Desktop.
git diff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git release/scripts/addons/node_wrangler.py b/node_wrangler.py | |
index 68573302..18cc4f2e 100644 | |
--- release/scripts/addons/node_wrangler.py | |
+++ release/scripts/addons/node_wrangler.py | |
@@ -28,7 +28,7 @@ bl_info = { | |
"category": "Node", | |
} | |
-import bpy, blf, bgl | |
+import bpy, bgl | |
import gpu | |
from bpy.types import Operator, Panel, Menu | |
from bpy.props import ( | |
@@ -1086,7 +1086,7 @@ def get_internal_socket(socket): | |
return iterator[i] | |
def is_viewer_link(link, output_node): | |
- if "Emission Viewer" in link.to_node.name or link.to_node == output_node and link.to_socket == output_node.inputs[0]: | |
+ if link.to_node == output_node and link.to_socket == output_node.inputs[0]: | |
return True | |
if link.to_node.type == 'GROUP_OUTPUT': | |
socket = get_internal_socket(link.to_socket) | |
@@ -1852,14 +1852,6 @@ class NWPreviewNode(Operator, NWBase): | |
self.search_sockets((emission if emission else materialout), self.used_viewer_sockets_other_mats) | |
return socket in self.used_viewer_sockets_other_mats | |
- @staticmethod | |
- def get_viewer_node(materialout): | |
- input_socket = materialout.inputs[0] | |
- if len(input_socket.links) > 0: | |
- node = input_socket.links[0].from_node | |
- if node.type == 'EMISSION' and node.name == "Emission Viewer": | |
- return node | |
- | |
def invoke(self, context, event): | |
space = context.space_data | |
# Ignore operator when running in wrong context. | |
@@ -1874,7 +1866,7 @@ class NWPreviewNode(Operator, NWBase): | |
select_node = bpy.ops.node.select(mouse_x=mlocx, mouse_y=mlocy, extend=False) | |
if 'FINISHED' in select_node: # only run if mouse click is on a node | |
active_tree, path_to_tree = get_active_tree(context) | |
- nodes, links = active_tree.nodes, active_tree.links | |
+ nodes = active_tree.nodes | |
base_node_tree = space.node_tree | |
active = nodes.active | |
@@ -1967,12 +1959,11 @@ class NWPreviewNode(Operator, NWBase): | |
force_update(context) | |
return {'FINISHED'} | |
- | |
# What follows is code for the shader editor | |
output_types = [x[1] for x in shaders_output_nodes_props] | |
valid = False | |
if active: | |
- if (active.name != "Emission Viewer") and (active.type not in output_types): | |
+ if (active.type not in output_types): | |
for out in active.outputs: | |
if is_visible_socket(out): | |
valid = True | |
@@ -1990,7 +1981,7 @@ class NWPreviewNode(Operator, NWBase): | |
materialout = base_node_tree.nodes.new(self.shader_output_ident) | |
materialout.location = get_output_location(base_node_tree) | |
materialout.select = False | |
- # Analyze outputs, add "Emission Viewer" if needed, make links | |
+ # Analyze outputs | |
out_i = None | |
valid_outputs = [] | |
for i, out in enumerate(active.outputs): | |
@@ -2010,54 +2001,12 @@ class NWPreviewNode(Operator, NWBase): | |
make_links = [] # store sockets for new links | |
delete_nodes = [] # store unused nodes to delete in the end | |
if active.outputs: | |
- # If output type not 'SHADER' - "Emission Viewer" needed | |
- if active.outputs[out_i].type != 'SHADER': | |
- socket_type = 'NodeSocketColor' | |
- # get Emission Viewer node | |
- emission_exists = False | |
- emission_placeholder = base_node_tree.nodes[0] | |
- for node in base_node_tree.nodes: | |
- if "Emission Viewer" in node.name: | |
- emission_exists = True | |
- emission_placeholder = node | |
- if not emission_exists: | |
- emission = base_node_tree.nodes.new(self.shader_viewer_ident) | |
- emission.hide = True | |
- emission.location = [materialout.location.x, (materialout.location.y + 40)] | |
- emission.label = "Viewer" | |
- emission.name = "Emission Viewer" | |
- emission.use_custom_color = True | |
- emission.color = (0.6, 0.5, 0.4) | |
- emission.select = False | |
- else: | |
- emission = emission_placeholder | |
- output_socket = emission.inputs[0] | |
+ # Output type is 'SHADER', no Viewer needed. | |
+ socket_type = 'NodeSocketShader' | |
+ materialout_index = 1 if active.outputs[out_i].name == "Volume" else 0 | |
+ make_links.append((active.outputs[out_i], materialout.inputs[materialout_index])) | |
+ output_socket = materialout.inputs[materialout_index] | |
- # If Viewer is connected to output by user, don't change those connections (patch by gandalf3) | |
- if emission.outputs[0].links.__len__() > 0: | |
- if not emission.outputs[0].links[0].to_node == materialout: | |
- make_links.append((emission.outputs[0], materialout.inputs[0])) | |
- else: | |
- make_links.append((emission.outputs[0], materialout.inputs[0])) | |
- | |
- # Set brightness of viewer to compensate for Film and CM exposure | |
- if context.scene.render.engine == 'CYCLES' and hasattr(context.scene, 'cycles'): | |
- intensity = 1/context.scene.cycles.film_exposure # Film exposure is a multiplier | |
- else: | |
- intensity = 1 | |
- | |
- intensity /= pow(2, (context.scene.view_settings.exposure)) # CM exposure is measured in stops/EVs (2^x) | |
- emission.inputs[1].default_value = intensity | |
- | |
- else: | |
- # Output type is 'SHADER', no Viewer needed. Delete Viewer if exists. | |
- socket_type = 'NodeSocketShader' | |
- materialout_index = 1 if active.outputs[out_i].name == "Volume" else 0 | |
- make_links.append((active.outputs[out_i], materialout.inputs[materialout_index])) | |
- output_socket = materialout.inputs[materialout_index] | |
- for node in base_node_tree.nodes: | |
- if node.name == 'Emission Viewer': | |
- delete_nodes.append((base_node_tree, node)) | |
for li_from, li_to in make_links: | |
base_node_tree.links.new(li_from, li_to) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment