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

Tile generation blue lines #4

Open
Nejcc opened this issue Aug 13, 2019 · 5 comments
Open

Tile generation blue lines #4

Nejcc opened this issue Aug 13, 2019 · 5 comments

Comments

@Nejcc
Copy link

Nejcc commented Aug 13, 2019

alt text here is the graphic issue to fix

@Hamsterman
Copy link

I see the same

@ladenedge
Copy link

ladenedge commented Sep 9, 2019

This appears to be a problem with the custom surface shader. The z-fighting seems to suggest it's coloring the triangles with both colors from the nearby biomes. (But why not the water? I dunno.)

Anyway, I solved this with the following steps:

  1. Replace the custom surface shader (in Terrain.shader) with a custom vertex shader. This one in the Unity wiki works for me.
  2. In TerrainGenerator.cs, add some color storage:
var colors = new List<Color> ();
Color[] startCols = { water.startCol, sand.startCol, grass.startCol };
Color[] endCols = { water.endCol, sand.endCol, grass.endCol };
  1. A bit below that, record the current tile color rather than UVs:
Vector2 uv = GetBiomeInfo (map[x, y], biomes);
// uvs.AddRange (new Vector2[] { uv, uv, uv, uv });  <-- not needed anymore
var color = Color.Lerp(startCols[(int)uv.x], endCols[(int)uv.x], uv.y);
colors.AddRange(new[] { color, color, color, color });
  1. Do the same in the big for loop that creates edges:
// uvs.AddRange (new Vector2[] { uv, uv, uv, uv });
colors.AddRange(new[] { color, color, color, color });
  1. In TerrainGenerator.cs, call SetColors() rather than SetUVs():
// mesh.SetUVs (0, uvs);  <-- no longer needed
mesh.SetColors(colors);

That should do it.

image

@mubin986
Copy link

This appears to be a problem with the custom surface shader. The z-fighting seems to suggest it's coloring the triangles with both colors from the nearby biomes. (But why not the water? I dunno.)

Anyway, I solved this with the following steps:

  1. Replace the custom surface shader (in Terrain.shader) with a custom vertex shader. This one in the Unity wiki works for me.
  2. In TerrainGenerator.cs, add some color storage:
var colors = new List<Color> ();
Color[] startCols = { water.startCol, sand.startCol, grass.startCol };
Color[] endCols = { water.endCol, sand.endCol, grass.endCol };
  1. A bit below that, record the current tile color rather than UVs:
Vector2 uv = GetBiomeInfo (map[x, y], biomes);
// uvs.AddRange (new Vector2[] { uv, uv, uv, uv });  <-- not needed anymore
var color = Color.Lerp(startCols[(int)uv.x], endCols[(int)uv.x], uv.y);
colors.AddRange(new[] { color, color, color, color });
  1. Do the same in the big for loop that creates edges:
// uvs.AddRange (new Vector2[] { uv, uv, uv, uv });
colors.AddRange(new[] { color, color, color, color });
  1. In TerrainGenerator.cs, call SetColors() rather than SetUVs():
// mesh.SetUVs (0, uvs);  <-- no longer needed
mesh.SetColors(colors);

That should do it.

image

You're really awesome!! :D

@VengantMjolnir
Copy link

Lol, I * solved * it a different way. The tiling parameter would cause the graphical artifacts when it was set to <= 1, but if you adjust tiling X in the material to something just slight > 1 the artifacts go away. I suspect it is prevision in the shader, but didn't really dig into it a lot.

@lolaswift
Copy link

Lol, I * solved * it a different way. The tiling parameter would cause the graphical artifacts when it was set to <= 1, but if you adjust tiling X in the material to something just slight > 1 the artifacts go away. I suspect it is prevision in the shader, but didn't really dig into it a lot.

you're awesome

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

6 participants