Page MenuHome

inconsistency in shader nodes when opening .blend vs. append in 2.8. Node conversion skipped when object is appended.
Closed, ResolvedPublic

Description

System Information
Operating system:
Graphics card: 2x 2080TI

Blender Version
(2.79b f4dc9f9d68b, blender2.79b, 2018-03-22)
(2.80, a280867ac2ed, blender2.8, 2019-03-07, as found on the splash screen)

I have models (.blend files) that were created in 2.79 cycles. When attempting to open them in 2.8 I see some nodes are reconfigured, 2.79a (where Displacement was a scalar socket) and 2.8 (where Displacement is a Vector), Blender automatically replaces the "RGB to BW" node connected to the material output with a proper normalmap displacement node setup.

However, unlike opening, instead, when appending from that same file, 2.8 will not reconfigure the shaders, It retains the same node configuration as from 2.79 resulting in displacement looking blocky and incorrect: https://i.stack.imgur.com/LrXpx.png

Here is my StackOverflow post explaining in more detail and with images of the node configurations.

Also, I was able to write a script that can be run just after appending objects into the scene. It will replace the nodes linked to the Material Output node with a proper displacement node setup. This resembles the way it would have been converted as if the object were opened instead of being appended.

FixDisplacementNodes.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = "Grant Olsen (2019)"
__credits__ = ["Rich Sedman", "batFinger"]
__version__ = "2.0.0"

import bpy


"""Given a material this will search for any RBG to BW nodes that are connected to a Material Output's Displacement input.
   If the RBG to BW node exists then this will create the proper Displacenment map node setup and link it to the
   RGB to BW node.
"""
def FixDisplacementNodes(mat):
	"""
	Explanation: this function takes one arguments: `mat`.
	`mat` is type bpy.types.Material and is the material for the object
	to be checked for any RBG to BW nodes connected to the Material Output node.
	Will replace with proper normal map node setup.    

	The return type is `None`.

	"""
	if mat is None:# an object can have an empty material slot where slot.material is None
		return #nothing to process
	
	for link in mat.node_tree.links: #loop over all node links for this material.   	
		if type(link.to_node) is bpy.types.ShaderNodeOutputMaterial: #check if this node is connected to the type: "Output Material" node
			if link.to_socket.identifier == 'Displacement': #check if this node is connected to the "Displacemnent" input
				if type(link.from_node) is bpy.types.ShaderNodeRGBToBW: #finally, is the child node an "RGB to BW" type node?
					
					bwNode = link.from_node #the RGB to BW node

					dNode = mat.node_tree.nodes.new('ShaderNodeDisplacement') #newly created Displacement Node
		
					mat.node_tree.links.new(dNode.inputs['Height'], bwNode.outputs['Val']) #connect the RGB to BW node to the Displacement node
					mat.node_tree.links.new(link.to_socket, dNode.outputs['Displacement']) #connect the Displacement node to the Material Output node

"""Loop through all objects in the scene, and for each object's material slot, passing it to Check_Material.
"""
if __name__ == '__main__':

	for mat in bpy.data.materials: #get list of materials, will save fixing same material for each object
		FixDisplacementNodes(mat)
		
	#for ob in bpy.data.objects: #get list of objects
	#   for slot in ob.material_slots:
	#   	FixDisplacementNodes(slot.material)

Exact steps for others to reproduce the error

  1. Start Blender 2.79 and switch it to Cycles mode.
  2. Select the default cube and edit it's material.
  3. Switch to node editor.
  4. Add Image texture (with a normalmap.png as the input texture).
  5. Add a RGB to BW node.
  6. Connect the "image texture" to input of "RGB to BW".
  7. Connect "RGB to BW" output to "Material Output" displacement input.
  8. Save.
  9. Start Blender 2.8.
  10. Open the file (the one created in 2.79).
  11. Look at the shader nodes and notice Blender 2.8 has added a Displacement node: [Image Texture > RGB to BW > Displacement > Material Output]
  12. Start Blender 2.8 (again)
  13. Append the cube object from file (the one created in 2.79).
  14. Notice how the nodes still remain as: [Image Texture > RGB to BW > Material Output]

Event Timeline

grant olsen (blended_blue) renamed this task from inconsistency in shaders nodes when opening .blend vs. append/link in 2.8. Node conversions are skipped when appending. to inconsistency in shader nodes when opening .blend vs. append/link in 2.8. Node conversion skipped when object is appended..Mar 10 2019, 10:54 AM
Sebastian Parborg (zeddb) triaged this task as Needs Information from User priority.Mar 11 2019, 1:05 PM

Can you attach a minimal 2.79 .blend file? My 2.79 builds are too new so they have converted to vector output there too.

Philipp Oeser (lichtwerk) raised the priority of this task from Needs Information from User to Confirmed, Medium.
Philipp Oeser (lichtwerk) claimed this task.

Can confirm. (for appending, if you link in the object it works after saving/reloading).
A fix was recently done for linking (in the fix for T54504).
Not even sure if do_version() runs for appending..., checking...

Philipp Oeser (lichtwerk) renamed this task from inconsistency in shader nodes when opening .blend vs. append/link in 2.8. Node conversion skipped when object is appended. to inconsistency in shader nodes when opening .blend vs. append in 2.8. Node conversion skipped when object is appended..Mar 11 2019, 8:50 PM

Turns out do_versions() is run in blender when appending, but the corresponding python handler is not.
And since cycles does its thing in a bpy.app.handlers.version_update this wont be called.

Brecht Van Lommel (brecht) raised the priority of this task from Confirmed, Medium to Confirmed, High.Apr 1 2019, 1:52 PM