Open Nejcc opened 5 years ago
I see the same
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:
var colors = new List<Color> ();
Color[] startCols = { water.startCol, sand.startCol, grass.startCol };
Color[] endCols = { water.endCol, sand.endCol, grass.endCol };
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 });
// uvs.AddRange (new Vector2[] { uv, uv, uv, uv });
colors.AddRange(new[] { color, color, color, color });
SetColors()
rather than SetUVs()
:// mesh.SetUVs (0, uvs); <-- no longer needed
mesh.SetColors(colors);
That should do it.
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:
- Replace the custom surface shader (in Terrain.shader) with a custom vertex shader. This one in the Unity wiki works for me.
- 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 };
- 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 });
- 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 });
- In TerrainGenerator.cs, call
SetColors()
rather thanSetUVs()
:// mesh.SetUVs (0, uvs); <-- no longer needed mesh.SetColors(colors);
That should do it.
You're really awesome!! :D
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.
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
here is the graphic issue to fix