Documentation

Unity Engine


Unity Engine


Simple unlit shader example in the Built-In Render Pipeline

Example of a shader that renders an unlit texture.
Read time 1 minuteLast updated a month ago

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.

A purple cat-like character lit using simple shading.

Shader "Unlit/SimpleUnlitTexturedShader"{ Properties { // we have removed support for texture tiling/offset, // so make them not be displayed in material inspector [NoScaleOffset] _MainTex ("Texture", 2D) = "white" {} } SubShader { Pass { HLSLPROGRAM // use "vert" function as the vertex shader #pragma vertex vert // use "frag" function as the pixel (fragment) shader #pragma fragment frag #include "UnityCG.cginc" // vertex shader inputs struct appdata { float4 vertex : POSITION; // vertex position float2 uv : TEXCOORD0; // texture coordinate }; // vertex shader outputs ("vertex to fragment") struct v2f { float2 uv : TEXCOORD0; // texture coordinate float4 vertex : SV_POSITION; // clip space position }; // vertex shader v2f vert (appdata v) { v2f o; // transform position to clip space // (multiply with model*view*projection matrix) o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); // just pass the texture coordinate o.uv = v.uv; return o; } // texture we will sample sampler2D _MainTex; // pixel shader; returns low precision ("half4" type) // color ("SV_Target" semantic) half4 frag (v2f i) : SV_Target { // sample texture and return it half4 col = tex2D(_MainTex, i.uv); return col; } ENDHLSL } }}