- Home /
Material for mesh based terrain
I'm tiling together a terrain using basic meshes that I construct in a script. This works well, but applying a material just doesn't look right. The corners don't blend smoothly with the sides
I've tried tweaking the material, the lighting, the mesh itself but can't find a awy to fix it. The corner triangles are too dark on the one side, and too bright on the other.
I don't mind experimenting with writing a shader but the Standard surface shader already has the same problem.
Is there a way to fix the shading so it looks smooth?
You need to assign the normals of the mesh. Check the Scripting API and User $$anonymous$$anual for Unity's mesh class.
I already run $$anonymous$$esh.RecalculateNormals after the mesh is created, does that not assign them automatically? The texture is actually applied well (just a simple grid texture).
Answer by Remy_Unity · Nov 27, 2017 at 12:34 PM
It clearly seem to be related to the mesh normals. When you use Mesh.RecalculateNormals, Unity simply creates the normals by looking at the shared vertices between triangles. Looking at your mesh, I guess that each quad is a separate mesh element (not separate mesh renderer, they just don't share vertices). If you want to have a hard edge at your corner, you need to separate the triangles that lay there : 2 triangles, 6 vertices (not 4), by doubling the vertices shared by the "hypotenuse".
Answer by Txguug · Nov 27, 2017 at 01:10 PM
you need to separate the triangles that lay there : 2 triangles, 6 vertices (not 4), by doubling the vertices shared by the "hypotenuse".
I think I understand,
so (using quads) instead of
(a)(b)
(c)(d)
with triangles (a,b,c) and (c,b,d)
iI'll try
(a)(b,c)
(d,e)(f)
with triangles (a,b,d) and (e,c,f)
Your answer
Follow this Question
Related Questions
Fresnel shader and mixed textures 0 Answers
Adding custom materials that are made using shadergraph to terrains 1 Answer
Laying a texture over an entire terrain 1 Answer
Highlighting an object just like in Editor Scene View 0 Answers
String name for particles / additive soft particles factor 1 Answer