@kitware/vtk.js 23.1.0 → 23.2.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/Rendering/OpenGL/ForwardPass.js +7 -3
- package/Rendering/OpenGL/Framebuffer.js +68 -11
- package/Rendering/OpenGL/ImageMapper.js +23 -4
- package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +293 -0
- package/Rendering/OpenGL/PolyDataMapper.js +20 -2
- package/Rendering/OpenGL/ShaderCache.js +10 -2
- package/Rendering/OpenGL/Texture.js +32 -16
- package/Rendering/OpenGL/glsl/vtkPolyDataFS.glsl.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import macro from '../../macros.js';
|
|
2
2
|
import vtkOpenGLFramebuffer from './Framebuffer.js';
|
|
3
3
|
import vtkRenderPass from '../SceneGraph/RenderPass.js';
|
|
4
|
+
import vtkOpenGLOrderIndependentTranslucentPass from './OrderIndependentTranslucentPass.js';
|
|
4
5
|
|
|
5
6
|
function vtkForwardPass(publicAPI, model) {
|
|
6
7
|
// Set our className
|
|
@@ -72,8 +73,11 @@ function vtkForwardPass(publicAPI, model) {
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
if (model.translucentActorCount > 0) {
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
if (!model.translucentPass) {
|
|
77
|
+
model.translucentPass = vtkOpenGLOrderIndependentTranslucentPass.newInstance();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
model.translucentPass.traverse(viewNode, renNode, publicAPI);
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
if (model.volumeCount > 0) {
|
|
@@ -136,7 +140,7 @@ function extend(publicAPI, model) {
|
|
|
136
140
|
Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API
|
|
137
141
|
|
|
138
142
|
vtkRenderPass.extend(publicAPI, model, initialValues);
|
|
139
|
-
macro.get(publicAPI, model, ['framebuffer']); // Object methods
|
|
143
|
+
macro.get(publicAPI, model, ['framebuffer', 'opaqueActorCount', 'translucentActorCount', 'volumeCount']); // Object methods
|
|
140
144
|
|
|
141
145
|
vtkForwardPass(publicAPI, model);
|
|
142
146
|
} // ----------------------------------------------------------------------------
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { newInstance as newInstance$1, obj,
|
|
1
|
+
import { newInstance as newInstance$1, obj, vtkErrorMacro, getArray } from '../../macros.js';
|
|
2
2
|
import vtkOpenGLTexture from './Texture.js';
|
|
3
3
|
import { VtkDataTypes } from '../../Common/Core/DataArray/Constants.js';
|
|
4
4
|
import { Filter } from './Texture/Constants.js';
|
|
@@ -23,6 +23,11 @@ function vtkFramebuffer(publicAPI, model) {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
publicAPI.saveCurrentBindings = function (modeIn) {
|
|
26
|
+
if (!model.context) {
|
|
27
|
+
vtkErrorMacro('you must set the OpenGLRenderWindow before calling saveCurrentBindings');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
var gl = model.context;
|
|
27
32
|
model.previousDrawBinding = gl.getParameter(model.context.FRAMEBUFFER_BINDING);
|
|
28
33
|
model.previousActiveFramebuffer = model.openGLRenderWindow.getActiveFramebuffer();
|
|
@@ -38,6 +43,11 @@ function vtkFramebuffer(publicAPI, model) {
|
|
|
38
43
|
};
|
|
39
44
|
|
|
40
45
|
publicAPI.restorePreviousBindings = function (modeIn) {
|
|
46
|
+
if (!model.context) {
|
|
47
|
+
vtkErrorMacro('you must set the OpenGLRenderWindow before calling restorePreviousBindings');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
41
51
|
var gl = model.context;
|
|
42
52
|
gl.bindFramebuffer(gl.FRAMEBUFFER, model.previousDrawBinding);
|
|
43
53
|
model.openGLRenderWindow.setActiveFramebuffer(model.previousActiveFramebuffer);
|
|
@@ -47,16 +57,28 @@ function vtkFramebuffer(publicAPI, model) {
|
|
|
47
57
|
};
|
|
48
58
|
|
|
49
59
|
publicAPI.bind = function () {
|
|
50
|
-
|
|
60
|
+
var modeArg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
61
|
+
var mode = modeArg;
|
|
62
|
+
|
|
63
|
+
if (mode === null) {
|
|
64
|
+
mode = model.context.FRAMEBUFFER;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
model.context.bindFramebuffer(mode, model.glFramebuffer);
|
|
51
68
|
|
|
52
|
-
|
|
53
|
-
model.
|
|
69
|
+
for (var i = 0; i < model.colorBuffers.length; i++) {
|
|
70
|
+
model.colorBuffers[i].bind();
|
|
54
71
|
}
|
|
55
72
|
|
|
56
73
|
model.openGLRenderWindow.setActiveFramebuffer(publicAPI);
|
|
57
74
|
};
|
|
58
75
|
|
|
59
76
|
publicAPI.create = function (width, height) {
|
|
77
|
+
if (!model.context) {
|
|
78
|
+
vtkErrorMacro('you must set the OpenGLRenderWindow before calling create');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
60
82
|
model.glFramebuffer = model.context.createFramebuffer();
|
|
61
83
|
model.glFramebuffer.width = width;
|
|
62
84
|
model.glFramebuffer.height = height;
|
|
@@ -65,6 +87,12 @@ function vtkFramebuffer(publicAPI, model) {
|
|
|
65
87
|
publicAPI.setColorBuffer = function (texture) {
|
|
66
88
|
var attachment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
67
89
|
var gl = model.context;
|
|
90
|
+
|
|
91
|
+
if (!gl) {
|
|
92
|
+
vtkErrorMacro('you must set the OpenGLRenderWindow before calling setColorBuffer');
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
68
96
|
var glAttachment = gl.COLOR_ATTACHMENT0;
|
|
69
97
|
|
|
70
98
|
if (attachment > 0) {
|
|
@@ -76,13 +104,19 @@ function vtkFramebuffer(publicAPI, model) {
|
|
|
76
104
|
}
|
|
77
105
|
}
|
|
78
106
|
|
|
79
|
-
model.
|
|
107
|
+
model.colorBuffers[attachment] = texture;
|
|
80
108
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, glAttachment, gl.TEXTURE_2D, texture.getHandle(), 0);
|
|
81
109
|
};
|
|
82
110
|
|
|
83
111
|
publicAPI.removeColorBuffer = function () {
|
|
84
112
|
var attachment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
85
113
|
var gl = model.context;
|
|
114
|
+
|
|
115
|
+
if (!gl) {
|
|
116
|
+
vtkErrorMacro('you must set the OpenGLRenderWindow before calling removeColorBuffer');
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
86
120
|
var glAttachment = gl.COLOR_ATTACHMENT0;
|
|
87
121
|
|
|
88
122
|
if (attachment > 0) {
|
|
@@ -95,9 +129,15 @@ function vtkFramebuffer(publicAPI, model) {
|
|
|
95
129
|
}
|
|
96
130
|
|
|
97
131
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, glAttachment, gl.TEXTURE_2D, null, 0);
|
|
132
|
+
model.colorBuffers = model.colorBuffers.splice(attachment, 1);
|
|
98
133
|
};
|
|
99
134
|
|
|
100
135
|
publicAPI.setDepthBuffer = function (texture) {
|
|
136
|
+
if (!model.context) {
|
|
137
|
+
vtkErrorMacro('you must set the OpenGLRenderWindow before calling setDepthBuffer');
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
101
141
|
if (model.openGLRenderWindow.getWebgl2()) {
|
|
102
142
|
var gl = model.context;
|
|
103
143
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, texture.getHandle(), 0);
|
|
@@ -107,6 +147,11 @@ function vtkFramebuffer(publicAPI, model) {
|
|
|
107
147
|
};
|
|
108
148
|
|
|
109
149
|
publicAPI.removeDepthBuffer = function () {
|
|
150
|
+
if (!model.context) {
|
|
151
|
+
vtkErrorMacro('you must set the OpenGLRenderWindow before calling removeDepthBuffer');
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
110
155
|
if (model.openGLRenderWindow.getWebgl2()) {
|
|
111
156
|
var gl = model.context;
|
|
112
157
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, null, 0);
|
|
@@ -137,10 +182,6 @@ function vtkFramebuffer(publicAPI, model) {
|
|
|
137
182
|
if (model.glFramebuffer) {
|
|
138
183
|
model.context.deleteFramebuffer(model.glFramebuffer);
|
|
139
184
|
}
|
|
140
|
-
|
|
141
|
-
if (model.colorTexture) {
|
|
142
|
-
model.colorTexture.releaseGraphicsResources();
|
|
143
|
-
}
|
|
144
185
|
};
|
|
145
186
|
|
|
146
187
|
publicAPI.getSize = function () {
|
|
@@ -155,6 +196,11 @@ function vtkFramebuffer(publicAPI, model) {
|
|
|
155
196
|
};
|
|
156
197
|
|
|
157
198
|
publicAPI.populateFramebuffer = function () {
|
|
199
|
+
if (!model.context) {
|
|
200
|
+
vtkErrorMacro('you must set the OpenGLRenderWindow before calling populateFrameBuffer');
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
158
204
|
publicAPI.bind();
|
|
159
205
|
var gl = model.context;
|
|
160
206
|
var texture = vtkOpenGLTexture.newInstance();
|
|
@@ -169,6 +215,11 @@ function vtkFramebuffer(publicAPI, model) {
|
|
|
169
215
|
gl.bindRenderbuffer(gl.RENDERBUFFER, model.depthTexture);
|
|
170
216
|
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, model.glFramebuffer.width, model.glFramebuffer.height);
|
|
171
217
|
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, model.depthTexture);
|
|
218
|
+
}; // For backwards compatibility. Use getColorBuffers()[0] going forward.
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
publicAPI.getColorTexture = function () {
|
|
222
|
+
return model.colorBuffers[0];
|
|
172
223
|
};
|
|
173
224
|
} // ----------------------------------------------------------------------------
|
|
174
225
|
// Object factory
|
|
@@ -178,7 +229,7 @@ function vtkFramebuffer(publicAPI, model) {
|
|
|
178
229
|
var DEFAULT_VALUES = {
|
|
179
230
|
openGLRenderWindow: null,
|
|
180
231
|
glFramebuffer: null,
|
|
181
|
-
|
|
232
|
+
colorBuffers: null,
|
|
182
233
|
depthTexture: null,
|
|
183
234
|
previousDrawBinding: 0,
|
|
184
235
|
previousReadBinding: 0,
|
|
@@ -192,7 +243,13 @@ function extend(publicAPI, model) {
|
|
|
192
243
|
Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API
|
|
193
244
|
|
|
194
245
|
obj(publicAPI, model);
|
|
195
|
-
|
|
246
|
+
|
|
247
|
+
if (model.colorBuffers) {
|
|
248
|
+
vtkErrorMacro('you cannot initialize colorBuffers through the constructor. You should call setColorBuffer() instead.');
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
model.colorBuffers = [];
|
|
252
|
+
getArray(publicAPI, model, ['colorBuffers']); // For more macro methods, see "Sources/macros.js"
|
|
196
253
|
// Object specific methods
|
|
197
254
|
|
|
198
255
|
vtkFramebuffer(publicAPI, model);
|
|
@@ -41,6 +41,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
41
41
|
|
|
42
42
|
publicAPI.buildPass = function (prepass) {
|
|
43
43
|
if (prepass) {
|
|
44
|
+
model.currentRenderPass = null;
|
|
44
45
|
model.openGLImageSlice = publicAPI.getFirstAncestorOfType('vtkOpenGLImageSlice');
|
|
45
46
|
model.openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer');
|
|
46
47
|
model.openGLRenderWindow = model.openGLRenderer.getParent();
|
|
@@ -58,8 +59,9 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
58
59
|
}
|
|
59
60
|
};
|
|
60
61
|
|
|
61
|
-
publicAPI.translucentPass = function (prepass) {
|
|
62
|
+
publicAPI.translucentPass = function (prepass, renderPass) {
|
|
62
63
|
if (prepass) {
|
|
64
|
+
model.currentRenderPass = renderPass;
|
|
63
65
|
publicAPI.render();
|
|
64
66
|
}
|
|
65
67
|
};
|
|
@@ -95,7 +97,12 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
95
97
|
};
|
|
96
98
|
|
|
97
99
|
publicAPI.buildShaders = function (shaders, ren, actor) {
|
|
98
|
-
publicAPI.getShaderTemplate(shaders, ren, actor);
|
|
100
|
+
publicAPI.getShaderTemplate(shaders, ren, actor); // apply any renderPassReplacements
|
|
101
|
+
|
|
102
|
+
if (model.lastRenderPassShaderReplacement) {
|
|
103
|
+
model.lastRenderPassShaderReplacement(shaders);
|
|
104
|
+
}
|
|
105
|
+
|
|
99
106
|
publicAPI.replaceShaderValues(shaders, ren, actor);
|
|
100
107
|
};
|
|
101
108
|
|
|
@@ -240,9 +247,21 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
240
247
|
// input modified
|
|
241
248
|
// light complexity changed
|
|
242
249
|
var tNumComp = model.openGLTexture.getComponents();
|
|
243
|
-
var iComp = actor.getProperty().getIndependentComponents();
|
|
250
|
+
var iComp = actor.getProperty().getIndependentComponents(); // has the render pass shader replacement changed? Two options
|
|
251
|
+
|
|
252
|
+
var needRebuild = false;
|
|
253
|
+
|
|
254
|
+
if (!model.currentRenderPass && model.lastRenderPassShaderReplacement) {
|
|
255
|
+
needRebuild = true;
|
|
256
|
+
model.lastRenderPassShaderReplacement = null;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (model.currentRenderPass && model.currentRenderPass.getShaderReplacement() !== model.lastRenderPassShaderReplacement) {
|
|
260
|
+
model.lastRenderPassShaderReplacement = model.currentRenderPass.getShaderReplacement();
|
|
261
|
+
needRebuild = true;
|
|
262
|
+
}
|
|
244
263
|
|
|
245
|
-
if (model.lastHaveSeenDepthRequest !== model.haveSeenDepthRequest || cellBO.getProgram() === 0 || model.lastTextureComponents !== tNumComp || model.lastIndependentComponents !== iComp) {
|
|
264
|
+
if (needRebuild || model.lastHaveSeenDepthRequest !== model.haveSeenDepthRequest || cellBO.getProgram() === 0 || model.lastTextureComponents !== tNumComp || model.lastIndependentComponents !== iComp) {
|
|
246
265
|
model.lastHaveSeenDepthRequest = model.haveSeenDepthRequest;
|
|
247
266
|
model.lastTextureComponents = tNumComp;
|
|
248
267
|
model.lastIndependentComponents = iComp;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
|
+
import macro from '../../macros.js';
|
|
3
|
+
import vtkOpenGLTexture from './Texture.js';
|
|
4
|
+
import vtkOpenGLFramebuffer from './Framebuffer.js';
|
|
5
|
+
import vtkRenderPass from '../SceneGraph/RenderPass.js';
|
|
6
|
+
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
7
|
+
import vtkHelper from './Helper.js';
|
|
8
|
+
import vtkProperty from '../Core/Property.js';
|
|
9
|
+
import vtkShaderProgram from './ShaderProgram.js';
|
|
10
|
+
import vtkVertexArrayObject from './VertexArrayObject.js';
|
|
11
|
+
|
|
12
|
+
var Representation = vtkProperty.Representation;
|
|
13
|
+
var vtkErrorMacro = macro.vtkErrorMacro; // ----------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
function translucentShaderReplacement(shaders) {
|
|
16
|
+
var substituteRes = vtkShaderProgram.substitute(shaders.Fragment, '//VTK::RenderPassFragmentShader::Impl', "\n float weight = gl_FragData[0].a * pow(max(1.1 - gl_FragCoord.z, 0.0), 2.0);\n gl_FragData[0] = vec4(gl_FragData[0].rgb*weight, gl_FragData[0].a);\n gl_FragData[1].r = weight;\n ", false);
|
|
17
|
+
shaders.Fragment = substituteRes.result;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var oitpFragTemplate = "//VTK::System::Dec\n\nin vec2 tcoord;\n\nuniform sampler2D translucentRTexture;\nuniform sampler2D translucentRGBATexture;\n\n// the output of this shader\n//VTK::Output::Dec\n\nvoid main()\n{\n vec4 t1Color = texture(translucentRGBATexture, tcoord);\n float t2Color = texture(translucentRTexture, tcoord).r;\n gl_FragData[0] = vec4(t1Color.rgb/max(t2Color,0.01), 1.0 - t1Color.a);\n}\n";
|
|
21
|
+
|
|
22
|
+
function vtkOpenGLOrderIndependentTranslucentPass(publicAPI, model) {
|
|
23
|
+
// Set our className
|
|
24
|
+
model.classHierarchy.push('vtkOpenGLOrderIndependentTranslucentPass'); // build vertices etc
|
|
25
|
+
|
|
26
|
+
publicAPI.createVertexBuffer = function () {
|
|
27
|
+
// 4 corner points in clipping space in order (x, y, z) where z is always set to -1
|
|
28
|
+
// prettier-ignore
|
|
29
|
+
var ptsArray = new Float32Array([-1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1]); // 4 corresponding corner points in texture space in order (x, y)
|
|
30
|
+
|
|
31
|
+
var tcoordArray = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]); // a square defined as cell relation ship in order (cell_size, v1, v2, v3, v4)
|
|
32
|
+
|
|
33
|
+
var cellArray = new Uint16Array([4, 0, 1, 3, 2]);
|
|
34
|
+
var points = vtkDataArray.newInstance({
|
|
35
|
+
numberOfComponents: 3,
|
|
36
|
+
values: ptsArray
|
|
37
|
+
});
|
|
38
|
+
points.setName('points');
|
|
39
|
+
var tcoords = vtkDataArray.newInstance({
|
|
40
|
+
numberOfComponents: 2,
|
|
41
|
+
values: tcoordArray
|
|
42
|
+
});
|
|
43
|
+
tcoords.setName('tcoords');
|
|
44
|
+
var cells = vtkDataArray.newInstance({
|
|
45
|
+
numberOfComponents: 1,
|
|
46
|
+
values: cellArray
|
|
47
|
+
});
|
|
48
|
+
model.tris.getCABO().createVBO(cells, 'polys', Representation.SURFACE, {
|
|
49
|
+
points: points,
|
|
50
|
+
tcoords: tcoords,
|
|
51
|
+
cellOffset: 0
|
|
52
|
+
});
|
|
53
|
+
model.VBOBuildTime.modified();
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
publicAPI.createFramebuffer = function (viewNode) {
|
|
57
|
+
var _model$framebuffer;
|
|
58
|
+
|
|
59
|
+
var size = viewNode.getSize();
|
|
60
|
+
var gl = viewNode.getContext();
|
|
61
|
+
model.framebuffer = vtkOpenGLFramebuffer.newInstance();
|
|
62
|
+
model.framebuffer.setOpenGLRenderWindow(viewNode);
|
|
63
|
+
|
|
64
|
+
(_model$framebuffer = model.framebuffer).create.apply(_model$framebuffer, _toConsumableArray(size));
|
|
65
|
+
|
|
66
|
+
model.framebuffer.saveCurrentBindingsAndBuffers();
|
|
67
|
+
model.framebuffer.bind();
|
|
68
|
+
model.translucentRGBATexture = vtkOpenGLTexture.newInstance();
|
|
69
|
+
model.translucentRGBATexture.setInternalFormat(gl.RGBA16F);
|
|
70
|
+
model.translucentRGBATexture.setFormat(gl.RGBA);
|
|
71
|
+
model.translucentRGBATexture.setOpenGLDataType(gl.HALF_FLOAT);
|
|
72
|
+
model.translucentRGBATexture.setOpenGLRenderWindow(viewNode);
|
|
73
|
+
model.translucentRGBATexture.create2DFromRaw(size[0], size[1], 4, 'Float32Array', null);
|
|
74
|
+
model.translucentRTexture = vtkOpenGLTexture.newInstance();
|
|
75
|
+
model.translucentRTexture.setInternalFormat(gl.R16F);
|
|
76
|
+
model.translucentRTexture.setFormat(gl.RED);
|
|
77
|
+
model.translucentRTexture.setOpenGLDataType(gl.HALF_FLOAT);
|
|
78
|
+
model.translucentRTexture.setOpenGLRenderWindow(viewNode);
|
|
79
|
+
model.translucentRTexture.create2DFromRaw(size[0], size[1], 1, 'Float32Array', null);
|
|
80
|
+
model.translucentZTexture = vtkOpenGLTexture.newInstance();
|
|
81
|
+
model.translucentZTexture.setOpenGLRenderWindow(viewNode);
|
|
82
|
+
model.translucentZTexture.createDepthFromRaw(size[0], size[1], 'Float32Array', null);
|
|
83
|
+
model.framebuffer.setColorBuffer(model.translucentRGBATexture, 0);
|
|
84
|
+
model.framebuffer.setColorBuffer(model.translucentRTexture, 1);
|
|
85
|
+
model.framebuffer.setDepthBuffer(model.translucentZTexture);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
publicAPI.createCopyShader = function (viewNode) {
|
|
89
|
+
model.copyShader = viewNode.getShaderCache().readyShaderProgramArray(['//VTK::System::Dec', 'attribute vec4 vertexDC;', 'attribute vec2 tcoordTC;', 'varying vec2 tcoord;', 'void main() { tcoord = tcoordTC; gl_Position = vertexDC; }'].join('\n'), oitpFragTemplate, '');
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
publicAPI.createVBO = function (viewNode) {
|
|
93
|
+
var gl = viewNode.getContext();
|
|
94
|
+
model.tris.setOpenGLRenderWindow(viewNode);
|
|
95
|
+
publicAPI.createVertexBuffer();
|
|
96
|
+
var program = model.copyShader; // prepare the vertex and triangle data for the image plane to render to
|
|
97
|
+
|
|
98
|
+
model.tris.getCABO().bind();
|
|
99
|
+
|
|
100
|
+
if (!model.copyVAO.addAttributeArray(program, model.tris.getCABO(), 'vertexDC', model.tris.getCABO().getVertexOffset(), model.tris.getCABO().getStride(), gl.FLOAT, 3, gl.FALSE)) {
|
|
101
|
+
vtkErrorMacro('Error setting vertexDC in copy shader VAO.');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!model.copyVAO.addAttributeArray(program, model.tris.getCABO(), 'tcoordTC', model.tris.getCABO().getTCoordOffset(), model.tris.getCABO().getStride(), gl.FLOAT, 2, gl.FALSE)) {
|
|
105
|
+
vtkErrorMacro('Error setting vertexDC in copy shader VAO.');
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
publicAPI.traverse = function (viewNode, renNode, forwardPass) {
|
|
110
|
+
if (model.deleted) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
var size = viewNode.getSize();
|
|
115
|
+
var gl = viewNode.getContext();
|
|
116
|
+
|
|
117
|
+
if (gl === null) {
|
|
118
|
+
// nothing to do -> no render context
|
|
119
|
+
// traverse delegate passes -> has to be done in order for the vtk render-pipeline to work correctly
|
|
120
|
+
model.delegates.forEach(function (val) {
|
|
121
|
+
val.traverse(viewNode, publicAPI);
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
} // if we lack the webgl2 and half floatsupport just do
|
|
125
|
+
// basic alpha blending
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
if (!viewNode.getWebgl2() || !gl.getExtension('EXT_color_buffer_half_float') && !gl.getExtension('EXT_color_buffer_float')) {
|
|
129
|
+
console.log('fallback');
|
|
130
|
+
publicAPI.setCurrentOperation('translucentPass');
|
|
131
|
+
renNode.traverse(publicAPI);
|
|
132
|
+
return;
|
|
133
|
+
} // prepare framebuffer // allocate framebuffer if needed and bind it
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
if (model.framebuffer === null) {
|
|
137
|
+
publicAPI.createFramebuffer(viewNode);
|
|
138
|
+
} else {
|
|
139
|
+
var fbSize = model.framebuffer.getSize();
|
|
140
|
+
|
|
141
|
+
if (fbSize === null || fbSize[0] !== size[0] || fbSize[1] !== size[1]) {
|
|
142
|
+
model.framebuffer.releaseGraphicsResources();
|
|
143
|
+
model.translucentRGBATexture.releaseGraphicsResources(viewNode);
|
|
144
|
+
model.translucentRTexture.releaseGraphicsResources(viewNode);
|
|
145
|
+
model.translucentZTexture.releaseGraphicsResources(viewNode);
|
|
146
|
+
publicAPI.createFramebuffer(viewNode);
|
|
147
|
+
} else {
|
|
148
|
+
// store framebuffer bindings to restore them later
|
|
149
|
+
model.framebuffer.saveCurrentBindingsAndBuffers();
|
|
150
|
+
model.framebuffer.bind();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
gl.drawBuffers([gl.COLOR_ATTACHMENT0]);
|
|
155
|
+
gl.clearBufferfv(gl.COLOR, 0, [0.0, 0.0, 0.0, 0.0]);
|
|
156
|
+
gl.clearBufferfv(gl.DEPTH, 0, [1.0]);
|
|
157
|
+
gl.colorMask(false, false, false, false); // rerender the opaque pass to set the depth buffer
|
|
158
|
+
// TODO remove when webgl1 is deprecated and instead
|
|
159
|
+
// have the forward pass use a texture backed zbuffer
|
|
160
|
+
|
|
161
|
+
if (forwardPass.getOpaqueActorCount() > 0) {
|
|
162
|
+
forwardPass.setCurrentOperation('opaquePass');
|
|
163
|
+
renNode.traverse(forwardPass);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
gl.colorMask(true, true, true, true);
|
|
167
|
+
gl.drawBuffers([gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1]);
|
|
168
|
+
gl.clearBufferfv(gl.COLOR, 0, [0.0, 0.0, 0.0, 1.0]);
|
|
169
|
+
gl.clearBufferfv(gl.COLOR, 1, [0.0, 0.0, 0.0, 0.0]);
|
|
170
|
+
gl.enable(gl.DEPTH_TEST);
|
|
171
|
+
gl.enable(gl.BLEND); // basic gist is we accumulate color into RGB We compute final opacity
|
|
172
|
+
// into A We store accumulated opacity into R of the R texture.
|
|
173
|
+
|
|
174
|
+
gl.blendFuncSeparate(gl.ONE, gl.ONE, gl.ZERO, gl.ONE_MINUS_SRC_ALPHA); // now do the translucent rendering
|
|
175
|
+
|
|
176
|
+
publicAPI.setCurrentOperation('translucentPass');
|
|
177
|
+
renNode.traverse(publicAPI);
|
|
178
|
+
gl.drawBuffers([gl.NONE]);
|
|
179
|
+
model.framebuffer.restorePreviousBindingsAndBuffers(); // gl.drawBuffers([gl.BACK]);
|
|
180
|
+
// make sure the copy shader is ready
|
|
181
|
+
|
|
182
|
+
if (model.copyShader === null) {
|
|
183
|
+
publicAPI.createCopyShader(viewNode);
|
|
184
|
+
} else {
|
|
185
|
+
viewNode.getShaderCache().readyShaderProgram(model.copyShader);
|
|
186
|
+
} // make sure we have a VAO
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
if (!model.copyVAO) {
|
|
190
|
+
model.copyVAO = vtkVertexArrayObject.newInstance();
|
|
191
|
+
model.copyVAO.setOpenGLRenderWindow(viewNode);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
model.copyVAO.bind(); // make sure the VBO is up to date
|
|
195
|
+
|
|
196
|
+
if (model.VBOBuildTime.getMTime() < publicAPI.getMTime()) {
|
|
197
|
+
publicAPI.createVBO(viewNode);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
|
201
|
+
gl.depthMask(false);
|
|
202
|
+
gl.depthFunc(gl.ALWAYS);
|
|
203
|
+
gl.viewport(0, 0, size[0], size[1]);
|
|
204
|
+
gl.scissor(0, 0, size[0], size[1]); // activate texture
|
|
205
|
+
|
|
206
|
+
model.translucentRGBATexture.activate();
|
|
207
|
+
model.copyShader.setUniformi('translucentRGBATexture', model.translucentRGBATexture.getTextureUnit());
|
|
208
|
+
model.translucentRTexture.activate();
|
|
209
|
+
model.copyShader.setUniformi('translucentRTexture', model.translucentRTexture.getTextureUnit()); // render quad
|
|
210
|
+
|
|
211
|
+
gl.drawArrays(gl.TRIANGLES, 0, model.tris.getCABO().getElementCount());
|
|
212
|
+
gl.depthMask(true);
|
|
213
|
+
gl.depthFunc(gl.LEQUAL);
|
|
214
|
+
model.translucentRGBATexture.deactivate();
|
|
215
|
+
model.translucentRTexture.deactivate();
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
publicAPI.getShaderReplacement = function () {
|
|
219
|
+
return translucentShaderReplacement;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
publicAPI.releaseGraphicsResources = function (viewNode) {
|
|
223
|
+
if (model.framebuffer) {
|
|
224
|
+
model.framebuffer.releaseGraphicsResources(viewNode);
|
|
225
|
+
model.framebuffer = null;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (model.translucentRGBATexture) {
|
|
229
|
+
model.translucentRGBATexture.releaseGraphicsResources(viewNode);
|
|
230
|
+
model.translucentRGBATexture = null;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (model.translucentRTexture) {
|
|
234
|
+
model.translucentRTexture.releaseGraphicsResources(viewNode);
|
|
235
|
+
model.translucentRTexture = null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (model.translucentZTexture) {
|
|
239
|
+
model.translucentZTexture.releaseGraphicsResources(viewNode);
|
|
240
|
+
model.translucentZTexture = null;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (model.copyVAO) {
|
|
244
|
+
model.copyVAO.releaseGraphicsResources(viewNode);
|
|
245
|
+
model.copyVAO = null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (model.copyShader) {
|
|
249
|
+
model.copyShader.releaseGraphicsResources(viewNode);
|
|
250
|
+
model.copyShader = null;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (model.tris) {
|
|
254
|
+
model.tris.releaseGraphicsResources(viewNode);
|
|
255
|
+
model.tris = null;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
publicAPI.modified();
|
|
259
|
+
};
|
|
260
|
+
} // ----------------------------------------------------------------------------
|
|
261
|
+
// Object factory
|
|
262
|
+
// ----------------------------------------------------------------------------
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
var DEFAULT_VALUES = {
|
|
266
|
+
framebuffer: null,
|
|
267
|
+
copyShader: null,
|
|
268
|
+
tris: null
|
|
269
|
+
}; // ----------------------------------------------------------------------------
|
|
270
|
+
|
|
271
|
+
function extend(publicAPI, model) {
|
|
272
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
273
|
+
Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API
|
|
274
|
+
|
|
275
|
+
vtkRenderPass.extend(publicAPI, model, initialValues);
|
|
276
|
+
model.VBOBuildTime = {};
|
|
277
|
+
macro.obj(model.VBOBuildTime, {
|
|
278
|
+
mtime: 0
|
|
279
|
+
});
|
|
280
|
+
model.tris = vtkHelper.newInstance();
|
|
281
|
+
macro.get(publicAPI, model, ['framebuffer']); // Object methods
|
|
282
|
+
|
|
283
|
+
vtkOpenGLOrderIndependentTranslucentPass(publicAPI, model);
|
|
284
|
+
} // ----------------------------------------------------------------------------
|
|
285
|
+
|
|
286
|
+
var newInstance = macro.newInstance(extend, 'vtkOpenGLOrderIndependentTranslucentPass'); // ----------------------------------------------------------------------------
|
|
287
|
+
|
|
288
|
+
var vtkOpenGLOrderIndependentTranslucentPass$1 = {
|
|
289
|
+
newInstance: newInstance,
|
|
290
|
+
extend: extend
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export { vtkOpenGLOrderIndependentTranslucentPass$1 as default, extend, newInstance };
|
|
@@ -46,6 +46,7 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
|
|
|
46
46
|
|
|
47
47
|
publicAPI.buildPass = function (prepass) {
|
|
48
48
|
if (prepass) {
|
|
49
|
+
model.currentRenderPass = null;
|
|
49
50
|
model.openGLActor = publicAPI.getFirstAncestorOfType('vtkOpenGLActor');
|
|
50
51
|
model.openGLRenderer = model.openGLActor.getFirstAncestorOfType('vtkOpenGLRenderer');
|
|
51
52
|
model.openGLRenderWindow = model.openGLRenderer.getParent();
|
|
@@ -54,8 +55,9 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
|
|
|
54
55
|
}; // Renders myself
|
|
55
56
|
|
|
56
57
|
|
|
57
|
-
publicAPI.translucentPass = function (prepass) {
|
|
58
|
+
publicAPI.translucentPass = function (prepass, renderPass) {
|
|
58
59
|
if (prepass) {
|
|
60
|
+
model.currentRenderPass = renderPass;
|
|
59
61
|
publicAPI.render();
|
|
60
62
|
}
|
|
61
63
|
};
|
|
@@ -92,7 +94,12 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
|
|
|
92
94
|
};
|
|
93
95
|
|
|
94
96
|
publicAPI.buildShaders = function (shaders, ren, actor) {
|
|
95
|
-
publicAPI.getShaderTemplate(shaders, ren, actor); //
|
|
97
|
+
publicAPI.getShaderTemplate(shaders, ren, actor); // apply any renderPassReplacements
|
|
98
|
+
|
|
99
|
+
if (model.lastRenderPassShaderReplacement) {
|
|
100
|
+
model.lastRenderPassShaderReplacement(shaders);
|
|
101
|
+
} // user specified pre replacements
|
|
102
|
+
|
|
96
103
|
|
|
97
104
|
var openGLSpec = model.renderable.getViewSpecificProperties().OpenGL;
|
|
98
105
|
var shaderReplacements = null;
|
|
@@ -603,6 +610,17 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
|
|
|
603
610
|
lastLightCount: numberOfLights
|
|
604
611
|
}, true);
|
|
605
612
|
needRebuild = true;
|
|
613
|
+
} // has the render pass shader replacement changed? Two options
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
if (!model.currentRenderPass && model.lastRenderPassShaderReplacement) {
|
|
617
|
+
needRebuild = true;
|
|
618
|
+
model.lastRenderPassShaderReplacement = null;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
if (model.currentRenderPass && model.currentRenderPass.getShaderReplacement() !== model.lastRenderPassShaderReplacement) {
|
|
622
|
+
model.lastRenderPassShaderReplacement = model.currentRenderPass.getShaderReplacement();
|
|
623
|
+
needRebuild = true;
|
|
606
624
|
} // has something changed that would require us to recreate the shader?
|
|
607
625
|
// candidates are
|
|
608
626
|
// property modified (representation interpolation and lighting)
|
|
@@ -46,8 +46,16 @@ function vtkShaderCache(publicAPI, model) {
|
|
|
46
46
|
if (gl2) {
|
|
47
47
|
nVSSource = vtkShaderProgram.substitute(nVSSource, 'varying', 'out').result;
|
|
48
48
|
nFSSource = vtkShaderProgram.substitute(nFSSource, 'varying', 'in').result;
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
var shaderOutputs = '';
|
|
50
|
+
var outputCount = 0;
|
|
51
|
+
|
|
52
|
+
while (nFSSource.includes("gl_FragData[".concat(outputCount, "]"))) {
|
|
53
|
+
nFSSource = vtkShaderProgram.substitute(nFSSource, "gl_FragData\\[".concat(outputCount, "\\]"), "fragOutput".concat(outputCount)).result;
|
|
54
|
+
shaderOutputs += "layout(location = ".concat(outputCount, ") out vec4 fragOutput").concat(outputCount, ";\n");
|
|
55
|
+
outputCount++;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
nFSSource = vtkShaderProgram.substitute(nFSSource, '//VTK::Output::Dec', shaderOutputs).result;
|
|
51
59
|
} // nFSSource = ShaderProgram.substitute(nFSSource, 'gl_FragData\\[0\\]',
|
|
52
60
|
// 'gl_FragColor').result;
|
|
53
61
|
|
|
@@ -456,7 +456,11 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
456
456
|
|
|
457
457
|
publicAPI.getOpenGLDataType = function (vtkScalarType) {
|
|
458
458
|
var useHalfFloatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
459
|
-
|
|
459
|
+
|
|
460
|
+
if (!model.openGLDataType) {
|
|
461
|
+
model.openGLDataType = publicAPI.getDefaultDataType(vtkScalarType, useHalfFloatType);
|
|
462
|
+
}
|
|
463
|
+
|
|
460
464
|
return model.openGLDataType;
|
|
461
465
|
};
|
|
462
466
|
|
|
@@ -561,13 +565,17 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
561
565
|
|
|
562
566
|
if (dataType !== VtkDataTypes.FLOAT && model.openGLDataType === model.context.FLOAT) {
|
|
563
567
|
for (var idx = 0; idx < data.length; idx++) {
|
|
564
|
-
|
|
568
|
+
if (data[idx]) {
|
|
569
|
+
var newArray = new Float32Array(pixCount);
|
|
565
570
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
571
|
+
for (var i = 0; i < pixCount; i++) {
|
|
572
|
+
newArray[i] = data[idx][i];
|
|
573
|
+
}
|
|
569
574
|
|
|
570
|
-
|
|
575
|
+
pixData.push(newArray);
|
|
576
|
+
} else {
|
|
577
|
+
pixData.push(null);
|
|
578
|
+
}
|
|
571
579
|
}
|
|
572
580
|
} // if the opengl data type is ubyte
|
|
573
581
|
// then the data array must be u8, we currently simply truncate the data
|
|
@@ -575,13 +583,17 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
575
583
|
|
|
576
584
|
if (dataType !== VtkDataTypes.UNSIGNED_CHAR && model.openGLDataType === model.context.UNSIGNED_BYTE) {
|
|
577
585
|
for (var _idx = 0; _idx < data.length; _idx++) {
|
|
578
|
-
|
|
586
|
+
if (data[_idx]) {
|
|
587
|
+
var _newArray = new Uint8Array(pixCount);
|
|
579
588
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
589
|
+
for (var _i = 0; _i < pixCount; _i++) {
|
|
590
|
+
_newArray[_i] = data[_idx][_i];
|
|
591
|
+
}
|
|
583
592
|
|
|
584
|
-
|
|
593
|
+
pixData.push(_newArray);
|
|
594
|
+
} else {
|
|
595
|
+
pixData.push(null);
|
|
596
|
+
}
|
|
585
597
|
}
|
|
586
598
|
} // if the opengl data type is half float
|
|
587
599
|
// then the data array must be u16
|
|
@@ -592,13 +604,17 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
592
604
|
|
|
593
605
|
if (halfFloat) {
|
|
594
606
|
for (var _idx2 = 0; _idx2 < data.length; _idx2++) {
|
|
595
|
-
|
|
607
|
+
if (data[_idx2]) {
|
|
608
|
+
var _newArray2 = new Uint16Array(pixCount);
|
|
596
609
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
610
|
+
for (var _i2 = 0; _i2 < pixCount; _i2++) {
|
|
611
|
+
_newArray2[_i2] = HalfFloat.toHalf(data[_idx2][_i2]);
|
|
612
|
+
}
|
|
600
613
|
|
|
601
|
-
|
|
614
|
+
pixData.push(_newArray2);
|
|
615
|
+
} else {
|
|
616
|
+
pixData.push(null);
|
|
617
|
+
}
|
|
602
618
|
}
|
|
603
619
|
} // The output has to be filled
|
|
604
620
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var vtkPolyDataFS = "//VTK::System::Dec\n\n/*=========================================================================\n\n Program: Visualization Toolkit\n Module: vtkPolyDataFS.glsl\n\n Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n All rights reserved.\n See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n PURPOSE. See the above copyright notice for more information.\n\n=========================================================================*/\n// Template for the polydata mappers fragment shader\n\nuniform int PrimitiveIDOffset;\n\n// VC position of this fragment\n//VTK::PositionVC::Dec\n\n// optional color passed in from the vertex shader, vertexColor\n//VTK::Color::Dec\n\n// optional surface normal declaration\n//VTK::Normal::Dec\n\n// extra lighting parameters\n//VTK::Light::Dec\n\n// Texture coordinates\n//VTK::TCoord::Dec\n\n// picking support\n//VTK::Picking::Dec\n\n// Depth Peeling Support\n//VTK::DepthPeeling::Dec\n\n// clipping plane vars\n//VTK::Clip::Dec\n\n// the output of this shader\n//VTK::Output::Dec\n\n// Apple Bug\n//VTK::PrimID::Dec\n\n// handle coincident offsets\n//VTK::Coincident::Dec\n\n//VTK::ZBuffer::Dec\n\nvoid main()\n{\n // VC position of this fragment. This should not branch/return/discard.\n //VTK::PositionVC::Impl\n\n // Place any calls that require uniform flow (e.g. dFdx) here.\n //VTK::UniformFlow::Impl\n\n // Set gl_FragDepth here (gl_FragCoord.z by default)\n //VTK::Depth::Impl\n\n // Early depth peeling abort:\n //VTK::DepthPeeling::PreColor\n\n // Apple Bug\n //VTK::PrimID::Impl\n\n //VTK::Clip::Impl\n\n //VTK::Color::Impl\n\n // Generate the normal if we are not passed in one\n //VTK::Normal::Impl\n\n //VTK::TCoord::Impl\n\n //VTK::Light::Impl\n\n if (gl_FragData[0].a <= 0.0)\n {\n discard;\n }\n\n //VTK::DepthPeeling::Impl\n\n //VTK::Picking::Impl\n\n // handle coincident offsets\n //VTK::Coincident::Impl\n\n //VTK::ZBuffer::Impl\n}\n";
|
|
1
|
+
var vtkPolyDataFS = "//VTK::System::Dec\n\n/*=========================================================================\n\n Program: Visualization Toolkit\n Module: vtkPolyDataFS.glsl\n\n Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n All rights reserved.\n See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n PURPOSE. See the above copyright notice for more information.\n\n=========================================================================*/\n// Template for the polydata mappers fragment shader\n\nuniform int PrimitiveIDOffset;\n\n// VC position of this fragment\n//VTK::PositionVC::Dec\n\n// optional color passed in from the vertex shader, vertexColor\n//VTK::Color::Dec\n\n// optional surface normal declaration\n//VTK::Normal::Dec\n\n// extra lighting parameters\n//VTK::Light::Dec\n\n// Texture coordinates\n//VTK::TCoord::Dec\n\n// picking support\n//VTK::Picking::Dec\n\n// Depth Peeling Support\n//VTK::DepthPeeling::Dec\n\n// clipping plane vars\n//VTK::Clip::Dec\n\n// the output of this shader\n//VTK::Output::Dec\n\n// Apple Bug\n//VTK::PrimID::Dec\n\n// handle coincident offsets\n//VTK::Coincident::Dec\n\n//VTK::ZBuffer::Dec\n\nvoid main()\n{\n // VC position of this fragment. This should not branch/return/discard.\n //VTK::PositionVC::Impl\n\n // Place any calls that require uniform flow (e.g. dFdx) here.\n //VTK::UniformFlow::Impl\n\n // Set gl_FragDepth here (gl_FragCoord.z by default)\n //VTK::Depth::Impl\n\n // Early depth peeling abort:\n //VTK::DepthPeeling::PreColor\n\n // Apple Bug\n //VTK::PrimID::Impl\n\n //VTK::Clip::Impl\n\n //VTK::Color::Impl\n\n // Generate the normal if we are not passed in one\n //VTK::Normal::Impl\n\n //VTK::TCoord::Impl\n\n //VTK::Light::Impl\n\n if (gl_FragData[0].a <= 0.0)\n {\n discard;\n }\n\n //VTK::DepthPeeling::Impl\n\n //VTK::Picking::Impl\n\n // handle coincident offsets\n //VTK::Coincident::Impl\n\n //VTK::ZBuffer::Impl\n\n //VTK::RenderPassFragmentShader::Impl\n}\n";
|
|
2
2
|
|
|
3
3
|
export { vtkPolyDataFS as v };
|