AmbientOcclusion.shader
3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
Shader "Hidden/Post FX/Ambient Occlusion"
{
CGINCLUDE
#pragma target 3.0
ENDCG
SubShader
{
ZTest Always Cull Off ZWrite Off
// 0: Occlusion estimation with CameraDepthTexture
Pass
{
CGPROGRAM
#pragma vertex VertMultitex
#pragma fragment FragAO
#pragma multi_compile FOG_OFF FOG_LINEAR FOG_EXP FOG_EXP2
#define SOURCE_DEPTH
#include "AmbientOcclusion.cginc"
ENDCG
}
// 1: Occlusion estimation with CameraDepthNormalsTexture
Pass
{
CGPROGRAM
#pragma vertex VertMultitex
#pragma fragment FragAO
#pragma multi_compile FOG_OFF FOG_LINEAR FOG_EXP FOG_EXP2
#define SOURCE_DEPTHNORMALS
#include "AmbientOcclusion.cginc"
ENDCG
}
// 2: Occlusion estimation with G-Buffer
Pass
{
CGPROGRAM
#pragma vertex VertMultitex
#pragma fragment FragAO
#pragma multi_compile FOG_OFF FOG_LINEAR FOG_EXP FOG_EXP2
#define SOURCE_GBUFFER
#include "AmbientOcclusion.cginc"
ENDCG
}
// 3: Separable blur (horizontal pass) with CameraDepthNormalsTexture
Pass
{
CGPROGRAM
#pragma vertex VertMultitex
#pragma fragment FragBlur
#define SOURCE_DEPTHNORMALS
#define BLUR_HORIZONTAL
#define BLUR_SAMPLE_CENTER_NORMAL
#include "AmbientOcclusion.cginc"
ENDCG
}
// 4: Separable blur (horizontal pass) with G-Buffer
Pass
{
CGPROGRAM
#pragma vertex VertMultitex
#pragma fragment FragBlur
#define SOURCE_GBUFFER
#define BLUR_HORIZONTAL
#define BLUR_SAMPLE_CENTER_NORMAL
#include "AmbientOcclusion.cginc"
ENDCG
}
// 5: Separable blur (vertical pass)
Pass
{
CGPROGRAM
#pragma vertex VertMultitex
#pragma fragment FragBlur
#define BLUR_VERTICAL
#include "AmbientOcclusion.cginc"
ENDCG
}
// 6: Final composition
Pass
{
CGPROGRAM
#pragma vertex VertMultitex
#pragma fragment FragComposition
#include "AmbientOcclusion.cginc"
ENDCG
}
// 7: Final composition (ambient only mode)
Pass
{
Blend Zero OneMinusSrcColor, Zero OneMinusSrcAlpha
CGPROGRAM
#pragma vertex VertCompositionGBuffer
#pragma fragment FragCompositionGBuffer
#include "AmbientOcclusion.cginc"
ENDCG
}
// 8: Debug visualization
Pass
{
CGPROGRAM
#pragma vertex VertMultitex
#pragma fragment FragComposition
#define DEBUG_COMPOSITION
#include "AmbientOcclusion.cginc"
ENDCG
}
}
}