multilayered vex shader

   9734   14   3
User Avatar
Member
33 posts
Joined: July 2005
Offline
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
Rudy Cortes
TDChannel [tdchannel.com]
User Avatar
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
There's at least one school like the old school!
User Avatar
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
Rudy Cortes
TDChannel [tdchannel.com]
User Avatar
Member
4140 posts
Joined: July 2005
Offline
Use the Shading Layer Parameter VOP…set it to UV coordinates, and “Attribute Layer” will control which layer you're referencing. It will look for those incoming attributes…use one VOP for each layer you're grabbing. “1” is for “uv”, “2” is for “uv2”, etc.

Cheers,

J.C.
John Coldrick
User Avatar
Member
33 posts
Joined: July 2005
Offline
I had figured it out already, but as usually you are right John C. That is exactly what I did..

got to go now… I got shaders to write.

cheers

rcortes
Rudy Cortes
TDChannel [tdchannel.com]
User Avatar
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.
User Avatar
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.
User Avatar
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
User Avatar
Member
7734 posts
Joined: July 2005
Offline
Your network should look like this:
box
|
uvproject1
|
layer2 (Current Layer set to 2)
|
uvproject2
|
shader (assign VEX Layered Surface SHOP)
User Avatar
Member
19 posts
Joined: July 2005
Offline
User Avatar
Member
7734 posts
Joined: July 2005
Offline
No, you assign only ONE shader (eg. a VEX Layered Surface SHOP) . In that SHOP, you can specify different texture maps for each of your layers.
User Avatar
Member
19 posts
Joined: July 2005
Offline
hmm, the thing is that i am trying to layer VEX shaders (done with VEX builder). Is there a SHOP that can do that since VEX layered Surface only layers Texture maps?
User Avatar
Member
7734 posts
Joined: July 2005
Offline
You should make the equivalent of something like the VEX Layered Surface Shader. ie. One SHOP that can take multiple layers. Then use the shadinglayer vop to access them individually.
User Avatar
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]


User Avatar
Member
19 posts
Joined: July 2005
Offline
wow, thanks a lot for the example, It's exactly what i was looking for.
I haven't studied it yet, i can't wait! Thanks a lot to the replies and hints.
  • Quick Links