kianzarrin / AutomaticNodePainter

0 stars 1 forks source link

PERSONAL TASK: mod to paint highway intersections/transitions #1

Closed kianzarrin closed 2 years ago

kianzarrin commented 4 years ago

Currently the highway intersections do not have any road painting. while it is possible to paint them manually, it is tedious. I wish to create a mod paint them dynamically based on TMPE lane connection or lane arrow information (there is going to be some cool mixture of the two).

Screenshot (1062)

TODO:

Proof of concept:

Stage 2:

stage 3:

originalfoo commented 4 years ago

Being able to programatically draw lines over junction nodes would open up all sorts of cool possibilities.

@pcfantasy made a mod that did this:

https://www.youtube.com/watch?v=ICjrLoy6tFA

He since deleted the mod though :(

We were hoping to implement it in TM:PE, integrating it with timed traffic lights, priority signs, etc: https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/issues/46

victoriacity commented 4 years ago

Being able to programatically draw lines over junction nodes would open up all sorts of cool possibilities.

@pcfantasy made a mod that did this:

https://www.youtube.com/watch?v=ICjrLoy6tFA

He since deleted the mod though :(

We were hoping to implement it in TM:PE, integrating it with timed traffic lights, priority signs, etc: CitiesSkylinesMods/TMPE#46

PCFantasy's mod did not draw lines. What was showed in the video was a deprecated road asset in the very early development of old CSUR before I joined in. It has the lines of the "turning zone" built in the node mesh. (US doesn't seem to have such markings so don't know it's formal name though)

victoriacity commented 4 years ago

Automatically creating road transitions is an extremely ambitious task. This is also part of the goal of the entire CSUR, and you can have an idea of the challenge giving how crippled CSUR is.

But the dream of simulating road networks, though, is definitely painting the markings given any road junction. To create markings on a blank junction one needs to either add extra decal mesh (prop or network) on top of the asphalt or change the texture mapping of the asphalt mesh. In one of my videos I've shown a tiny bit about how to do this for vanilla roads https://www.youtube.com/watch?v=TcupMdsiB8k&t=246s

I personally feel that the first approach is more tractable, since you'd need to create texture and UV coordinates from scratch to really paint the asphalt. For example, the widths of shoulders of vanilla 2-lane highway and vanilla 4-lane highway are different. Then the "painted" node texture will have a slightly slanted white line rather than vertical as in regular road textures, and each transition combination will probably need a unique texture, which is very prone to performance issues.

Automatically painting roads is actually achieved by a very limited extent using the Parallel Road Tool. You can create a white line and a highway together to make an emergency lane. So it would be possible to extend this into, say, a "non-parallel road tool", which finds where the lines end before entering a node and builds a line network over the node.

kianzarrin commented 4 years ago

Automatically creating road transitions is an extremely ambitious task. This is also part of the goal of the entire CSUR, and you can have an idea of the challenge giving how crippled CSUR is.

I personally feel that the first approach is more tractable, since you'd need to create texture and UV coordinates from scratch to really paint the asphalt. For example, the widths of shoulders of vanilla 2-lane highway and vanilla 4-lane highway are different. Then the "painted" node texture will have a slightly slanted white line rather than vertical as in regular road textures, and each transition combination will probably need a unique texture, which is very prone to performance issues.

imagine how much harder would it be to implement the lod atlas! No this is not the way!

My idea is to use TMPE lane connector to understand which lanes should be connected for some simple situations. then I can put props over road. I can't imagine in to be too difficult @victoriacity TMPE already calculates lane end lane widths is also stored. So I can look at these values to draw lanes. this should work fine for some simple highway transitions. I think knowing how to create props is harder than the math.

originalfoo commented 4 years ago

With props you're risking hitting the prop limit very soon - each junction could have lots of props, and there are lots of junctions... and detailers are already placing insane numbers of props in thier cities.

Assuming the lines will only continue for the main road at a junction, would it not be more feasible to dynamically add a rectangular sub-mesh to road prefabs/assets, and set the texture of that mesh to same as the road? (ie. it will inherit texture of the main part of the road, assuming you can filter out pavements, etc?)

The mesh would extend in to the junction node; possibly with some way to set the "amount of extension" based on size of that node? That would create the road texture across the node. Only one mesh would be required per junction; you'd need to pick one segment of the main road and display its mesh. Another benefit of this approach is that if user deletes a segment, the game will automatically remove the mesh because it's part of the road - so you don't need a load of stuff to remove individual props.

With additional work, the mesh could be more advanced; copy the road mesh including median if there is one, now you have ability to continue median across road and toggle it on/off depending on traffic lights :)

In theory it would also be possible to curve the mesh (and thus its texture) to handle situations where the main road doesn't go directly straight ahead. Admittedly, it would only work where the main road segments are same type, but that is the most common case for most junctions and would drastically improve overall appearance of the city.

There would likely need to be some way to control the width of the mesh, eg. to trim off edge lines or parking lanes. That could be achieved automatically by looking at the lane types.

From vague memory, UK Roads - Motorways uses meshes that extend in to the junctions.

originalfoo commented 4 years ago

Other benefits of the mesh approach are that you don't need more textures, because you reuse existing road textures. Also, you don't need to deal with prop assets and different line styles (eg. thickness, length, gap size, etc) because the road texture already has that taken care of. Oh, and most of the work can be done up-front, when the city loads. After that it's mainly just toggling the mesh on/off, maybe bending it and changing it's length.

Note also that junction nodes are flat by default, which simplifies things somewhat.

originalfoo commented 4 years ago

Network Tiling mod will likely be of use if the texture needs to repeat.

kianzarrin commented 4 years ago

@aubergine10 Assuming the lines will only continue for the main road at a junction, would it not be more feasible to dynamically add a rectangular sub-mesh to road prefabs/assets, and set the texture of that mesh to same as the road? (ie. it will inherit texture of the main part of the road, assuming you can filter out pavements, etc?)

My Node controller mod already does that. its the bend or stretch option. but bending/stretching cannot count for the difference in number of lanes, Screenshot (999)

In theory it would also be possible to curve the mesh (and thus its texture) to handle situations where the main road doesn't go directly straight ahead. Admittedly, it would only work where the main road segments are same type, but that is the most common case for most junctions and would drastically improve overall appearance of the city.

Yep I curve and stretch it too(well CS does i just give the clues!)! look at the wiki

With additional work, the mesh could be more advanced; copy the road mesh including median if there is one, now you have ability to continue median across road and toggle it on/off depending on traffic lights :)

Direct connect has a code of its own. I had a skim but didn't understood how to arrive at that code path. I will have a look again later as part of my direct connect issue kianzarrin/myrepo#2

There would likely need to be some way to control the width of the mesh, eg. to trim off edge lines or parking lanes. That could be achieved automatically by looking at the lane types.

Already discussed in https://github.com/kianzarrin/myrepo/issues/2#issuecomment-623274986 (its pictures without explanation i think. but if the meshes are well designed all I have to do is to cut out the UV's beyond an x coordinate.

With props you're risking hitting the prop limit very soon - each junction could have lots of props, and there are lots of junctions... and detailers are already placing insane numbers of props in thier cities.

my props will be instead of detailers props. If they don't like my props they can turn it off (an extension to node controller?).

Note also that junction nodes are flat by default, which simplifies things somewhat.

this issue is for highway transitions (eg 2 lane to 3 lane) not intersections. although it might be in the future. if prop count is really an issue I can make it such that the user has to activate this per node manually so that too many nodes will not be painted.

kianzarrin commented 4 years ago

Network Tiling mod will likely be of use if the texture needs to repeat.

striped networks mod can be useful to me and it uses Network Tiling

Does network tiling use props or textures I wonder?

kianzarrin commented 4 years ago

I never managed to put props on my road to my satisfaction. Why do they get so ugly when I zoom out?

Screenshot (1066)

I have maximized my graphic settings.

Screenshot (1067)