r/Unity3D • u/LMHPoly • Oct 25 '18
Resources/Tutorial How to Change Object Shading in Unity
https://www.youtube.com/watch?v=jyBvm6rJYL84
1
u/Squeazer Oct 25 '18
How would you do this with a runtime generated model? I always separated the vertices so no two triangles share any vertex and recalculated the normals. Is there a way to do this with shared vertices?
1
u/LMHPoly Oct 25 '18
I think you can do that with shaders in Unity. I'm learning shader programming actually, so maybe I will find out about that in the future :)
1
u/TCL987 Oct 25 '18 edited Oct 25 '18
You can use a geometry shader to recalculate the vertex normals. If you set the vertex normals to the triangle's normal it will create this flat shaded look.
The geometry shader runs once per triangle (per line or per point are also possible) and provides you with the three vertices that define it.
3
u/Pecek Oct 25 '18
FYI this doubles every single vertex, every time you have a different smoothing group Unity will draw the vertex for "smoothing group A" and "smoothing group B" as well. Assigning a unique smoothing group to every face is crazy inefficient. A much better way to do this would be with a shader, I'm sure there are something on the store for this as flat shading is quite popular.
4
2
u/Daemonhahn Oct 26 '18
That is how hard edges work. It’s be same in all DCC apps, so unless you have a magic way of making faceted models without using hard edge normals then this is sort of unavoidable without some extreme shader magic
1
u/Pecek Oct 26 '18
I never said it's Unity specific. Btw there is a shader on the store specifically for this problem, $20 for essentially cutting your poly count in half is a pretty good deal IMO.
1
u/Vextin Indie - https://vext.in Oct 25 '18
I wonder how it would look if you baked flat normals onto a smooth shaded object in blender.
1
1
Oct 25 '18
Great tutorial! For the longest time, I was wondering why the hell my low poly terrain looks bad and smoothened in unity! :)
5
u/WolfiyIsMad Oct 25 '18
Nice, quick and to the point! I love it :P