232bird opened this issue on Sep 27, 2011 · 19 posts
232bird posted Sun, 30 October 2011 at 8:17 PM
I am happy to report that after way too long I have been able to make some progress, and learn some things as well. This script has evolved a bit, my goal is now to be able to take any material set and strip it down to the bare essentials. My motivation for doing this is that
Older material sets employ "tricks" that are no longer necessary and don't work well with render gamma correction, IDL, and now built-in SSS
Complex shader trees are not needed with and sometimes don't even work with Pose2Lux and other exporters
3) I've been lurking long enough and have learned quite a lot since I first found this website, so now I want to start contributing
So... this script is intended to clean out the surface node, for example get rid of the kd_lite_multiplier, diffuse colors, ambience, etc. that were used way back in the day but are no longer needed. Then, follow the connections from the color inputs down to the image maps and plug those image maps directly to the color inputs. Then the user can apply the new SSS, or VSS, or whatever without worrying about things going haywire, or export to another program/renderer without having an all black figure because the maths didn't bake properly.
Here is what I have so far:
import poser
#declare materials
mats = poser.Scene().CurrentFigure().Materials()
shaderTree = poser.Scene().CurrentMaterial().ShaderTree()
for mat in mats:
shaderTree = mat.ShaderTree()
node = shaderTree.NodeByInternalName("PoserSurface")
node.Input(0).SetColor(1.0,1.0,1.0)
node.Input(1).SetFloat(0.8)
node.Input(2).SetColor(1.0,1.0,1.0)
node.Input(3).SetFloat(0.2)
node.Input(6).SetFloat(0.0)
node.Input(20).SetFloat(0.0)
#node.Input(21).setInput(0)
#Function to test if a node is an image map
def testIMG():
Diff_Color_Input = node0.InNode()
node2 = Diff_Color_Input
node2_type = node2.Type()
print node2_type
if node2_type == "image_map":
print "node is an image map"
return
else:
print "Node is not an image map, moving to next input..."
node1 = node2
node2 = node1.InNode(0)
testIMG()
#Find Diffuse image map
for mat in mats:
shaderTree = mat.ShaderTree()
node = shaderTree.NodeByInternalName("PoserSurface")
Diff_Color = node.InputByInternalName("Diffuse_Color")
node0 = Diff_Color
testIMG()
shaderTree.UpdatePreview()
poser.Scene().DrawAll()
Forgive me if I missed an indent or such, that is a copy/paste from my editor and then liberal use of the spacebar applied.
I have hit a couple problems so far. The biggest is that the script exits with
Traceback (most recent call last):
File "V:Pythonmats.py", line 40, in ?
testIMG()
File "V:Pythonmats.py", line 23, in testIMG
node2_type = node2.Type()
AttributeError: 'NoneType' object has no attribute 'Type'
as the error. I thought the "return" command would break the function, but it appears it isn't doing what I thought it would. As a sidenote to that, I'm pretty sure there is a problem with how I am reassigning the nodes after the "else:" line.
The other is the line
#node.Input(21).setInput(0)
I cannot for the life of me get the Reflection_kd_Mult to uncheck in the script. It worked fine for Reflection_lite_mult by giving it a 0.0 floating number. For what it's worth I ran a Type() command on the Reflection_kd_Mult and Poser returned "4", whatever that means. Oh, and I know it has a # in front, I just stuck that there so I could move on to other things for the time being.