Hello there. I have a question for those vex shader writers out there.
Im writting a shader and I need to make it mutli-layered (like the one that ships with houdini). How do I go about implementing that in vex code.
my first layer will be applied with a
texture (“layer01.tx”,s,t); ## .
how do I apply the second layer? according to the manuals a layer sop will turn s and t into s2 t2.. do i just use those to index my texture,
texture(“layer02.tx”,s2,t2);
???
your help is greatly appreciated.
RCortes
multilayered vex shader
9734 14 3- rcortes
- Member
- 33 posts
- Joined: July 2005
- Offline
- old_school
- Staff
- 2540 posts
- Joined: July 2005
- Offline
First you can trivially add or multiply the two color vectors directly with float scales.
You can use the lerp() or smooth() functions to combine two different layers together with more control than simply adding or multiplying the layers together. lerp() stands for linear interpolation while smooth does a nice ease-in and ease-out at the start and end of the channels. The two layers can be floats or vectors (color for example).
lerp( value1, value2, amount)
smooth( value1, value2, amount)
smooth( value1, value2, amount, rolloff)
You could even do your texture look-ups right in the lerp() like:
float mix = 0.5;
vector clr = 0;
clr = lerp( texture (“layer01.tx”,s,t), texture (“layer02.tx”,s,t), mix);
If you want to mix several layers together, then you can use one of the spline functions: cspline(), ckspline(), lspline(), lkspline().
-jeff
You can use the lerp() or smooth() functions to combine two different layers together with more control than simply adding or multiplying the layers together. lerp() stands for linear interpolation while smooth does a nice ease-in and ease-out at the start and end of the channels. The two layers can be floats or vectors (color for example).
lerp( value1, value2, amount)
smooth( value1, value2, amount)
smooth( value1, value2, amount, rolloff)
You could even do your texture look-ups right in the lerp() like:
float mix = 0.5;
vector clr = 0;
clr = lerp( texture (“layer01.tx”,s,t), texture (“layer02.tx”,s,t), mix);
If you want to mix several layers together, then you can use one of the spline functions: cspline(), ckspline(), lspline(), lkspline().
-jeff
There's at least one school like the old school!
- rcortes
- Member
- 33 posts
- Joined: July 2005
- Offline
That sounds good, but i think i didnt get m point across right.. sorry about that..
what I need to do is use a DIFERENT uv projection or coordinates for each of the layers, for instance to add a very detailed tatoo on a character that already has a base layer uv.
My question still remains “ how do I make my shader read the UV coords from layer a, b,c,…etc. ”?
Thanks a lot.. it was still very helpfull
Cheers
RCortes
what I need to do is use a DIFERENT uv projection or coordinates for each of the layers, for instance to add a very detailed tatoo on a character that already has a base layer uv.
My question still remains “ how do I make my shader read the UV coords from layer a, b,c,…etc. ”?
Thanks a lot.. it was still very helpfull
Cheers
RCortes
- JColdrick
- Member
- 4140 posts
- Joined: July 2005
- Offline
- rcortes
- Member
- 33 posts
- Joined: July 2005
- Offline
- muigoan
- Member
- 19 posts
- Joined: July 2005
- Offline
Hello there,
I have am new to Houdini and have been very interested about this thread. Actually I have tried to layer shaders but rather do it it with Vex shaders (built with vex builder) rather than texture shaders.
I am having a hell of a time figuring out how to overlap one home written vex shader with alpha channel over another home written vex shader (vex plastic like shader).
Would you have any clues about how to make this? thanks a lot for your help.
I have am new to Houdini and have been very interested about this thread. Actually I have tried to layer shaders but rather do it it with Vex shaders (built with vex builder) rather than texture shaders.
I am having a hell of a time figuring out how to overlap one home written vex shader with alpha channel over another home written vex shader (vex plastic like shader).
Would you have any clues about how to make this? thanks a lot for your help.
- MichaelC
- Member
- 344 posts
- Joined: July 2005
- Offline
I'm not sure that it's the “right” way to do it, but to layer shaders that I've written in VEX I just write a whole new shader that's a combination of the two using lerp or smoth as described above. If you want to go the easy route put the two three or however many shaders to you want to layer into SHOPS.
Right click on each shader and select “Create new VOP Type”
Go into VOPS and create a new surface shader VOP net.
Inside the VOP net lay down the VOPS you created from the shaders.
Use a daisy chan of Color Mix VOPs with biases or Switches or whatever custom functions you want to mix between as many shaders as you want.
Hook up parameters for whatever inputs you want in the shader.
Create a new shop.
That's pretty much it.
With Alpha, if you want to use an alpha to layer the shaders, use the alpha as a bias to the ColorMix VOP, otherwise if you are speaking as alpha dor the whole shader, you'd just pipe it into the output VOP as usual.
Right click on each shader and select “Create new VOP Type”
Go into VOPS and create a new surface shader VOP net.
Inside the VOP net lay down the VOPS you created from the shaders.
Use a daisy chan of Color Mix VOPs with biases or Switches or whatever custom functions you want to mix between as many shaders as you want.
Hook up parameters for whatever inputs you want in the shader.
Create a new shop.
That's pretty much it.
With Alpha, if you want to use an alpha to layer the shaders, use the alpha as a bias to the ColorMix VOP, otherwise if you are speaking as alpha dor the whole shader, you'd just pipe it into the output VOP as usual.
- muigoan
- Member
- 19 posts
- Joined: July 2005
- Offline
actually, this is is the sop network i have made:
box
|
uvproject1
|
shop1
|
layer2
|
uvproject2
|
shop2
The final render seems to ignore the first layer shader though there's an alpha channel in the second shader. It seems like like the second shader can't see the first layer's colour…
I can't figure out what's wrong about this network…
would you have any clue?
thanks again
box
|
uvproject1
|
shop1
|
layer2
|
uvproject2
|
shop2
The final render seems to ignore the first layer shader though there's an alpha channel in the second shader. It seems like like the second shader can't see the first layer's colour…
I can't figure out what's wrong about this network…
would you have any clue?
thanks again
- edward
- Member
- 7734 posts
- Joined: July 2005
- Offline
- muigoan
- Member
- 19 posts
- Joined: July 2005
- Offline
- edward
- Member
- 7734 posts
- Joined: July 2005
- Offline
- muigoan
- Member
- 19 posts
- Joined: July 2005
- Offline
- edward
- Member
- 7734 posts
- Joined: July 2005
- Offline
- MichaelC
- Member
- 344 posts
- Joined: July 2005
- Offline
Take a look at this file. It has two simple shaders created as VOP Nets, and a third Surface Shader VOP Net that layers the two using the Opacity of one of the shaders as a mask.. The object has two sets of UVs and each shader uses a different set.
All you have to do is right click on your shader VOP Nets, save them as new VOP types, bring the new VOP types into a new surface shader VOP net and wire them up with a color mix operator. You could even copy and paste both shader VOP Nets into a new VOP net if you wanted.
This example is really simple, but you can do anything you want.
http://s91408461.onlinehome.us/layered.hipnc [s91408461.onlinehome.us]
All you have to do is right click on your shader VOP Nets, save them as new VOP types, bring the new VOP types into a new surface shader VOP net and wire them up with a color mix operator. You could even copy and paste both shader VOP Nets into a new VOP net if you wanted.
This example is really simple, but you can do anything you want.
http://s91408461.onlinehome.us/layered.hipnc [s91408461.onlinehome.us]
- muigoan
- Member
- 19 posts
- Joined: July 2005
- Offline
-
- Quick Links