@vitessce/spatial-accelerated 3.8.0
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/LICENSE +21 -0
- package/dist/index.js +52925 -0
- package/dist-tsc/SpatialWrapper.d.ts +2 -0
- package/dist-tsc/SpatialWrapper.d.ts.map +1 -0
- package/dist-tsc/SpatialWrapper.js +45 -0
- package/dist-tsc/VolumeDataManager.d.ts +170 -0
- package/dist-tsc/VolumeDataManager.d.ts.map +1 -0
- package/dist-tsc/VolumeDataManager.js +1273 -0
- package/dist-tsc/VolumeDataManager.test.d.ts +2 -0
- package/dist-tsc/VolumeDataManager.test.d.ts.map +1 -0
- package/dist-tsc/VolumeDataManager.test.js +164 -0
- package/dist-tsc/VolumeRenderManager.d.ts +265 -0
- package/dist-tsc/VolumeRenderManager.d.ts.map +1 -0
- package/dist-tsc/VolumeRenderManager.js +396 -0
- package/dist-tsc/VolumeShader.d.ts +262 -0
- package/dist-tsc/VolumeShader.d.ts.map +1 -0
- package/dist-tsc/VolumeShader.js +73 -0
- package/dist-tsc/VolumeView.d.ts +2 -0
- package/dist-tsc/VolumeView.d.ts.map +1 -0
- package/dist-tsc/VolumeView.js +521 -0
- package/dist-tsc/index.d.ts +2 -0
- package/dist-tsc/index.d.ts.map +1 -0
- package/dist-tsc/index.js +1 -0
- package/dist-tsc/shaders/GaussianFragmentShader.d.ts +2 -0
- package/dist-tsc/shaders/GaussianFragmentShader.d.ts.map +1 -0
- package/dist-tsc/shaders/GaussianFragmentShader.js +242 -0
- package/dist-tsc/shaders/GaussianVertexShader.d.ts +2 -0
- package/dist-tsc/shaders/GaussianVertexShader.d.ts.map +1 -0
- package/dist-tsc/shaders/GaussianVertexShader.js +51 -0
- package/dist-tsc/shaders/VolumeFragmentShader.d.ts +2 -0
- package/dist-tsc/shaders/VolumeFragmentShader.d.ts.map +1 -0
- package/dist-tsc/shaders/VolumeFragmentShader.js +1817 -0
- package/dist-tsc/shaders/VolumeVertexShader.d.ts +2 -0
- package/dist-tsc/shaders/VolumeVertexShader.d.ts.map +1 -0
- package/dist-tsc/shaders/VolumeVertexShader.js +110 -0
- package/package.json +63 -0
- package/src/SpatialWrapper.js +60 -0
- package/src/VolumeDataManager.js +1515 -0
- package/src/VolumeDataManager.test.js +180 -0
- package/src/VolumeRenderManager.js +589 -0
- package/src/VolumeShader.js +74 -0
- package/src/VolumeView.js +651 -0
- package/src/index.js +1 -0
- package/src/shaders/GaussianFragmentShader.js +243 -0
- package/src/shaders/GaussianVertexShader.js +52 -0
- package/src/shaders/VolumeFragmentShader.js +1818 -0
- package/src/shaders/VolumeVertexShader.js +111 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// Attribution: Originally written by @alexandrairger
|
|
2
|
+
// Moved from .glsl file to .js file in this commit: https://github.com/vitessce/vitessce/pull/2264/commits/7f17fc003674a4ed1a8de6140db802781871cf88
|
|
3
|
+
/*
|
|
4
|
+
* Gaussian Blur Fragment Shader
|
|
5
|
+
*
|
|
6
|
+
* This shader applies Gaussian blur filtering to a texture using different kernel sizes.
|
|
7
|
+
* The blur strength is controlled by the 'gaussian' uniform parameter.
|
|
8
|
+
*
|
|
9
|
+
* ASCII Art Diagrams:
|
|
10
|
+
*
|
|
11
|
+
* 3x3 Gaussian Kernel (gaussian3):
|
|
12
|
+
* ┌─────────┬─────────┬─────────┐
|
|
13
|
+
* │ 0.0625 │ 0.125 │ 0.0625 │
|
|
14
|
+
* ├─────────┼─────────┼─────────┤
|
|
15
|
+
* │ 0.125 │ 0.25 │ 0.125 │
|
|
16
|
+
* ├─────────┼─────────┼─────────┤
|
|
17
|
+
* │ 0.0625 │ 0.125 │ 0.0625 │
|
|
18
|
+
* └─────────┴─────────┴─────────┘
|
|
19
|
+
*
|
|
20
|
+
* 5x5 Gaussian Kernel (gaussian5):
|
|
21
|
+
* ┌─────┬─────┬─────┬─────┬─────┐
|
|
22
|
+
* │ 1/273│ 4/273│ 7/273│ 4/273│ 1/273│
|
|
23
|
+
* ├─────┼─────┼─────┼─────┼─────┤
|
|
24
|
+
* │ 4/273│16/273│26/273│16/273│ 4/273│
|
|
25
|
+
* ├─────┼─────┼─────┼─────┼─────┤
|
|
26
|
+
* │ 7/273│26/273│41/273│26/273│ 7/273│
|
|
27
|
+
* ├─────┼─────┼─────┼─────┼─────┤
|
|
28
|
+
* │ 4/273│16/273│26/273│16/273│ 4/273│
|
|
29
|
+
* ├─────┼─────┼─────┼─────┼─────┤
|
|
30
|
+
* │ 1/273│ 4/273│ 7/273│ 4/273│ 1/273│
|
|
31
|
+
* └─────┴─────┴─────┴─────┴─────┘
|
|
32
|
+
*
|
|
33
|
+
* 7x7 Gaussian Kernel (gaussian7):
|
|
34
|
+
* ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
|
|
35
|
+
* │ │ │ 1/1003│ 2/1003│ 1/1003│ │ │
|
|
36
|
+
* ├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
|
|
37
|
+
* │ │ 3/1003│13/1003│22/1003│13/1003│ 3/1003│ │
|
|
38
|
+
* ├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
|
|
39
|
+
* │1/1003│13/1003│59/1003│97/1003│59/1003│13/1003│1/1003│
|
|
40
|
+
* ├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
|
|
41
|
+
* │2/1003│22/1003│97/1003│159/1003│97/1003│22/1003│2/1003│
|
|
42
|
+
* ├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
|
|
43
|
+
* │1/1003│13/1003│59/1003│97/1003│59/1003│13/1003│1/1003│
|
|
44
|
+
* ├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
|
|
45
|
+
* │ │ 3/1003│13/1003│22/1003│13/1003│ 3/1003│ │
|
|
46
|
+
* ├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
|
|
47
|
+
* │ │ │ 1/1003│ 2/1003│ 1/1003│ │ │
|
|
48
|
+
* └─────┴─────┴─────┴─────┴─────┴─────┴─────┘
|
|
49
|
+
*
|
|
50
|
+
* How it works:
|
|
51
|
+
* 1. For each pixel, sample neighboring pixels based on kernel size
|
|
52
|
+
* 2. Weight each sample by the corresponding kernel value
|
|
53
|
+
* 3. Sum all weighted samples to get the blurred pixel color
|
|
54
|
+
* 4. Larger kernels create stronger blur effects
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
// lang: glsl
|
|
58
|
+
export const gaussianFragmentShader = `//
|
|
59
|
+
// Input texture to blur
|
|
60
|
+
uniform sampler2D tDiffuse;
|
|
61
|
+
// Resolution of the texture (width, height)
|
|
62
|
+
uniform vec2 resolution;
|
|
63
|
+
// Blur strength: 1=no blur, 2-3=3x3 kernel, 4-5=5x5 kernel, 6+=7x7 kernel
|
|
64
|
+
uniform int gaussian;
|
|
65
|
+
// Texture coordinates for current pixel
|
|
66
|
+
varying vec2 vUv;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* No blur - returns the original pixel color
|
|
70
|
+
*/
|
|
71
|
+
vec4 noGaussian() {
|
|
72
|
+
vec4 color = texture2D(tDiffuse, vUv);
|
|
73
|
+
return color;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Applies 3x3 Gaussian blur kernel
|
|
78
|
+
* Samples 9 pixels in a 3x3 grid around the current pixel
|
|
79
|
+
* Weights are based on 2D Gaussian distribution
|
|
80
|
+
*/
|
|
81
|
+
vec4 gaussian3(vec2 texel) {
|
|
82
|
+
vec4 color = vec4(0.0);
|
|
83
|
+
|
|
84
|
+
// Top row: weights [0.0625, 0.125, 0.0625]
|
|
85
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-1.0, -1.0)) * 0.0625;
|
|
86
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 0.0, -1.0)) * 0.125;
|
|
87
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 1.0, -1.0)) * 0.0625;
|
|
88
|
+
|
|
89
|
+
// Middle row: weights [0.125, 0.25, 0.125] (center pixel gets highest weight)
|
|
90
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-1.0, 0.0)) * 0.125;
|
|
91
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 0.0, 0.0)) * 0.25;
|
|
92
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 1.0, 0.0)) * 0.125;
|
|
93
|
+
|
|
94
|
+
// Bottom row: weights [0.0625, 0.125, 0.0625]
|
|
95
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-1.0, 1.0)) * 0.0625;
|
|
96
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 0.0, 1.0)) * 0.125;
|
|
97
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 1.0, 1.0)) * 0.0625;
|
|
98
|
+
|
|
99
|
+
return color;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Applies 5x5 Gaussian blur kernel
|
|
104
|
+
* Samples 25 pixels in a 5x5 grid around the current pixel
|
|
105
|
+
* Weights sum to 1.0 (273/273) for proper normalization
|
|
106
|
+
*/
|
|
107
|
+
vec4 gaussian5(vec2 texel) {
|
|
108
|
+
vec4 color = vec4(0.0);
|
|
109
|
+
|
|
110
|
+
// Row 1: weights [1/273, 4/273, 7/273, 4/273, 1/273]
|
|
111
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-2.0, -2.0)) * 1.0/273.0;
|
|
112
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-1.0, -2.0)) * 4.0/273.0;
|
|
113
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 0.0, -2.0)) * 7.0/273.0;
|
|
114
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 1.0, -2.0)) * 4.0/273.0;
|
|
115
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 2.0, -2.0)) * 1.0/273.0;
|
|
116
|
+
|
|
117
|
+
// Row 2: weights [4/273, 16/273, 26/273, 16/273, 4/273]
|
|
118
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-2.0, -1.0)) * 4.0/273.0;
|
|
119
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-1.0, -1.0)) * 16.0/273.0;
|
|
120
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 0.0, -1.0)) * 26.0/273.0;
|
|
121
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 1.0, -1.0)) * 16.0/273.0;
|
|
122
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 2.0, -1.0)) * 4.0/273.0;
|
|
123
|
+
|
|
124
|
+
// Row 3 (center): weights [7/273, 26/273, 41/273, 26/273, 7/273]
|
|
125
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-2.0, 0.0)) * 7.0/273.0;
|
|
126
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-1.0, 0.0)) * 26.0/273.0;
|
|
127
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 0.0, 0.0)) * 41.0/273.0; // Center pixel
|
|
128
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 1.0, 0.0)) * 26.0/273.0;
|
|
129
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 2.0, 0.0)) * 7.0/273.0;
|
|
130
|
+
|
|
131
|
+
// Row 4: weights [4/273, 16/273, 26/273, 16/273, 4/273]
|
|
132
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-2.0, 1.0)) * 4.0/273.0;
|
|
133
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-1.0, 1.0)) * 16.0/273.0;
|
|
134
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 0.0, 1.0)) * 26.0/273.0;
|
|
135
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 1.0, 1.0)) * 16.0/273.0;
|
|
136
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 2.0, 1.0)) * 4.0/273.0;
|
|
137
|
+
|
|
138
|
+
// Row 5: weights [1/273, 4/273, 7/273, 4/273, 1/273]
|
|
139
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-2.0, 2.0)) * 1.0/273.0;
|
|
140
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-1.0, 2.0)) * 4.0/273.0;
|
|
141
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 0.0, 2.0)) * 7.0/273.0;
|
|
142
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 1.0, 2.0)) * 4.0/273.0;
|
|
143
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 2.0, 2.0)) * 1.0/273.0;
|
|
144
|
+
|
|
145
|
+
return color;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Applies 7x7 Gaussian blur kernel
|
|
150
|
+
* Samples 49 pixels in a 7x7 grid around the current pixel
|
|
151
|
+
* Weights sum to 1.0 (1003/1003) for proper normalization
|
|
152
|
+
* Creates the strongest blur effect
|
|
153
|
+
*/
|
|
154
|
+
vec4 gaussian7(vec2 texel) {
|
|
155
|
+
vec4 color = vec4(0.0);
|
|
156
|
+
|
|
157
|
+
// Row 1: weights [0, 0, 1/1003, 2/1003, 1/1003, 0, 0]
|
|
158
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-1.0, -3.0)) * 1.0/1003.0;
|
|
159
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 0.0, -3.0)) * 2.0/1003.0;
|
|
160
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 1.0, -3.0)) * 1.0/1003.0;
|
|
161
|
+
|
|
162
|
+
// Row 2: weights [0, 3/1003, 13/1003, 22/1003, 13/1003, 3/1003, 0]
|
|
163
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-2.0, -2.0)) * 3.0/1003.0;
|
|
164
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-1.0, -2.0)) * 13.0/1003.0;
|
|
165
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 0.0, -2.0)) * 22.0/1003.0;
|
|
166
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 1.0, -2.0)) * 13.0/1003.0;
|
|
167
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 2.0, -2.0)) * 3.0/1003.0;
|
|
168
|
+
|
|
169
|
+
// Row 3: weights [1/1003, 13/1003, 59/1003, 97/1003, 59/1003, 13/1003, 1/1003]
|
|
170
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-3.0, -1.0)) * 1.0/1003.0;
|
|
171
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-2.0, -1.0)) * 13.0/1003.0;
|
|
172
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-1.0, -1.0)) * 59.0/1003.0;
|
|
173
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 0.0, -1.0)) * 97.0/1003.0;
|
|
174
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 1.0, -1.0)) * 59.0/1003.0;
|
|
175
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 2.0, -1.0)) * 13.0/1003.0;
|
|
176
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 3.0, -1.0)) * 1.0/1003.0;
|
|
177
|
+
|
|
178
|
+
// Row 4 (center): weights [2/1003, 22/1003, 97/1003, 159/1003, 97/1003, 22/1003, 2/1003]
|
|
179
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-3.0, 0.0)) * 2.0/1003.0;
|
|
180
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-2.0, 0.0)) * 22.0/1003.0;
|
|
181
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-1.0, 0.0)) * 97.0/1003.0;
|
|
182
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 0.0, 0.0)) * 159.0/1003.0; // Center pixel
|
|
183
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 1.0, 0.0)) * 97.0/1003.0;
|
|
184
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 2.0, 0.0)) * 22.0/1003.0;
|
|
185
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 3.0, 0.0)) * 2.0/1003.0;
|
|
186
|
+
|
|
187
|
+
// Row 5: weights [1/1003, 13/1003, 59/1003, 97/1003, 59/1003, 13/1003, 1/1003]
|
|
188
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-3.0, 1.0)) * 1.0/1003.0;
|
|
189
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-2.0, 1.0)) * 13.0/1003.0;
|
|
190
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-1.0, 1.0)) * 59.0/1003.0;
|
|
191
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 0.0, 1.0)) * 97.0/1003.0;
|
|
192
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 1.0, 1.0)) * 59.0/1003.0;
|
|
193
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 2.0, 1.0)) * 13.0/1003.0;
|
|
194
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 3.0, 1.0)) * 1.0/1003.0;
|
|
195
|
+
|
|
196
|
+
// Row 6: weights [0, 3/1003, 13/1003, 22/1003, 13/1003, 3/1003, 0]
|
|
197
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-2.0, 2.0)) * 3.0/1003.0;
|
|
198
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-1.0, 2.0)) * 13.0/1003.0;
|
|
199
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 0.0, 2.0)) * 22.0/1003.0;
|
|
200
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 1.0, 2.0)) * 13.0/1003.0;
|
|
201
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 2.0, 2.0)) * 3.0/1003.0;
|
|
202
|
+
|
|
203
|
+
// Row 7: weights [0, 0, 1/1003, 2/1003, 1/1003, 0, 0]
|
|
204
|
+
color += texture2D(tDiffuse, vUv + texel * vec2(-1.0, 3.0)) * 1.0/1003.0;
|
|
205
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 0.0, 3.0)) * 2.0/1003.0;
|
|
206
|
+
color += texture2D(tDiffuse, vUv + texel * vec2( 1.0, 3.0)) * 1.0/1003.0;
|
|
207
|
+
|
|
208
|
+
return color;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Main fragment shader function
|
|
213
|
+
* Determines which blur kernel to apply based on the 'gaussian' uniform
|
|
214
|
+
*/
|
|
215
|
+
void main() {
|
|
216
|
+
// Calculate the size of one texel (pixel) in texture coordinates
|
|
217
|
+
vec2 texel = 1.0 / resolution;
|
|
218
|
+
|
|
219
|
+
// Initialize output color (this line appears to be unused/debug code)
|
|
220
|
+
vec4 color = vec4(1.0, 0.0, 0.0, 0.0);
|
|
221
|
+
|
|
222
|
+
// TODO: remove these variables since not used
|
|
223
|
+
bool left = vUv.x < 0.5;
|
|
224
|
+
bool top = vUv.y < 0.5;
|
|
225
|
+
|
|
226
|
+
if (gaussian > 1 && gaussian <= 3) {
|
|
227
|
+
// Apply 3x3 Gaussian blur for values 2-3
|
|
228
|
+
color = gaussian3(texel);
|
|
229
|
+
} else if (gaussian > 3 && gaussian <= 5) {
|
|
230
|
+
// Apply 5x5 Gaussian blur for values 4-5
|
|
231
|
+
color = gaussian5(texel);
|
|
232
|
+
} else if (gaussian > 5) {
|
|
233
|
+
// Apply 7x7 Gaussian blur for values 6 and above
|
|
234
|
+
color = gaussian7(texel);
|
|
235
|
+
} else {
|
|
236
|
+
// No blur for value 1 or less
|
|
237
|
+
color = noGaussian();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Output the final blurred color
|
|
241
|
+
gl_FragColor = color;
|
|
242
|
+
}
|
|
243
|
+
`;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Attribution: Originally written by @alexandrairger
|
|
2
|
+
// Moved from .glsl file to .js file in this commit: https://github.com/vitessce/vitessce/pull/2264/commits/7f17fc003674a4ed1a8de6140db802781871cf88
|
|
3
|
+
/*
|
|
4
|
+
This is a simple vertex shader used for post-processing effects, specifically
|
|
5
|
+
Gaussian blur filtering applied to the final rendered image. It's part of a
|
|
6
|
+
two-pass rendering pipeline in the spatial-accelerated volume viewer.
|
|
7
|
+
|
|
8
|
+
USAGE CONTEXT:
|
|
9
|
+
- Used in VolumeView.js for the "blit pass" (screen-space post-processing)
|
|
10
|
+
- Applied to a full-screen quad (2x2 plane) that covers the entire viewport
|
|
11
|
+
- Works with GaussianFragmentShader to apply blur effects for performance optimization
|
|
12
|
+
|
|
13
|
+
COMPARISON WITH VolumeVertexShader:
|
|
14
|
+
|
|
15
|
+
VolumeVertexShader (Complex 3D Volume Rendering):
|
|
16
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
17
|
+
│ • Handles 3D volume data with complex coordinate transformations│
|
|
18
|
+
│ • Calculates ray directions for GPU-accelerated ray casting │
|
|
19
|
+
│ • Transforms camera positions and volume coordinates │
|
|
20
|
+
│ • Supports multiple volume channels and LOD systems │
|
|
21
|
+
│ • Used for the main volume rendering pass │
|
|
22
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
23
|
+
|
|
24
|
+
GaussianVertexShader (Simple 2D Post-Processing):
|
|
25
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
26
|
+
│ • Handles simple 2D screen-space coordinates │
|
|
27
|
+
│ • No complex transformations - just passes through UV coords │
|
|
28
|
+
│ • Used for post-processing effects on the final rendered image │
|
|
29
|
+
│ • Part of adaptive quality system (blur for performance) │
|
|
30
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
31
|
+
|
|
32
|
+
RENDERING PIPELINE:
|
|
33
|
+
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
|
34
|
+
│ Volume Rendering│───▶│ Gaussian Blur │───▶│ Final Display │
|
|
35
|
+
│ (VolumeShader) │ │ (This Shader) │ │ │
|
|
36
|
+
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
|
37
|
+
│ 3D volume data │ 2D texture │ Blurred result
|
|
38
|
+
│ ray casting │ screen quad │ for performance
|
|
39
|
+
|
|
40
|
+
ADAPTIVE QUALITY SYSTEM:
|
|
41
|
+
- When user is interacting: Apply strong blur (gaussian=7) for performance
|
|
42
|
+
- When user is still: No blur (gaussian=0) for best quality
|
|
43
|
+
- Automatic quality adjustment based on frame rate */
|
|
44
|
+
|
|
45
|
+
// lang: glsl
|
|
46
|
+
export const gaussianVertexShader = `//
|
|
47
|
+
varying vec2 vUv;
|
|
48
|
+
void main() {
|
|
49
|
+
vUv = uv;
|
|
50
|
+
gl_Position = vec4(position, 1.0);
|
|
51
|
+
}
|
|
52
|
+
`;
|