I’m creating a simple mesh (literally just a one sided plane). I’m applying a custom material (default settings from creation). Then I’m applying an ‘advanced’ texture which has Read/Write enabled and wrap mode set to repeat.
this is the code I’m using specifically, to generate and set-up the mesh
public Mesh GenerateMesh()
{
vertices = new Vector3[] { //positions are off by 0.5f because coordinates point to the CENTER of a tile, not a corner
new Vector3( -0.5f, -0.5f, 0), //0
new Vector3( -0.5f, height - 0.5f, 0), //1
new Vector3( width - 0.5f, height - 0.5f, 0), //2
new Vector3( width - 0.5f, -0.5f, 0) //3
};
uv = new Vector2[]
{
new Vector2(0, 0), //0
new Vector2(0, 1), //1
new Vector2(1, 1), //2
new Vector2(1, 0) //3
};
triangles = new int[]
{
3, 0, 1,
1, 2, 3
};
roomMesh = new Mesh();
roomMesh.vertices = vertices;
roomMesh.uv = uv;
roomMesh.triangles = triangles;
MeshFilter meshFilter = gameObject.GetComponent<MeshFilter>();
meshFilter.mesh = roomMesh;
MeshRenderer meshRenderer = gameObject.GetComponent<MeshRenderer>();
meshRenderer.material = Sys.LoadMaterial("Materials/floor_material");
meshRenderer.material.SetTexture("_MainTex", Sys.LoadTexture(texPath));
meshRenderer.material.SetTextureScale("_MainTex", new Vector2(width, height));
return roomMesh;
}
All the textures used are fairly bright, vibrant colors, however when I run the game they look dark
I’ve tried adding local lights and directional lights, set for runtime lighting (baking is not an option as I’m generating the floors at run time)
Surely there’s something I’m missing? Why won’t these planes light up?
I could switch the shader to an unlit shader, but Ideally I’d like to do lighting in the scene to simulate torches, lanterns, etc.