So I am working on a super basic shader. Is it possible to use both surface and vert+frag? From surface → vert → frag.
Basically, I want the shader to be physically based, support most features of unity lighting for my artist. All I need is to add a few things on top of a “traditional” unity shader.
Surface shaders are a highlevel method of writing shaders. The compiler actually creates a vertex and a fragment shader out of your surface shader since that’s the only thing the GPU understands / supports. However a surface shader can result even in several passes with different vert/frag shaders.
It’s hard to answer your question without anything more concrete. Unity’s lighting models are quite complex. Depending on the renderpath lighting might be done in seperate shader passes. “Traditional” shader code might not be compatible with that.
Yes you can, I found the answer here (thank you Farfarer)
Shader "Blee" {
Properties {
}
SubShader{
Pass
{
CGPROGRAM
// Vertex and fragment shader here.
ENDCG
}
Pass
{
CGPROGRAM
// More if you want, you can use Blend and all.
ENDCG
}
CGPROGRAM
// Surface shader here.
ENDCG
}
Fallback "Blou"
}
You can also control when the passes are applied by writing your surface shader before (I haven’t tried in between though).
Using this method, you can use the nice Standard Shader with all the fancy physically based stuff, and add/blend specialized things your artist demands.
You can in multiple passes but one pass will write on top of the other obviously. What you probably want. what your question actually is, is how to write to some frag pass which the surface shader takes in as albedo texture (mainTex). That I don’t know how to do off the top of my head but would be interested in knowing how. Should be able to do it somehow now that you said it this way.