Mon, Dec 23, 1:11 PM CST

Renderosity Forums / Poser - OFFICIAL



Welcome to the Poser - OFFICIAL Forum

Forum Coordinators: RedPhantom

Poser - OFFICIAL F.A.Q (Last Updated: 2024 Dec 23 8:11 am)



Subject: Material Preset to Change ONLY Colors on a Blender Node?


perpetualrevision ( ) posted Tue, 21 August 2018 at 10:36 PM · edited Mon, 23 December 2024 at 1:05 PM

I've put together a freebie package of "messy painter" objects (paint brushes, ladder, sawhorse, towels, etc.), and each object has its own transparency mask that applies a paint color in various splatter shapes over the object's regular texture. The paint color comes from a Blender node with two close shades, blended by a Turbulence node.

To change the color of the paint splatters on the objects, all the user needs to do is change the colors on the Blender node for each mat zone. Sounds easy enough, until you discover just how many mat zones there are, esp. for objects with different transparency masks for each part, like the ladder. So I want to find a way to make it as easy as possible for users to choose their own paint colors.

Here's the best I've come up with so far:

  1. With only the Blender & Turbulence nodes selected, save the new color as an MT5 w/ "Selected nodes only" checked.
  2. Load the MT5 on a different object or mat zone using the Library's double check button ("Add to Scene"), rather than the default of "Replace." That loads the new color nodes into the shader setup, but the user would then need to delete the existing one and hook up the new one to the right input. And that would be pretty tedious to do over and over, given the number of mat zones.

A better solution would be a material preset that changes ONLY the colors on the Blender node without changing anything else about the shader setup. If such a thing is possible, the user could then set up a new paint color and save it, and then apply it to each mat zone with a simple click.

I suspect that Semidieu's Advanced Shader Builder can do this, but I still haven't quite wrapped my head around how it works, despite several attempts a year ago. And I'm not sure how many users would want to go to the trouble of installing it in order to use shaders created with it. (I installed it to use VYK's handy Sexy Skinz Clothes Shaders for V4.)

If there's no way within Poser to save a material preset that will ONLY change colors on a Blender node when applied (w/o changing anything else about the shader), might there be a simpler Python script available that could do this? Or any other ideas?

Below is a screenshot of the shader setup for one mat zone on one of the props, so you can how it works. What I want is a way for users to easily change the colors on the Blender node w/o touching any other part of the shader, so that they can apply the change to material zones that have different color maps, transparency masks and/or other elements.

Thanks! {PR}Ladder-TreadMats-PaintBlender-Example.png



TOOLS: MacBook Pro; Poser Pro 11; Cheetah3D; Photoshop CC

FIGURES: S-16 (improved V4 by Karina), M4, K4, Mavka, Toons, and Nursoda's people

GOALS: Stylized and non-photorealistic renders in various fantasy styles



ironsoul ( ) posted Wed, 22 August 2018 at 1:45 AM · edited Wed, 22 August 2018 at 1:48 AM

Never tried it but if the blender node can be given a unique tag (eg name) it should be possible to write a python script to scan through a scene and copy a value to each node with the same tag it finds.

In an ideal world how would you see this being used? For example would the user set the colour on the currently selected prop's mat room and the script take the value from there, or do you see it as clicking on the side menu to bring up a colour picker? Also would this be applied to all your props or just the currently selected one?



perpetualrevision ( ) posted Wed, 22 August 2018 at 6:34 PM

ironsoul posted at 5:32PM Wed, 22 August 2018 - #4335175

Never tried it but if the blender node can be given a unique tag (eg name) it should be possible to write a python script to scan through a scene and copy a value to each node with the same tag it finds.

In an ideal world how would you see this being used? For example would the user set the colour on the currently selected prop's mat room and the script take the value from there, or do you see it as clicking on the side menu to bring up a colour picker? Also would this be applied to all your props or just the currently selected one?

Thanks for the response and for giving this some thought!

Ultimately my goal is for it to be as easy as possible for the end user to change the color of paint used in a scene, using a paint color of their choosing. A script that would allow them to change the color of the paint on all paint-ready objects in the scene would be amazing, if it's possible. As for where the new color would come from, I'm open to suggestions!

I'm assuming users would be comfortable enough with Poser's Advanced Material Room to change the colors on a Blender node, to create a new paint color. That's what I'd originally intended them to do, but when I went through every item to save MT5 presets with pink and then white paint, I realized that it's kind of a pain to change each one manually b/c there are so many!

So maybe the user could choose a new paint color on one object (by clicking on the Paint Color Blender's color chips), and somehow a script would apply that color to all the other objects with Paint Color Blender nodes? Or maybe the user would save the new paint color as an MT5 (perhaps w/ only the Blender and color mixer nodes selected) and the script would somehow apply/change only those nodes on all the other paint-ready objects? I'm comfortable enough with scripting languages to edit Python scripts, but I don't know much about how Poser Python works, so I'm not sure what's possible.

Every mat zone that takes paint has the paint color set up the same way, as shown in the screenshot above (two close colors on a Blender node, mixed by a Turbulence node). What varies is what the Paint Color Blender node is plugged into, as well as other things like bump, transparency, specular settings, etc. I also use Blender nodes elsewhere in the shader setup for most objects, to apply the trans-masked paint splats and to limit the glossy specular to them, but I'm guessing there's a way to make the Paint Color Blender nodes a unique ID? Would the external name of the node be sufficient, or would I need to go through the MT5 files and make sure all the Paint Color blenders use a specific internal name, like Blender_5?

Again, thank you for giving this some thought, as I know it's kind of an odd request. However, being able to change only one component of a shader setup would be useful for many purposes, I'd imagine! I'm pretty sure I can do that with D3D's Extended Shader manager, but I can't count on end users to have that.



TOOLS: MacBook Pro; Poser Pro 11; Cheetah3D; Photoshop CC

FIGURES: S-16 (improved V4 by Karina), M4, K4, Mavka, Toons, and Nursoda's people

GOALS: Stylized and non-photorealistic renders in various fantasy styles



perpetualrevision ( ) posted Wed, 22 August 2018 at 11:32 PM · edited Wed, 22 August 2018 at 11:33 PM

Here's an early promo render so you can see what's in the "Messy Painter" set. The set (like all of mine) is meant to be stylized/slightly toony rather than photorealistic, since I'm making things to use in my own young-adult graphic novel.

{PR}MessyPainterSet-Clean-v-Messy.jpg



TOOLS: MacBook Pro; Poser Pro 11; Cheetah3D; Photoshop CC

FIGURES: S-16 (improved V4 by Karina), M4, K4, Mavka, Toons, and Nursoda's people

GOALS: Stylized and non-photorealistic renders in various fantasy styles



KarinaKiev ( ) posted Thu, 23 August 2018 at 3:11 PM · edited Thu, 23 August 2018 at 3:19 PM

Thanks for the nice preview! You ain't a painter in real life, perchance? :D

For a possible solution, please look at your other thread at SM Poser Forum

HTH Karina


ironsoul ( ) posted Thu, 23 August 2018 at 4:11 PM · edited Thu, 23 August 2018 at 4:17 PM

Rough poc script below to see if we're thinking in the same area, putting the user interaction bit to one side at the moment + didn't see Karina's post before doing it so based on original pics

It assumes the Blender node to be changed on each prop is called "CTag" at the moment, this can be changed
Assumes the material with the blender node is active when the script is run
Need to render to see effect at moment


import poser

############################################
# Function returns Node within a shader tree
# that has the given name
############################################
def findNodeInMat( oMat, sName ):

    oFoundNode = None    
    oShaderTree = oMat.ShaderTree()
    oNodeSet =  oShaderTree.Nodes()

    for Node in oNodeSet:
        if Node.Name() == sName:
            oFoundNode = Node
            break

    return oFoundNode

###############################################################
# Copies blender colour nodes from source to destinattion
###############################################################

def CopyInputs(oSource, oDest):
    
    (cRed,cGreen,cBlue) = oSource.InputByInternalName("Input_1").Value()
    oDest.InputByInternalName("Input_1").SetColor(cRed,cGreen,cBlue)
    (cRed,cGreen,cBlue) = oSource.InputByInternalName("Input_2").Value()
    oDest.InputByInternalName("Input_2").SetColor(cRed,cGreen,cBlue)

    return


#####################################################################
# Main
####################################################################
scene = poser.Scene()

scn = poser.Scene()
cMat = scn.CurrentMaterial()

oCopyName = findNodeInMat(cMat,"CTag")
oActorSet = scn.Actors()

for oActor in oActorSet:
    
    if oActor.IsProp():
        oMats = oActor.Materials()
        
        for Mat in oMats:
           
            fNode = findNodeInMat(Mat,"CTag")
            if fNode:
                
                if fNode != oCopyName:
                    CopyInputs(oCopyName,fNode)
                    



ironsoul ( ) posted Fri, 24 August 2018 at 1:08 PM · edited Fri, 24 August 2018 at 1:10 PM

Based on Dimension 3D's " Running Python Scripts in Poser" the following lines in a mt5 file will execute the above code (assuming its saved to a file called matSwap.py) This is outside of my experience so not sure what versions of Poser support this (it worked ok in p11)

{
    version
    {
        number 4
    }
    runPythonScript "Runtime:Python:poserScripts:matSwap:matSwap.py
}

Hope that provides some ideas.



perpetualrevision ( ) posted Fri, 24 August 2018 at 3:06 PM

ironsoul posted at 2:02PM Fri, 24 August 2018 - #4335272

Hope that provides some ideas.

Thank you SO MUCH for doing this! I came back to this thread to post an update about Karina's suggestion on the SM forums and hadn't expected to see an actual script I could try!

I will test it out shortly. So do I need to change the Blender nodes' names to CTag, or should I change CTag in the script to Blender-PaintColor (which is the name I used for all the paint color Blender nodes)?

Thanks again for being so helpful!



TOOLS: MacBook Pro; Poser Pro 11; Cheetah3D; Photoshop CC

FIGURES: S-16 (improved V4 by Karina), M4, K4, Mavka, Toons, and Nursoda's people

GOALS: Stylized and non-photorealistic renders in various fantasy styles



ironsoul ( ) posted Fri, 24 August 2018 at 3:18 PM

Would be easier to change the script to use "Blender-PaintColor". Cheers



KarinaKiev ( ) posted Sat, 25 August 2018 at 12:25 PM · edited Sat, 25 August 2018 at 12:33 PM

@ ironsoul:

What do you think about my solution?

http://sasha-16.forumprofi.de/showthread.php?tid=93&pid=605#pid605

The drawback is that it's still in tkPython, but I don't know any better yet. What do you think?

Cheers! K


ironsoul ( ) posted Sat, 25 August 2018 at 9:07 PM

KarinaKiev posted at 2:49AM Sun, 26 August 2018 - #4335299

@ ironsoul:

What do you think about my solution?

http://sasha-16.forumprofi.de/showthread.php?tid=93&pid=605#pid605

The drawback is that it's still in tkPython, but I don't know any better yet. What do you think?

Cheers! K

I'd never have thought to use output nodes like that, not having to scan through all nodes on every shader tree will make it much quicker.



KarinaKiev ( ) posted Sun, 26 August 2018 at 12:35 PM

That what I intended with this setup. Since I never saw the "Custom_output_" nodes used in any texture I ever saw, so I just tried it and it works.

Fortunam temptare... 😄

K .


perpetualrevision ( ) posted Sun, 26 August 2018 at 7:37 PM

@ironsoul: I just had a chance to try your script, but it doesn't seem to do anything in my scene.

The first time I tried it, I had changed the references to CTag in the script to my custom Blender node name instead (Blender-PaintColor), and when that didn't work I thought maybe I'd messed something up by editing the script.

So I reverted to the original version of the script and changed the Material on an object so that the paint color blender's name was instead CTag. That didn't work either (I tried both launching the MT5 file from the library and running the script from Poser's File menu command).

Just out of curiosity, I then tried running the script on an object with the original Blender-PaintColor name instead of CTag, and I got the error shown below. So the script is doing something, but I don't know enough about Poser Python to debug it! Any thoughts?

IronSoul-ScriptError-screenshot.png



TOOLS: MacBook Pro; Poser Pro 11; Cheetah3D; Photoshop CC

FIGURES: S-16 (improved V4 by Karina), M4, K4, Mavka, Toons, and Nursoda's people

GOALS: Stylized and non-photorealistic renders in various fantasy styles



perpetualrevision ( ) posted Sun, 26 August 2018 at 7:58 PM

Just FYI for anyone following this thread here and not on the SM forum: I'm not able to test out Karina's Batch Color Gadget b/c of the error message shown below (which is something all Poser script writers should probably be aware of).

Karina-ColorScriptError-screenshot.png

But if any Windows users are willing to test the gadget, on their own props are on my "Messy Painter" prop set, please let me know.

If it works for Windows users, I will change all the Materials to use the setup Karina's gadget works with and include info about the gadget in the Readme.

But a.big THANK YOU to both Karina and ironsoul for sharing potential solutions with me!



TOOLS: MacBook Pro; Poser Pro 11; Cheetah3D; Photoshop CC

FIGURES: S-16 (improved V4 by Karina), M4, K4, Mavka, Toons, and Nursoda's people

GOALS: Stylized and non-photorealistic renders in various fantasy styles



KarinaKiev ( ) posted Wed, 29 August 2018 at 12:06 PM · edited Wed, 29 August 2018 at 12:10 PM

Hold out Lady Paintalot! Rescue is near!

Actually, a wxPython script I dangled together the last days. It's not the most elegant one, but it should be OK for now. It should work alike on an MS-Windows-PC AND a MAC.

Still trying to implement some additional features into the script, but since this is my first attempt od a wxPython script, it take some time until I Googled for useful code snippets and made them work.

For more details, look at the SM Poser forum thread

https://forum.smithmicro.com/topic/7939/mat-preset-to-change-only-colors-on-a-blender-node/17#

  • Special thanks to @ironsoul for his code examples:

This is exactly what I need to improve my knowledge, because I can look at thes code and see how it's actually done! Most other "examples" found in the InterWebs are far from useful because they are too abstract.

Thank you ALL for helping us!

Karina


perpetualrevision ( ) posted Fri, 31 August 2018 at 1:38 AM

KarinaKiev posted at 12:09AM Fri, 31 August 2018 - #4335432

Hold out Lady Paintalot! Rescue is near!

Actually, a wxPython script I dangled together the last days. It's not the most elegant one, but it should be OK for now. It should work alike on an MS-Windows-PC AND a MAC.

That's awesome, Karina! Thanks so much for working on this! I look forward to testing it out.

I haven't yet posted my "Messy Painter" freebie set b/c I want to finish up a companion set first ("Messy Fx," w/ lots of blobs, drips, splats, and spills). So I can still fiddle with the Messy Painter props' materials, if need be, so that they'll work with your script.

Again, thank you!



TOOLS: MacBook Pro; Poser Pro 11; Cheetah3D; Photoshop CC

FIGURES: S-16 (improved V4 by Karina), M4, K4, Mavka, Toons, and Nursoda's people

GOALS: Stylized and non-photorealistic renders in various fantasy styles



perpetualrevision ( ) posted Thu, 06 September 2018 at 6:03 PM

Just wanted to post a quick update to let anyone looking for a similar solution know that Karina's Batch Color Gadget works very well for the purpose I described above!

You just have to set up your materials so that the main color is driven by a Simple_Color node that's plugged into a black/0 Ambient channel. The Simple_Color node should also be plugged into whatever part of your shader tree makes the most sense. If I was still using the Blender method I started with, I would've plugged into the Blender inputs. But now I have it plugged into the inputs on a Clouds node that mixes two shades of the color. If I want to change the color on multiple props, I just invoke Karina's gadget, select a new color, and voila, everything has the new color! Very nifty. THANK YOU Karina!!

You can find the Batch Color Gadget on Karina's Sasha-16 forums in this post.

Here's a screenshot of one of my simpler materials to illustrate. (You'll note that I changed the name of the Simple_Color node, but the script still works!)

ColorGadgetInfo-PaintStrip.png



TOOLS: MacBook Pro; Poser Pro 11; Cheetah3D; Photoshop CC

FIGURES: S-16 (improved V4 by Karina), M4, K4, Mavka, Toons, and Nursoda's people

GOALS: Stylized and non-photorealistic renders in various fantasy styles



KarinaKiev ( ) posted Sat, 08 September 2018 at 2:38 PM · edited Sat, 08 September 2018 at 2:41 PM

Hello all!

I just wanted to add that my script (and the special shader node wiring) was set up like this for the only reason of speed!

Because the script doesn't have to iterate through all shader nodes in a material to find that one relevant node.

However, my script still causes errors on a MAC (but miraculously still works if you click them all away).

I don't have a MAC for testing so I'm dependent on @perpetualrevision's help to fix them.

So if it takes a few more days it's my fault, not @perpetualrevision's!

Please bear with us...

K


perpetualrevision ( ) posted Fri, 14 September 2018 at 8:46 PM

Just in case anyone reading this thread is interested in the "Messy Painter" freebie set, I just uploaded it to ShareCG.

I used scripts by KarinaKiev and IronSoul to set up the materials for this set and a companion "Messy FX" set I'm still finishing up, but neither script is included with the set. Many thanks to both of you for your help!

Here's the final promo image, which got kinda crowded b/c Renderosity only allows one promo image for freebies:

{PR}MessyPainter-Promo1-SideBySide-1200x800.jpg



TOOLS: MacBook Pro; Poser Pro 11; Cheetah3D; Photoshop CC

FIGURES: S-16 (improved V4 by Karina), M4, K4, Mavka, Toons, and Nursoda's people

GOALS: Stylized and non-photorealistic renders in various fantasy styles



KarinaKiev ( ) posted Sun, 23 September 2018 at 11:40 AM

The script to change colours is finally out:

https://sharecg.com/v/92298/view/11/Poser/Karinas-Batch-Colour-Gadget-MR

Thank you again to all who contributed to the making of this tool, especially to @perpetualrevision for having had the initial idea!

Karina


Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.