Unity3D: terrain object's textures flickering on long distances - unity3d

I'm making RTS project on Unity3D.
I created terrain with Unity's standard Terrain tool, and added textures of grass, mood etc. on it. Then, for creating "man-made" objects of terrain (roads, sidewalks, road curbs etc) - I'm created this objects in separate assets, and placed on terrain.
And I have one issue with this solution. On moving camera away from the terrain, terrain's texture(e.g. mood) are flickering under roads, sidewalks and other objects. AFAIK, this bug caused by insuficcient accuracy of floating-point coordinates in Unity3D engine (?).
Now, as I concerned, my approach to creating terrain objects is not correct. I must create one mesh with terrain, and all manmade objects in 3D modeling software, and then create UV-map for texturing all of it. Is this approach correct? If "yes", is any special approach for modelling and texturing so large and complex object as terrain?

I had the same issue time ago and I solve it by increasing camera's near plane value. I had many objects on the plane that were flickering when moving the camera and was due to having the near plane value at 0.01. I change it to 0.5 and none of the objects where flickering anymore.
I hope this helps!

Related

No collision on Terrain in the shade of the trees

I have a Terrain with a path drawn using Path Painter. (The terrain is uneven and contains trees).
The trees next to the marked places are added manually as objects. The marked places show the shadow of these trees. I have a problem here. During the game, Cubes are loaded and fall from the top. At these points, sometimes there is no collision and the Cube falls below the Terrain.
In short, it is sometimes the Collider Terrain that does not work where the shade of the tree is. What could it be? After building the game there is also this problem. I ran Unity several times etc.
The shadows do not interact with the collision at all. Are the cubes moving too fast? When a Rigidbody is not set to continuous as #harry said, sometimes the physics engine can 'miss' that they were supposed to collide.

Unity is multiplying the vertex count of my mesh twenty fold when importing it from blender?

This is my first time using such a massive mesh as its meant to be terrain but I cannot use Unity's terrain feature to make it. In Blender it shows as just under 20k vertices, yet when I bring it into Unity it shows a staggering 493k. I've never had this problem with a mesh before. Creating the terrain was the first step in this project so there are absolutely no other meshes or objects in the scene beyond two planes that are used for water, yet they aren't the culprit since disabling or deleting them has no noticeable effect on the vertex count.
As you can see in the images, the vertex count in blender shows 19,129, while in Unity it is 492.2k. My hierarchy is empty except a player prefab containing canvas elements, and a camera, a directional light, and event system.
I have really no idea what could be causing this.
The vertex count from the statistic window includes all vertices in the rendering. A lot of it is probably coming from the camera, which probably includes a skybox, shadows (as the statistic window shows: "Shadow casters: 2"), and depth texture. Try delete everything in your hierarchy except for the terrain, then check again.

Recommendations for clipping an entire scene in Unity

I'm looking for ways to clip an entire unity scene to a set of 4 planes. This is for an AR game, where I want to be able to zoom into a terrain, yet still have it only take up a given amount of space on a table (i.e: not extend over the edges of the table).
Thus far I've got clipping working as I want for the terrain and a water effect:
The above shows a much larger terrain being clipped to the size of the table. The other scene objects aren't clipped, since they use unmodifed standard shaders.
Here's a pic showing the terrain clipping in the editor.
You can see the clipping planes around the visible part of the terrain, and that other objects (trees etc) are not clipped and appear off the edge of the table.
The way I've done it involves adding parameters to each shader to define the clipping planes. This means customizing every shader I want to clip, which was fine when I was considering just terrain.
While this works, I'm not sure it's a great approach for hundreds of scene objects. I would need to modify whatever shaders I'm using, and then I'd have to be setting additional shader parameters every update for every object.
Not being an expert in Unity, I'm wondering if there are other approaches that are not "per shader" based that I might investigate?
The end goal is to render a scene within the bounds of some plane.
One easy way would be to use Box Colliders as triggers on each side of your plane. You could then turn off Renderers on objects staying in the trigger with OnTriggerEnter/OnTriggerStay and turn them on with OnTriggerExit.
You can also use Bounds.Contains.

2D Sprites in Isometric 3D Unity Project

The project works under a isometric orthographic camera, in a 3d space using 2d sprites.
What we are using are billboarding sprites into 3D colliders to archieve the 3d feeling.
The problem is that we don't really believe the way we are doing it it's the most optimal. We are also having problems introducing high areas, because we need to reply the sprite form in isometric perspective as colliders.
Because we are using 3D world, the tilemaps tools conflicts with the other vertical sprites.
We can not use a entire 2d floor billboarding sprite because that suposes to have a huge vertical sprite in front of the camera, so we can not display the others.
We are just researching for a solution before to change to a 2D world.
If you plan on sticking with isometric in 3D, get rid of the tilemaps entirely. They are just going to give you a headache and make your game lag itself to death. If you want to convert to entirely 2D isometric, you can stick with them as they would work fine. Now, a few comparisons between the 2D and 3D approaches, and how best to approach them. This is a jumbled list of drawbacks/advantages to each type, so it's more of a ramble after this point than an answer, but I couldn't be more specific without knowing more about your project's overall requirements and specifications.
Unity recently added Isometric Tilemapping as a dedicated feature. So, if you choose to fake it with 2D, your life will be a lot easier.
Controls are a lot easier in 3D, as the physics won't ever have to be
faked.
3D allows foreground objects to automatically cover up background
objects without having to add an arbitrary system to achieve the same
effect.
2D is fundamentally faster than 3D, and if you're aiming for mobile,
that's going to be very important to your project's success.
3D allows you to rotate your camera if you design it right. (Check out Don't Starve Together for an example of this design).

Is there a way to recalculate the polygon collider at runtime? and possibly with better accuracy?

so I have this game in which I have destructible terrain. my setup is that when terrain is destroyed a part of the terrain texture is made transparent, to act as a crater. after any kind of change takes place, I delete the polygon collider on the texture for the terrain and create a new one in order to recalculate the terrain, but obviously this is very taxing on processing power. is there a way to reset the polygon collider without having to do this?
in addition, the polygon collider is not very accurate and I've been told that pixel perfect collision is not possible in unity, but I hold out hope. is there a way to increase the accuracy at least?
here is an example of my problem:
Collider recalculation is expensive, and there's no way around it in Unity, you can't even do it asynchronously.
It depends on your exact situation, but for a Worms-type game with dynamic terrain destruction, I wouldn't use polygonal colliders/Unity physics engine at all.
I'd create my own pixel-perfect collision system that would rely only on the underlying terrain texture.
You already have the terrain data, checking for collisions could be done with Bresenham's algorithm.
Here's a tutorial: http://gamedevelopment.tutsplus.com/tutorials/coding-destructible-pixel-terrain-how-to-make-everything-explode--gamedev-45
I would recommend setting up cluster-based colliders in this case. How do you calculate the area of texture that becomes transparent? If it has a fixed size, you can create a one big collider, which consists of many smaller (hexagon shaped maybe?) sized colliders, whose size equals to the area of texture made transparent.
After you make the texture transparent, you simply destroy the cluster. Though you would have to make the hex(if this shape you choose) grid for every map.
This would be harder to implement in procedurally-generated maps, but it is still possible, as there are no dynamic colliders at the moment.