Just for optimization, currently in the code you posted the road object is refreshed after each marker is added. Since in this specific case all markers are added one by one you may want to use:
Road.AddMarker(Points[t].position, false);
The road object will not update after adding each road marker. Roads.Refresh() in your code will take care of that after adding all the road markers.
"Shader error in āEasyRoads3D/Legacy/Terrain/ER Terrain Mesh Tesselationā: maximum ps_5_0 sampler register index (16) exceeded at Tesselation.shader(149) (on d3d11)
Now i can create all roads in the editor. Code uses the children of the selected object in the inspector.
I have to improve the code, but it works ! THANKS Raul !
Yes, that indeed seems the way to go for your situation, generate this through the scripting API by, for example, adding a menu item to the Unity editor main menu.
Regarding the shader error message in the other post, this is an older shader used for terrain mesh overlays in the older v3.1 demo scene. It is a more complex shader used on a mesh for which the main purpose is to show how side objects can be generated as terrain detail objects which can be useful in hilly areas. The shader is more complex and can indeed cause the specific error depending on the build platform. In that case, please remove this shader from /Assets/EasyRoads3D/Shaders/Legacy/Misc/. This folder includes a similar but less complex version in case you want to use a shader like this but as mentioned it is an older shader, Unity built-in render pipeline only.
The error is:
āShader error in āEasyRoads3D/Legacy/Terrain/ER Terrain Mesh Tesselationā: maximum ps_5_0 sampler register index (16) exceeded at Tesselation.shader(149) (on d3d11)ā
The link in the error message points to the shader path that is visible in the Inspector of the specific material, this path is defined at the top of the shader source and visible when opening the specific shader file.
This path is unrelated to the actual physical location of the shader file in the project folder, which is:
/Assets/EasyRoads3D/Shaders/Legacy/Misc/
And the specific shader file name in this folder is āER Terrain Mesh Tesselationā. That is the file/asset that can be removed.
I have a strange behaviour.
The complete train rail road (Bologna-Milano) scene is large 7.3 GB on disk .
I tried to reduce the size removing all ātrainConcreteā gamebjects.
Finalizing command donāt remove them it, nor ābatchā gameobjects.
All seem working ā¦
After this, size is less than 3 GB on disk.
Can you check the status of āCombineā for this specific āTrain Rail Concreteā side object in the Side Object Manager? You will find it further below in the Inspector. When āCombineā is active all instances will be combined in batches in a single mesh inside the scene. When āCombineā is not active these objects will all be instances of the prefab in the project folder which should reduce the size significantly in your case.
High speed train route, 257 Km.
Itās a huge map.
The āTrain Rail Concreteā are combined.
The children ātrainConcreteā inside "batch x"gameobjects are still present.
and if I deleted, are still visible (āBox01matā combined mesh i think).
Also āRailRoadMetalPlateā have this behaviour.
trainConcrete and RailRoadMetalPlate are still present after finalizing road network.
I tested another train route, 95Km long:
using combined and DELETED trainConcrete and RailRoadMetalPlate, size is 1,2 GB
using not combined trainConcrete and RailRoadMetalPlate, size is 1 GB.
Obviously worse performance. (from -25% to -40% fps)
257km will result in a huge mesh when all instances are combined
These are assets in the Demo package which are primary intended for learning purposes to show for example side objects can be used in different ways. You may want to do further tests, for example create LOD Groups for the specific prefab, and not render it at all from a certain distance.
We will look in these children still being present when āCombineā is used. For sure that will be required when for example Box Colliders are involved but that is probably not the case here.
Yes, I should have written a large amount of combined meshes because in this situation the meshes will be created in batches anyway due to the max vertex limitation in Unity (and various build platforms) per mesh object. That is not the case when using instances of the original prefab in the project folder.
I have a strange behavior on my unique small road. My project is under Unity 6000, and EasyRoad 3.2 Pro. On a flat terrain, I created a simple road, and, when running the scene, i walk my avatar to the road, and the road progressively disappears (shrinks).
On first screenshot, road is just after the first house. My avatar is running to the road.
What is the āRaiseā value of the road network in Build Mode?
The EasyRoads3D shaders have an offset option to deal with Z-fighting with the terrain, the offset strength can be set in the road material.
This offset becomes progressively stronger further away from the cam which can be useful to deal with the terrain LOD system. It seems that is what is happening in your scene. Near the cam the terrain is rendered on top of the road, further away the road renders on top of the terrain because of the stronger offset.
A āRaiseā value of 0.01 or 0.02 should be enough to make the road render on top of the terrain also near the cam.
It seems you are looking at this with the road network in Edit Mode, is that correct?
Press the middle mountain tab of the EasyRoads3D toolbar visible in the screenshot you posted. After that press the āBuild Terrain(s)ā button. This will put the road network in Build Mode with the terrain adjusted to match the road network and you will see the āRaiseā control. Probably at this moment the issue is already fixed because the default value for āRaiseā is 0.02.
Hi Raul.
Can you help me, please ?
Iām traying to connect 2 ERRoad by code using ConnectRoad, but i get error:
āNullReferenceException: Object reference not set to an instance of an object
EasyRoads3Dv3.ODODCOQODD.JoinRoads (System.Collections.Generic.List`1[EasyRoads3Dv3.SelectedObject]& objects, EasyRoads3Dv3.ERModularRoad& road, System.Int32& marker) (at <36f3e32e9182460a909544e4a6e0f589>:0)
EasyRoads3Dv3.ERRoadNetwork.ConnectRoads (EasyRoads3Dv3.ERRoad road1, EasyRoads3Dv3.ERRoad road2) (at <36f3e32e9182460a909544e4a6e0f589>:0)ā
Unfortunately it is impossible to give feedback with the current info. What is the exact status of these two road objects? Given previous conversations, how were these road objects created? How can we recreate this error?
And also given previous conversation, do you actually want to use ConnectRoads() which will merge the two road objects in one, or do you want to insert an I Connector between the two road objects for a smooth curve between the two road objects?
Thanks for reply. I only need to join two near erroads (train rails).
But if joining will impact on vertex limit of the resulting mesh I think iās better to insert an I connector.
Iām building a long rail tran route by code and i need to improve looking of the connecting roads.
Iād like a code to mimic the join command in editor
(" Roads of the same road type can be connected by selecting the two markers that should connect (hold the Shift key when selecting the marker) and pressing the āJoin Selected Roadsā button in the Inspector or Shift + J.")