Troubleshooting the Forward+ rendering path in URP
Solve common issues with the Forward+ rendering path, for example reduce the maximum number of visible lights to reduce build times.
読み終わるまでの所要時間 2 分最終更新 22日前
Reduce build time
Due to the wide variety of use cases, target platforms, renderers, and features used in projects, certain URP configurations can result in a large number of shader variants. That can lead to long compilation times.
Long shader compilation time affects both player build time and the time for a scene to render in the Editor.
The per-camera visible light limit value affects the compilation time for each Lit and Complex Lit shader variant. In the Forward+ Rendering Path, on desktop platforms, that limit is 256.
This section describes how to reduce the shader compilation time by changing the default maximum per-camera visible light count.
Change the maximum number of visible lights
The Universal Render Pipeline Config package contains the settings that define the number of maximum visible light. The following instructions describe how to change those settings.
-
In your project folder, copy the URP Config Package folder fromto
/Library/PackageCache/com.unity.render-pipelines.universal-config./Packages/com.unity.render-pipelines.universal-config -
Open the file.
/com.unity.render-pipelines.universal-config/Runtime/ShaderConfig.cs.hlslThe file contains multiple definitions that start withand end with the target platform name. Change the value in brackets to a suitable maximum in-frustum per-camera light count for your project, for example,MAX_VISIBLE_LIGHT_COUNT.MAX_VISIBLE_LIGHT_COUNT_DESKTOP (32)For the Forward+ Rendering Path, the value includes the Main Light. For the Forward Rendering Path, the value does not include the Main Light. -
Open the file.
/com.unity.render-pipelines.universal-config/Runtime/ShaderConfig.csThe file contains multiple definitions that start withand end with the platform name. Change the value so that it matches the value set in thek_MaxVisibleLightCountfile, for exampleShaderConfig.cs.hlsl.k_MaxVisibleLightCountDesktop = 32; -
Save the edited files and restart the Unity Editor. Unity automatically configures your project and shaders to use the new configuration.
Now the Player build time should be shorter due to the reduced compilation time for each shader variant.