Skip to content
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

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

Open
kianzarrin opened this issue Dec 29, 2019 · 3 comments
Open

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

kianzarrin opened this issue Dec 29, 2019 · 3 comments

Comments

@kianzarrin
Copy link
Collaborator

kianzarrin commented Dec 29, 2019

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.

  • I do not know if the shrinking factor is always a constant 91%.
  • My criteria of searching the road name to determine decoration is hackish and not future proof.
  • Is it really the roads without median/decoration that have texture mismatch?

###Need

  • better criterion for determining road decoration (info.GetDecorationArea() does not work - maybe calculate integral of yellow color in the segment texture?).
  • my criteria of looking for decorations/median seems hackish and not future proof. I need to know what part of code is responsible for this texture mismatch and replicate that code or myself.

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:
#1 (comment)

@kianzarrin kianzarrin mentioned this issue Dec 29, 2019
46 tasks
@kianzarrin
Copy link
Collaborator Author

My improved road textures:
Screenshot (263)

@kianzarrin
Copy link
Collaborator Author

Cgameworld wrote: #1 (comment)

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
Copy link
Collaborator Author

kianzarrin commented Dec 29, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant