tessellation shader dx9

hi all helpful ppl.
what i would like to do is: i have a simple tessellation shader runs perfect on dx11. now i wish if i could make it run on dx9 without the tessellation. i’ve tried the

        CGPROGRAM
    	#ifdef SHADER_API_D3D11
      		#pragma surface surf NoLight alpha:fade vertex:dispNone tessellate:tessEdge tessphong:_Phong nolightmap
      		#include "Tessellation.cginc"
      		#pragma target 5.0
      	#else
       		#pragma surface surf NoLight alpha:fade nolightmap
      		#pragma target 3.0
      	#endif

but it just ignores the second pragma surf and compile to dx11, so the shader does nothing on dx9
(Shader warning in ‘Shieldeffect’: Duplicate #pragma surface found, ignoring: #pragma surface surf NoLight alpha:fade nolightmap at line 43 (on ))

id like to know if it could be done with multipasses or multi_compile. any idea welcome :slight_smile:
thanks

You’ll need to write two subshaders for DX11 and DX9 versions. Unity will pick right subshader version for your target platform

Something like that:

Shader{
Properties { ... }
CGINCLUDE
    float4 YourTessellateFunction (appdata v0, appdata v1, appdata v2){...}
    void YourSurfFunction(Input IN, inout SurfaceOutput o){...}
ENDCG
SubShader // DX11 version
{
    Tags { "RenderType"="Opaque" }
    LOD 300
   
    CGPROGRAM
    #pragma surface YourSurfFunction Lambert tessellate:YourTessellateFunction
    ENDCG
}
SubShader // DX9 version
{
    Tags { "RenderType"="Opaque" }
    LOD 200
   
    CGPROGRAM
    #pragma surface YourSurfFunction Lambert
    ENDCG
}
}

You’ll need to write two subshaders for DX11 and DX9. Unity will pick right version for your target platform.

Something like that:

    Shader{
    Properties { ... }
    CGINCLUDE
        float4 YourTessellateFunction (appdata v0, appdata v1, appdata v2){...}
        void YourSurfFunction(Input IN, inout SurfaceOutput o){...}
    ENDCG
    SubShader //DX11 version
    {
        Tags { "RenderType"="Opaque" }
        LOD 300
       
        CGPROGRAM
        #pragma surface YourSurfFunction Lambert tessellate:YourTessellateFunction
        ENDCG
    }
    SubShader //DX9 version
    {
        Tags { "RenderType"="Opaque" }
        LOD 200
       
        CGPROGRAM
        #pragma surface YourSurfFunction Lambert
        ENDCG
    }
    }