Last active
March 19, 2022 14:15
-
-
Save DevEarley/1020fc4921057dc10239a1a39ea337f6 to your computer and use it in GitHub Desktop.
Shader that works well with Unity3d. Tested with Collada file that had vertex colors.
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/VertexColorEmissive" | |
{ | |
Properties | |
{ | |
_MainTex("Color (RGB) Alpha (A)", 2D) = "white" {} | |
_Glossiness ("Smoothness", Range(0,1)) = 0.5 | |
_Metallic("Metallic", Range(0,1)) = 0.0 | |
_Emissive ("Emissive", Range(0,1)) = 1.0 | |
_Cutoff("Alpha cutoff", Range(0,1)) = 0.2 | |
} | |
SubShader | |
{ | |
Tags {"Queue" = "AlphaTest" "RenderType" = "TransparentCutout"} | |
LOD 200 | |
CGPROGRAM | |
#pragma surface surf Standard vertex:vert alphatest:_Cutoff | |
#pragma target 3.0 | |
sampler2D _MainTex; | |
struct Input | |
{ | |
float4 vertColor; | |
float2 uv_MainTex; | |
}; | |
half _Glossiness; | |
half _Emissive; | |
half _Metallic; | |
fixed4 _Color; | |
UNITY_INSTANCING_BUFFER_START(Props) | |
UNITY_INSTANCING_BUFFER_END(Props) | |
void vert(inout appdata_full v, out Input o) { | |
UNITY_INITIALIZE_OUTPUT(Input, o); | |
o.vertColor = v.color; | |
} | |
void surf (Input IN, inout SurfaceOutputStandard o) | |
{ | |
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * IN.vertColor; | |
o.Albedo = c.rgb; | |
o.Metallic = _Metallic; | |
o.Smoothness = _Glossiness; | |
o.Emission = tex2D(_MainTex, IN.uv_MainTex).rgb * IN.vertColor *_Emissive; | |
o.Alpha = tex2D(_MainTex, IN.uv_MainTex).a; | |
} | |
ENDCG | |
} | |
FallBack "Diffuse" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment