Last active
June 18, 2019 20:29
-
-
Save MichaelZhou/c3056f5efed0129171fc4e84770062e7 to your computer and use it in GitHub Desktop.
Shader that allows 3D meshes that support vertex colors (.fbx, .ply) to be colored by their vertices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Custom/VertexColor" { // Where it will appear inside of the Shader Dropdown Menu of the Material / Name of the shader | |
Properties{ | |
_Toggle ("Toggle context", int) = 1 | |
} | |
SubShader{ | |
Tags { "RenderType" = "Opaque" } | |
LOD 200 | |
CGPROGRAM | |
#pragma surface surf Lambert vertex:vert | |
#pragma target 3.0 | |
#include "UnityCG.cginc" | |
struct Input { | |
float4 vertColor; | |
}; | |
void vert(inout appdata_full v, out Input o) { | |
UNITY_INITIALIZE_OUTPUT(Input, o); | |
o.vertColor = v.color; | |
} | |
void surf(Input IN, inout SurfaceOutput o) { | |
#include "UnityCG.cginc" | |
o.Albedo = IN.vertColor.rgb; | |
clip(Toggle * (0.5f - IN.vertColor.b)); | |
} | |
ENDCG | |
} | |
FallBack "Diffuse" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment