Unity-URP学习笔记(八)使用RendererFeature制作屏幕后期-高斯模糊
URP使用RendererFeature制作高斯模糊
结果展示
Shader展示
Shader "Custom/GaussianBlur"
{
Properties
{
_MainTex ("ScreenTexture", 2D) = "" {
}
}
HLSLINCLUDE
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct a2v
{
float4 vertex:POSITION;
float2 texcoord:TEXCOORD0;
};
struct v2f
{
float4 pos : POSITION;
float2 uv : TEXCOORD0;
float4 uv01 : TEXCOORD1;
float4 uv23 : TEXCOORD2;
float4 uv45 : TEXCOORD3;
};
float2 _offset;
sampler2D _MainTex;
v2f vert (a2v v) {
v2f o;
o.pos = TransformObjectToHClip(v.vertex);
o.uv.xy = v.texcoord.xy;
o.uv01 = v.texcoord.xyxy + _offset.xyxy * float4(1,1, -1,-1);
o.uv23 = v.texcoord.xyxy + _offset.xyxy * float4(1,1, -1,-1) * 2.0;
o.uv45 = v.texcoord.xyxy + _offset.xyxy * float4(1,1, -1,-1) * 3.0;
return o;
}
half4 frag (v2f i) : COLOR {
half4 color = float4 (0,0,0