Converting surface shader to usable vertex/fragment shader

I am writing a shader that will interpolate between two sets of lightmaps (night and day). I have it working correctly as a vertex/fragment shader. I realized recently, that I also need dynamic lights as well. I found the Normal-Diffuse.shader and it works perfectly - it just needs the custom interpolation code.

What I need now is to have the Normal-Diffuse (Legacy Diffuse) as a vertex/fragment shader. I clicked “Show Generated Code”, copied the results of this back into the shader and it still works (the file is around 1750 lines of code).

The problem I am having is that when I edit the code, the changes don’t seem to be reflected. The generated shader contains the original surface shader code. When I edit this, it changes. But when I edit the generated fragment and vertex code (the stuff I need to change), nothing changes. Even introducing errors doesn’t seem to affect anything. Is it incorrectly thinking it is still a surface shader? Is there any way to fix this? Is this even a possible way to do this?

Thanks for your help!

You don’t want to use the generated code. Download the “Built-in shaders” package for your given Unity version, and browse through the CGINC files that the shaders use, you’ll find all the vert/frag functions that the surface shaders end up using and can adapt them for your own usage.

Thanks for the reply. This idea makes sense but I am unsure of which vert/frag functions are actually used. Here is the surface shader in question:

// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)

Shader "Legacy Shaders/Diffuse" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
    Tags { "RenderType"="Opaque" }
    LOD 200

CGPROGRAM
#pragma surface surf Lambert

sampler2D _MainTex;
fixed4 _Color;

struct Input {
    float2 uv_MainTex;
};

void surf (Input IN, inout SurfaceOutput o) {
    fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    o.Albedo = c.rgb;
    o.Alpha = c.a;
}
ENDCG
}

Fallback "Legacy Shaders/VertexLit"
}

Where do I start in terms of conversion?

Do a “Search for Text” in files, for that whole built-in shaders folder, and just search for the term “Lambert”. You’ll find all the Lambert related sections.

If you look at the Standard.shader, you can see how it doesn’t even have any surface shaders in it, it just has passes that references CGINC files. In these CGINC files you can find the vert/frag passes for these types of shader passes and figure out how they’re working and then implement them how you like. This is the “template” for a surface shader basically. But the Lambert shader just has a different Lighting Model set on it, so it will have some lighting functions swapped out for Lambert labelled versions.