Why could we have more than one forwardbase pass in a shader

Why could we have more than one forwardbase pass in a SubShader,
and they will all be executed,
could we have more than one ForwardAdd or PrePass in a SubShader?

Yes, you could have multiple passes of the same type, and they will all be executed.

However I’m not sure why you would want that - it’s almost always more efficient to do stuff in one pass compared to multiple passes. Except if you’re trying to do something really exotic.

Thank you for your answer,
Yes , it means more trick available for a new bie :slight_smile:

My first thought would be depth priming.

But apparently,Unity dont set up Light inform frequently for each time send a pass to GPU, ie, it does not clear up used light data after a pass has been executed, it just set up light data before a pass will be executed,but dont clear when finished! so when it comes to lighting caculation, i dont think multiple passes of the same type is reliable when out of Unity’s build in process

Are you expecting light information to be different between two passes with the same tag?

Not exaclty,
Ie : I delete a light, but it’s inform is still there, In the array ,not updated, Unitl the next time Unity prepare data for the same type pass before send data to GPU, so the situation could forsee, but sometimes when comes to many different type passes, this could get you messed up,
especially when you dont work with surface shader, write your own vertex+fragment shader

There’s zero difference between a surface shader and a hand-written shader that does exactly the same thing.

Anyway, if you delete a light, Unity should not set it’s information to the shader. If you see other behavior, please file a bug with a repro project.

There no bug there, Sorry about my poor expression,
My mean is A Light First exist, in an array like unity_LightPosition[3] ,
and late change it, so it moved to unity_LightPosition[2],if there is no another light has been set to unity_LightPosition[3], the old light is still there,maybe the unity_LightPosition[ ].w component or correspond unity_LightColor[ ] declares it is a invalid data
It would be a little confusion for a guy who dont use func like ShadeVertexLights(),directly access the lights in array,

After all there is still a big question confused me, about unity’s cache,
It is delivered herehttp://forum.unity3d.com/threads/170662-One-mat-applied-twice-with-porblem-happens

Maybe there is a lot place available to cache things for performance,
So it could be a big maze when data is cahced, when is not,
Or maybe all cache is designed works perfectly fine, but something unexcepted happens, like Unity crashed,so the links broken
and then it lead to something like link i provide
and some times the cache still streched to Build

so the problem is how do we know ,or could we disable the cache mechanism in the future edition
or tell us how does Unity’s cache works, so when problem happens , we could have a good guess to exclude possible cause

Sorry about my boresome expression :slight_smile:

unty_LightPosition/Color array will be filled with lights starting with the brightest one. If there are no more lights, the rest of the unity_LightColor array will be set to black color.