mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-02 19:02:29 +02:00
Merge pull request #2074 from alicevision/mug/scenePreviewFreestyle
[blender] preview: use Freestyle for line art shading
This commit is contained in:
commit
851099d7a7
1 changed files with 13 additions and 30 deletions
|
@ -216,37 +216,20 @@ def setupWireframeShading(mesh, color):
|
||||||
|
|
||||||
|
|
||||||
def setupLineArtShading(obj, mesh, color):
|
def setupLineArtShading(obj, mesh, color):
|
||||||
'''Setup materials and Solidify modifier for line art shading.'''
|
'''Setup line art shading using Freestyle.'''
|
||||||
# Transparent filling material
|
# Freestyle
|
||||||
matFill = bpy.data.materials.new('Fill')
|
bpy.context.scene.render.use_freestyle = True
|
||||||
matFill.use_backface_culling = True
|
bpy.data.linestyles["LineStyle"].color = (color[0], color[1], color[2])
|
||||||
matFill.use_nodes = True
|
# Holdout material
|
||||||
matFill.blend_method = 'BLEND'
|
material = bpy.data.materials.new('Holdout')
|
||||||
matFill.show_transparent_back = False
|
material.use_nodes = True
|
||||||
matFill.node_tree.links.clear()
|
material.node_tree.links.clear()
|
||||||
nodeTransparent = matFill.node_tree.nodes.new(type='ShaderNodeBsdfTransparent')
|
nodeHoldout = material.node_tree.nodes.new(type='ShaderNodeHoldout')
|
||||||
nodeOutputFill = matFill.node_tree.nodes['Material Output']
|
nodeOutput = material.node_tree.nodes['Material Output']
|
||||||
matFill.node_tree.links.new(nodeTransparent.outputs['BSDF'], nodeOutputFill.inputs['Surface'])
|
material.node_tree.links.new(nodeHoldout.outputs['Holdout'], nodeOutput.inputs['Surface'])
|
||||||
# Colored edge material
|
# Apply material to mesh
|
||||||
matEdge = bpy.data.materials.new('Edge')
|
|
||||||
matEdge.use_backface_culling = True
|
|
||||||
matEdge.use_nodes = True
|
|
||||||
matEdge.blend_method = 'BLEND'
|
|
||||||
matEdge.node_tree.links.clear()
|
|
||||||
nodeEmission = matEdge.node_tree.nodes.new(type='ShaderNodeEmission')
|
|
||||||
nodeEmission.inputs['Color'].default_value = color
|
|
||||||
nodeOutputEdge = matEdge.node_tree.nodes['Material Output']
|
|
||||||
matEdge.node_tree.links.new(nodeEmission.outputs['Emission'], nodeOutputEdge.inputs['Surface'])
|
|
||||||
# Apply materials to mesh
|
|
||||||
mesh.materials.clear()
|
mesh.materials.clear()
|
||||||
mesh.materials.append(matFill)
|
mesh.materials.append(material)
|
||||||
mesh.materials.append(matEdge)
|
|
||||||
# Solidify modifier
|
|
||||||
solidify = obj.modifiers.new('Solidify', type='SOLIDIFY')
|
|
||||||
solidify.thickness = -0.01
|
|
||||||
solidify.use_rim = False
|
|
||||||
solidify.use_flip_normals = True
|
|
||||||
solidify.material_offset = 1
|
|
||||||
|
|
||||||
|
|
||||||
def setupPointCloudShading(obj, color, size):
|
def setupPointCloudShading(obj, color, size):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue