_LightColor isn’t supposed to be valid during deferred rendering. The fact it shows something at all is kind of the bug.
The whole idea behind deferred rendering is when you’re rendering the objects themselves, you don’t know anything about the lighting of the scene. Most real time games modify this a bit such that they’ll know about fully baked direct / baked ambient lighting, but any real time lights the shader intentionally has no knowledge of. If something like _LightColor is still set with any value during the rendering of an object during deferred rendering it’s because it wasn’t unset from the previous time it was set to something. But that doesn’t mean it’ll be at all valid.
Or it means the object you’re rendering isn’t opaque, thus its being rendered using forward rendering and not deferred.
Is the custom shader one you have directly on an object, or is it a copy of Internal-DeferredShading.shader that you’re overriding in the Graphics settings. If it’s on the object, then you can’t rely on _LightColor. If it’s an override of the internal shader, then what you have should work, though you’d need to be setting _Color as a shader global.
The shader is on a material which is the single material assigned to a meshrenderer of a mesh on a GameObject
are you implying unitys documentation is unsuited to the case the title of the category the documentation is in implies it is suited for? The shader is a vertex / fragment shader and the code is in the fragment part.
The entire premise behind deferred rendering techniques is that the lighting and the object rendering are separated into different unrelated shaders. The “lighting pass shader” mentioned in the documentation is specifically referring to the Internal-DeferredShading.shader I mentioned above. I’ll agree the documentation isn’t terribly clear about that.
Unity doesn’t use Cg, it uses HLSL. And even then, the reference implementation isn’t necessarily the required implementation. The “reference” is just an “example” implementation that GPUs can implement any way they choose. HLSL doesn’t even include any reference for it in their spec.
Yes, the Unity shader code uses CGPROGRAM and there are .cginc files everywhere. But Unity delete the last uses of Cg about 5 years ago and actively stopped using Cg as the main shader language about 8 years ago when Nvidia themselves ceased development on Cg. They just never bothered to update the shader code and file extensions to reflect that fact until the Post Processing Stack and Scriptable Render Pipelines, all of which use HLSLPROGRAM and .hlsl files. But really CGPROGRAM and HLSLPROGRAM are interchangeable and both are running HLSL.