Multi shaders or textures in one mesh/object

Multi shaders or textures in one mesh/object

Hi,
Here a little trick to show you how we can connect multiple shaders or texture on one mesh/object.
I use this technique in production, when the animation guy give me one mesh with a cache.

The scene :
A chair, with 5 shaders (red, blue, yellow, green, white).

powered by WordPress Multibox Plugin v1.3.5

UVs :

We have 5 shaders, so, we must set all UV in 5 « UV space » in the same UVset. See the image, you will understand :

powered by WordPress Multibox Plugin v1.3.5

To move you uv, you can use this mel :

polyEditUV -u 0 -v -1 for UV space U 0 and V -1 (red here)

If you want move you UV like « blue » space, you must select your UV and write : polyEditUV -u -1 -v -1

Yellow : polyEditUV -u -1 -v 0

etc etc…

After that, combine all meshs in one mesh.

Build your « one » shader :

We will start to merge the « white » shader and the « yellow » shader.

To do this, we use the « blendColor » utility.

powered by WordPress Multibox Plugin v1.3.5

When the blender attribut in the blendColor utility is set to 1, we have the color 1. When is set to 0, we have the color 2.

Create a ramp with one white color, and a dark default color.

powered by WordPress Multibox Plugin v1.3.5

Now select the « place2dTexture » from your ramp, uncheck wrap U, unckeck wrap V.

In the translate frame attribut, set the same value like you UV space for every shaders.

For example, for the « yellow shader », we set the value to -1 and 0.

powered by WordPress Multibox Plugin v1.3.5

When we do this, we have a white color in the -1,  0 UV space, and a black color in other UV space.

powered by WordPress Multibox Plugin v1.3.5

Now it is simple, connect the outColorR (or B or G) of the ramp to blender attribut of the blendColors.

And connect the output of the blendColors to a surfaceShader. Apply the surface shader in your object, here, my chair.

powered by WordPress Multibox Plugin v1.3.5

If your render your image, you will have this :

powered by WordPress Multibox Plugin v1.3.5

So, connect your « yellow » shader in the red slot (color 1) on the blendColor utility.

Now in the blue slot, you will connect and other blendColor utility (blendColor2).

Now we must apply the green shader.

Create a white ramp, default color to black, uncheck wrap U, wrap V, and set the value of the translate frame to 1, -1.

powered by WordPress Multibox Plugin v1.3.5

Like before, connect this ramp on the blender attribut of the blendColor2.

In the color 1, connect your green shader.

Your will have this :

powered by WordPress Multibox Plugin v1.3.5

powered by WordPress Multibox Plugin v1.3.5

Now continu with the same logic on all UV space and you will have this :

powered by WordPress Multibox Plugin v1.3.5

powered by WordPress Multibox Plugin v1.3.5

Enjoy !

This trick work also for texture map.

Téléchargement multi shaders Version 1

Share on TumblrShare on TwitterShare via email

Comments

Hi Damien, Great.

admin

Thank you ytsejam.

It a little like in this tutorial:
http://features.cgsociety.org/story_custom.php?story_id=4006&page=2
http://features.cgsociety.org/stories/2007_04/night_elf/aft_03.jpg

Another technique I use sometime:

Instead of have many uv spaces, I put all the uv in « many rectangle » in the « standard » uv space and just change the uv coord in the place2Dtexture. This is usefull because it permit to have rectangular textures. :)

Glim

Elle est trop bien cette astuce !!!

Post you comment here





Deex

Le blog de Damien BATAILLE