hi all,

I am translating a old XNA *.fx shader effect to Unity5. previously I defined multiple vertex and pixel shaders, and compiled them in arrays, and use some parameter to tell the rendering pipeline which vertex/fragment shader combinations to use in one pass:

VertexShader VSArray[3] =
{
compile vs_2_0 VSSin(),
compile vs_2_0 VSSquare(),
compile vs_2_0 VSLinear(),
};

PixelShader PSArray[2] =
{
compile ps_2_0 PSNone(),
compile ps_2_0 PSGaussian(),
};

technique Technique1
{
pass Pass1
{
VertexShader = (VSArray[VSIndex]);
PixelShader = (PSArray[PSIndex]);
}
}


but in unity5 shaderlab, I don’t have a clue how to achieve this. I tried to define more than one vertex/fragment shaders:

Shader “myshader”
{
Properties
{

    sigma("Sigma", Float) = 0.05
    sf("SF", Float) = 0.2
    time("Time", Float)=0
}
	SubShader
{
	Tags { "RenderType" = "Opaque" "Queue" = "Transparent" }
	Blend SrcAlpha OneMinusSrcAlpha
    LOD 100

	Pass
	{
		CGPROGRAM
        #pragma vertex vert
        #pragma vertex vert1
        #pragma fragment frag
        # include "UnityCG.cginc"
          
             //.....
        ENDCG
     }
}

}

and unity5 editor showed “Duplicated #pragma…”

I am wondering is it possible to do something similar to my old .fx effect. or I have to separate each vertex/fragment shader in each shader file, and use some other parameter to combine them in one pass?

thanks,

Sounds like you’re looking for #pragma multi_compile