Search - User list
Full Version: transparency fade off for overlapping multi-layer shaders
Root » Technical Discussion » transparency fade off for overlapping multi-layer shaders
deecue
I was wondering if there was a way I could have two overlapping textures fade in to one another on my geometry.

For example, I have a model with a layered surface shader applied. Base layer has texture of an ear and some extended skin areas of the head. The second layer has a texture of the side of the head. I uv pelted around the ear and have the texture applied. Appended a layer sop. Then uv pelted the side of the head and have that texture applied. The two pelts as well as the the two textures overlap eachother.

I'm aware of the different compositing methods for the multi-layer shop (add, subtract, multiply, and over) and those are great. But what i want to be able to do is have the two fade in to each other. Almost like having something that could make the ear texture be at 0% transparency when it meets with the head texture and 100% transparency at the end of the ear texture. And, of course, the same thing happening for the head texture. So that way they would blend nicely in to one another and thus reducing seams. It would also be cool if you could have different methods for the fading (i.e. linear, cubic).

Does this make sense at all? Is there a way to be able to do this? Any thoughts are appreciated.


Thanks,
Dave
JColdrick
You could do it by combining your two shaders into one - of course you'd need to be comfortable with the VOP editor or VEX programming. If you assigned an attribute to your data, say varying from 0 to 1, paint it up from black with a soft edge, then that attribute could be read by your shader to blend between two chunks of code that are mixes - bob's your uncle.

Cheers,

J.C.
Siavash Tehrani
I attempted to do the same thing a while back deecue. I had overlapping UV coordinates, and I was trying to blend the overlapping areas using a black/white ramp texture for the Opacity of the top layer. However that didn't work, and the top material blocked out the bottom one. :?
MichaelC
JColdrick
You could do it by combining your two shaders into one - of course you'd need to be comfortable with the VOP editor or VEX programming. If you assigned an attribute to your data, say varying from 0 to 1, paint it up from black with a soft edge, then that attribute could be read by your shader to blend between two chunks of code that are mixes - bob's your uncle.

Cheers,

J.C.

This is pretty damn slick. I always painted a map to do this. I tried this method out and it works great. You can use whatever sort of blending function you want and provide parameters in the shader for the user to manipulate the attibute after it has been painted. Really cool.

Here's an example (using color mix with the custom attribute as a bias) applied to an ear with 2 sets of overlapping UVs..

http://s91408461.onlinehome.us/ear.hipnc [s91408461.onlinehome.us]
deecue
this is pretty damn neat. really great away to go about it J.C. And very nice solution MichaelC.

I also went ahead and tried to push the same idea in a different way. I wanted to be able to do it with the layered surface shader and didn't want to get Vops involved. I wanted to do this for a few reasons:

One, I wanted to be able to see my textures in the viewport after projecting or pelting them on to my model. This way i could directly paint right on top of them as opposed to guessing where it might be.

Two, I wanted to be able to paint a texture's alpha that is being composited over another. This made more sense to me when dealing with 3+ layers of textures that need to be faded in to one another. Of course with MichaelC's method, we could just keep daisy chaining color mix vops with newly added layers and textures. But this seemed wierd to me because you would be painting the mix bias of one texture with the mix bias of two other textures and so on and so on. And that just got confusing to me for some reason (especially if you got more and more layers). So I thought it would just make more sense to be able to paint away the alpha of one texture that is sitting over another.

And finally three, people that don't know Vops and are happy just with the layered shader can use this method and take advantage of how powerful it really is.

The disadvantage of this way is that as much as i like being able to see my textures as i directly paint them away, it's kind of hard to tell the values i am painting at times. You could just connect the paint sop above the shader to see the values much better and then back down after the projections if you really wanted to though. Also, you can use the infra-red, red-white, and grayscale visualizations while painting, but you have to use the grayscale method when rendering. It's kind of annoying because I like the infra-red. But if i leave it on that, then it turns my texture a tint of red or yellow or green, etc..

Well anyways, I've blabbed on enough already. Mucho thanks JColdrick and MichaelC. Both were great idea's and solutions to this.

Dave


http://studentpages.scad.edu/~dquiru20/paintlayered.hip [studentpages.scad.edu]
deecue
so i was noticing something else with my method. that whole colorization problem when using infra-red that bothered me so much (the visualization colors were tinting my shaders at render time)… well it was actually happening even as grayscale, it just wasn't as noticeable. i don't know why i didn't pick up on the fact that each paint sop was creating another set of Cd attributes.

so to fix any kind of visualization colors affecting the render, i just added an attribute stop to the end and in the delete attribute param. I put “ Cd* ”. This got rid of any coloring information that the paint sops were creating. And now i can use infra-red visualization and my renders still look good.
JColdrick
Yup I forgot to mention that you'll probably need to “manage” your attributes, whatever they may be…

Also worth noting that with the custom attribute approach you could have as many “shaders” as you want - each with their own attribute that can be blended any way you want. However yes, you'd need to get happy with the Vex editor for this. I strongly recommend it, when you find the time - it's an amazingly powerful and fast way to build shaders once you get past the basics…

Glad you got it working…

Cheers,

J.C.
deecue
However yes, you'd need to get happy with the Vex editor for this. I strongly recommend it, when you find the time - it's an amazingly powerful and fast way to build shaders once you get past the basics…

I think you made a good point about this and I started thinking about how great it would be if I could paint blend my procedural shaders with some texture ones. But I'm having some trouble figuring it out. I know VOPs basics and can create some procedural stuff as well as just a simple texture shader, but I am far from knowing what every vop node does and how it can be used.

I'm still sticking with the idea of blending the alpha of one shader and another and can't get it. I want to be able to have multiple shaders applied to the model seperated by shading layers but I can't even figure that out. (can you have two different shaders that are applied to the same group?) Right now I have just created two simple texture shaders and am trying to control their opacity with the paint (i couldn't get the surface alpha to do anything).

Maybe you guys could tell me what I'm doing wrong and point me in the right direction? I like MichaelC's way of using the color mix but I'm just wondering if i can create a number of different shaders in vops, and then blend their alphas with the paint.

Thanks again,

Dave
deecue
forgot to post the file to explain my above post:

http://studentpages.scad.edu/~dquiru20/vops_alpha.hip [studentpages.scad.edu]
JColdrick
Not near houdini right now but I'll answer your post blindly…

First off, wih VOPs, don't try to run before walking. There's some basic tutorials that should get you started, and a good thing to do after that is examine the sample materials that ship with Houdini - look under the Materials tab when you're in a VOP shader and add one. Many of them have blue text labels which means you can select them and hit enter, and go inside to see a sample shader. You should really look at this stuff before trying to make a combo procedural/tmap shader utilizing user-supplied attributes…that's an intermediate topic. Not trying to discourage you - just the opposite! It's a great thing to learn.

The other problem with multiple shaders…in the end a given poly needs to have a colour - that colour is determined by a number of things but the shader's obviously a big part. The problem is that at some point, on either the object level or in the SOP level with a Shader SOP, you need to assign a given shader to that poly. When you use the Shader SOP you're actually assigning an attribute - and that attribute is a shader string(well, a pointer to one prob). Since only the renderer can interpret what that shader will do at a given point, it's not known in houdini before the render, so you can't really “blend” them together.

What *will* work is to have the shader sort of thing mentioned before, but it all needs to be inside one shader. So really it shouldn't make any difference to you - just control the layering in the Uber-shader using whatever mechinism you prefer(attributes created mathematically, painted attributes, etc.).

Painting the alpha is fine but don't forget that's the *alpha* of the object. You'll probably need to manipulate that stuff so that you create your own attribute - either that or your shader needs to utilize the alpha and not let it affect things like transparency. Again, this all requires having more control over the actual shader than whay you'd get with using the pre-existing vex shaders…

Again - do a little Vopness research - and also a little reading about attributes(reading the help on the various attribute SOPs) would make it click…

Cheers,

J.C.
deecue
but it all needs to be inside one shader.

yea, this was definately wrong with my approach…

in the Uber-shader

best - word - ever

Not trying to discourage you - just the opposite! It's a great thing to learn.

This has definately been a huge encouragement. I can't thank you enough for all your advice..

Dave
Wren
This has been an amazing thread… Thank you as well.
deecue
i'm just gonna add this here since we were kinda talking about vops…

if im just wanting to composite something over an other in vops, how do i do that? i know there are the add, multiply, and subtract vops that will allow me to composite them in those methods (as well as the color mix vop for rgb mixing), but what if i don't want any layer interaction? (just like the composite - over parameter in the vex layered surface shader).

It seems like this should be simple enough, but i can't figure it out.

any help is appreciated…
MichaelC
Can't see the forest for the trees , huh? You'd use the Color Mix VOP, pretty much just like what was demonstrated in this thread.

The bottom layer goes into the primary input of colormix
The top layer gets premultiplied by it's alpha and the product goes into colormix secondary.
The alpha then goes into bias of colormix.
puma.snyder
there is a composite vop at odforce http://www.odforce.net/codex/shaders.php?type=surface [odforce.net]
deecue
ohhh..god that makes complete sense…:roll:

i was always in this mindframe that the color mix vop was just used to “blend” two colors/textures together based on the bias slider as opposed to feeding the alpha channel in to the bias which will just composite them together (duh ops: ). thanks MichaelC, i completely just passed right over that.

and thanks for the link puma.snyder. I wasn't aware of that over at odforce.
Siavash Tehrani
Sorry for resurrecting such an old topic, but I have a little problem. ops:
I'm using the method that JC described and Michael put up in the example file. Everything works great, and it's really nice to be able to paint masks directly onto the geometry, but, when I render as subdivision surfaces mantra quits halfway through, which also causes mplay to hang. Works fine when I render as polys. Does this happen to anyone else? I'm still using 6.1.149 so maybe this is something that's been resolved in newer versions?
miguel
DaJuice, same thing on 6.5.53 on windows. I tried it on MichaelC's scene.
Siavash Tehrani
Hmmn, thank you miguel.
deecue
yea, that file def doesn't like poly's as subd's at render time.. but if you throw down a subd sop at the end of the model and render from there it works fine. plus, i opened up some old tests with painting transparency i found on my machine and they all worked fine with poly's as subd's rendering.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB