Skip to content

Instantly share code, notes, and snippets.

@F1Soda
Created July 2, 2025 15:58
Show Gist options
  • Save F1Soda/4840c877c89c38dfdcfcfdedc2b8db04 to your computer and use it in GitHub Desktop.
Save F1Soda/4840c877c89c38dfdcfcfdedc2b8db04 to your computer and use it in GitHub Desktop.
Cheat sheet with all ShaderLab features for URP Unity 6
// https://docs.unity3d.com/6000.2/Documentation/Manual/SL-Shader.html
Shader "Unlit/temp"
{
// https://docs.unity3d.com/6000.2/Documentation/Manual/SL-Properties.html
Properties
{
// Numeric types
_ExampleFloat ("Float display", Float) = 0.5
_ExampleRange ("Range slider", Range(0.0, 1.0)) = 0.75
_ExampleInteger ("Integer display", Integer) = 2
// Vector type
_ExampleVector ("4‑component vector", Vector) = (1, 0.5, 0, 1)
// Color type
_ExampleColor ("Color picker", Color) = (0.2, 0.8, 0.6, 1)
// Texture types
_ExampleTex2D ("2D Texture", 2D) = "white" {}
_ExampleTex3D ("3D Texture", 3D) = "" {}
_ExampleCubemap ("Cube Texture", Cube) = "" {}
_ExampleCubeArray ("CubeArray", CubeArray) = "" {}
_ExampleTex2DArray ("2DArray", 2DArray) = "" {}
_OffsetUnitScale ("Offset unit scale", Integer) = 1
// https://docs.unity3d.com/6000.2/Documentation/Manual/shader-keywords-material-inspector.html
[ToggleOff] _RED ("Make red", Integer) = 0
[KeywordEnum(RED, GREEN, BLUE)] _COLOR ("Color", Integer) = 0
// Optional attributes
// [HideInInspector] – hides in inspector
// [NoScaleOffset] – removes tiling/offset UI from textures
// [Normal] – flags texture as normal map
// [HDR] – HDR color/texture using HDR picker or warning
// [Gamma] – treat float/vector as sRGB-coded
// [PerRendererData] – read-only per-instance data
// [MainTexture], [MainColor] – set main texture/color override
}
// https://docs.unity3d.com/6000.2/Documentation/Manual/SL-Other.html
Category
{
// GPU Render State Commands
// They can be set either in SubShader or in Pass
// https://docs.unity3d.com/6000.2/Documentation/Manual/SL-Commands.html
AlphaToMask On
// https://docs.unity3d.com/6000.2/Documentation/Manual/SL-SubShader-object.html
SubShader
{
// https://docs.unity3d.com/6000.1/Documentation/Manual/writing-shader-include-shader-program.html
HLSLINCLUDE
// HLSL code that you want to share goes here
ENDHLSL
// https://docs.unity3d.com/6000.2/Documentation/Manual/writing-shader-tags-require-package.html
PackageRequirements
{
"com.unity.render-pipelines.universal": "[10.2.1,11.0]"
"com.unity.textmeshpro": "3.2"
}
// https://docs.unity3d.com/6000.2/Documentation/Manual/SL-ShaderLOD.html
LOD 100
// https://docs.unity3d.com/6000.2/Documentation/Manual/SL-SubShaderTags.html
// https://docs.unity3d.com/6000.2/Documentation/Manual/add-shader-tag.html
Tags
{
"RenderPipeline" = "UniversalPipeline"
"Queue" = "Overlay + 100"
"RenderType" = "String" // There are no set values for this parameter
"ForceNoShadowCasting" = "True"
"DisableBatching" = "LODFading"
"IgnoreProjector" = "False"
"PreviewType" = "Skybox"
}
// GPU Render State Commands
// They can be set either in SubShader or in Pass
// https://docs.unity3d.com/6000.2/Documentation/Manual/SL-Commands.html
AlphaToMask On
Blend One Zero
BlendOp RevSub
ColorMask RGB 0 // writes only RGB to render target 0
ColorMask 0 1 // disables RGB on RT1, but writes alpha only
ColorMask RGB 2 // writes only RGB to RT2
Conservative True
Cull Back
// https://docs.unity3d.com/6000.2/Documentation/Manual/writing-shader-use-material-properties.html
Offset 0, [_OffsetUnitScale]
Stencil
{
Ref 2
Comp equal
Pass keep
ZFail decrWrap
}
ZClip False
ZTest Equal
ZWrite Off
// UsePass directive
UsePass "Examples/ContainsNamedPass/EXAMPLENAMEDPASS"
// https://docs.unity3d.com/6000.2/Documentation/Manual/SL-SubShader-pass.html
Pass
{
// https://docs.unity3d.com/6000.2/Documentation/Manual/SL-Name.html
Name "My Pass"
// GPU Render State Commands
// They can be set either in SubShader or in Pass
ZClip False
ZTest Equal
// https://docs.unity3d.com/6000.1/Documentation/Manual/urp/urp-shaders/urp-shaderlab-pass-tags.html
Tags
{
"LightMode" = "UniversalGBuffer"
"UniversalMaterialType" = "Lit"
}
HLSLPROGRAM
// Cg/HLSL can also accept uniform keyword, but it is not necessary:
uniform float4 _MyColor;
// All about #pragma
// https://docs.unity3d.com/6000.2/Documentation/Manual/SL-PragmaDirectives.html
// https://docs.unity3d.com/6000.1/Documentation/Manual/SL-MultipleProgramVariants-declare.html
// https://docs.unity3d.com/6000.2/Documentation/Manual/SL-MultipleProgramVariants.html
#pragma shader_feature KEK
#pragma multi_compile MAIN_LIGHT_EXAMPLE
#pragma dynamic_branch
#pragma target 2.0
#pragma region lol
//
#pragma endregion
// https://docs.unity3d.com/6000.2/Documentation/Manual/SL-MultipleProgramVariants-shortcuts.html
#pragma multi_compile_fwdadd
#pragma skip_variants POINT POINT_COOKIE
#pragma vertex Vert
#pragma fragment Frag
#pragma geometry Geom
#pragma hull Hull
#pragma require tesselation
#pragma domain Domain
// and a lot of cool pragma stuf in manual
#define SOME_PARAM 1337
ENDHLSL
}
}
SubShader
{
}
}
// https://docs.unity3d.com/6000.2/Documentation/Manual/writing-shader-display-types.html
CustomEditor "ExampleShaderGUI"
// https://docs.unity3d.com/6000.2/Documentation/Manual/SL-Fallback.html
Fallback "ExampleFallbackShader"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment