Hi guys.
Ive created a simple cube for this particular example that is supposed to use a texture that i quickly made in paint.Net for the purpose of experimentation. The image is a 80x40, with the first 40px being totally black, the other half is a black X on a transparent background, saved as png.
Now the cube needs to have the X part of the texture on all 4 sides, and the black part on the top. and i want the sides to use the transparency component of the texture to make it “see through” on the parts where the transparent pixels are only.
But instead of doing that, the entire image is black and made semi transparent.
Heres my Uv mapping code:
private void BuildRampFace(Vector3 corner, Vector3 up, Vector3 right, bool reversed, List<Vector3> verts, List<Vector2> uvs, List<int> tris, bool isTop = false, bool isRampStairs = false) {
int index = verts.Count;
verts.Add((isTop ? corner : new Vector3(corner.x, corner.y - (isRampStairs ? 0 : 1), corner.z)));
verts.Add(corner + up);
verts.Add(corner + up + right);
verts.Add((isTop ? corner : new Vector3(corner.x, corner.y - (isRampStairs ? 0 : 1), corner.z)) + right);
Vector2 uvWidth = new Vector2(40f, 40f);
Vector2 uvCorner = new Vector2((isTop ? 0 : 40), 0);
uvs.Add(uvCorner);
uvs.Add(new Vector2(uvCorner.x, uvCorner.y + uvWidth.y));
uvs.Add(new Vector2(uvCorner.x + uvWidth.x, uvCorner.y + uvWidth.y));
uvs.Add(new Vector2(uvCorner.x + uvWidth.x, uvCorner.y));
if(reversed) {
tris.Add(index + 0);
tris.Add(index + 1);
tris.Add(index + 2);
tris.Add(index + 2);
tris.Add(index + 3);
tris.Add(index + 0);
} else {
tris.Add(index + 1);
tris.Add(index + 0);
tris.Add(index + 2);
tris.Add(index + 3);
tris.Add(index + 2);
tris.Add(index + 0);
}
}
How do i make the cube display the actual image parts i choose on the sides, and then only make the transparent pixels of the texture be transparent while the black parts are not?