CitiesSkylinesMods / HideCrosswalks

MIT License
8 stars 3 forks source link

Fix road/node texture mismatch on "plain" roads #2

Open kianzarrin opened 4 years ago

kianzarrin commented 4 years ago

In the picture bellow 4L road has smooth segment to junction transition but there is a APR texture missmatch for the 6L road. Screenshot (1)

After doing a few experiments it appears that only plain roads(no aymmetry/decoration/medians) have this problem.

sometimes CS stretches node texture WRT the segment texture before rendering them. In such circumstances blending in the segment texture to node texture can result into texture mismatch.

// Simplified blending code
float weight= i/length; 
node_color[i] = node_color[i]*weight+segment_color[i]*(1-weight);

So far I look for grass/trees in the name of the road to determine if it has decoration and look for a lane with laneType == None to find medians. If so I shrink segment textures by 91%.

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 one another and I do not know how much is the scaling factor.

Need

Further notes

In the images bellow I put the segment texture underthe generated (by blending) node APR texture for 4L and 6L road:

Screenshot (246) - Copy

node melt_APRMap

related: https://github.com/kianzarrin/HideTMPECrosswalks/issues/1#issuecomment-568302473

kianzarrin commented 4 years ago

My improved road textures: Screenshot (263)

kianzarrin commented 4 years ago

Cgameworld wrote: https://github.com/kianzarrin/HideTMPECrosswalks/issues/1#issuecomment-569488906

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

@Cgameworld I checked meshes using mod tools. I compared "6L plain road" VS "6L grass road" because the plain road has mismatch problem and the grass road does not.

there is no difference in the uv of the nodes and segments. the same is true with all other parameters of the Mesh. The only thing that grabbed my attention are the vertices.

"6L grass road" VS "6L plain road" : Screenshot (268)

But then again the vertices of the "6L plain road" are the same between node and segment meshes. So this is a dead end!

EDIT: sorry the original message was not readable so I almost edited the whole message!