At the moment I'm creating my mesh and texturing it. This works from one side, but from the other its transparent.
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();
How do I go about fixing this so it's textured on both sides?
Set Cull to off to your shader to render backface culled. Here you have an example of doubleside standard 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" = "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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.