- Implemented a preview tool for rectifying images with interactive aspect controls in `preview.py`. - Added tests for depth metadata loading to ensure consistent schema usage in `test_depth_metadata.py`. - Developed comprehensive tests for cutout calibration processes in `test_cutout_calibration.py`, including stability checks and depth calibration. - Created tests for frame compositing operations in `test_frame_compositing.py`, ensuring correct handling of depth and transparency. - Introduced material slot inheritance functionality in `material_slots.py` to manage geometry material assignments. - Built shared shader nodes for material processing in `shader.py`, including roughness and bump mapping setups.
26 lines
1.3 KiB
Python
26 lines
1.3 KiB
Python
"""Carry the input mesh's material slots onto generated geometry."""
|
|
|
|
|
|
def inherit_material_slots(group, geometry, source):
|
|
nodes, links = group.nodes, group.links
|
|
size = nodes.new("GeometryNodeAttributeDomainSize")
|
|
size.component = "MESH"
|
|
links.new(source, size.inputs["Geometry"])
|
|
index = nodes.new("GeometryNodeInputIndex")
|
|
source_vertices = nodes.new("FunctionNodeCompare")
|
|
source_vertices.data_type, source_vertices.operation = "INT", "LESS_THAN"
|
|
links.new(index.outputs["Index"], source_vertices.inputs[2])
|
|
links.new(size.outputs["Point Count"], source_vertices.inputs[3])
|
|
join = nodes.new("GeometryNodeJoinGeometry")
|
|
# Multi-input links are prepended: source occupies the first point range.
|
|
links.new(geometry, join.inputs["Geometry"])
|
|
links.new(source, join.inputs["Geometry"])
|
|
material = nodes.new("GeometryNodeSetMaterialIndex")
|
|
material.inputs["Material Index"].default_value = 0
|
|
links.new(join.outputs["Geometry"], material.inputs["Geometry"])
|
|
delete = nodes.new("GeometryNodeDeleteGeometry")
|
|
delete.domain = "POINT"
|
|
links.new(material.outputs["Geometry"], delete.inputs["Geometry"])
|
|
links.new(source_vertices.outputs["Result"], delete.inputs["Selection"])
|
|
return delete.outputs["Geometry"]
|