19. URP Shader Methods Reference (URP 17.3.0)
This chapter is a dictionary (reference) chapter that collects “symbols that are frequently used when studying shaders.”
Principle:
- All items are provided with return value/parameter/definition location (file/line).
- The list is curated only for “learning core”. For the full index, search generated.
19.0 Accurate Reference (Generated)
- Full function signature: @@TOK_0_20e1594e@@
- All macros: @@TOK_1_9ecae65e@@
- Lit core symbol xref (definition + representative call destination): @@TOK_2_8394c928@@
19.1 Transform / Space (Coordinate transformation)
| API | Signature | Defined-in | Used-by / Notes |
|---|---|---|---|
TransformObjectToWorld |
float3 (float3 positionOS) |
<CORE>/ShaderLibrary/SpaceTransforms.hlsl:79 |
OS→WS basic conversion |
TransformObjectToHClip |
float4 (float3 positionOS) |
<CORE>/ShaderLibrary/SpaceTransforms.hlsl:108 |
OS→Clip (most often) |
TransformWorldToView |
float3 (float3 positionWS) |
<CORE>/ShaderLibrary/SpaceTransforms.hlsl:97 |
WS→VS |
TransformWorldToHClip |
float4 (float3 positionWS) |
<CORE>/ShaderLibrary/SpaceTransforms.hlsl:115 |
WS→Clip |
TransformWorldToShadowCoord |
float4 (float3 positionWS) |
<URP>/ShaderLibrary/Shadows.hlsl:356 |
WS→ShadowCoord |
19.2 Vertex input helper (Attributes → Inputs)
| API | Signature | Defined-in | Used-by / Notes |
|---|---|---|---|
GetVertexPositionInputs |
VertexPositionInputs (float3 positionOS) |
<URP>/ShaderLibrary/ShaderVariablesFunctions.hlsl:8 |
Prepare WS/VS/CS/NDC at once |
GetVertexNormalInputs |
VertexNormalInputs (float3 normalOS) |
<URP>/ShaderLibrary/ShaderVariablesFunctions.hlsl:22 |
Case without tangent |
GetVertexNormalInputs |
VertexNormalInputs (float3 normalOS, float4 tangentOS) |
<URP>/ShaderLibrary/ShaderVariablesFunctions.hlsl:31 |
tangent basis preparation |
Related (struct field): @@TOK_27_de3113a7@@
| ## 19.3 Screen/UV/Depth helper (core screen-based effects) | API | Signature | Defined-in | Used-by / Notes |
|---|---|---|---|---|
GetNormalizedScreenSpaceUV |
float2 (float4 positionCS) |
<URP>/ShaderLibrary/ShaderVariablesFunctions.hlsl:570 |
Forward+ (cluster) key input | |
SampleSceneColor |
float3 (float2 uv) |
<URP>/ShaderLibrary/DeclareOpaqueTexture.hlsl:10 |
OpaqueTexture sample | |
SampleSceneDepth |
float (float2 uv) |
<URP>/ShaderLibrary/DeclareDepthTexture.hlsl:18 |
raw depth (nonlinear) | |
SampleSceneNormals |
float3 (float2 uv) |
<URP>/ShaderLibrary/DeclareNormalsTexture.hlsl:26 |
normals texture sample | |
Linear01Depth |
float (float depth, float4 zBufferParam) |
<CORE>/ShaderLibrary/Common.hlsl:1198 |
raw→0..1 linear | |
LinearEyeDepth |
float (float depth, float4 zBufferParam) |
<CORE>/ShaderLibrary/Common.hlsl:1208 |
raw→eye depth |
Practical Checklist: @@TOK_18_d1d44a5e@@
19.4 Lit entry/initialization (Forward)
| API | Returns | Params (Summary) | Defined-in | Used-by / Notes |
|---|---|---|---|---|
LitPassVertex |
Varyings |
Attributes input |
<URP>/Shaders/LitForwardPass.hlsl:158 |
ForwardLit vertex entry |
LitPassFragment |
void |
Varyings input, out SV_Target0 ... |
<URP>/Shaders/LitForwardPass.hlsl:223 |
out SV_Target contract |
InitializeStandardLitSurfaceData |
void |
float2 uv, out SurfaceData |
<URP>/Shaders/LitInput.hlsl:252 |
Configure SurfaceData |
InitializeInputData |
void |
Varyings, normalTS, out InputData |
<URP>/Shaders/LitForwardPass.hlsl:72 |
Configure InputData |
InitializeBakedGIData |
void |
Varyings, inout InputData |
<URP>/Shaders/LitForwardPass.hlsl:132 |
Baked GI preparation |
ApplyDecalToSurfaceData |
void |
positionCS, inout SurfaceData, inout InputData |
<URP>/ShaderLibrary/DBuffer.hlsl:191 |
DBuffer decals |
UniversalFragmentPBR |
half4 |
InputData, SurfaceData |
<URP>/ShaderLibrary/Lighting.hlsl:282 |
PBR synthesis |
MixFog |
half3 |
half3 color, half fog |
<URP>/ShaderLibrary/ShaderVariablesFunctions.hlsl:513 |
fog combined |
OutputAlpha |
half |
half alpha, bool transparent |
<URP>/ShaderLibrary/ShaderVariablesFunctions.hlsl:239 |
Transparent processing |
Call flow/edit point: @@TOK_55_e356ea28@@
19.5 Lights (main/additional lights) + Forward+ (cluster) loop
| ### 19.5.1 Light access function | API | Returns | Params (Summary) | Defined-in | Notes |
|---|---|---|---|---|---|
GetMainLight |
Light |
(none) | <URP>/ShaderLibrary/RealtimeLights.hlsl:81 |
Simplest | |
GetMainLight |
Light |
float4 shadowCoord |
<URP>/ShaderLibrary/RealtimeLights.hlsl:102 |
Includes shadow input | |
GetAdditionalLight |
Light |
uint i, float3 positionWS |
<URP>/ShaderLibrary/RealtimeLights.hlsl:224 |
Forward Basic | |
GetAdditionalLight |
Light |
uint i, InputData, half4 shadowMask, AO |
<URP>/ShaderLibrary/RealtimeLights.hlsl:257 |
Function combination | |
GetAdditionalLightsCount |
int |
(none) | <URP>/ShaderLibrary/RealtimeLights.hlsl:271 |
May be 0 in Forward+ (Contract) |
19.5.2 Forward+ loop macro (most important)
| Symbol | Kind | Defined-in | Key Points |
|---|---|---|---|
_CLUSTER_LIGHT_LOOP |
shader keyword | <URP>/ShaderLibrary/ForwardPlusKeyword.deprecated.hlsl:20 etc. |
variant branch |
USE_CLUSTER_LIGHT_LOOP |
macro 0/1 | <URP>/ShaderLibrary/Core.hlsl:14 / :16 |
include internal switches |
LIGHT_LOOP_BEGIN/END |
macros | <URP>/ShaderLibrary/RealtimeLights.hlsl:28 / :36 |
loop implementation unification |
Forward+ Advanced: 07
19.6 Shadows
| API | Returns | Params (Summary) | Defined-in | Notes |
|---|---|---|---|---|
GetShadowCoord |
float4 |
VertexPositionInputs |
<URP>/ShaderLibrary/Shadows.hlsl:524 |
Main light shadowCoord ready |
MainLightRealtimeShadow |
half |
float4 shadowCoord |
<URP>/ShaderLibrary/Shadows.hlsl:385 |
main light realtime shadow |
AdditionalLightRealtimeShadow |
half |
int lightIndex, float3 positionWS, half3 lightDir |
<URP>/ShaderLibrary/Shadows.hlsl:425 |
Additional light shadow |
Macro (representative):
| Macro | Kind | Defined-in | Notes |
|---|---|---|---|
SAMPLE_SHADOWMASK |
function-like macro | <URP>/ShaderLibrary/Shadows.hlsl:45 etc. |
shadow mixing path |
19.7 Indirect / SH / GI (indirect light)
| API | Returns | Params (Summary) | Defined-in | Notes |
|---|---|---|---|---|
SampleSHVertex |
half3 |
half3 normalWS |
<URP>/ShaderLibrary/GlobalIllumination.hlsl:45 |
Vertex SH |
SampleSHPixel |
half3 |
half3 L2Term, half3 normalWS |
<URP>/ShaderLibrary/GlobalIllumination.hlsl:60 |
Pixel SH |
SampleSH |
real3 |
real3 normalWS |
<CORE>/ShaderLibrary/AmbientProbe.hlsl:69 |
Core SH sample |
Macro (representative):
| Macro | Kind | Defined-in | Notes |
|---|---|---|---|
SAMPLE_GI |
function-like macro | <URP>/ShaderLibrary/GlobalIllumination.hlsl:212 etc. |
Lightmap/Probe Branch |
19.8 “The function I am looking for is not found” — Quick find routine
- Search function name in @@TOK_54_20e1594e@@
- Check the context by opening the local URP/Core source with the path
Defined-in - If you need call flow: xref: @@TOK_56_8394c928@@