Hey everyone,
Often people wonder how to add specific textures to specific objects without use of separate materials. Or how to get specific textures all in one render pass, i.e. extra texture pass that contains multiple various textures. Here is a basic tutorial on how to set this up. I my self just recently came across the need of this, and coming from max where they have multi sub object/multi sub texture which pretty much does this kind of thing, in maya we have nothing like that.
Now there is an attribute in vray which allows user to specify where to apply which texture.
Lets say we create a simple scene, 3 spheres and one plane. Each sphere should get its own texture color, but we will only use one vray material and assign it to everything.
For each object that you wish to have custom texture assigned you must add a specific vray attribute called vray user scalar to the shape node. Here is mel command below:
addAttr -ln "vrayUserScalar_typeSwitch" -at double |pSphere3|pSphereShape3;
Note that "vrayUserScalar" must be named exactly like that, after one underscore, the custom name can be used, I used "typeSwitch", you can use whatever, but you must not use any underscores in your name otherwise it will not work.
At each custom texture you must enter a vray user scalar value, for my case its:
- 1 ramp (sphere1)
- 2 checker (sphere2)
- 3 noise (sphere3)
- 4 red ramp (plane)
The most complicated part is to set up the shader. Now we connect the texture to a condition node. We create a vrayUserScalar texture. Set the name of the attribute to your custom name (in my case typeSwitch). Set the default value to 0.0 (returns black in areas where there is no texture)
Connect the vray user scalar texture to the condition's first term. Set the second term to be the same number as you specified in your object's shape node. For sphere 1, ramp, user scalar is 1, so in the condition node we will set operation as "equal", and connect the ramp to color if true. Set the color if false to 0,0,0, otherwise it will render grey in areas where this map is not true.
Repeat the operation for as many textures/objects you wish to have.
Now I create layered texture and add all the condition nodes into it. I am ready to connect it to the diffuse channel of my shader as well as my vray extra texture.
Thats it.
A small wish. Vlado it would be awesome to have this kind of setup as a single vray attribute which user can assign to any maya texture, much like the gamma/filter option right now. Just a user scalar value, to remove the need for condition node.
And a scene file.
vr_usr_scalar.zip
Often people wonder how to add specific textures to specific objects without use of separate materials. Or how to get specific textures all in one render pass, i.e. extra texture pass that contains multiple various textures. Here is a basic tutorial on how to set this up. I my self just recently came across the need of this, and coming from max where they have multi sub object/multi sub texture which pretty much does this kind of thing, in maya we have nothing like that.
Now there is an attribute in vray which allows user to specify where to apply which texture.
Lets say we create a simple scene, 3 spheres and one plane. Each sphere should get its own texture color, but we will only use one vray material and assign it to everything.
For each object that you wish to have custom texture assigned you must add a specific vray attribute called vray user scalar to the shape node. Here is mel command below:
addAttr -ln "vrayUserScalar_typeSwitch" -at double |pSphere3|pSphereShape3;
Note that "vrayUserScalar" must be named exactly like that, after one underscore, the custom name can be used, I used "typeSwitch", you can use whatever, but you must not use any underscores in your name otherwise it will not work.
At each custom texture you must enter a vray user scalar value, for my case its:
- 1 ramp (sphere1)
- 2 checker (sphere2)
- 3 noise (sphere3)
- 4 red ramp (plane)
The most complicated part is to set up the shader. Now we connect the texture to a condition node. We create a vrayUserScalar texture. Set the name of the attribute to your custom name (in my case typeSwitch). Set the default value to 0.0 (returns black in areas where there is no texture)
Connect the vray user scalar texture to the condition's first term. Set the second term to be the same number as you specified in your object's shape node. For sphere 1, ramp, user scalar is 1, so in the condition node we will set operation as "equal", and connect the ramp to color if true. Set the color if false to 0,0,0, otherwise it will render grey in areas where this map is not true.
Repeat the operation for as many textures/objects you wish to have.
Now I create layered texture and add all the condition nodes into it. I am ready to connect it to the diffuse channel of my shader as well as my vray extra texture.
Thats it.
A small wish. Vlado it would be awesome to have this kind of setup as a single vray attribute which user can assign to any maya texture, much like the gamma/filter option right now. Just a user scalar value, to remove the need for condition node.
And a scene file.
vr_usr_scalar.zip
Comment