在Unity的內建shader中,預設的顯像方式是 "Back-Face Culling",也就是背面是看不見的,如果需要呈現雙面法線時,我們可以透過修改Shader來達到正反面都顯示的效果。

1.預設的顯示模式,反面是看不見的。


如何让模型产生双面法线效果



2.新增一個自訂shader文件。


如何让模型产生双面法线效果



3.以內建的Diffuse為例,修改其中的Pass函数,增加一行 "Cull Off"。


如何让模型产生双面法线效果



4.新增一個材質球並套用修改過的shader,即可達到雙面顯像的效果。


如何让模型产生双面法线效果 
Shader "DoubleSided" { 
   Properties { 
      _Color ("Main Color", Color) = (1,1,1,1) 
      _MainTex ("Base (RGB)", 2D) = "white" {} 
      //_BumpMap ("Bump (RGB) Illumin (A)", 2D) = "bump" {} 
   } 
   SubShader {       
      //UsePass "Self-Illumin/VertexLit/BASE" 
      //UsePass "Bumped Diffuse/PPL" 
       
      // Ambient pass 
      Pass { 
      Name "BASE" 
      Tags {"LightMode" = "PixelOrNone"} 
      Color [_PPLAmbient] 
      SetTexture [_BumpMap] { 
         constantColor (.5,.5,.5) 
         combine constant lerp (texture) previous 
         } 
      SetTexture [_MainTex] { 
         constantColor [_Color] 
         Combine texture * previous DOUBLE, texture*constant 
         } 
      } 
    
   // Vertex lights 
   Pass { 
      Name "BASE" 
      Tags {"LightMode" = "Vertex"} 
      Material { 
         Diffuse [_Color] 
         Emission [_PPLAmbient] 
         Shininess [_Shininess] 
         Specular [_SpecColor] 
         } 
      SeparateSpecular On 
      Lighting On 
      Cull Off 
      SetTexture [_BumpMap] { 
         constantColor (.5,.5,.5) 
         combine constant lerp (texture) previous 
         } 
      SetTexture [_MainTex] { 
         Combine texture * previous DOUBLE, texture*primary 
         } 
      } 
   } 
   FallBack "Diffuse", 1 
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
  • 2021-12-10
  • 2021-06-23
  • 2021-10-18
  • 2021-12-25
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-10
  • 2021-08-08
  • 2021-06-24
  • 2021-06-13
  • 2021-05-06
相关资源
相似解决方案