-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Personal TASK: Remove crosswalks from individual roads #1
Comments
Don't know if NoCrosswalks mods has shared code. dnspy results in strange function names. RenderTexture renderTexture = NoCrosswalks.\u200E\u202B\u202A\u200E\u202E\u206B\u206E\u206B\u206C\u202C\u206F\u206D\u202C\u202B\u206A\u200F\u202E\u202A\u200D\u202A\u202C\u200C\u200D\u202E\u206E\u206A\u200C\u200B\u202A\u202B\u206D\u202A\u202C\u206C\u202D\u200B\u202E\u200E\u206E\u206E\u202E(NoCrosswalks.\u202B\u202D\u206D\u202B\u202D\u200E\u206C\u202E\u202B\u202D\u206B\u202A\u200B\u206E\u200F\u200E\u202E\u202B\u202E\u206C\u206E\u200C\u202D\u206B\u202D\u206E\u200E\u200E\u202A\u200D\u200B\u202D\u202D\u206E\u206E\u206C\u200C\u200E\u202D\u200D\u202E(source), NoCrosswalks.\u202C\u200D\u200C\u200C\u202D\u200E\u202E\u202A\u200D\u202C\u202D\u200D\u206A\u206A\u200B\u206C\u206C\u202C\u200C\u206A\u200E\u206B\u206C\u202B\u202E\u202A\u206E\u200E\u202E\u206A\u200D\u202B\u206E\u206D\u200C\u200F\u200D\u200F\u206F\u206F\u202E(source), 0, 7, 1); ILspy is no better but DotPeek can actually do it right renderTexture1 = NoCrosswalks.NoCrosswalks.\u200E(NoCrosswalks.NoCrosswalks.\u202B((Texture) source), NoCrosswalks.NoCrosswalks.\u202C((Texture) source), 0, (RenderTextureFormat) 7, (RenderTextureReadWrite) 1); Don't know why. I wish to de-compile numbers to hexadecimal. don't know how? |
Code of |
These mods remove crosswalks: |
Random guess:
|
The same author as |
Wow! obfuscation is a thing! I probably can use a c# debosfusicator but I am concerned about moral implication of that. Why do people obfuscate free code anyway? Maybe I can ask the author for help? |
Maybe they want to hide something or just want to be the only author of the mod, so other people cannot use it to make it better or share as own code. |
After reading some code I am starting to think this tasks is beyond me. I have never dealt with detours before. I have no experience in mesh and textures either. So don't hold your breaths for me. I need to learn each of this concept separately one step at a time. I am considering to accept easier issues that require such skills to ease up the learning curve. |
|
@kianzarrin try toggling the |
|
My general thoughts are that if it's not possible to remove crosswalks on segment by segment basis, remove them all and then have a way to add (non-distorted!) crosswalk decals where necessary (but also allow for invisible crossings too - eg. on dirt roads). With decals, if you get them at the right height, they won't overlap pavements. Or we could potentially examine the segment mesh and work out where the road surface is vs. pavement, and crop decals to fit, taking in to account things like medians, etc. |
I think this can be managed in the same way Network skins manages everything. each road needs to have its own segmentData and detours will access the segmentData to check which texture to use. I am hesitant to create my own detours. wouldn't that create incompatibility with Network skins? I think its best to have network skins to read TMPE or TMPE to use NetworkSkins API. |
according to https://cslmodding.info/asset/network/#flags
In any case there is no harm in trying it out. |
I used modtools to check the crossing flags. They are not set at junctions. |
I am trying to " practice change color on a local basis". I patched GetColor but that was not enough to change the road colors. NetInfo.m_color is used in a few more places. I tried to copy paste the parts of the network skins 2 code that changes color. but I failed to identify them I even failed in installing harmony by copy pasting Netwrok Skins 2 implementation of ILoading interface. I gave up on Harmony! I am going to use redirection framework. |
I wonder if I can duplicate netInfo. while i suspect this would be hard hacking the game code is going to be even harder. I will try to search where netInfo code is being initialized. Some of the netinfo functions are virtual. In such cases I may be able to simply inherit netinfo instead of patching the code. |
I found this code that clones Netinfo. This is part of asset editor utilities: // AssetEditorRoadUtils
using UnityEngine;
private static NetInfo Instantiate(NetInfo template)
{
NetInfo netInfo = Object.Instantiate(template);
netInfo.name = template.name;
InstantiateLanes(netInfo);
InstantiateSegments(netInfo);
InstantiateNodes(netInfo);
InstantiateModel(netInfo);
netInfo.gameObject.SetActive(value: false);
netInfo.gameObject.name = GetUniqueNetInfoName(netInfo.gameObject.name);
netInfo.m_prefabInitialized = false;
PrefabCollection<NetInfo>.InitializePrefabs("Custom Assets", netInfo, null);
netInfo.CheckReferences();
netInfo.RefreshLevelOfDetail();
return netInfo;
} although there are some complications.
This also creates some problems with saving and loading data. I am thinking Maybe I should inherit Netinfo. then I can simply override its methods. public class NetInfoExt: NetInfo { }
something = (NetInfoExt)segment.info; |
Inheriting NetInfo is not beneficial since its NetManager methods that I need to override. |
|
lol! typo in a test code. I played with the flipping algorithm a bit. The junctions look nicer if you flip "_MainTex" but not "_APRMap". Flip(nodeMaterial, "_MainTex");
//Flip(nodeMaterial, "_APRMap"); // looks nicer when commented out. Now I have created detour of NetNode.RenderInstance() and trying to hide crossings only on junctions where my tool has disabled crossings visuals. private static Material FixMaterial(ushort nodeID, ushort segmentID, NetInfo.Node node) {
NetNode thisNode = Node(nodeID);
var info = thisNode.Info;
var ai = info.m_netAI;
Material material = node.m_nodeMaterial;
if (!(ai is RoadAI)) { // or RoadBaseAI ?
return material;
}
// TODO: complete code
return material;
} |
I manged to hide cross walks on individual basis. right now I flip node textures to hide crosswalks: public static Hashtable NodeMaterialTable = new Hashtable(100); // table of flipped node textures
public static Material HideCrossing(NetInfo.Node node) {
if (NodeMaterialTable.Contains(node)) {
return (Material)NodeMaterialTable[node];
}
Material material = new Material(node.m_nodeMaterial);
TextureUtils.Flip(material, "_MainTex");
NodeMaterialTable[node] = material;
return material;
}
private static Material FixMaterial(ushort nodeID, ushort segmentID, NetInfo.Node node) {
Material ret = node.m_nodeMaterial;
//return ret // performance
if (Node(nodeID).Info.m_netAI is RoadAI && HasCrossingBan(segmentID, nodeID)) {
ret = HideCrossing(node);
}
return ret;
//MaterialPropertyBlock block = netMan.m_materialBlock;//TODO investigate
// TODO 2: mess around with NetSegment.RenderLod(cameraInfo, combinedLod); for far distance
} It still does not work with far away textures. I think I need to fix Also I think I will not need to flip textures if I utilize |
@boformer @aubergine18 @krzychu124 @kvakvs I would like to discuss integration of this hide crosswalk feature. Which one of these requirements do we want? Issue 1: Issue 2: Issue 3: |
So, I think about this as use cases rather than mods:
For scenario 1, there are already numerous mods that allow users to remove crosswalk textures, and there are other methods such as using ploppable asphalt+. For scenario 2, the pathfinder needs to know - so that's very much TM:PE territory (everything is already set up, the only thing missing is toggling the crossing decals to visually reflect the junction settings). |
@aubergine10
Yes but they do it on a global basis rather than individual basis.
ploppable asphalt+ is manually painting on the road which is a bit time consuming. much better to do it in Network skins. That said I am not sure if there is any use case. If banning crossings by TMPE hides cross walks, then I doubt if people would like to hide cross walks on individual basis for any other reason. In any case should the functionality to hide crosswalks be implemented in TMPE mod? CurrentlyTMPE only changes functionality not textures. If we do this it would be the first time TMPE influnces textures. Also I am a bit worried in terms of compatibility with other mods since I have took a detour of NetNode.RenderInstance(). |
@aubergine10 I want to draw your attension to this comment:
|
I have been investigating this LOD issue for a some time and playing around with things. Its really confusing. I do not fully understand what is going on. So far I think this is whats going on:
So far I am manged to hide crossing when camera is close and far. But I failed to do anything about when the camera is really far. Even the Road Options mod fails to hide the road crossings when the camera is very far away. I have been trying to comment out parts of the code to see which function is responsible for rendering what.
There is a difference between commenting out the all of |
It's layer for rendering animated icons. On screenshot above you can see one at the end of unfinished highway (dead end). [Edit] |
Read following guide by author of Loading Screen Mod about how the LOD atlas works. While it's more for asset creators, it will give you better idea of how things are fitting together in the game engine. https://steamcommunity.com/workshop/filedetails/discussion/667342976/1636416951459546732/ Notably, the game can share LOD textures between different assets (roads) if the use same material. So I suspect the "very far" issue is going to be difficult to tackle because if you alter a texture in a material it will affect all roads using that material (maybe?). There might be some way to change the LOD distance for customised nodes? Although that might have some slight performance impact (hopefully nothing too bad). Effectively at the 'very far' range, find some way to convince those nodes (or the camera rendering them) that they are closer to camera so it uses the more normal LOD or whatever? |
I don't actually change the material but rather I take a copy of it and store it in a hash-table of cleared materials: @aubergine10
convincing the camera that I am closer than I really am is exactly what I do for now. But only for the cases where the crosswalks are removed. so that does not cause too much performance issue. the convincing approach does not work with when camera is very far away. |
The screen shots bellow demonstrate that texture flipping works with all roads. including vanilla, Network extension 2, and other custom roads. The crossings can be hidden when camera is close or far but not when it is very far which is as good as the road options mod (and better than all others I could find) except I can do it to individual segment ends. I do not see the need for storing no crossing textures in png files in phase 1. |
Looking really good! IMO even with the very far LODs still showing crossings, it's still a major improvement over what we currently have. |
TMPE removes cross walks functionally but not visually
NoCrosswalks removes all crosswalks. but does not have individual control.
NetworkSkins has individual control over road texture just not crosswalks.
It seems I should mix all these mods together.
Tasks:
Phase 1
EDIT: I'd Phase 1 of this tasks is complete. See #1 (comment)
Phase 2: boformer/NetworkSkins#42
related:
CitiesSkylinesMods/TMPE#27
https://github.com/boformer/NetworkSkins/
CitiesSkylinesMods/TMPE#27 (comment)
CitiesSkylinesMods/TMPE#40
my current code is here https://github.com/kianzarrin/KianHoverTool/tree/toggle-crosswalksrepo : https://github.com/kianzarrin/HideTMPECrosswalks
The text was updated successfully, but these errors were encountered: