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.3 (6000.3) / URP 17.3.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.3.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.3.0 ide index.
For the full list, search @@TOK_15_20e1594e@@.| Symbol | Returns | Params(요약) | Defined-in | related | |---|---|---|---|---| | TransformObjectToHClip | float4 | float3 positionOS | <CORE>/ShaderLibrary/SpaceTransforms.hlsl:108 | 08 | | GetVertexPositionInputs | VertexPositionInputs | float3 positionOS | <URP>/ShaderLibrary/ShaderVariablesFunctions.hlsl:8 | 21 | | GetVertexNormalInputs | VertexNormalInputs | float3 normalOS, float4 tangentOS 了 | <URP>/ShaderLibrary/ShaderVariablesFunctions.hlsl:22 | 21 | | GetMainLight | Light | (overloads) | <URP>/ShaderLibrary/RealtimeLights.hlsl | 07 | | GetAdditionalLight | Light | uint i, float3 positionWS 了 | <URP>/ShaderLibrary/RealtimeLights.hlsl | 07 | | GetAdditionalLightsCount | int | (none) | <URP>/ShaderLibrary/RealtimeLights.hlsl:271 | 07 | | UniversalFragmentPBR | half4 | InputData, SurfaceData | <URP>/ShaderLibrary/Lighting.hlsl:282 | 22 | | InitializeStandardLitSurfaceData | void | float2 uv, out SurfaceData | <URP>/Shaders/LitInput.hlsl:252 | 22 | | InitializeInputData | void | Varyings, normalTS, out InputData | <URP>/Shaders/LitForwardPass.hlsl:72 | 22 |

representative xref(정의 + 아이처): @@TOK_34_8394c928@@

13.4 HLSL(URP) core structure: FIELD/정의 ויציק

Search the entire list from @@TOK_35_11a7626e@@.

StructureFields(개수)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

|---|---|---|---| | _CLUSTER_LIGHT_LOOP | shader keyword | <URP>/ShaderLibrary/ForwardPlusKeyword.deprecated.hlsl:20 etc | variant branch (Forward+) | | USE_CLUSTER_LIGHT_LOOP | macro(0/1) | <URP>/ShaderLibrary/Core.hlsl:14 / :16 | include inner loop switch | | LIGHT_LOOP_BEGIN/END | macros | <URP>/ShaderLibrary/RealtimeLights.hlsl:28 / :36 | Forward/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.3.0 Lit)

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

Total ticket/consumption stage of the contract: @@TOK_18_b865c9ce@@

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 호환 셰이더 작성