Jump to content

Set Material's Diffuse Color to Object Wire Color?


Kirsten Zirngibl
 Share

Recommended Posts

I'm working on a 3DS Max 2017/Vray 3.6 project with hundreds of objects, each with a unique wire color. I want to apply a single material to all of them such that its diffuse color is whatever that specific object's wire color is.

 

This was possible in Mental Ray, via the object color shader, but I'm not finding it in Vray.

 

Here is an example of applying a metallic material to everything in the scene via Mental Ray while using wire color (bottommost image).

 

 

 

I found and fixed a script that allows you to generate a Vray material for each object with its wire color as diffuse. However, it doesn't really do what I'm asking because now each object has a separate Vray material. The whole idea is to use one material (and one I already have in my library) to apply to all the objects at once...

 

I'll put it in here in case anyone if it's helpful to anyone stumbling on this thread, though:

objs = selectByName title:"Select the objects you want to create a VRay material for"
for obj in objs do (
newMat = VRayMtl()
newMat.diffuse = obj.wirecolor
obj.material = newMat  
)

Really hope there's a way to do this. It's practically a necessity if I'm to stick with Vray for this type of personal work. Thanks!

Edited by kirstenzirngibl
Link to comment
Share on other sites

  • 2 weeks later...

1) Add a single "VRayMtl" to all your objects

2) In the diffuse slot, stick a "VRayUserColor"

3) In the Attribute name, add "diffuse_col_from_wire"

don't add the quotation marks as part of the attribute name, just the name

4) Select all the objects you want the script to affect

5) Run this script:

 

 

for obj in selection do
(
   dcfw = (color (obj.wirecolor.r/255)(obj.wirecolor.g/255)(obj.wirecolor.b/255))
   setUserProp obj "\ndiffuse_col_from_wire" ((dcfw.r as string) + "," + (dcfw.g as string) + "," + (dcfw.b as string))
) 

click render and have fun

Link to comment
Share on other sites

This works beautifully, so many thanks, Morné! I knew there had to be some way to do this...

 

 

I see "diffuse_col_from_wire = 0.443137,0.529412,0.0235294" in the User Defined Object Properties field for one of the objects I ran the script on. Multiplying those decimals by 255 yields the wire color. Nifty!

Edited by kirstenzirngibl
Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...