@zephyr3d/editor 0.3.8 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{index-BZ1L8ggE.js → index-CO6yA4Rj.js} +313 -11
- package/dist/assistant/zephyr-types-index.json +13834 -11679
- package/dist/index.html +1 -1
- package/dist/modules/zephyr3d_backend-webgpu.js +1 -1
- package/dist/modules/zephyr3d_backend-webgpu.js.map +1 -1
- package/dist/modules/zephyr3d_device.js +2 -2
- package/dist/modules/zephyr3d_device.js.map +1 -1
- package/dist/modules/zephyr3d_scene.js +2325 -515
- package/dist/modules/zephyr3d_scene.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/device/dist/device.js +2 -2
- package/dist/vendor/zephyr3d/device/dist/device.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/app/engine.js +3 -1
- package/dist/vendor/zephyr3d/scene/dist/app/engine.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/asset/assetmanager.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/asset/assetmanager.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/camera/camera.js +87 -0
- package/dist/vendor/zephyr3d/scene/dist/camera/camera.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/index.d.ts +158 -4
- package/dist/vendor/zephyr3d/scene/dist/index.js +3 -0
- package/dist/vendor/zephyr3d/scene/dist/index.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/meshmaterial.js +8 -1
- package/dist/vendor/zephyr3d/scene/dist/material/meshmaterial.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/shader/helper.js +6 -0
- package/dist/vendor/zephyr3d/scene/dist/material/shader/helper.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/skin.js +263 -0
- package/dist/vendor/zephyr3d/scene/dist/material/skin.js.map +1 -0
- package/dist/vendor/zephyr3d/scene/dist/posteffect/compositor.js +3 -0
- package/dist/vendor/zephyr3d/scene/dist/posteffect/compositor.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/posteffect/skinsss.js +194 -0
- package/dist/vendor/zephyr3d/scene/dist/posteffect/skinsss.js.map +1 -0
- package/dist/vendor/zephyr3d/scene/dist/posteffect/ssr.js +26 -49
- package/dist/vendor/zephyr3d/scene/dist/posteffect/ssr.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/posteffect/sss.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/posteffect/sss.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/posteffect/taa.js +2 -40
- package/dist/vendor/zephyr3d/scene/dist/posteffect/taa.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/abuffer_oit.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/render/abuffer_oit.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/drawable_mixin.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/render/drawable_mixin.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/fbm_wavegenerator.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/gerstner_wavegenerator.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/globalbindgroup_allocator.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/lightpass.js +4 -1
- package/dist/vendor/zephyr3d/scene/dist/render/lightpass.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/render_queue.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/render/render_queue.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/renderer.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/render/renderer.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/device_pool_allocator.js +12 -5
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/forward_plus_builder.js +78 -8
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/basesprite.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/basesprite.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/batchgroup.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/batchgroup.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/environment.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/environment.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/light.js +158 -154
- package/dist/vendor/zephyr3d/scene/dist/scene/light.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/mesh.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/mesh.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/msdftext.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/msdftext.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/msdftextsprite.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/particlesys.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/particlesys.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/scene.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/scene.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/terrain-cm/grass.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/terrain-cm/grassmaterial.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/terrain-cm/terrain-cm.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/water.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/water.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shaders/shadow.js +617 -1
- package/dist/vendor/zephyr3d/scene/dist/shaders/shadow.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/esm.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/esm.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/pcf_opt.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/pcf_pd.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/pcss.js +182 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/pcss.js.map +1 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/shader.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/shader.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/shadowmapper.js +183 -105
- package/dist/vendor/zephyr3d/scene/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/ssm.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/ssm.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/vsm.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/vsm.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js +3 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/animation.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/batch.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/camera.js +122 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/common.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/light.js +102 -21
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/material.js +195 -3
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/mesh.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/node.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/particle.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/primitive.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/sprite.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/terrain.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/text.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/water.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/values.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/values.js.map +1 -1
- package/electron/main.cjs +30 -6
- package/package.json +4 -4
|
@@ -2,8 +2,324 @@ import { hasDepthChannel } from '@zephyr3d/device';
|
|
|
2
2
|
import { LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_RECT, LIGHT_TYPE_POINT, LIGHT_TYPE_SPOT } from '../values.js';
|
|
3
3
|
import { encodeNormalizedFloatToRGBA, decode2HalfFromRGBA, decodeNormalizedFloatFromRGBA } from './misc.js';
|
|
4
4
|
import { ShaderHelper } from '../material/shader/helper.js';
|
|
5
|
+
import { smoothNoise3D } from './noise.js';
|
|
5
6
|
import { getDevice } from '../app/api.js';
|
|
6
7
|
|
|
8
|
+
/*
|
|
9
|
+
const PCF_KERNEL_3x3 = [
|
|
10
|
+
[0.5, 1.0, 0.5],
|
|
11
|
+
[1.0, 1.0, 1.0],
|
|
12
|
+
[0.5, 1.0, 0.5]
|
|
13
|
+
];
|
|
14
|
+
const PCF_KERNEL_SUM_3x3 = 7;
|
|
15
|
+
|
|
16
|
+
const PCF_KERNEL_5x5 = [
|
|
17
|
+
[0.0, 0.5, 1.0, 0.5, 0.0],
|
|
18
|
+
[0.5, 1.0, 1.0, 1.0, 0.5],
|
|
19
|
+
[1.0, 1.0, 1.0, 1.0, 1.0],
|
|
20
|
+
[0.5, 1.0, 1.0, 1.0, 0.5],
|
|
21
|
+
[0.0, 0.5, 1.0, 0.5, 0.0]
|
|
22
|
+
];
|
|
23
|
+
const PCF_KERNEL_SUM_5x5 = 17;
|
|
24
|
+
|
|
25
|
+
const PCF_KERNEL_7x7 = [
|
|
26
|
+
[0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0],
|
|
27
|
+
[0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
|
|
28
|
+
[0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5],
|
|
29
|
+
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
|
|
30
|
+
[0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5],
|
|
31
|
+
[0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
|
|
32
|
+
[0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0]
|
|
33
|
+
];
|
|
34
|
+
const PCF_KERNEL_SUM_7x7 = 33;
|
|
35
|
+
|
|
36
|
+
const PCF_KERNEL_9x9 = [
|
|
37
|
+
[0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0],
|
|
38
|
+
[0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0],
|
|
39
|
+
[0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
|
|
40
|
+
[0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5],
|
|
41
|
+
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
|
|
42
|
+
[0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5],
|
|
43
|
+
[0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
|
|
44
|
+
[0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0],
|
|
45
|
+
[0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0]
|
|
46
|
+
];
|
|
47
|
+
const PCF_KERNEL_SUM_9x9 = 53;
|
|
48
|
+
*/ const PCF_POISSON_DISC = [
|
|
49
|
+
[
|
|
50
|
+
0.511749,
|
|
51
|
+
0.547686
|
|
52
|
+
],
|
|
53
|
+
[
|
|
54
|
+
0.58929,
|
|
55
|
+
0.257224
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
0.165018,
|
|
59
|
+
0.57663
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
0.407692,
|
|
63
|
+
0.742285
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
0.707012,
|
|
67
|
+
0.646523
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
0.31463,
|
|
71
|
+
0.466825
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
0.801257,
|
|
75
|
+
0.485186
|
|
76
|
+
],
|
|
77
|
+
[
|
|
78
|
+
0.418136,
|
|
79
|
+
0.146517
|
|
80
|
+
],
|
|
81
|
+
[
|
|
82
|
+
0.579889,
|
|
83
|
+
0.0368284
|
|
84
|
+
],
|
|
85
|
+
[
|
|
86
|
+
0.79801,
|
|
87
|
+
0.140114
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
-0.0413185,
|
|
91
|
+
0.371455
|
|
92
|
+
],
|
|
93
|
+
[
|
|
94
|
+
-0.0529108,
|
|
95
|
+
0.627352
|
|
96
|
+
],
|
|
97
|
+
[
|
|
98
|
+
0.0821375,
|
|
99
|
+
0.882071
|
|
100
|
+
],
|
|
101
|
+
[
|
|
102
|
+
0.17308,
|
|
103
|
+
0.301207
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
-0.120452,
|
|
107
|
+
0.867216
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
0.371096,
|
|
111
|
+
0.916454
|
|
112
|
+
],
|
|
113
|
+
[
|
|
114
|
+
-0.178381,
|
|
115
|
+
0.146101
|
|
116
|
+
],
|
|
117
|
+
[
|
|
118
|
+
-0.276489,
|
|
119
|
+
0.550525
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
0.12542,
|
|
123
|
+
0.126643
|
|
124
|
+
],
|
|
125
|
+
[
|
|
126
|
+
-0.296654,
|
|
127
|
+
0.286879
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
0.261744,
|
|
131
|
+
-604975e-8
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
-0.213417,
|
|
135
|
+
0.715776
|
|
136
|
+
],
|
|
137
|
+
[
|
|
138
|
+
0.425684,
|
|
139
|
+
-0.153211
|
|
140
|
+
],
|
|
141
|
+
[
|
|
142
|
+
-0.480054,
|
|
143
|
+
0.321357
|
|
144
|
+
],
|
|
145
|
+
[
|
|
146
|
+
-0.0717878,
|
|
147
|
+
-0.0250567
|
|
148
|
+
],
|
|
149
|
+
[
|
|
150
|
+
-0.328775,
|
|
151
|
+
-0.169666
|
|
152
|
+
],
|
|
153
|
+
[
|
|
154
|
+
-0.394923,
|
|
155
|
+
0.130802
|
|
156
|
+
],
|
|
157
|
+
[
|
|
158
|
+
-0.553681,
|
|
159
|
+
-0.176777
|
|
160
|
+
],
|
|
161
|
+
[
|
|
162
|
+
-0.722615,
|
|
163
|
+
0.120616
|
|
164
|
+
],
|
|
165
|
+
[
|
|
166
|
+
-0.693065,
|
|
167
|
+
0.309017
|
|
168
|
+
],
|
|
169
|
+
[
|
|
170
|
+
0.603193,
|
|
171
|
+
0.791471
|
|
172
|
+
],
|
|
173
|
+
[
|
|
174
|
+
-0.0754941,
|
|
175
|
+
-0.297988
|
|
176
|
+
],
|
|
177
|
+
[
|
|
178
|
+
0.109303,
|
|
179
|
+
-0.156472
|
|
180
|
+
],
|
|
181
|
+
[
|
|
182
|
+
0.260605,
|
|
183
|
+
-0.280111
|
|
184
|
+
],
|
|
185
|
+
[
|
|
186
|
+
0.129731,
|
|
187
|
+
-0.487954
|
|
188
|
+
],
|
|
189
|
+
[
|
|
190
|
+
-0.537315,
|
|
191
|
+
0.520494
|
|
192
|
+
],
|
|
193
|
+
[
|
|
194
|
+
-0.42758,
|
|
195
|
+
0.800607
|
|
196
|
+
],
|
|
197
|
+
[
|
|
198
|
+
0.77309,
|
|
199
|
+
-0.0728102
|
|
200
|
+
],
|
|
201
|
+
[
|
|
202
|
+
0.908777,
|
|
203
|
+
0.328356
|
|
204
|
+
],
|
|
205
|
+
[
|
|
206
|
+
0.985341,
|
|
207
|
+
0.0759158
|
|
208
|
+
],
|
|
209
|
+
[
|
|
210
|
+
0.947536,
|
|
211
|
+
-0.11837
|
|
212
|
+
],
|
|
213
|
+
[
|
|
214
|
+
-0.103315,
|
|
215
|
+
-0.610747
|
|
216
|
+
],
|
|
217
|
+
[
|
|
218
|
+
0.337171,
|
|
219
|
+
-0.584
|
|
220
|
+
],
|
|
221
|
+
[
|
|
222
|
+
0.210919,
|
|
223
|
+
-0.720055
|
|
224
|
+
],
|
|
225
|
+
[
|
|
226
|
+
0.41894,
|
|
227
|
+
-0.36769
|
|
228
|
+
],
|
|
229
|
+
[
|
|
230
|
+
-0.254228,
|
|
231
|
+
-0.49368
|
|
232
|
+
],
|
|
233
|
+
[
|
|
234
|
+
-0.428562,
|
|
235
|
+
-0.404037
|
|
236
|
+
],
|
|
237
|
+
[
|
|
238
|
+
-0.831732,
|
|
239
|
+
-0.189615
|
|
240
|
+
],
|
|
241
|
+
[
|
|
242
|
+
-0.922642,
|
|
243
|
+
0.0888026
|
|
244
|
+
],
|
|
245
|
+
[
|
|
246
|
+
-0.865914,
|
|
247
|
+
0.427795
|
|
248
|
+
],
|
|
249
|
+
[
|
|
250
|
+
0.706117,
|
|
251
|
+
-0.311662
|
|
252
|
+
],
|
|
253
|
+
[
|
|
254
|
+
0.545465,
|
|
255
|
+
-0.520942
|
|
256
|
+
],
|
|
257
|
+
[
|
|
258
|
+
-0.695738,
|
|
259
|
+
0.664492
|
|
260
|
+
],
|
|
261
|
+
[
|
|
262
|
+
0.389421,
|
|
263
|
+
-0.899007
|
|
264
|
+
],
|
|
265
|
+
[
|
|
266
|
+
0.48842,
|
|
267
|
+
-0.708054
|
|
268
|
+
],
|
|
269
|
+
[
|
|
270
|
+
0.760298,
|
|
271
|
+
-0.62735
|
|
272
|
+
],
|
|
273
|
+
[
|
|
274
|
+
-0.390788,
|
|
275
|
+
-0.707388
|
|
276
|
+
],
|
|
277
|
+
[
|
|
278
|
+
-0.591046,
|
|
279
|
+
-0.686721
|
|
280
|
+
],
|
|
281
|
+
[
|
|
282
|
+
-0.769903,
|
|
283
|
+
-0.413775
|
|
284
|
+
],
|
|
285
|
+
[
|
|
286
|
+
-0.604457,
|
|
287
|
+
-0.502571
|
|
288
|
+
],
|
|
289
|
+
[
|
|
290
|
+
-0.557234,
|
|
291
|
+
0.00451362
|
|
292
|
+
],
|
|
293
|
+
[
|
|
294
|
+
0.147572,
|
|
295
|
+
-0.924353
|
|
296
|
+
],
|
|
297
|
+
[
|
|
298
|
+
-0.0662488,
|
|
299
|
+
-0.892081
|
|
300
|
+
],
|
|
301
|
+
[
|
|
302
|
+
0.863832,
|
|
303
|
+
-0.4072
|
|
304
|
+
]
|
|
305
|
+
];
|
|
306
|
+
function getPCSSRotationMatrix(scope, sampleCoord, temporalJitter) {
|
|
307
|
+
const funcName = `lib_getPCSSRotationMatrix_${temporalJitter ? 1 : 0}`;
|
|
308
|
+
const pb = scope.$builder;
|
|
309
|
+
pb.func(funcName, [
|
|
310
|
+
pb.vec2('sampleCoord')
|
|
311
|
+
], function() {
|
|
312
|
+
if (temporalJitter) {
|
|
313
|
+
this.$l.frame = pb.mod(pb.float(ShaderHelper.getFramestamp(this)), 64);
|
|
314
|
+
this.$l.randomAngle = pb.mul(smoothNoise3D(this, pb.vec3(pb.mul(this.sampleCoord, 0.35), pb.mul(this.frame, 0.61803398875))), 2 * Math.PI);
|
|
315
|
+
this.$l.randomBase = pb.vec2(pb.cos(this.randomAngle), pb.sin(this.randomAngle));
|
|
316
|
+
this.$return(pb.mat2(this.randomBase.x, this.randomBase.y, pb.neg(this.randomBase.y), this.randomBase.x));
|
|
317
|
+
} else {
|
|
318
|
+
this.$return(pb.mat2(0.8660254, 0.5, -0.5, 0.8660254));
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
return pb.getGlobalScope()[funcName](sampleCoord);
|
|
322
|
+
}
|
|
7
323
|
function getShadowMapTexelSize(scope) {
|
|
8
324
|
return scope.$builder.div(1, ShaderHelper.getShadowCameraParams(scope).z);
|
|
9
325
|
}
|
|
@@ -84,6 +400,216 @@ function sampleShadowMapPCF(scope, shadowMapFormat, pos, offset, depth, cascade)
|
|
|
84
400
|
cascade
|
|
85
401
|
] : []);
|
|
86
402
|
}
|
|
403
|
+
function sampleShadowDepthPCSS(scope, shadowMapFormat, pos, bounds, cascade) {
|
|
404
|
+
const funcName = `lib_sampleShadowDepthPCSS_${shadowMapFormat}_${cascade ? 1 : 0}`;
|
|
405
|
+
const pb = scope.$builder;
|
|
406
|
+
pb.func(funcName, [
|
|
407
|
+
pb.vec2('coords'),
|
|
408
|
+
pb.vec4('bounds'),
|
|
409
|
+
...cascade ? [
|
|
410
|
+
pb.int('cascade')
|
|
411
|
+
] : []
|
|
412
|
+
], function() {
|
|
413
|
+
this.$l.depth = pb.float(1);
|
|
414
|
+
this.$l.sampleInside = pb.all(pb.bvec4(pb.greaterThanEqual(this.coords.x, this.bounds.x), pb.lessThanEqual(this.coords.x, this.bounds.z), pb.greaterThanEqual(this.coords.y, this.bounds.y), pb.lessThanEqual(this.coords.y, this.bounds.w)));
|
|
415
|
+
this.$if(this.sampleInside, function() {
|
|
416
|
+
this.$l.boundsPadding = pb.mul(pb.sub(this.bounds.zw, this.bounds.xy), getShadowMapTexelSize(this), 0.5);
|
|
417
|
+
this.$l.sampleCoord = pb.clamp(this.coords, pb.add(this.bounds.xy, this.boundsPadding), pb.sub(this.bounds.zw, this.boundsPadding));
|
|
418
|
+
this.$l.shadowTex = cascade && getDevice().type !== 'webgl' ? pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), this.sampleCoord, this.cascade, 0) : pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.sampleCoord, 0);
|
|
419
|
+
this.depth = shadowMapFormat === 'rgba8unorm' ? decodeNormalizedFloatFromRGBA(this, this.shadowTex) : this.shadowTex.x;
|
|
420
|
+
});
|
|
421
|
+
this.$return(this.depth);
|
|
422
|
+
});
|
|
423
|
+
return pb.getGlobalScope()[funcName](pos, bounds, ...cascade ? [
|
|
424
|
+
cascade
|
|
425
|
+
] : []);
|
|
426
|
+
}
|
|
427
|
+
function samplePointShadowDepthPCSS(scope, shadowMapFormat, dir) {
|
|
428
|
+
const funcName = `lib_samplePointShadowDepthPCSS_${shadowMapFormat}`;
|
|
429
|
+
const pb = scope.$builder;
|
|
430
|
+
pb.func(funcName, [
|
|
431
|
+
pb.vec3('dir')
|
|
432
|
+
], function() {
|
|
433
|
+
this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.dir, 0);
|
|
434
|
+
this.$return(shadowMapFormat === 'rgba8unorm' ? decodeNormalizedFloatFromRGBA(this, this.shadowTex) : this.shadowTex.x);
|
|
435
|
+
});
|
|
436
|
+
return pb.getGlobalScope()[funcName](dir);
|
|
437
|
+
}
|
|
438
|
+
function compareShadowDepthPCSS(scope, sampleDepth, compareDepth, transitionWidth) {
|
|
439
|
+
const funcName = 'lib_compareShadowDepthPCSS';
|
|
440
|
+
const pb = scope.$builder;
|
|
441
|
+
pb.func(funcName, [
|
|
442
|
+
pb.float('sampleDepth'),
|
|
443
|
+
pb.float('compareDepth'),
|
|
444
|
+
pb.float('transitionWidth')
|
|
445
|
+
], function() {
|
|
446
|
+
this.$l.depthDelta = pb.sub(this.sampleDepth, this.compareDepth);
|
|
447
|
+
this.$return(pb.smoothStep(pb.neg(this.transitionWidth), this.transitionWidth, this.depthDelta));
|
|
448
|
+
});
|
|
449
|
+
return pb.getGlobalScope()[funcName](sampleDepth, compareDepth, transitionWidth);
|
|
450
|
+
}
|
|
451
|
+
function sampleShadowPCFPCSS(scope, shadowMapFormat, pos, bounds, compareDepth, texelSize, receiverPlaneDepthBias, cascade) {
|
|
452
|
+
const funcName = `lib_sampleShadowPCFPCSS_${shadowMapFormat}_${receiverPlaneDepthBias ? 1 : 0}_${cascade ? 1 : 0}`;
|
|
453
|
+
const pb = scope.$builder;
|
|
454
|
+
pb.func(funcName, [
|
|
455
|
+
pb.vec2('coords'),
|
|
456
|
+
pb.vec4('bounds'),
|
|
457
|
+
pb.float('compareDepth'),
|
|
458
|
+
pb.vec2('texelSize'),
|
|
459
|
+
...receiverPlaneDepthBias ? [
|
|
460
|
+
pb.vec3('receiverPlaneDepthBias')
|
|
461
|
+
] : [],
|
|
462
|
+
...cascade ? [
|
|
463
|
+
pb.int('cascade')
|
|
464
|
+
] : []
|
|
465
|
+
], function() {
|
|
466
|
+
this.$l.shadow = pb.float(0);
|
|
467
|
+
this.$l.transitionWidth = receiverPlaneDepthBias ? pb.max(pb.dot(pb.abs(this.receiverPlaneDepthBias.xy), this.texelSize), 1 / 65535) : pb.float(1 / 65535);
|
|
468
|
+
this.$l.offset = pb.vec2();
|
|
469
|
+
this.$l.tapCoord = pb.vec2();
|
|
470
|
+
this.$l.sampleDepth = pb.float();
|
|
471
|
+
this.$l.tapCompareDepth = pb.float();
|
|
472
|
+
const offsets = [
|
|
473
|
+
[
|
|
474
|
+
-0.35,
|
|
475
|
+
-0.35
|
|
476
|
+
],
|
|
477
|
+
[
|
|
478
|
+
0.35,
|
|
479
|
+
-0.35
|
|
480
|
+
],
|
|
481
|
+
[
|
|
482
|
+
-0.35,
|
|
483
|
+
0.35
|
|
484
|
+
],
|
|
485
|
+
[
|
|
486
|
+
0.35,
|
|
487
|
+
0.35
|
|
488
|
+
]
|
|
489
|
+
];
|
|
490
|
+
for (const [ox, oy] of offsets){
|
|
491
|
+
this.offset = pb.mul(pb.vec2(ox, oy), this.texelSize);
|
|
492
|
+
this.tapCoord = pb.add(this.coords, this.offset);
|
|
493
|
+
this.sampleDepth = sampleShadowDepthPCSS(this, shadowMapFormat, this.tapCoord, this.bounds, this.cascade);
|
|
494
|
+
this.tapCompareDepth = receiverPlaneDepthBias ? pb.add(this.compareDepth, pb.dot(this.offset, this.receiverPlaneDepthBias.xy)) : this.compareDepth;
|
|
495
|
+
this.shadow = pb.add(this.shadow, compareShadowDepthPCSS(this, this.sampleDepth, this.tapCompareDepth, this.transitionWidth));
|
|
496
|
+
}
|
|
497
|
+
this.$return(pb.mul(this.shadow, 0.25));
|
|
498
|
+
});
|
|
499
|
+
return pb.getGlobalScope()[funcName](pos, bounds, compareDepth, texelSize, ...receiverPlaneDepthBias ? [
|
|
500
|
+
receiverPlaneDepthBias
|
|
501
|
+
] : [], ...cascade ? [
|
|
502
|
+
cascade
|
|
503
|
+
] : []);
|
|
504
|
+
}
|
|
505
|
+
function samplePointShadowPCFPCSS(scope, shadowMapFormat, dir, compareDepth, texelSize, tangent, bitangent) {
|
|
506
|
+
const funcName = `lib_samplePointShadowPCFPCSS_${shadowMapFormat}`;
|
|
507
|
+
const pb = scope.$builder;
|
|
508
|
+
pb.func(funcName, [
|
|
509
|
+
pb.vec3('dir'),
|
|
510
|
+
pb.float('compareDepth'),
|
|
511
|
+
pb.float('texelSize'),
|
|
512
|
+
pb.vec3('tangent'),
|
|
513
|
+
pb.vec3('bitangent')
|
|
514
|
+
], function() {
|
|
515
|
+
this.$l.shadow = pb.float(0);
|
|
516
|
+
this.$l.transitionWidth = pb.float(1 / 65535);
|
|
517
|
+
this.$l.offset = pb.vec2();
|
|
518
|
+
this.$l.sampleDir = pb.vec3();
|
|
519
|
+
this.$l.sampleDepth = pb.float();
|
|
520
|
+
const offsets = [
|
|
521
|
+
[
|
|
522
|
+
-0.35,
|
|
523
|
+
-0.35
|
|
524
|
+
],
|
|
525
|
+
[
|
|
526
|
+
0.35,
|
|
527
|
+
-0.35
|
|
528
|
+
],
|
|
529
|
+
[
|
|
530
|
+
-0.35,
|
|
531
|
+
0.35
|
|
532
|
+
],
|
|
533
|
+
[
|
|
534
|
+
0.35,
|
|
535
|
+
0.35
|
|
536
|
+
]
|
|
537
|
+
];
|
|
538
|
+
for (const [ox, oy] of offsets){
|
|
539
|
+
this.offset = pb.mul(pb.vec2(ox, oy), this.texelSize);
|
|
540
|
+
this.sampleDir = pb.normalize(pb.add(this.dir, pb.add(pb.mul(this.tangent, this.offset.x), pb.mul(this.bitangent, this.offset.y))));
|
|
541
|
+
this.sampleDepth = samplePointShadowDepthPCSS(this, shadowMapFormat, this.sampleDir);
|
|
542
|
+
this.shadow = pb.add(this.shadow, compareShadowDepthPCSS(this, this.sampleDepth, this.compareDepth, this.transitionWidth));
|
|
543
|
+
}
|
|
544
|
+
this.$return(pb.mul(this.shadow, 0.25));
|
|
545
|
+
});
|
|
546
|
+
return pb.getGlobalScope()[funcName](dir, compareDepth, texelSize, tangent, bitangent);
|
|
547
|
+
}
|
|
548
|
+
function findBlockerPCSS(scope, shadowMapFormat, tapCount, texCoord, bounds, searchRadius, transitionWidth, matrix, cascade) {
|
|
549
|
+
const funcName = `lib_findBlockerPCSS_${shadowMapFormat}_${cascade ? 1 : 0}`;
|
|
550
|
+
const pb = scope.$builder;
|
|
551
|
+
pb.func(funcName, [
|
|
552
|
+
pb.vec4('texCoord'),
|
|
553
|
+
pb.vec4('bounds'),
|
|
554
|
+
pb.vec2('searchRadius'),
|
|
555
|
+
pb.float('tapCount'),
|
|
556
|
+
pb.float('transitionWidth'),
|
|
557
|
+
pb.mat2('matrix'),
|
|
558
|
+
...cascade ? [
|
|
559
|
+
pb.int('cascade')
|
|
560
|
+
] : []
|
|
561
|
+
], function() {
|
|
562
|
+
this.$l.blockerDepthSum = pb.float(0);
|
|
563
|
+
this.$l.blockerCount = pb.float(0);
|
|
564
|
+
this.$l.duv = pb.vec2();
|
|
565
|
+
this.$l.sampleCoord = pb.vec2();
|
|
566
|
+
this.$l.sampleDepth = pb.float();
|
|
567
|
+
this.$l.blockerWeight = pb.float();
|
|
568
|
+
this.$for(pb.float('i'), 0, this.tapCount, function() {
|
|
569
|
+
this.duv = pb.mul(pb.mul(this.matrix, this.PCSSpdSamples.at(pb.mod(pb.mul(pb.int(this.i), 19), PCF_POISSON_DISC.length))), this.searchRadius);
|
|
570
|
+
this.sampleCoord = pb.add(this.texCoord.xy, this.duv);
|
|
571
|
+
this.sampleDepth = sampleShadowDepthPCSS(this, shadowMapFormat, this.sampleCoord, this.bounds, this.cascade);
|
|
572
|
+
this.blockerWeight = pb.sub(1, pb.smoothStep(pb.neg(this.transitionWidth), this.transitionWidth, pb.sub(this.sampleDepth, this.texCoord.z)));
|
|
573
|
+
this.blockerDepthSum = pb.add(this.blockerDepthSum, pb.mul(this.sampleDepth, this.blockerWeight));
|
|
574
|
+
this.blockerCount = pb.add(this.blockerCount, this.blockerWeight);
|
|
575
|
+
});
|
|
576
|
+
this.$return(pb.vec2(this.$choice(pb.greaterThan(this.blockerCount, 0), pb.div(this.blockerDepthSum, pb.max(this.blockerCount, 0.0001)), -1), this.blockerCount));
|
|
577
|
+
});
|
|
578
|
+
return pb.getGlobalScope()[funcName](texCoord, bounds, searchRadius, tapCount, transitionWidth, matrix, ...cascade ? [
|
|
579
|
+
cascade
|
|
580
|
+
] : []);
|
|
581
|
+
}
|
|
582
|
+
function findPointBlockerPCSS(scope, shadowMapFormat, tapCount, dir, compareDepth, searchRadius, transitionWidth, matrix, tangent, bitangent) {
|
|
583
|
+
const funcName = `lib_findPointBlockerPCSS_${shadowMapFormat}`;
|
|
584
|
+
const pb = scope.$builder;
|
|
585
|
+
pb.func(funcName, [
|
|
586
|
+
pb.vec3('dir'),
|
|
587
|
+
pb.float('compareDepth'),
|
|
588
|
+
pb.float('searchRadius'),
|
|
589
|
+
pb.float('tapCount'),
|
|
590
|
+
pb.float('transitionWidth'),
|
|
591
|
+
pb.mat2('matrix'),
|
|
592
|
+
pb.vec3('tangent'),
|
|
593
|
+
pb.vec3('bitangent')
|
|
594
|
+
], function() {
|
|
595
|
+
this.$l.blockerDepthSum = pb.float(0);
|
|
596
|
+
this.$l.blockerCount = pb.float(0);
|
|
597
|
+
this.$l.duv = pb.vec2();
|
|
598
|
+
this.$l.sampleDir = pb.vec3();
|
|
599
|
+
this.$l.sampleDepth = pb.float();
|
|
600
|
+
this.$l.blockerWeight = pb.float();
|
|
601
|
+
this.$for(pb.float('i'), 0, this.tapCount, function() {
|
|
602
|
+
this.duv = pb.mul(pb.mul(this.matrix, this.PCSSpdSamples.at(pb.mod(pb.mul(pb.int(this.i), 19), PCF_POISSON_DISC.length))), this.searchRadius);
|
|
603
|
+
this.sampleDir = pb.normalize(pb.add(this.dir, pb.add(pb.mul(this.tangent, this.duv.x), pb.mul(this.bitangent, this.duv.y))));
|
|
604
|
+
this.sampleDepth = samplePointShadowDepthPCSS(this, shadowMapFormat, this.sampleDir);
|
|
605
|
+
this.blockerWeight = pb.sub(1, pb.smoothStep(pb.neg(this.transitionWidth), this.transitionWidth, pb.sub(this.sampleDepth, this.compareDepth)));
|
|
606
|
+
this.blockerDepthSum = pb.add(this.blockerDepthSum, pb.mul(this.sampleDepth, this.blockerWeight));
|
|
607
|
+
this.blockerCount = pb.add(this.blockerCount, this.blockerWeight);
|
|
608
|
+
});
|
|
609
|
+
this.$return(pb.vec2(this.$choice(pb.greaterThan(this.blockerCount, 0), pb.div(this.blockerDepthSum, pb.max(this.blockerCount, 0.0001)), -1), this.blockerCount));
|
|
610
|
+
});
|
|
611
|
+
return pb.getGlobalScope()[funcName](dir, compareDepth, searchRadius, tapCount, transitionWidth, matrix, tangent, bitangent);
|
|
612
|
+
}
|
|
87
613
|
function chebyshevUpperBound(scope, distance, occluder) {
|
|
88
614
|
const funcNameChebyshevUpperBound = 'lib_chebyshevUpperBound';
|
|
89
615
|
const pb = scope.$builder;
|
|
@@ -264,6 +790,96 @@ function chebyshevUpperBound(scope, distance, occluder) {
|
|
|
264
790
|
cascade
|
|
265
791
|
] : []);
|
|
266
792
|
}
|
|
793
|
+
/** @internal */ function filterShadowPCSS(scope, lightType, shadowMapFormat, texCoord, receiverPlaneDepthBias, cascade, temporalJitter = true, numCascades = 1) {
|
|
794
|
+
const funcNameFilterShadowPCSS = `lib_filterShadowPCSS_${lightType}_${shadowMapFormat}_${receiverPlaneDepthBias ? 1 : 0}_${cascade ? 1 : 0}_${temporalJitter ? 1 : 0}_${numCascades}`;
|
|
795
|
+
const pb = scope.$builder;
|
|
796
|
+
pb.func(funcNameFilterShadowPCSS, [
|
|
797
|
+
pb.vec4('texCoord'),
|
|
798
|
+
...receiverPlaneDepthBias ? [
|
|
799
|
+
pb.vec3('receiverPlaneDepthBias')
|
|
800
|
+
] : [],
|
|
801
|
+
...cascade ? [
|
|
802
|
+
pb.int('cascade')
|
|
803
|
+
] : []
|
|
804
|
+
], function() {
|
|
805
|
+
this.$l.PCSSblockerSampleCount = ShaderHelper.getShadowImplParams(this).y;
|
|
806
|
+
this.$l.PCSSfilterSampleCount = ShaderHelper.getShadowImplParams(this).z;
|
|
807
|
+
this.$l.PCSSlightRadius = ShaderHelper.getShadowImplParams(this).x;
|
|
808
|
+
this.$l.PCSSmaxFilterRadius = ShaderHelper.getShadowImplParams(this).w;
|
|
809
|
+
this.$l.PCSSsearchRadius = this.$choice(pb.greaterThan(this.PCSSlightRadius, 0), pb.max(this.PCSSlightRadius, this.PCSSmaxFilterRadius), 0);
|
|
810
|
+
if (!pb.getGlobalScope().PCSSpdSamples) {
|
|
811
|
+
pb.getGlobalScope().PCSSpdSamples = PCF_POISSON_DISC.map((s)=>pb.vec2(s[0], s[1]));
|
|
812
|
+
}
|
|
813
|
+
if (lightType === LIGHT_TYPE_POINT) {
|
|
814
|
+
this.$l.lightDepth = this.texCoord.w;
|
|
815
|
+
this.$l.sampleDir = pb.normalize(this.texCoord.xyz);
|
|
816
|
+
this.$l.shadowMapTexelSize = pb.mul(getShadowMapTexelSize(this), 2);
|
|
817
|
+
this.$l.matrix = getPCSSRotationMatrix(this, pb.mul(this.sampleDir.xy, pb.vec2(getShadowMapSize(this))), temporalJitter);
|
|
818
|
+
this.$l.searchRadius = pb.mul(pb.clamp(this.PCSSsearchRadius, 0, pb.max(0, this.PCSSmaxFilterRadius)), this.shadowMapTexelSize);
|
|
819
|
+
this.$l.blockerTransitionWidth = pb.float(1 / 65535);
|
|
820
|
+
this.$l.up = this.$choice(pb.lessThan(pb.abs(this.sampleDir.y), 0.999), pb.vec3(0, 1, 0), pb.vec3(1, 0, 0));
|
|
821
|
+
this.$l.tangent = pb.normalize(pb.cross(this.up, this.sampleDir));
|
|
822
|
+
this.$l.bitangent = pb.cross(this.sampleDir, this.tangent);
|
|
823
|
+
this.$l.blocker = findPointBlockerPCSS(this, shadowMapFormat, this.PCSSblockerSampleCount, this.sampleDir, this.lightDepth, this.searchRadius, this.blockerTransitionWidth, this.matrix, this.tangent, this.bitangent);
|
|
824
|
+
this.$if(pb.lessThanEqual(this.blocker.y, 0), function() {
|
|
825
|
+
this.$return(pb.float(1));
|
|
826
|
+
});
|
|
827
|
+
this.$l.penumbra = pb.div(pb.max(pb.sub(this.lightDepth, this.blocker.x), 0), pb.max(this.blocker.x, 0.0001));
|
|
828
|
+
this.$l.filterRadius = pb.mul(pb.clamp(pb.mul(this.penumbra, this.PCSSlightRadius), 0, pb.max(0, this.PCSSmaxFilterRadius)), this.shadowMapTexelSize);
|
|
829
|
+
this.$l.shadow = pb.float(0);
|
|
830
|
+
this.$l.duv = pb.vec2();
|
|
831
|
+
this.$l.samplePointDir = pb.vec3();
|
|
832
|
+
this.$for(pb.float('i'), 0, this.PCSSfilterSampleCount, function() {
|
|
833
|
+
this.duv = pb.mul(pb.mul(this.matrix, this.PCSSpdSamples.at(pb.mod(pb.mul(pb.int(this.i), 19), PCF_POISSON_DISC.length))), this.filterRadius);
|
|
834
|
+
this.samplePointDir = pb.normalize(pb.add(this.sampleDir, pb.add(pb.mul(this.tangent, this.duv.x), pb.mul(this.bitangent, this.duv.y))));
|
|
835
|
+
this.shadow = pb.add(this.shadow, samplePointShadowPCFPCSS(this, shadowMapFormat, this.samplePointDir, this.lightDepth, this.shadowMapTexelSize, this.tangent, this.bitangent));
|
|
836
|
+
});
|
|
837
|
+
this.shadow = pb.div(this.shadow, this.PCSSfilterSampleCount);
|
|
838
|
+
this.$return(this.shadow);
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
this.$l.lightDepth = this.texCoord.z;
|
|
842
|
+
if (receiverPlaneDepthBias) {
|
|
843
|
+
this.lightDepth = pb.sub(this.lightDepth, this.receiverPlaneDepthBias.z);
|
|
844
|
+
}
|
|
845
|
+
this.$l.sampleBounds = pb.vec4(0, 0, 1, 1);
|
|
846
|
+
if (cascade && getDevice().type === 'webgl' && numCascades > 1) {
|
|
847
|
+
const numCols = numCascades > 1 ? 2 : 1;
|
|
848
|
+
const numRows = numCascades > 2 ? 2 : 1;
|
|
849
|
+
this.$l.cascadeIndex = pb.float(this.cascade);
|
|
850
|
+
this.$l.cascadeCol = pb.mod(this.cascadeIndex, 2);
|
|
851
|
+
this.$l.cascadeRow = pb.floor(pb.mul(this.cascadeIndex, 0.5));
|
|
852
|
+
this.sampleBounds = pb.vec4(pb.mul(this.cascadeCol, 1 / numCols), pb.mul(this.cascadeRow, 1 / numRows), pb.mul(pb.add(this.cascadeCol, 1), 1 / numCols), pb.mul(pb.add(this.cascadeRow, 1), 1 / numRows));
|
|
853
|
+
}
|
|
854
|
+
this.$l.shadowMapTexelSize = pb.mul(pb.sub(this.sampleBounds.zw, this.sampleBounds.xy), getShadowMapTexelSize(this));
|
|
855
|
+
this.$l.matrix = getPCSSRotationMatrix(this, pb.mul(this.texCoord.xy, pb.vec2(getShadowMapSize(this))), temporalJitter);
|
|
856
|
+
this.$l.searchRadius = pb.mul(pb.clamp(this.PCSSsearchRadius, 0, pb.max(0, this.PCSSmaxFilterRadius)), this.shadowMapTexelSize);
|
|
857
|
+
this.$l.blockerTransitionWidth = receiverPlaneDepthBias ? pb.max(pb.dot(pb.abs(this.receiverPlaneDepthBias.xy), this.searchRadius), 1 / 65535) : pb.float(1 / 65535);
|
|
858
|
+
this.$l.blocker = findBlockerPCSS(this, shadowMapFormat, this.PCSSblockerSampleCount, pb.vec4(this.texCoord.xy, this.lightDepth, this.texCoord.w), this.sampleBounds, this.searchRadius, this.blockerTransitionWidth, this.matrix, this.cascade);
|
|
859
|
+
this.$if(pb.lessThanEqual(this.blocker.y, 0), function() {
|
|
860
|
+
this.$return(pb.float(1));
|
|
861
|
+
});
|
|
862
|
+
this.$l.penumbra = pb.div(pb.max(pb.sub(this.lightDepth, this.blocker.x), 0), pb.max(this.blocker.x, 0.0001));
|
|
863
|
+
this.$l.filterRadius = pb.mul(pb.clamp(pb.mul(this.penumbra, this.PCSSlightRadius), 0, pb.max(0, this.PCSSmaxFilterRadius)), this.shadowMapTexelSize);
|
|
864
|
+
this.$l.shadow = pb.float(0);
|
|
865
|
+
this.$l.duv = pb.vec2();
|
|
866
|
+
this.$l.sampleCoord = pb.vec2();
|
|
867
|
+
this.$l.compareDepth = pb.float();
|
|
868
|
+
this.$for(pb.float('i'), 0, this.PCSSfilterSampleCount, function() {
|
|
869
|
+
this.duv = pb.mul(pb.mul(this.matrix, this.PCSSpdSamples.at(pb.mod(pb.mul(pb.int(this.i), 19), PCF_POISSON_DISC.length))), this.filterRadius);
|
|
870
|
+
this.sampleCoord = pb.add(this.texCoord.xy, this.duv);
|
|
871
|
+
this.compareDepth = receiverPlaneDepthBias ? pb.add(this.lightDepth, pb.dot(this.duv, this.receiverPlaneDepthBias.xy)) : this.lightDepth;
|
|
872
|
+
this.shadow = pb.add(this.shadow, sampleShadowPCFPCSS(this, shadowMapFormat, this.sampleCoord, this.sampleBounds, this.compareDepth, this.shadowMapTexelSize, this.receiverPlaneDepthBias, this.cascade));
|
|
873
|
+
});
|
|
874
|
+
this.shadow = pb.div(this.shadow, this.PCSSfilterSampleCount);
|
|
875
|
+
this.$return(this.shadow);
|
|
876
|
+
});
|
|
877
|
+
return pb.getGlobalScope()[funcNameFilterShadowPCSS](texCoord, ...receiverPlaneDepthBias ? [
|
|
878
|
+
receiverPlaneDepthBias
|
|
879
|
+
] : [], ...cascade ? [
|
|
880
|
+
cascade
|
|
881
|
+
] : []);
|
|
882
|
+
}
|
|
267
883
|
|
|
268
|
-
export { computeReceiverPlaneDepthBias, computeShadowMapDepth, filterShadowESM, filterShadowPCF, filterShadowVSM };
|
|
884
|
+
export { computeReceiverPlaneDepthBias, computeShadowMapDepth, filterShadowESM, filterShadowPCF, filterShadowPCSS, filterShadowVSM };
|
|
269
885
|
//# sourceMappingURL=shadow.js.map
|