Unity-NorthStar / data /Assets /Tutorial /pages /URP Modifications.asset
introvoyz041's picture
Migrated from GitHub
d883ffe verified
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4510294d23d964fe59443526f1ca7c4b, type: 3}
m_Name: URP Modifications
m_EditorClassIdentifier:
m_displayName: URP Modifications
m_hierarchyName: URP Modifications
m_context: {fileID: 11400000, guid: 9be0af5c5d3ad9f45a1a0843c4381d44, type: 2}
m_markdownFile: {fileID: 0}
m_priority: 1013
m_overrideMarkdownText: "## URP Modifications\n\nThe Universal Render Pipeline
(URP) is an excellent foundation for projects, offering many features and flexibility
to start development. To better meet project needs, we modified URP shaders and
code.\n\n**Shader Modifications**\n\nWe replaced the Unity BRDF with a more accurate
approximation, enhancing lighting on the ocean and shiny surfaces. This change
slightly increases the cost for all surfaces. To mitigate this, we included a
specialized non-metallic BRDF for non-metallic surfaces, configurable in the
Shader Graph Settings by toggling \u201CNon-Metallic Surface.\u201D\n\nUnity
shadowing is flexible, allowing runtime selection between quality settings. However,
reading cbuffer values, reducing shader size, and potentially reducing register
usage present optimization opportunities. We hard-coded these values where appropriate.
Surfaces facing away from the light source or with fully attenuated light are
unaffected by shadow sampling. We moved shadow sampling into a branch to prevent
sampling from the shadow map for surfaces not facing the light source.\n\nThe
ship uses Reflection Probes to simulate reflections on the deck, especially when
wet. These probes and the box projection must rotate with the ship for realism.
We achieve this by passing a _ProbeReorientation matrix into GlobalIllumination.hlsl
and applying it when calculating the cubemap sample point.\n\n### Relevant Files\n-
[BRDF.hlsl](../Packages/com.unity.render-pipelines.universal/ShaderLibrary/BRDF.hlsl)\n-
[UniversalLitSubTarget.cs](../Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalLitSubTarget.cs)\n-
[Shadows.hlsl](../Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl)\n-
[Lighting.hlsl](../Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl)\n-
[GlobalIllumination.hlsl](../Packages/com.unity.render-pipelines.universal/ShaderLibrary/GlobalIllumination.hlsl)\n\n**Code
Modifications**\n\nBy default, the XR display matches the MSAA value configured
in the URP asset. However, any post-processing forces an MSAA resolve, making
it unnecessary to blit to an MSAA display target.\n\nURP versions before 14.0.9
have a bug causing excessive texture reallocation with Dynamic Resolution, leading
to poor framerate and potential out-of-memory crashes. Fix this by following
the guide [here](https://developers.meta.com/horizon/documentation/unity/dynamic-resolution-unity/).
We also enabled DynamicResolution support in the RTHandles system immediately
after initializing it in UniversalRenderPipeline.cs.\n\nWe use ShadowImportanceVolumes
to dynamically adjust the shadow map projection, requiring an entry point in
ShadowUtils. This allows modifying the shadow projection matrix and distance
values. We also modified MainLightShadowCasterPass.cs to pass through camera
data for accurate shadow importance volumes.\n\n### Relevant Files\n- [UniversalRenderPipeline.cs](../Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs)\n-
[UniversalRenderer.cs](../Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs)\n-
[ShadowUtils.cs](../Packages/com.unity.render-pipelines.universal/Runtime/ShadowUtils.cs)\n-
[MainLightShadowCasterPass.cs](../Packages/com.unity.render-pipelines.universal/Runtime/Passes/MainLightShadowCasterPass.cs)\n"
m_overrideMarkdownRoot: .\Documentation/