目前我正在创建我的网格并对其进行纹理化。这可以从一方面起作用,但从另一方面起作用。
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 :(得分:1)
将Cull设置为关闭到着色器以渲染背面。 这里有一个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
}