Static Batching and Custom Lighting

When I use a custom lighting model in a surface shader it seems to break static batching, no matter how simple that lighting model is (ie. I just return the albedo directly with no processing). Is this expected behavior? Is there something that needs to be done in the shader to fix up batching?

My test was to take a default shader and just add the custom lighting code. Worked before, as soon as I added:

half4 LightingSimpleLambertAlph (SurfaceOutput s, half3 lightDir, half atten) {
	half4 c;
	c.rgb = s.Albedo;
	c.a = s.Alpha;
	return c;
	}

It stopped working.

Thanks

Stephen

I take it the same material is applied to all the objects that are to be statically batched?

Yes. As I mentioned, by looking at the stats, I can see that switching between Cutout/Diffuse and this slight alteration of that shader results in far fewer meshes batching.

Sorry, does no one have any info on this? Is there another forum I should be asking this question in?

please create bug report with repro case and post case number here for reference

Thanks for the response, bug logged Case 533961

Hopefully it gives you the information you need to investigate.

well, it works for me - thats why i was asking for repro project not just shader in question

Sorry, I didn’t see project in the request. I will file a new bug with a project that repros on my end. FWIW, with the shader I sent I was seeing half the number of objects batched compared to the standard Cutout->Diffuse.

OK, I have added a new bug with a project attached, Case 535322. Sorry it took a while, but hopefully this will demonstrate what I am seeing. Thanks!

oh i see - it is deferred rendering that is to blame [if you change to forward everything just works] :wink:
i’ll poke people responsible no worries

Great Alexey, thanks for the quick response!