スポンサーリンク
今私が使っているバージョンでは、Blenderを起動直後、オブジェクトにマテリアルが割り当てられている状態で他のレンダラ(Cycles)等からV-Rayに変更すると、最初の一つにはツリーが作成されない。
以下のスクリプトで、ツリーを作成できる
import bpy from vb30.nodes import tree_defaults bpy.context.scene.render.engine = "VRAY_RENDER_RT" mat = bpy.data.materials['Material-000'] tree_defaults.AddMaterialNodeTree(mat) mat.vray.ntree.name = mat.name + '-vray'
以下で、ツリー内の全ノードを削除できる
import bpy bpy.context.scene.render.engine = "VRAY_RENDER_RT" mat = bpy.data.materials['Material-000'] for vn in mat.vray.ntree.nodes: mat.vray.ntree.nodes.remove(vn)
import bpy bpy.context.scene.render.engine = "VRAY_RENDER_RT" mat = bpy.data.materials['Material-000'] vray_nodetree = mat.vray.ntree voutput = vray_nodetree.nodes.new(type='VRayNodeOutputMaterial') voutput.location.x = 0 voutput.location.y = 0 vsingle = vray_nodetree.nodes.new(type='VRayNodeMtlSingleBRDF') vsingle.location.x = voutput.location.x - voutput.width - 20 vsingle.location.y = 0 vraymat = vray_nodetree.nodes.new(type='VRayNodeBRDFVRayMtl') vraymat.location.x = vsingle.location.x - vsingle.width - 20 vraymat.location.y = 0
import bpy bpy.context.scene.render.engine = "VRAY_RENDER_RT" mat = bpy.data.materials['Material-000'] vray_nodetree = mat.vray.ntree ########################## # Add nodes ########################## voutput = vray_nodetree.nodes.new(type='VRayNodeOutputMaterial') voutput.location.x = 0 voutput.location.y = 0 vsingle = vray_nodetree.nodes.new(type='VRayNodeMtlSingleBRDF') vsingle.location.x = voutput.location.x - voutput.width - 20 vsingle.location.y = 0 vraymat = vray_nodetree.nodes.new(type='VRayNodeBRDFVRayMtl') vraymat.location.x = vsingle.location.x - vsingle.width - 20 vraymat.location.y = 0 ########################## # Add links ########################## vray_nodetree.links.new( vraymat.outputs['BRDF'] , vsingle.inputs['BRDF'] ) vray_nodetree.links.new( vsingle.outputs['Material'] , voutput.inputs['Material'] )
import bpy bpy.context.scene.render.engine = "VRAY_RENDER_RT" mat = bpy.data.materials['Material-000'] vray_nodetree = mat.vray.ntree vray_nodetree.nodes['VRayMtl'].inputs['Diffuse'].value.r = 1.0