CommandBuffer 描边

参考:
Glow highlighting in Unity
Unity Shader-Command Buffer的使用(景深与描边效果重置版)

Compare Camera Depth

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

sampler2D _CameraDepthTexture;

#if defined(UNITY_REVERSED_Z)
#define COMPARE_DEPTH(a, b) step(b, a)
#else
#define COMPARE_DEPTH(a, b) step(a, b)
#endif

...

// in vert

o.projPos = ComputeScreenPos(o.pos);
o.projPos.z = COMPUTE_DEPTH_01;

...

// in frag

float depth = SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos));
depth = Linear01Depth(depth);=

COMPARE_DEPTH(i.projPos.z, depth);
分享