Version: Unity 6 (6000.0)
Language : English
Shader methods in URP
Transform positions in a custom URP shader

Import a file from the URP shader library

The High-Level ShaderA program that runs on the GPU. More info
See in Glossary
Language (HLSL) shader files for the Universal Render PipelineA series of operations that take the contents of a Scene, and displays them on a screen. Unity lets you choose from pre-built render pipelines, or write your own. More info
See in Glossary
(URP) are in the Packages/com.unity.render-pipelines.universal/ShaderLibrary/ folder in your project.

To import a shader file into a custom shader file, add an #include directive inside the HLSLPROGRAM in your shader file. For example:

HLSLPROGRAM
...
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
...
ENDHLSL

You can then use the helper methods from the file. For example:

float3 cameraPosition = GetCameraPositionWS();

Refer to Shader methods in URP for more information about the different shader files.

You can also import shader files from the core Scriptable Render Pipeline (SRP). Refer to Shader methods in Scriptable Render Pipeline (SRP) Core.

Examples

Refer to Writing custom shaders for examples of using variables and helper methods from the files in the URP shader library.

Additional resources

Shader methods in URP
Transform positions in a custom URP shader
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961