Share surf code between Surface shaders

I know how how to share custom lighting between Surfaces shaders with a .cginc file. I’m wondering, is there a way to share surf function code as well?

My ultimate goal is to have multiple Surface shaders that share as much code as possible, with the only difference being how things like alpha blending / alpha cutout / culling are handled.

While it appears to be straightforward to share vert and frag functions, my thought was to avoid fragment shaders because I want my shaders to handle multiple lights, mixed lights with shadow distance fading, and baked lighting, and that seems like a pretty difficult task to create all that functionality in a fragment shader…

I’m developing for mobile but URP isn’t an option at this time.

You can put your surf in your cginc file just like any other function. It doesn’t even have to be called surf(). What matters is the structure of the function and that your #pragma surf FunctionName points to the function you want.

That’s what I thought. I got confused by some errors related to having a #pragma surface inside a pass. Once I removed the pass, it all worked. Thanks for verifying I’m on the right track.