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

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.

Related

when importing a model to unity from blender, i get odd material results

i imported my blender backrooms model to unity, and i got a wierd mess, this is the model in unity , when its in blender it looks exactly as intended, and even when i render a image of the model in blender all the textures look like they should,this is the model in blender, not a rendered image, ive browsed countless "solutions" and i cant find one that applies to mine, i have tried changing unity import settings, extracting both materials and images, and so on, nothing makes the materials look proper, my guess is that its not accounting for UV mapping junk so its stretching the image so far that it becomes blurred beyond recognitiion, if anybody can help me out it would be much appreciated, also just a side note but i dont think the displacement maps work in unity like they do in blender
edit: the model has multiple objects, the floor ceiling and walls are all 3 seperate objects
edit again: here is the node layout for the floor, every other node layout for the walls and ceiling is just the floors layout but without a displacement map on it
It's been a minute since I've used Unity. But without looking at the blender file, I would suspect that it could maybe be that there's two UVs on your model, and Unity is using the wrong one. I believe Unity uses the first UV Map for texture info, while the others are used for lightmap info. If that's the case, just delete the wrong one in your model. Hopefully that helps!
Edit (more info): I created a basic model with walls, ceiling, and floor. The walls, and ceiling only have a UV Map called UVMap. However, the floor has two UV Maps: UVMap and UVMap.001. Like so:
Now, if I click on that little camera icon next to the UVMap/UVMap.001 you will possibly see the overall size of the bricks change. If so, delete the wrongly scaled UV Map so you only have one UV Map in that window. After that, I would just ensure all your UV Maps are called the same on your other meshes, which is typically UVMap as default. You will also want to be sure all of your images are being mapped by UV, not Object or Generated as Unity cannot use that information. From there you should be good to go!

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.

Unity3D: Why is particle lighting making directional shadows disappear?

UPDATE: As #BenHayward suspected, this is a bug. <link>
I have a very simple setup of cubes on a plane comprising a grid of quads. A directional light is shining down at the scene at an angle, producing a set of shadows from the cubes onto the quads.
Now I'm trying to produce an explosion effect with Unity's particle system, but when I add a point light to the particle system it causes all the directional-lighting shadows to disappear, whether they're in line of sight of the particle or not.
The shadows reappear when the particle is destroyed. Replicating the particle effect with pure C# doesn't cause any problems.
(Oh, and obviously I'm using the deferred rendering path.)
Any ideas? This is driving me off the wall.
[EDIT: I should have mentioned that the point light added to the particle system is set to cast shadows. The Unity standard particle pack has shadow-casting disabled by default. They too cause the problem when I turn the shadow-casting on.]
Based on the project that you linked to, it seems as though the particle system is causing the shadow cast from the directional light to flicker on and off quickly. I suspect this is a bug, since if it were intended behaviour, I wouldn't expect it to flicker in this manner.
In cases where this is not a bug, the problem can be caused by a couple of issues:
You can only have a certain number of dynamic (shadow casting) lights in your scene which are seen by the camera frustum. By default, this number is quite low (I think it's 4). You can increase this number by going to Edit > Project Settings > Quality. Set the Pixel Light count higher from its default value. You will need to increase this value to be greater than the total number of lights in your effect. Higher values will allow more lights to be rendered on the screen, but this reduces performance.
It depends on the shaders which you are using to receive the shadows. Some shaders will only render shadows for one directional light. The light which is used isn't necessarily too easy to determine. If you are using the standard Unity shader this shouldn't be a problem. But if you are using a mobile compatible surface shader or something you've written yourself then this could be the cause of the problem.
Also, for an explosion, I'd recommend using just one single point light (not lights attached to each particle), as this is all that is required. Any more lights would result in considerable performance impact on the GPU especially if there are more than one explosion in the scene at any one time.
I recreated the scene as you described, i can't recreate your issue.
i mostly followed this tutorial, and added a few cubes in a plane:
https://unity3d.com/learn/tutorials/topics/graphics/adding-lighting-particles
I will need a screenshot of your lights componnents, both the directional and the point light, the particles, and the cubes (mostly the material); I cannot comment because i dont have enough reputation yet, so i'll delete this once you add the screenshots;

Hexagon Unity TIles - Slow Performance

When implementing a large hexagonal grid (256x256) of tiles in a Unity game, the game becomes very slow and hardly able to function. The hexagons are in a prefab. A script controls the size of the grid and the spacing between each hexagon. How does one go about rendering a 1024x1024 grid of Unity objects?
When the game is built on Win64 it is also still quite slow.
This is an image of hexagons rendered:
http://i.imgur.com/UbA6USt.png
Try making the grid elements static and make sure static batching is turned ON in player settings. This will optimize their rendering significantly. You probably should even go as far as combining them all into a single mesh (see tools like this one for that purpose).
If you can show us the actual scene hierarchy and the actual structure of your grid nodes then we can help even more.
Because of how Unity works, non-static objects have a tendency to get heavy - they each end up with their own transforms and end up getting drawn even when they're not on screen.
It's the reason more minecraft clones aren't seen coming out of Unity.
If you can't set the hexagons to static for some reason (i.e.: creating procedural levels etc), you'll have to perhaps simulate the hexagons through creative shader manipulation (like saving each mesh into a single array of vertices with a second that tracks a corresponding mesh id) or by writing a script that creates/adds vertices and faces to a single mesh on a single game object.
You may also speed up the scene by creating smaller levels and loading/unloading them as the player moves towards them. See: Application.LoadLevelAdditive

Unity3D: terrain object's textures flickering on long distances

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!