【日常記錄】Unity3D 中的 Surface Shader 是不支持在 Pass中使用的,因為自動生成了 Pass


如題

搞了好久,一直報錯:

Shader error in 'custom_outline_effect': Parse error: syntax error, unexpected TOK_PASS, expecting TOK_SETTEXTURE or '}' at line 69

只要是把 #pragma surface ... 寫在 Pass中就算出錯,這種情況只要不寫 Pass{} 中就行了,因為會自動生成的

 1         Pass { // 這樣寫會報錯,使用 surface 不需要寫在 Pass 中
 2                 CGPROGRAM
 3                     #pragma surface surf Lambert
 4 
 5                     sampler2D _MainTex;
 6 
 7                     struct Input {
 8                         float2 uv_MainTex;
 9                     };
10 
11                     void surf (Input IN, inout SurfaceOutput o) {
12                         half4 c = tex2D (_MainTex, IN.uv_MainTex);
13                         o.Albedo = c.rgb;
14                         o.Alpha = c.a;
15                     }
16                  ENDCG
17         }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM