- Home /
Unity - cube primitive clipping issues?
I'm currently building a voxel-based map system; however, I've found that Unity appears to have issues with the cube primitive "clipping"; i.e: two cubes placed perfectly side-by-side, but when viewed from a certain angle, will show a gap between them.
example; http://i.imgur.com/eOix3E3.png
This is generally quite difficult to pinpoint from a player perspective; you need to stop in precisely the correct position to see this. However, these lines are constantly appearing/disappearing as you move the map around; for the player, it results in the map looking like it's constantly flickering. It's quite painful to look at for an extended period of time.
Would anyone have any ideas on what causes this, and how it can be repaired?
Answer by erick_weil · Feb 15, 2014 at 03:03 AM
you need to use a diferent algoritm to generate that "voxel" world, you need a LOT scripting to make a mesh that only shows the surface, the visible portion, not all the cubes will be rendered, only the vetices that have in the surface, and this will solve the VBO problem, you have 2048 VBO! and 643 draw calls! this is not effycient.
see that tutorial ( in C#) to make a nice cubic voxel mesh;
or try to uderstand my smooth Marching Cubes voxel-based game
and see that !
That's a shame - the cube primitives were working quite well. The draw calls went through the roof due to some additional models I was adding into the scenes for testing.
Literally the only problem is the clipping - and due to the nature in which the voxels are being manipulated by the player, the cube primitive really works perfectly here. Is there no way to solve this clipping issue and continue using the cube prefabs I've built the game around?
the clipping occurs because have some triangles that is in the same position(face is shared), with a surface generation for the terrain, the clipping will disappear.
I don't see any other ways to solve this and continue with shared faces, faces sharing the same space will create cliping.
but if your terrain is all plane, try to Instantiate quads ins$$anonymous$$d cubes.
The terrain is literally all cubes - just one layer! It's not being made in a $$anonymous$$ecraft digging style or anything like that. Each cube is actually it's own prefab based on terrain type - the map generator script loads them all in, and assigns them placement on the map based on position (i.e: snow/tundra at the poles, desert in the center).
It was very fun to write up, but this is literally the only problem I'm faced with now. They're also set to switch to planes based on LOD settings.
i sayied that if your terrain have no mountains or caves, is all in the same y position, is a flat terrain, is plane, is all in the same layer.
try... do not use cubes, use quads, and the cliping will disappear
and the performance gives up, cubes( formed by 24 vertices and 12 tris ), quads( a plane formed by 4 vertices and 2 tris )
but the quads have a mesh collider, and any other mesh coliders with the convex not marked will not collide with the quads, solve this by create a GREAT invisible cube with a box collider...
That does sound like a much better idea - however, the reasoning behind using voxels is that it's a strategy game, where players can move/manipulate the map.. i.e: raise terrain themselves (moving the block up above the ground, or below the ground.
That's why I went with cubes. The blocks need to be capable of being seen at all angles. If I were to use a quad, I'd surely have to use 6 of them to recreate a cube, and I'd be back to square one?
Your answer
Follow this Question
Related Questions
Best way to render bunch of cubes/planes? 3 Answers
Voxels and LOD in Unity 1 Answer
Help: Shooting a cube 1 Answer
highlight a portion of a mesh in runtime 1 Answer
Create a circle using cubes? 3 Answers