1.CG关键字
凡是 CG关键字 ,都改为HLSL
比如 CGPROGRAM 改完 HLSLPROGRAM 等等
ENDCG 改为 ENDHLSL
- FallBack
FallBack "Hidden/Universal Render Pipeline/FallbackError"
3."LightMode"
"LightMode" 要改为URP支持的模式, 比如
"LightMode" = "Forward"
替换为
"LightMode" = "UniversalForward"
其他常用URP的mode类型:
"LightMode" = "Universal2D"
"LightMode" = "Meta"
"LightMode" = "DepthOnly"
"LightMode" = "ShadowCaster"
- URP自带shader的Tags
添加 RenderPipeline关键字了, 我们自己的shader可以不加
例如:
Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "IgnoreProjector" = "True"}
- include的库
内置管线库,默认使用cg文件
URP管线,默认使用hlsl文件。
内置管线的shader库全部删除,不能再使用。
需要重新使用URP管线的库。
自己编写shader主要使用
Packages/Core RP Library/ShaderLibrary
和
Packages/Universal RP/ShaderLibrary
这两个库
一些例子:
内置管线
include "Lighting.HLSLinc"
替换为:URP管线
include "LitInput.hlsl"
include "LitForwardPass.hlsl"
include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
阴影:
include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
- 内置结构体、内置函数 和矩阵
appdata_full 这种结构体不能用了,如何一一替换我就不举例了:
内置函数 和矩阵需要查阅Packages/Universal RP/ShaderLibrary/UnityInput
内置结构体、函数需要查阅
Packages/Universal RP/ShaderLibrary/Input
Packages/Universal RP/ShaderLibrary/Core
后处理部分
后处理统一使用 Post Processsing V2
//关于URP参考内容需要科学上网
https://teodutra.com/unity/shaders/urp/graphics/2020/05/18/From-Built-in-to-URP/