book/13-reference-cheatsheet.md

13. Reference (cheat sheet)

A page to quickly find SRP/URP/RenderGraph/HLSL core symbols by “signature + definition location + reference (xref)” based on Unity 6.5 (6000.5) / URP 17.5.0

This page is a reference for “quickly finding things when you get confused while studying.”
In particular, HLSL items do not provide “concepts” but return value/signature/definition location/representative reference (xref).

13.0 Accurate Reference (IDE, URP 17.5.0)

13.1 C# (SRP/URP) core types

13.2 URP Frame Data (frequently used, RenderGraph path)

These are the data types accessed by ContextContainer frameData in the RenderGraph path.

Official documentation:

13.3 HLSL(URP) core functions: signature/return value/definition location

The table below is the “Learning Core” extracted from the URP 17.5.0 ide index. For the full list, search IDE Index.

SymbolReturnsParams (summary)Defined-inRelated
TransformObjectToHClipfloat4float3 positionOS<CORE>/ShaderLibrary/SpaceTransforms.hlsl:10808
GetVertexPositionInputsVertexPositionInputsfloat3 positionOS<URP>/ShaderLibrary/ShaderVariablesFunctions.hlsl:821
GetVertexNormalInputsVertexNormalInputsfloat3 normalOS, float4 tangentOS<URP>/ShaderLibrary/ShaderVariablesFunctions.hlsl:2221
GetMainLightLight(overloads)<URP>/ShaderLibrary/RealtimeLights.hlsl07
GetAdditionalLightLightuint i, float3 positionWS<URP>/ShaderLibrary/RealtimeLights.hlsl07
GetAdditionalLightsCountint(none)<URP>/ShaderLibrary/RealtimeLights.hlsl:27107
UniversalFragmentPBRhalf4InputData, SurfaceData<URP>/ShaderLibrary/Lighting.hlsl:28222
InitializeStandardLitSurfaceDatavoidfloat2 uv, out SurfaceData<URP>/Shaders/LitInput.hlsl:25222
InitializeInputDatavoidVaryings, normalTS, out InputData<URP>/Shaders/LitForwardPass.hlsl:7222

Representative xref (definition + call site): IDE Index

13.4 HLSL(URP) core structures: fields and definitions

Search the entire list from IDE Index.

StructureFields (count)Defined-inRelated
Light5<URP>/ShaderLibrary/RealtimeLights.hlsl:1207
InputData23<URP>/ShaderLibrary/Input.hlsl:4321
SurfaceData10<URP>/ShaderLibrary/SurfaceData.hlsl:521
VertexPositionInputs4<URP>/ShaderLibrary/Core.hlsl:25921
VertexNormalInputs3<URP>/ShaderLibrary/Core.hlsl:26721
SymbolTypeDefined-inKey Points
_CLUSTER_LIGHT_LOOPshader keyword<URP>/ShaderLibrary/ForwardPlusKeyword.deprecated.hlsl:20 etcvariant branch (Forward+)
USE_CLUSTER_LIGHT_LOOPmacro(0/1)<URP>/ShaderLibrary/Core.hlsl:14 / :16include inner loop switch
LIGHT_LOOP_BEGIN/ENDmacros<URP>/ShaderLibrary/RealtimeLights.hlsl:28 / :36Forward/Forward+ loop unification

The most common pitfall is that GetAdditionalLightsCount() in Forward+ can be 0.
Detailed debugging routine: 07

13.6 ShaderLab Pass tags/LightMode (9 types as of URP 17.5.0 Lit)

LightModePurpose (Summary)
UniversalForwardForward color
UniversalGBufferDeferred GBuffer
ShadowCastershadow
DepthOnlyDepth
DepthNormalsDepth+Normal
MetaBaking
MotionVectorsvelocity
XRMotionVectorsXR velocity(+stencil)
Universal2D2D Renderer

Full pass and consumption-stage contract: 20. Pass Tags and LightMode Contract

13.7 Commonly seen calls (concepts) in RenderGraph “Builder”

The exact signature may be different for different versions of URP, but conceptually you see the following call over and over again:

  • Add pass: renderGraph.AddRasterRenderPass<T>(...)
  • Texture creation: renderGraph.CreateTexture(desc)
  • Import external RTHandle: renderGraph.ImportTexture(rtHandle)
  • Read declaration: builder.UseTexture(handle, AccessFlags.Read)
  • Color target setting: builder.SetRenderAttachment(handle, index, AccessFlags.Write)
  • Execution function settings: builder.SetRenderFunc((data, ctx) => { ... })

Related: 04. RenderGraph

13.8 Frequently seen calls (concepts) in ComputeGraphContext (Compute Pass)

In the Compute pass, ComputeGraphContext is passed, usually repeating the following pattern.

  • Add pass: renderGraph.AddComputePass<T>(...)
  • UAV texture creation: desc.enableRandomWrite = true
  • Texture read/write declaration: builder.UseTexture(handle, AccessFlags.Read/Write)
  • Binding: cmd.SetComputeTextureParam(...), cmd.SetComputeBufferParam(...)
  • Run: cmd.DispatchCompute(...)

Related: 17. RenderGraph Compute/UAV

13.9 ShaderLab tag/key (representative)

  • Tags { "RenderPipeline"="UniversalPipeline" } — Declare shader for URP
  • Tags { "LightMode"="UniversalForward" } — Declaration of pass usage selected by URP
  • Queue / RenderType — Render queue/render type (opaque/transparent) classification

Related: 09. URP 호환 셰이더 작성