Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by gabrielpda · Oct 06, 2020 at 09:04 PM · minecraftblocksgaps

How remove block mesh gap

I'm creating a minecraft based world, but i came across a problem.
When I generate the world, it becomes like the image with this little gap between blocks.
How i remove it?

alt text


I'm creating each quad individually and then combining it in a single chunk.

This is the code used to combine:

 private void CombineQuads()
 {
     var meshFilters = Object.GetComponentsInChildren<MeshFilter>();
     var combine = new CombineInstance[meshFilters.Length];
 
     for (int i = 0; i < meshFilters.Length; i++)
     {
         combine[i].mesh = meshFilters[i].sharedMesh;
         combine[i].transform = meshFilters[i].transform.localToWorldMatrix;
     }
 
     var mf = Object.AddComponent<MeshFilter>();
     mf.mesh = new Mesh();
 
     mf.mesh.CombineMeshes(combine);
 
     MeshRenderer renderer = Object.AddComponent<MeshRenderer>();
     renderer.material = TextureAtlas;
 
     foreach (Transform quad in Object.transform)
     {
         GameObject.Destroy(quad.gameObject);
     }
 }


And this what i use to create each single quad:

 private void CreateQuad(CubeSide side)
 {
     var mesh = new Mesh
     {
         name = side.ToString() + "QuadMesh",
     };
 
     var p0 = new Vector3(-0.5f, -0.5f, 0.5f);
     var p1 = new Vector3(0.5f, -0.5f, 0.5f);
     var p2 = new Vector3(0.5f, -0.5f, -0.5f);
     var p3 = new Vector3(-0.5f, -0.5f, -0.5f);
     var p4 = new Vector3(-0.5f, 0.5f, 0.5f);
     var p5 = new Vector3(0.5f, 0.5f, 0.5f);
     var p6 = new Vector3(0.5f, 0.5f, -0.5f);
     var p7 = new Vector3(-0.5f, 0.5f, -0.5f);
 
     switch (side)
     {
         case CubeSide.Bottom:
             mesh.vertices = new Vector3[] { p0, p1, p2, p3 };
             mesh.normals = new Vector3[] {Vector3.down, Vector3.down,
                                     Vector3.down, Vector3.down};
             break;
         case CubeSide.Top:
             mesh.vertices = new Vector3[] { p7, p6, p5, p4 };
             mesh.normals = new Vector3[] {Vector3.up, Vector3.up,
                                     Vector3.up, Vector3.up};
             break;
         case CubeSide.Left:
             mesh.vertices = new Vector3[] { p7, p4, p0, p3 };
             mesh.normals = new Vector3[] {Vector3.left, Vector3.left,
                                     Vector3.left, Vector3.left};
             break;
         case CubeSide.Right:
             mesh.vertices = new Vector3[] { p5, p6, p2, p1 };
             mesh.normals = new Vector3[] {Vector3.right, Vector3.right,
                                     Vector3.right, Vector3.right};
             break;
         case CubeSide.Front:
             mesh.vertices = new Vector3[] { p4, p5, p1, p0 };
             mesh.normals = new Vector3[] {Vector3.forward, Vector3.forward,
                                     Vector3.forward, Vector3.forward};
             break;
         case CubeSide.Back:
             mesh.vertices = new Vector3[] { p6, p7, p3, p2 };
             mesh.normals = new Vector3[] {Vector3.back, Vector3.back,
                                     Vector3.back, Vector3.back};
             break;
     }
 
     mesh.uv = Block.UVs.TryGetValue(side, CubeSide.Front).ToArray();
     mesh.triangles = new int[] { 3, 1, 0, 3, 2, 1 };
 
     mesh.RecalculateBounds();
 
     var quad = new GameObject("Quad");
     quad.transform.parent = Parent.Object.transform;
     quad.transform.position = Position;
 
     var meshFilter = quad.AddComponent<MeshFilter>();
     meshFilter.mesh = mesh;
 }

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Oct 06, 2020 at 11:15 PM

It's hard to tell from the single screenshot. The issue is most likely a rendering issue. Though since Unity now supports several render pipelines and countless different shaders we can't really suggest much at this point. It could be an issue with your mipmaps. Do you use an atlas texture? If so are your tiles of a power of two size? Also what filtering method does the texture use? The Minecraft texture atlas doesn't require any padding space between tiles because it uses point filter mode and ensures to sample the center of a texel rather than the edge / corner.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

136 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Add perlin noise to blocky terrain 0 Answers

Minecraft like building system 0 Answers

NES Battle city like movement when turning (teleporting to fit through the gap of blocks without getting stuck) 2 Answers

15625 blocks are making my game lag? Increase performance? 3 Answers

Help with placing and destroying blocks 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges