2017-08-20 11 views
0

現在、私はメッシュを作成してそれをテクスチャリングしています。これは一方の側からは動作しますが、他方からは透過します。Unity3Dでメッシュの両面をどのようにテクスチャ付けするのですか?

 m.name = "TopWallMesh"; 
     m.vertices = new Vector3[] { 
      new Vector3(-width, 0f, -height), 
      new Vector3(width, 0f, -height), 
      new Vector3(-width, 0.1f, -height), 
      new Vector3(width, 0.1f, -height) 
     }; 
     m.uv = new Vector2[] { 
      new Vector2 (0, 0), 
      new Vector2 (0, 1), 
      new Vector2 (1, 0), 
      new Vector2 (1, 1) 
     }; 
     m.triangles = new int[] { 0, 1, 2, 1, 3, 2 }; 
     m.RecalculateNormals(); 

これを修正して両面にテクスチャを付けるにはどうすればよいですか?

+0

逆標準で別の面を作成することができます – Lestat

答えて

1

カールをシェーダに設定して、バックフェースをレンダリングします。 ここでは、doubleside標準シェーダの例を示します。

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" = "Always" /* Upgrade NOTE: changed from PixelOrNone to Always */} 
    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 
} 
関連する問題