Open kianzarrin opened 4 years ago
Currently the node textures with cross walks removed have sharp transitions:
I am trying to SMOOTH out the node textures. I do not want to create PNG files manually because that approach is not practical for custom roads. This also reduces precious production time.
One way is to use the ARPMap of the segment textures and make it gradually fade out.
I am also thinking I don't need to crop out the node textures I can simply use a 1x1 texture with the median color of the Main texture. ( 1x1 textures are rendered properly :) )
Future idea:
additionally I am thinking of replacing the crosswalks with a stop line. This is going to further distract the user from sharp node textures. But I think I should only do so when there is a yield or stop sign. Another exciting improvement of TMPE :) though I think this should probably should be a prop not texture.
some node textures have built in stop line and crosswalks. In the image bellow the stop line for parking is part of the node texture but the stop line for cars is part of the road texture. What to do ... what to do? adding a stop line prop here could be bad! maybe we can Ask people to be NS2 friendly and create extra node textures if they really want their junctions to be pretty. We can have options weather or not to add stop line when there is a Yeild/stop sign (only when stop line texture is not found).
The picture above shows NEXT2 asym-6L ARPMap with road texture under the node texture. According to this picture I don't see how melding road ARP into node ARP is possible.
EDIT: Perhaps I can check for values that are too high and replace them with low values. I need to check a bunch of other ARP maps to be sure.
I can't use mod tools to take a full dump I have to DIY
when caching textures its important that my OnLevelLoaded is called after TMPE.
In order to determine mod orders I traced the code to LoadAssembliesRO
string[] files = Directory.GetFiles(modPath, "*.dll", SearchOption.AllDirectories);```
So it is kind of random. `m_LevelLoaded` event is called before `OnLevelLoaded()`.
It seems I have no choice but to Patch the loading functionality.
Hi @kianzarrin - As you asked me on Steam for some information what are E/B Model of roads.... (E)levated/(B)ridge ;) I think that makes it clear
So if you have a road transition ground to elevated, ground to bridge, bridge to bridge or elevated to bridge the crossings are not removed at all on all the roads i mentioned in my comment on Steam.
the bugfix aka Chamëleon
@thebugfixnet thanks . I haven't got around supporting bridge and tunnel transactions yet. I'll update the mod info.
@thebugfixnet Fixed the E/B/T problem It was a one word fix!
I kind of wished I had done this sooner and have saved you the effort of reporting all this.
No problem - it is fixed that's all that is important 🥇 I'll test again :)
Could this be cause by your update? I have nothing new -only your mod is updated...
Seems to collide with Garbage Bin Controller https://steamcommunity.com/sharedfiles/filedetails/?id=1386697922 ???
A Mod caused an error [System.Exception] Details: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: No target method specified for class VanillaGarbageBinBlocker.PropManagerDataPatch (declaringType=, methodName =AfterDeserialize, methodType=, argumentTypes=NULL) at Harmony.PatchProcessor.PrepareType () [0x00000] in 1 sequence, System.Action
1 action) [0x00000] in
@thebugfixnet I disabled Harmony self patching as NS2 does to make it compatible with Real time mod. I will have a look into this.
@thebugfixnet I cannot reproduce the problem. Can you please tell me the minimum number of mods to reproduce the problem and does removing my mod solves it?
I did got this though:
My mods were: Garbabe bin controler Hide TMPE crosswalks V2.2 ALPHA TMPE labs NS2 Unlock all roads.
I will try to get to the bottom of it.
I closed the game and opened it again. I can't reproduce this any more.
@thebugfixnet enabling and disabling mods does not always work due to an internal bug in the game resulting in "zombie" mods. You need to restart CS particularly if you migrate between different mod versions.
@kianzarrin - the pipette Tool of NS2 still not work for me. If i click just nothing happens.
I failed to provide always/never options. The speed is just not fast enough. It requires optimization. I will postponed this feature.
This is my current progress on smoothing node textures. I am blending in the segment textures into node textures after cropping out the crosswalks. The 4L road has problem with median. Clamping the APR values should solve this problem. The 6L road has a another problem. Mismatch between node texture and segment texture. so the blending has created a sharp edge. I don't know why 4L road does not have this problem. I am of-course stretching the textures before blending them.
I managed to smoothen out the barrier APR of the 4L road.:
The 6L road is still creating a sharp junction texture. the APR maps of the node and segments are the same size. here I have put segment texture under the node texture: Edit: same image with increased contrast:
EDIT:
~It is not very obvious why It creates a sharp transition like shown in the first screenshot~ EDIT: in the first screenshot for the 6L road, the segment to junction transition looks good in the middle of the texture. But it is being displaced outward as we go further away from the center. To understand why this happens for the 6L road and not the 4L road I am including the 4L APR too:
All these textures are 1024x1024
I Do not understand why there is no texture displacement for the 4L but there is for 6L road. They both use the same piece of code.
//simplified code: all textures are 1024x1024
Color[] colors2 = tex2.GetPixels(0, yM2, tex2.width, 1);
for (int j = 0; j < yM; j++) {
Color []colors = tex .GetPixels(0, j, tex.width, 1);
float w= (float)j / (float)yM; //weight
for (int i = 0; i < colors.Length; ++i) {
Color c = colors[i];
Color c2 = colors2[i];
colors[i] = c * w+ c2 * (1 - w);
}
ret.SetPixels(0, j, tex.width, 1, colors);
}
ret.SetPixels(0, yM, tex.width, tex.height - yM, tex.GetPixels(0, yM, tex.width, tex.height - yM));
EDIT: bellow is the segment APRMap under the result of the code above:
Roads affected by this (APR mismatch): all Meduim/Large Vanilla/NExt2 roads which do not have decoration or central barriers. ( haven't tested it on small roads due to complications)
- Roads not effected by this: all roads that have decorations (Grass/trees) or central barriers.
- conclusion: So it seems that roads without decorations/barriers, scale the node texture differently.
- problem: I do not know what exactly to look for (is there a field or a flag I need to check) to distinguish such roads from others and I do not know how much is the scaling factor. I have some ways of dealing with this problem in mind (check for a central lane without cars, check if road has decorations) but I am worried they may be hackish and complex and not future proof. I need to know what is the best solution to this problem rather than shooting in the dark.
Awesome to see the progress of this project
The scaling mismatch of the node textures could be due to the uv map on the node meshes being different, depending on the road. Try copying the uv map from another road’s node
You can also try grabbing the uv coordinates of the mesh with this
PrefabCollection<NetInfo>.FindLoaded(road).m_nodes[0].m_mesh.uv
The mesh uv coordinates could be grabbed from each side of the road at the curb and a scale factor calculated based on that?
I fixed #2 using hackish code. I also mostly solved the asym roads. But the 2+3 NExt2 road has some problems.
Comparing the two images bellow (this is the vanilla 4 lane avenue), the zebra crossings of the lod texture starts after and offset:
I had to hard code 16 pixels offset into my code.
This is the preview of the mesh and the UV in blender:
Why is there an offset for the lod textures. is it the same for all the [custom] roads?
I made some progress with the lods. I replaced the original lod textures with new ones for testing just to prove my lods are good.
I am having trouble to switch between normal textures and lod textures when TMPE activates and deactivates crosswalks. I think the problem is that segment textures are not updated when TMPE pans crossing.
I probably will end up patching TMPE using harmony.
I patched TMPE to updatesegment() Everything works :)
Did it have any performance impact?
IMO, assuming we will be deprecating the old v10.20 STABLE branch it might be worth updating TMPE if there's no performance hit. We could test it on v11 ALPHA (which will become v11 LABS soon) once v11 STABLE is live.
@aubergine10 Did it have any performance impact?
IMO, assuming we will be deprecating the old v10.20 STABLE branch it might be worth updating TMPE if there's no performance hit. We could test it on v11 ALPHA (which will become v11 LABS soon) once v11 STABLE is live.
It takes a few seconds to patch so that adds to startup time. No big deal for now but I work arounds tend to pile up if not dealt with.
I am not planning to support depricated TMPE.
It works with all TMPE versions.
Benchmarking:
Info 417.5347036: BENCHMARK> totalCollisions=0 averageCollisions=0
Info 417.5356472: BENCHMARK> peforming cache speed benchmark:
Info 417.6368915: BENCHMARK> Done peforming cache speed benchmark 469*1000 times
Info 417.6382061: Benchmarking Done!
so 469 materials cause no cache collision and take 0.1 sec load from material cache.
Moving https://github.com/boformer/NetworkSkins2/issues/42 to here because it does not sound like I am merging this with NS2 in the next version. and even if I do it may be a submodule.
In this task I hide tmpe cross walks here I continue to version 2 of the operation to make further improvements.
Version 2.0 released:
merge with ns2Check compatibility with NS2Version 2.5 released:
benchmark/fix cache (array VS hashtable)EDIT: this won't apply to version 3Version 3.0:
Version 3.*
Version 4:
Debug tools:
related: https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/issues/27 https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/issues/27#issuecomment-478048558 https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/issues/40