For optimization purpose, I’m trying to build a shader that would do Self Illumination + texturing (so 2 textures limit would be reached), and that additionally would create transparency based on a particular color in the lightmap texture.
For example, color #785634 would render its mainTex to alpha 0.5
Is it possible ?
This feature would be actually vital for iPhone environment rendering, as transparency is needed in most modern scenes (glass, water, etc), coupled with selfillum for performance saving. But the 2 textures shader limit puts a brake on it.
The solution would be to use a RGBA mainTex, but that would result in huge memory allocations, so that particular color solution would be perfect.
I won’t be able to be in front of my computer until tomorrow, but it’s just the Illum-VertexLit Shader in this link.
I was thinking the same as you when I downloaded it, but still tried, and bam it works.
In fact, the illum is different from the lightmap as it doesn’t use color, but alpha map.
So I just put my white lights on a transparent background in a PNG, import it under the self illum texture, and job’s done.
I tested it in the editor, with different directional light intensities, and then without the self illum map. Got it on a scene with window lit buildings and neons, coupled with a glass texture on a shop.
Everything works perfectly, even on iPhone.
Ok, that looks like it should work. I’d forgotten that there would only be one pass. If you did the same thing with a pixel shader, you’d get strange looking lighting.
In fact, the built-in shader has two passes (ambient + vertex lights), but I strippped it to one (vertex lights).
I’m a real newbie in term of shaders, so I can’t seize how much pixel light could enhance visuals. But as I see on the iPhone screen, there’s not much that difference between pixel and vertex lightings.
On another hand, I wish we could use CG with iPhone shaders, because having control over unlight zones would be cool. Actually, it puts too much black, unless we use several lights or some emission. But emission is not so elegant
The built-in shader only uses one pass. It has two different passes defined, but one is used when there are pixel lights or no lights, and the other is used when there are vertex lights.