inconsistency in shader nodes when opening .blend vs. append in 2.8. Node conversion skipped when object is appended. #62415

Closed
opened 2019-03-10 10:20:54 +01:00 by grant olsen · 14 comments

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

Blender Version
(2.79b f4dc9f9d68, blender2.79b, 2018-03-22)
(2.80, a280867ac2, 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]
  1. Start Blender 2.8 (again)
  2. Append the cube object from file (the one created in 2.79).
  3. Notice how the nodes still remain as:
   [Image Texture > RGB to BW > Material Output]
**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 ](https://blender.stackexchange.com/questions/133779/find-any-node-connected-to-a-materials-displacement-input-and-replace-it-with-a/133918#133918) 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]
Author

Added subscriber: @blended_blue

Added subscriber: @blended_blue

#62881 was marked as duplicate of this issue

#62881 was marked as duplicate of this issue
grant olsen changed title 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. 2019-03-10 10:54:49 +01:00

Added subscriber: @ZedDB

Added subscriber: @ZedDB

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.

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.
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Philipp Oeser self-assigned this 2019-03-11 20:49:57 +01:00
Member

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 #54504).
Not even sure if do_version() runs for appending..., checking...

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 #54504). Not even sure if do_version() runs for appending..., checking...
Philipp Oeser changed title 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. 2019-03-11 20:50:23 +01:00
Member

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.

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.
Member

D4499 is a possible solution

[D4499](https://archive.blender.org/developer/D4499) is a possible solution

Added subscriber: @YegorSmirnov

Added subscriber: @YegorSmirnov

This issue was referenced by blender/cycles@0f2c51ffb9

This issue was referenced by blender/cycles@0f2c51ffb9e511f7c4ede544bc599c35002fc31a

This issue was referenced by cc5a75d572

This issue was referenced by cc5a75d5727ab45c2521bf6103a28aa2503fbafc

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Member

Added subscriber: @brecht

Added subscriber: @brecht
Member

@brecht: thank you!

@brecht: thank you!
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#62415
No description provided.