R147 Instancing with Shadows

There seems to have been an update in r147 that has caused shadows to stop working for my instanced meshes. I believe it is related to customDepthMaterial. This seems to no longer be needed for meshes that have materials with alpha.

I do not use InstanceMesh but extend the shaders. I have been using this up through 146. Now this no longer works.

mesh.customDepthMaterial = new THREE.MeshDepthMaterial( {

	depthPacking: THREE.RGBADepthPacking,
	map: map,
	alphaTest: 0.5

} );

mesh.customDepthMaterial.onBeforeCompile = shader => {

	shader.vertexShader = '#define DEPTH_PACKING 3201'+"\n"+MY_SHADERCHUNKS.instance_pars_vertex + "\n" + shader.vertexShader;

	shader.vertexShader = shader.vertexShader.replace('#include <begin_vertex>','#include <begin_vertex>'+MY_SHADERCHUNKS.instance_vertex);

	shader.fragmentShader = '#define DEPTH_PACKING 3201'+"\n" + shader.fragmentShader;

};

I can make a fiddle but perhaps someone is already familiar with what happened in 147 and how to fix?

Hmm. Seems WebGLShadowMap: Support material.map with alphaTest by WestLangley · Pull Request #25000 · mrdoob/three.js · GitHub overwrites custom materials now if alphaTest is > 0.

If I revert this change custom material works again of course.

Is this a bug? Should I report an issue or is custom material now expected to be overwritten like this?
If not a bug, how can I make shadows work on these instances now without custom depth material being recognized?

I suggest you comment at the linked PR to report your issue.

Okie dokie then. Done.

Mugen, he said to bring this to you:

this @ there already pinged mugen

Doh! How stupid of me. Oh no!