-
-
Save jhorikawa/7a236ae0b801bf2aca2d8a3038b9bf40 to your computer and use it in GitHub Desktop.
| Shader "Custom/VertexColor" { | |
| SubShader { | |
| Tags { "RenderType"="Opaque" } | |
| LOD 200 | |
| CGPROGRAM | |
| #pragma surface surf Lambert vertex:vert | |
| #pragma target 3.0 | |
| 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) { | |
| o.Albedo = IN.vertColor.rgb; | |
| } | |
| ENDCG | |
| } | |
| FallBack "Diffuse" | |
| } |
I'm going to figure out how to add some transparency to your shader. Thanks for sharing!
hey, did u manage to do it? I see that u added o.Alpha = .5; but its not working for me, in my case, im trying to stream rgba from grasshopper and I have issues with alpha and saturation.
Thanks a bunch, this is exactly what i needed.
@jhorikawa Still works great for Unity 2019.2.
Do you have an idea how to use it with the Lightweight-Renderpipeline?
hi jhorikawa
Thank you for sharing this shader code! I'm not a programmer just a gfx guy :)
I made a test. I changed your code in line 20:
o.Emissive = IN.vertColor.rgb;
because I want only vertex color lit on the scene without any lamp. (vertex color with ambient support)
But I have a "small" problem in Unity.

Left is the original mesh in Maya without lighting/shading - vertex color as "emissive"
The mesh's edges are smooth (each vertex has 1 vertex normal).
When I importing the mesh with vertex color and give this shader to them the colors
- changed to yellow (no lights in the scene)
- looks like there is some kind of shading and looks like the vertex normals changed
I don't know how can I fix this.
Do you have any idea?
Lifesaver🙌🙌

I'm going to figure out how to add some transparency to your shader. Thanks for sharing!