- Home /
Dynamic mesh is black except up-close
I'm making a bunch procedural blocks in code ( no, not cloning minecraft just a good practice for learning ) and i'm mapping textures onto the block faces with the uv coordinates provided by texture2D.PackTextures().
the problem is the mesh is completely dark unless I get really up close ( and then the far parts are still completely dark. ) also a lot of seams and lines appear. The material is using the Diffuse Legacy shader, though I've tried just about every shader and it doesn't work.
If I remove the uv textures, and just put a blank color, the color appears from any distance.
I've been looking at this for over 5 hours and I can't seem to fix it.
what it probably ISN'T:
the uv-coordinates are probably correct because when I go up close, the correct texture colors are all there.
the normals for the mesh are correct. ive both set them manually and used RecalculateNormals() and there is no difference.
there is lightning in the scene and other objects are lit properly.
the triangles all wend Clockwise and display correctly.
The GameObject has a MeshRenderer and a MeshFilter with both the atlas texture and the dynamic mesh supplied.
Some sample code:
uvRect = atlas.GetTexCoords( type ); // Custom class encapsulates an atlas and the uv-rect. returned values are verified correct.
vertexIndex = vertices.Count;
vertices.Add( new Vector3( x, y+1, z) );
vertices.Add( new Vector3( x, y+1, z+1 ) );
vertices.Add( new Vector3( x+1, y+1, z+1 ) );
vertices.Add( new Vector3( x+1, y+1, z ) );
// triangles
triangles.Add( vertexIndex );
triangles.Add( vertexIndex+1);
triangles.Add( vertexIndex+2 );
//
triangles.Add( vertexIndex+2 );
triangles.Add( vertexIndex+3 );
triangles.Add( vertexIndex );
uvs.Add( new Vector2( uvRect.x, uvRect.y ) );
uvs.Add( new Vector2( uvRect.xMax, uvRect.y ) );
uvs.Add( new Vector2( uvRect.xMax, uvRect.yMax ) );
uvs.Add( new Vector2( uvRect.x, uvRect.yMax ) );
Answer by the_lemur · Jul 01, 2015 at 05:32 PM
Turning mipmaps off on the original textures (surprisingly) solves the far-lightning problem.
All that remains is the ugly-seams problem and some odd color effects at a distance.
Your answer
Follow this Question
Related Questions
Lighting Banding Artifact 0 Answers
Strange point light on generated mesh 1 Answer
Light passing through walls in android build but not in editor 1 Answer
Light creates distortion on mesh? 1 Answer
Simple plane generation 1 Answer