cjurjiu / FlatShader

Unity Shader which achieves flat-shading, without the need for duplicating polygon vertices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FlatShader

A very simple shader which performs flatshading without the need for duplicating vertices when building the geometry.

Standard unity shader FlatShader

This is especially useful on mobile devices, which don't really enjoy pushing more vertices than they have to.

The basic idea behind how it works is that it computes a normal at the fragment level, which is then used in a custom lightning function. Original solution posted here. Also, this might also prove to be a useful reference.

The shader in this repository is not production ready in any way, and the lightning needs more tweaking. However, it ilustrates the concept.

Sample project used to create the images in the FlatShaderSampleProject folder. The Materials folder contains two materials: One uses the standard unity shader, the other uses the FlatShader presented here.

Just import the project in Unity, open the scene, hit play then swap the materials on the terrain in order to see how this behaves in comparison to the default Unity Standard shader.

Enjoy

About

Unity Shader which achieves flat-shading, without the need for duplicating polygon vertices.

License:The Unlicense


Languages

Language:ShaderLab 100.0%