Xameva opened this issue on Jul 06, 2011 · 25 posts
markschum posted Wed, 06 July 2011 at 6:54 PM
import poser, string
myimg = ":Runtime:Textures:myimgs:myimg.jpg"
mymask = ":Runtime:Textures:myimgs:mymask.jpg"
fig = poser.Scene().CurrentFigure()
mat = fig.Material("2_SkinTorso")
nod = mat.ShaderTree().NodeByInternalName("PoserSurface")
inp = nod.InputByInternalName("Diffuse_Color")
mynode = inp.InNode()
if mynode:
inp.Disconnect()
blndnode = mat.ShaderTree().CreateNode(poser.kNodeTypeCodeBLENDER)
blndnode.SetName("Overlay Blender")
blndnode.SetPreviewCollapsed(0)
blndnode.SetInputsCollapsed(1)
blndnode.SetLocation(231,80)
inpdif = blndnode.Input(0)
inpimg = blndnode.Input(1)
inpmask = blndnode.Input(2)
blndnode.Input(2).SetFloat(1)
imgnode = mat.ShaderTree().CreateNode(poser.kNodeTypeCodeIMAGEMAP)
imgnode.SetName("Overlay Image")
imgnode.SetPreviewCollapsed(0)
imgnode.SetInputsCollapsed(1)
imgnode.SetLocation(231,111)
#imgnode.Input(0).SetString(myimg) # remove comment to enable <<<<<<<<<<<<<
masknode = mat.ShaderTree().CreateNode(poser.kNodeTypeCodeIMAGEMAP)
masknode.SetName("Overlay Mask")
masknode.SetPreviewCollapsed(0)
masknode.SetInputsCollapsed(1)
masknode.SetLocation(231,141)
#masknode.Input(0).SetString(mymask) # remove comment to enable <<<<<<<<<<<<<
mynode.ConnectToInput(inpdif) # connect diffuse map original to blender
imgnode.ConnectToInput(inpimg) # connect overlay map to blender
masknode.ConnectToInput(inpmask) # connect mask to blender
blndnode.ConnectToInput(inp) # connect blender to diffuse
mat.ShaderTree().UpdatePreview()
poser.Scene().DrawAll()
it finds and detaches the node plugged into Diffuse color
creates a blender and two image nodes
myimg is the overlay image
mymask is the overlay mask
plugs the node from the diffuse color into blender
plugs the blender node into diffuse color
this may not be all thats needed but should be close
I may have to unplug and attach blender to specular as well ?
This is hardcoded to overlay onto 2_SkinTorso material , that is what I need to know or I can make it current selected material .
the script needs some changes , uncomment the two lines that set the image names , and edit the script to use the proper image names rather than my test names
rename it to a .py extension and put in the poser python folder. run from file menu.