CitiesSkylinesMods / HideCrosswalks

MIT License
8 stars 3 forks source link

tasks #1

Open kianzarrin opened 4 years ago

kianzarrin commented 4 years ago

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:

Version 2.5 released:

Version 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

kianzarrin commented 4 years ago

Currently the node textures with cross walks removed have sharp transitions: Screenshot (223)

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.

Future idea:

kianzarrin commented 4 years ago

Ground_Node__AlphaMap 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.

kianzarrin commented 4 years ago

I can't use mod tools to take a full dump Screenshot (225) I have to DIY

kianzarrin commented 4 years ago

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.
chameleon-tbn commented 4 years ago

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

image

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.

image

the bugfix aka Chamëleon

kianzarrin commented 4 years ago

@thebugfixnet thanks . I haven't got around supporting bridge and tunnel transactions yet. I'll update the mod info.

kianzarrin commented 4 years ago

@thebugfixnet Fixed the E/B/T problem It was a one word fix! Screenshot (231)

I kind of wished I had done this sooner and have saved you the effort of reporting all this.

chameleon-tbn commented 4 years ago

No problem - it is fixed that's all that is important 🥇 I'll test again :)

chameleon-tbn commented 4 years ago

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 :0 at Harmony.PatchProcessor..ctor (Harmony.HarmonyInstance instance, System.Type type, Harmony.HarmonyMethod attributes) [0x00000] in :0 at Harmony.HarmonyInstance.b__6_0 (System.Type type) [0x00000] in :0 at Harmony.CollectionExtensions.Do[Type] (IEnumerable1 sequence, System.Action1 action) [0x00000] in :0 at Harmony.HarmonyInstance.PatchAll (System.Reflection.Assembly assembly) [0x00000] in :0 at VanillaGarbageBinBlocker.UserMod.OnEnabled () [0x00000] in :0 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception

kianzarrin commented 4 years ago

@thebugfixnet I disabled Harmony self patching as NS2 does to make it compatible with Real time mod. I will have a look into this.

kianzarrin commented 4 years ago

@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: Screenshot (232)

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.

kianzarrin commented 4 years ago

I closed the game and opened it again. I can't reproduce this any more. Screenshot (234)

@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.

chameleon-tbn commented 4 years ago

@kianzarrin - the pipette Tool of NS2 still not work for me. If i click image just nothing happens.

kianzarrin commented 4 years ago

I failed to provide always/never options. The speed is just not fast enough. It requires optimization. I will postponed this feature.

kianzarrin commented 4 years ago

This is my current progress on smoothing node textures. I am blending in the segment textures into node textures after cropping out the crosswalks. Screenshot (241) 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.

kianzarrin commented 4 years ago

I managed to smoothen out the barrier APR of the 4L road.: Screenshot (1)

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: Screenshot (243) - Copy Edit: same image with increased contrast: piant edited

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: Screenshot (246) - Copy

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: node melt_APRMap

Cgameworld commented 4 years ago

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?

kianzarrin commented 4 years ago

I fixed #2 using hackish code. I also mostly solved the asym roads. But the 2+3 NExt2 road has some problems.

kianzarrin commented 4 years ago

Comparing the two images bellow (this is the vanilla 4 lane avenue), the zebra crossings of the lod texture starts after and offset: RoadMediumnode_d RoadMediumNode_LOD-No Name-rgb

I had to hard code 16 pixels offset into my code.

This is the preview of the mesh and the UV in blender: Screenshot (292)

Why is there an offset for the lod textures. is it the same for all the [custom] roads?

kianzarrin commented 4 years ago

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. Screenshot (294)

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.

kianzarrin commented 4 years ago

I patched TMPE to updatesegment() Everything works :) Screenshot (296)

originalfoo commented 4 years ago

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.

kianzarrin commented 4 years ago

@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.

kianzarrin commented 4 years ago

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.