- Home /
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 :) thanks
Answer by defaxer · Apr 20, 2015 at 01:32 PM
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
 }
 }
Answer by defaxer · Apr 20, 2015 at 01:32 PM
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
     }
     }
 
Your answer
 
 
             Follow this Question
Related Questions
No Shadows on Tessellated Terrain 1 Answer
How to avoid "tesselation gap" 5 Answers
How to use this tessellation cginc with URP? 1 Answer
Standard Shader with Phong Tessellation? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                