Important: The Built-In Render Pipeline is deprecated and will be made obsolete in a future release.
It remains supported, including bug fixes and maintenance, through the full Unity 6.7 LTS lifecycle.
For more information on migration, refer to Migrating from the Built-In Render Pipeline to the Universal Render Pipeline and Render pipeline feature comparison.
Use prebuilt HLSL vertex input structures from UnityCG.cginc to simplify vertex shader declarations in the Built-In Render Pipeline.
To use a prebuilt structure, follow these steps:
#include "UnityCG.cginc" at the top of your HLSLPROGRAM. This imports the UnityCG.cginc file, which contains the prebuilt structures.appdata_base, use v2f vert (appdata_base vertex_data).The prebuilt structures in UnityCG.cginc are:
appdata_base: Declares vertex for position, normal, and texcoord.appdata_tan: Declares vertex for position, tangent, normal, and texcoord.appdata_full: Declares vertex for position, tangent, normal, color, texcoord, texcoord1, texcoord2, and texcoord3.appdata_img: Declares vertex for position, and texcoord.The following shader uses appdata_base, and colors the mesh based on its normals.
Shader "VertexInputSimple" {
SubShader {
Pass {
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
// Declare the structure for data passed from the vertex shader to the fragment shader.
struct v2f {
float4 position : SV_POSITION;
half4 color : COLOR;
};
// Use the built-in appdata_base structure for the vertex shader.
v2f vert (appdata_base v)
{
v2f output_data;
// Use the position from appdata_base.
output_data.position = UnityObjectToClipPos(v.vertex);
// Use the normal from appdata_base.
output_data.color.xyz = v.normal * 0.5 + 0.5;
output_data.color.w = 1.0;
return output_data;
}
half4 frag (v2f i) : SV_Target {
return i.color;
}
ENDHLSL
}
}
}