Skip to content

Instantly share code, notes, and snippets.

@haosizheng
Last active August 17, 2026 20:16
Show Gist options
  • Select an option

  • Save haosizheng/0b6f628149ee8645d3219c2c8cd8694e to your computer and use it in GitHub Desktop.

Select an option

Save haosizheng/0b6f628149ee8645d3219c2c8cd8694e to your computer and use it in GitHub Desktop.
UnityUrpVertexColoredShader
// this shader using vertex color as input and show on meshes' surface.
// have searched a long time but there is no one upload a vertex-colored shader for urp so I made this.
// have a good day.
Shader "Example/VertexColor" {
Properties
{
}
SubShader {
Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" }
Pass
{
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes
{
float4 positionOS : POSITION;
float4 vertColor: COLOR;
};
struct Varyings {
float4 positionHCS : SV_POSITION;
float4 color: COLOR;
};
Varyings vert(Attributes IN){
Varyings OUT;
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
OUT.color = IN.vertColor;
return OUT;
}
half4 frag(Varyings IN) : SV_Target
{
return IN.color.rgba;
// return float4(0,0,1,0);
}
ENDHLSL
}
}
}
@DebbyX3

DebbyX3 commented Aug 17, 2026

Copy link
Copy Markdown

thanks! it still works in unity 6000.2.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment