Self Illum + Alpha

Hello.

We are applying a bake to a new project, but this one includes a set of plants whose foilage is made with opacity maps. If we use an alpha shader, we have no self illumination, while if we use a self illumination shader we have no alpha. Is there a way to either invoke the transparendy of the map or add a self lit channel to the opacity shader?

Current situation:
!(http://filexchange.zerofractal.com/public/alejandro.gonzalez/forums/unity/picture 5.jpg)

You can use a alpha shader that has no lighting…I believe there’s at least one on the wiki just for that purpose. (You can set the brightness of the object with a slider.)

–Eric

Ok, so you want alpha channel for transparency; and an illumination channel somewhere else? That could be done with a small custom shader.

…if you tell where exactly each channel is needed. E.g. is it main texture = RGB color + A transparency; another texture = A illumination or vice versa.

I tested the two shaders available at the wiki with the following result:

AlphaSelfIllum.shader. at first glance normals seemed to be crazy, but I changed the “ZWrite Off” to “ZWrite On” and it was fixed. It seems to work but has issues when dealing with transparent object opaque parts of itself. It laso seems to have issues with transparent object over transparent objects.

UnlitAlpha. This one is much more stable, but the way the transparency is computed (via Alphatest Greater 0.5) makes plants looks simply awful since it turns a nice 8 bit channel to an ugly 1 bit channel. Plus if the channel is premultiplied by, for example, black, the leaves look really bad.

If you want I could upload some screengrabs :slight_smile:

If anyone knows if this two cases are somehow avoidable, even at the cost of extra rendeing cost, please drop me a line.

Thanks,

Try the vegetation shaders from the nature pack, specifically the two-pass shader. As someone from OTEE once wisely said, alpha is hard. :wink: I don’t know if it’s even possible to get 100% perfect results in all circumstances, but the two-pass works pretty well (though I modified it somewhat for my stuff). One pass has zwrite on and one pass has zwrite off, so you mostly avoid the weirdness of parts showing through other parts, and also avoid that “1-bit” cutout look. The downside is that it’s slower, of course.

–Eric