PDA

View Full Version : connect one shader to many materials?


Roham
07-28-2012, 01:55 PM
Hi all,

Is there any chance we could have a shader (ie: Phong), shared between two different materials?

For example, we have a watch model and there are so many metal parts and many of them are the same kind of metal but with different displacement or bumps. Is there any way to connect the same shader to many materials?

Thanks,

toonafish
07-28-2012, 05:32 PM
I suspect the easiest way would be to use weightmaps on a single shader, instead of separate cluster materials. I think there's some scripts available to automatically convert your clusters to weightmaps.

Roham
07-28-2012, 06:36 PM
Thanks for your reply my friend, but my objects are not merged.
Suppose, we have 100 metal objects animated and we want them to have the same shader with different displacement maps. Is there any way to do this?

Stoehr
07-28-2012, 07:41 PM
Each object that has a new displacement map will require a new material, as you've discovered, and to change the phong in each material, to be the same, you'll need to make changes through scripting. Find the phong nodes, by name or by material, and make changes with the script. Hope that helps. I'd recommend making phong preset, and simply load a preset to all phongs that need it to your scene with the script. If I recall my scripting correctly, you're looking for the material source.

For example, this little thing would find the first node in the light material:


//add a point light
var oLight = oRoot.AddLight("Point", false, "auto_atten_light");
var oLightShader = oLight.Shaders(0);

fLightDefaults(oLightShader);

function fLightDefaults(oShader)
{
oShader.shadow = true;
oShader.factor = 0.0;
oShader.intensity = 1.0;
oShader.atten = true;
}

I would also Google search for "Bernard Lebel and XSI materials". He's particularly good at this stuff.

toonafish
07-29-2012, 10:16 AM
You could also make the material of every object that needs a different displacement map unique, then select all objects that should have the same Phong shader properties, open the Phong PPG ( F3 ) and change the shader settings of all all selected objects simultaneously.

Or...you could use an override for every displacement and bump map that needs different settings. You could either create a group for every object that needs a different displacement map and add the override to the group, or you could create a separate partition for each object and add the override to the partition.

And of course you could do it the other way around, make all materials unique, add all objects that need to share the same Phong shader to a group or partition, create an override for the surface, and plug in a Phong shader.

I suspect the latter to be the easiest solution in your situation.

Roham
07-29-2012, 12:42 PM
Thanks guys,

I would prefer the last solution cause I'm not experienced with Softimage. Is there a chance you could create a simple scene, please?

Thanks again,

toonafish
07-29-2012, 01:10 PM
Sure, I've put a simple scene in dropbox, with a ball and a torus having different displacement settings but sharing a phong shader by using a surface override in a partition : https://dl.dropbox.com/u/4271217/Shared_Shader_v001.rar

There's a "Ball and Torus Partition" in the Default Pass with the override.

Here's a link to a wiki page about using overrides with groups, a partition is basically the same as a group in SI: http://softimage.wiki.softimage.com/xsidocs/properties_OverridingProperties.htm

gustavoeb
07-29-2012, 08:08 PM
IMHO the easiest way (and the standard way really) to doing this in softimage would be the following: http://download.autodesk.com/global/docs/softimage2013/en_us/userguide/files/weightmaps_TextureMaps.htm#

You apply a texture map to each one of your obects, with whatever texture you want. Then you use a texturemap lookup in your render tree and it will read whatever texture is assigned to each object.
Although not being able to instance parts of a material in another material is a real bummer, in this specific situation I do find the texturemap solution very elegant.

Tell me if you the documentaion was enough to get you going, if not Ill try to post a screenshot...

Roham
07-30-2012, 08:17 AM
Sure, I've put a simple scene in dropbox, with a ball and a torus having different displacement settings but sharing a phong shader by using a surface override in a partition : https://dl.dropbox.com/u/4271217/Shared_Shader_v001.rar

There's a "Ball and Torus Partition" in the Default Pass with the override.

Here's a link to a wiki page about using overrides with groups, a partition is basically the same as a group in SI: http://softimage.wiki.softimage.com/xsidocs/properties_OverridingProperties.htm

Thanks a lot my friend. You're the best.

Roham
07-30-2012, 08:21 AM
IMHO the easiest way (and the standard way really) to doing this in softimage would be the following: http://download.autodesk.com/global/docs/softimage2013/en_us/userguide/files/weightmaps_TextureMaps.htm#

You apply a texture map to each one of your obects, with whatever texture you want. Then you use a texturemap lookup in your render tree and it will read whatever texture is assigned to each object.
Although not being able to instance parts of a material in another material is a real bummer, in this specific situation I do find the texturemap solution very elegant.

Tell me if you the documentaion was enough to get you going, if not Ill try to post a screenshot...

Thanks for your answer. toonafish's way already works great but I'm curious to know your way too. I don't understand texturemap lookup. would you post a simple scene please? I really appreciate it.

gustavoeb
07-30-2012, 03:03 PM
here it is:

https://dl.dropbox.com/u/39280733/lookup.JPG

Ohmanoggin
07-30-2012, 07:19 PM
Caffeineabuse has a tutorial showing how to use multiple textures on a single material using map lookup.

http://caffeineabuse.blogspot.com/2011/05/using-individual-textures-in-shared.html

Hope this helps,
Ohmanoggin

NNois
07-31-2012, 09:49 AM
why not using material overides, it works very well and you can share your shader with all your objects. Just use an overide on changing parts

Roham
08-01-2012, 11:25 AM
Thank you all guys :)

ViCoX
08-02-2012, 06:27 PM
gustavoeb (http://forums.cgsociety.org/member.php?u=333079) thats clever : ) Thanks for the tip!

CGTalk Moderation
08-02-2012, 06:27 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.