Comments (7)
Most likely due to Blender 4.1. I was using the latest Blender 3.6.x release
from the_lightmapper.
https://wiki.blender.org/wiki/Reference/Release_Notes/4.0/Python_API
I think it would need to be:
if 'Occlusion' not in gltf_settings_node.items_tree:
gltf_settings_node.node_tree.interface.new_socket(name="Occlusion", in_out='INPUT')
This worked!!
from the_lightmapper.
For anyone else struggling with this. I dug into the code and did some readup on the topic. This is how I changed the TLM_AddGLTFNode in tlm.py to get it working
class TLM_AddGLTFNode(bpy.types.Operator):
bl_idname = "tlm.add_gltf_node"
bl_label = "Add GLTF Node"
bl_description = "Add to GLTF node to active material and connect lightmap if present"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
scene = context.scene
cycles = scene.cycles
for obj in bpy.context.scene.objects:
print("Iterating: " + obj.name)
if obj.type == 'MESH' and obj.name in bpy.context.view_layer.objects:
if obj.TLM_ObjectProperties.tlm_mesh_lightmap_use:
for slot in obj.material_slots:
material = slot.material
nodes = material.node_tree.nodes
# create group data
gltf_settings = bpy.data.node_groups.get('glTF Material Output')
if gltf_settings is None:
bpy.data.node_groups.new('glTF Material Output', 'ShaderNodeTree')
# add group to node tree
gltf_settings_node = nodes.get('glTF Material Output')
if gltf_settings_node is None:
gltf_settings_node = nodes.new('ShaderNodeGroup')
gltf_settings_node.name = 'glTF Material Output'
gltf_settings_node.node_tree = bpy.data.node_groups['glTF Material Output']
# create group inputs
if 'Occlusion' not in gltf_settings_node.node_tree.inputs:
gltf_settings_node.node_tree.inputs.new('NodeSocketFloat','Occlusion')
gltf_settings_node.location.y = 400
lightmapNode = nodes.get("TLM_Lightmap")
material.node_tree.links.remove(lightmapNode.outputs[0].links[0])
material.node_tree.links.new(lightmapNode.outputs[0], gltf_settings_node.inputs[0])
#If the material have a node called "Lightmap_Multiplication" and it does have a input into Color2 called "Lightmap_BasecolorNode_A" remove both "Lightmap_BasecolorNode_A" and ""Lightmap_Multiplication". This needs to be done for materials that dont have a base texture but instead using a just a color
# Check if the "Lightmap_Multiplication" node exists
lightmap_multiplication_node = nodes.get("Lightmap_Multiplication")
if lightmap_multiplication_node is not None:
# Check if the "Lightmap_BasecolorNode_A" node is connected to the "Color2" input of the "Lightmap_Multiplication" node
color2_input = lightmap_multiplication_node.inputs.get("Color2")
if color2_input is not None and color2_input.is_linked:
lightmap_basecolor_node_a = color2_input.links[0].from_node
if lightmap_basecolor_node_a.name == "Lightmap_BasecolorNode_A":
# Remove the "Lightmap_BasecolorNode_A" node
nodes.remove(lightmap_basecolor_node_a)
# Remove the "Lightmap_Multiplication" node
nodes.remove(lightmap_multiplication_node)
else:
# Remove the "Lightmap_Multiplication" node
nodes.remove(lightmap_multiplication_node)
return {'FINISHED'}
from the_lightmapper.
Hi, thank you! Here is the diff:
https://gist.github.com/jywarren/b021a934995eeb690352fe9004ae4aa1/revisions
Applied to this file:
from the_lightmapper.
I'm now seeing a different error -
File "/Users/warren/Library/Application Support/Blender/4.1/scripts/addons/thelightmapper/addon/operators/tlm.py", line 1710, in execute if 'Occlusion' not in gltf_settings_node.node_tree.inputs:
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ShaderNode Tree' object has no attribute 'inputs'
from the_lightmapper.
Ah - noting I'm in Blender 4.1. I'm seeing some slightly different-looking naming conventions which could be related:
The_Lightmapper/addon/utility/utility.py
Lines 270 to 300 in 6e9e3a8
from the_lightmapper.
Just noting via this post:
in Blender 4.0 its inputs and outputs cannot be accessed anymore like this:
input_socket = groupTree.inputs.new('NodeSocketFloat', 'Input')
instead,
the new python API:
tree.interface.new_socket(name="My Input", in_out='INPUT')
from the_lightmapper.
Related Issues (20)
- Blender 3.4.1 and Lightmapper finishes bake under a second and no lightmaps are generated HOT 7
- Can't bake object with multiple instances HOT 1
- Possible path issue when cleaning using Linux/Mac
- strange artifacts with denoise activated HOT 5
- Fix OpenCV installation with Blender 3.5+ HOT 1
- Cannot build lightmaps (Blender 3.5) HOT 1
- Proposal: export glTF files with lightmaps HOT 9
- Background baking not working with AtlasGroups HOT 1
- Add option to build lights with a neutral white color as material
- can i bake multiple matirial into one lightmap with this tool and how can i do it ? HOT 8
- It use CPU insteade of GPU to render HOT 3
- Expose GPU mode when using OIDN 2.0
- Some faces are darker for no reason
- Enabling denoise causes problems Blender 3.6 HOT 1
- Addon renders scene from camera view instead of generating a lightmap. HOT 1
- Update addon for Blender 4.0 HOT 3
- Certain objects don't clean up properly in the "clean lightmaps" step HOT 1
- Support for Flamenco Renderfarm HOT 1
- bpy.ops.tlm.build_lightmaps() failed by python console HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from the_lightmapper.