@xeokit/xeokit-sdk 2.5.2-beta-11 → 2.5.2-beta-13

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.
Files changed (52) hide show
  1. package/dist/xeokit-sdk.cjs.js +146 -132
  2. package/dist/xeokit-sdk.es.js +146 -132
  3. package/dist/xeokit-sdk.es5.js +84 -84
  4. package/dist/xeokit-sdk.min.cjs.js +1 -1
  5. package/dist/xeokit-sdk.min.es.js +1 -1
  6. package/dist/xeokit-sdk.min.es5.js +1 -1
  7. package/package.json +1 -1
  8. package/src/viewer/scene/model/SceneModel.js +1 -1
  9. package/src/viewer/scene/model/vbo/batching/triangles/VBOBatchingTrianglesLayer.js +1 -1
  10. package/src/viewer/scene/model/vbo/instancing/triangles/VBOInstancingTrianglesLayer.js +1 -1
  11. package/src/viewer/scene/webgl/Renderer.js +20 -19
  12. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesColorRenderer.js +0 -238
  13. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesColorTextureRenderer.js +0 -270
  14. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesDepthRenderer.js +0 -126
  15. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesEdgesColorRenderer.js +0 -127
  16. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesEdgesRenderer.js +0 -133
  17. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesFlatColorRenderer.js +0 -235
  18. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesNormalsRenderer.js +0 -139
  19. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesOcclusionRenderer.js +0 -125
  20. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPBRRenderer.js +0 -561
  21. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickDepthRenderer.js +0 -144
  22. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickMeshRenderer.js +0 -130
  23. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickNormalsFlatRenderer.js +0 -121
  24. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickNormalsRenderer.js +0 -131
  25. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesRenderer.js +0 -33
  26. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesRenderers.js +0 -375
  27. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesShadowRenderer.js +0 -107
  28. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesSilhouetteRenderer.js +0 -136
  29. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesSnapInitRenderer.js +0 -311
  30. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesSnapRenderer.js +0 -308
  31. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOSceneModelTriangleBatchingEdgesRenderer.js +0 -12
  32. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesColorRenderer.js +0 -253
  33. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesColorTextureRenderer.js +0 -278
  34. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesDepthRenderer.js +0 -126
  35. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesEdgesColorRenderer.js +0 -132
  36. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesEdgesRenderer.js +0 -134
  37. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesFlatColorRenderer.js +0 -244
  38. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesFlatNormalsRenderer.js +0 -130
  39. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesNormalsRenderer.js +0 -138
  40. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesOcclusionRenderer.js +0 -128
  41. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPBRRenderer.js +0 -561
  42. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickDepthRenderer.js +0 -149
  43. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickMeshRenderer.js +0 -136
  44. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickNormalsFlatRenderer.js +0 -130
  45. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickNormalsRenderer.js +0 -145
  46. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesRenderers.js +0 -376
  47. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesShadowRenderer.js +0 -113
  48. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesSilhouetteRenderer.js +0 -139
  49. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesSnapInitRenderer.js +0 -342
  50. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesSnapRenderer.js +0 -325
  51. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOSceneModelTriangleInstancingEdgesRenderer.js +0 -12
  52. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOSceneModelTriangleInstancingRenderer.js +0 -29
@@ -1,132 +0,0 @@
1
- import {VBOSceneModelTriangleInstancingEdgesRenderer} from "./VBOSceneModelTriangleInstancingEdgesRenderer.js";
2
-
3
- /**
4
- * @private
5
- */
6
-
7
-
8
- export class VBOInstancingTrianglesEdgesColorRenderer extends VBOSceneModelTriangleInstancingEdgesRenderer {
9
-
10
- _buildVertexShader() {
11
- const scene = this._scene;
12
- const sectionPlanesState = scene._sectionPlanesState;
13
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
14
- const src = [];
15
- src.push("#version 300 es");
16
- src.push("// VBOInstancingTrianglesEdgesColorRenderer vertex shader");
17
-
18
- src.push("uniform int renderPass;");
19
- src.push("in vec3 position;");
20
- src.push("in vec4 color;");
21
- if (scene.entityOffsetsEnabled) {
22
- src.push("in vec3 offset;");
23
- }
24
- src.push("in float flags;");
25
- src.push("in vec4 modelMatrixCol0;"); // Modeling matrix
26
- src.push("in vec4 modelMatrixCol1;");
27
- src.push("in vec4 modelMatrixCol2;");
28
-
29
- this._addMatricesUniformBlockLines(src);
30
-
31
- if (scene.logarithmicDepthBufferEnabled) {
32
- src.push("uniform float logDepthBufFC;");
33
- src.push("out float vFragDepth;");
34
- src.push("bool isPerspectiveMatrix(mat4 m) {");
35
- src.push(" return (m[2][3] == - 1.0);");
36
- src.push("}");
37
- src.push("out float isPerspective;");
38
- }
39
-
40
- if (clipping) {
41
- src.push("out vec4 vWorldPosition;");
42
- src.push("out float vFlags;");
43
- }
44
-
45
- src.push("out vec4 vColor;");
46
-
47
- src.push("void main(void) {");
48
-
49
- // edgeFlag = NOT_RENDERED | EDGES_COLOR_OPAQUE | EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
50
- // renderPass = EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
51
-
52
- src.push(`int edgeFlag = int(flags) >> 8 & 0xF;`);
53
- src.push(`if (edgeFlag != renderPass) {`);
54
- src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
55
-
56
- src.push("} else {");
57
- src.push("vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
58
- src.push("worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
59
- if (scene.entityOffsetsEnabled) {
60
- src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
61
- }
62
- src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
63
- if (clipping) {
64
- src.push("vWorldPosition = worldPosition;");
65
- src.push("vFlags = flags;");
66
- }
67
- src.push("vec4 clipPos = projMatrix * viewPosition;");
68
- if (scene.logarithmicDepthBufferEnabled) {
69
- src.push("vFragDepth = 1.0 + clipPos.w;");
70
- src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
71
- }
72
- src.push("gl_Position = clipPos;");
73
- // src.push("vColor = vec4(float(color.r-100.0) / 255.0, float(color.g-100.0) / 255.0, float(color.b-100.0) / 255.0, float(color.a) / 255.0);");
74
- src.push("vColor = vec4(float(color.r*0.5) / 255.0, float(color.g*0.5) / 255.0, float(color.b*0.5) / 255.0, float(color.a) / 255.0);");
75
- src.push("}");
76
- src.push("}");
77
- return src;
78
- }
79
-
80
- _buildFragmentShader() {
81
- const scene = this._scene;
82
- const sectionPlanesState = scene._sectionPlanesState;
83
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
84
- const src = [];
85
- src.push("#version 300 es");
86
- src.push("// VBOInstancingTrianglesEdgesColorRenderer fragment shader");
87
-
88
- src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
89
- src.push("precision highp float;");
90
- src.push("precision highp int;");
91
- src.push("#else");
92
- src.push("precision mediump float;");
93
- src.push("precision mediump int;");
94
- src.push("#endif");
95
- if (scene.logarithmicDepthBufferEnabled) {
96
- src.push("in float isPerspective;");
97
- src.push("uniform float logDepthBufFC;");
98
- src.push("in float vFragDepth;");
99
- }
100
- if (clipping) {
101
- src.push("in vec4 vWorldPosition;");
102
- src.push("in float vFlags;");
103
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
104
- src.push("uniform bool sectionPlaneActive" + i + ";");
105
- src.push("uniform vec3 sectionPlanePos" + i + ";");
106
- src.push("uniform vec3 sectionPlaneDir" + i + ";");
107
- }
108
- }
109
- src.push("in vec4 vColor;");
110
- src.push("out vec4 outColor;");
111
- src.push("void main(void) {");
112
- if (clipping) {
113
- src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
114
- src.push(" if (clippable) {");
115
- src.push(" float dist = 0.0;");
116
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
117
- src.push("if (sectionPlaneActive" + i + ") {");
118
- src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
119
- src.push("}");
120
- }
121
- src.push(" if (dist > 0.0) { discard; }");
122
- src.push("}");
123
- }
124
- if (scene.logarithmicDepthBufferEnabled) {
125
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
126
- }
127
- src.push("outColor = vColor;");
128
- src.push("}");
129
- return src;
130
- }
131
- }
132
-
@@ -1,134 +0,0 @@
1
- import {VBOSceneModelTriangleInstancingEdgesRenderer} from "./VBOSceneModelTriangleInstancingEdgesRenderer.js";
2
-
3
- /**
4
- * @private
5
- */
6
-
7
-
8
- export class VBOInstancingTrianglesEdgesRenderer extends VBOSceneModelTriangleInstancingEdgesRenderer {
9
-
10
- drawLayer(frameCtx, instancingLayer, renderPass) {
11
- super.drawLayer(frameCtx, instancingLayer, renderPass, {colorUniform: true});
12
- }
13
-
14
- _buildVertexShader() {
15
- const scene = this._scene;
16
- const sectionPlanesState = scene._sectionPlanesState;
17
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
18
- const src = [];
19
- src.push("#version 300 es");
20
- src.push("// VBOInstancingTrianglesEdgesRenderer vertex shader");
21
-
22
- src.push("uniform int renderPass;");
23
- src.push("uniform vec4 color;");
24
- src.push("in vec3 position;");
25
- if (scene.entityOffsetsEnabled) {
26
- src.push("in vec3 offset;");
27
- }
28
- src.push("in float flags;");
29
- src.push("in vec4 modelMatrixCol0;"); // Modeling matrix
30
- src.push("in vec4 modelMatrixCol1;");
31
- src.push("in vec4 modelMatrixCol2;");
32
-
33
- this._addMatricesUniformBlockLines(src);
34
-
35
- if (scene.logarithmicDepthBufferEnabled) {
36
- src.push("uniform float logDepthBufFC;");
37
- src.push("out float vFragDepth;");
38
- src.push("bool isPerspectiveMatrix(mat4 m) {");
39
- src.push(" return (m[2][3] == - 1.0);");
40
- src.push("}");
41
- src.push("out float isPerspective;");
42
- }
43
-
44
- if (clipping) {
45
- src.push("out vec4 vWorldPosition;");
46
- src.push("out float vFlags;");
47
- }
48
-
49
- src.push("out vec4 vColor;");
50
-
51
- src.push("void main(void) {");
52
-
53
- // edgeFlag = NOT_RENDERED | EDGES_COLOR_OPAQUE | EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
54
- // renderPass = EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
55
-
56
- src.push(`int edgeFlag = int(flags) >> 8 & 0xF;`);
57
- src.push(`if (edgeFlag != renderPass) {`);
58
- src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
59
-
60
- src.push("} else {");
61
- src.push("vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
62
- src.push("worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
63
- if (scene.entityOffsetsEnabled) {
64
- src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
65
- }
66
- src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
67
- if (clipping) {
68
- src.push("vWorldPosition = worldPosition;");
69
- src.push("vFlags = flags;");
70
- }
71
- src.push("vec4 clipPos = projMatrix * viewPosition;");
72
- if (scene.logarithmicDepthBufferEnabled) {
73
- src.push("vFragDepth = 1.0 + clipPos.w;");
74
- src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
75
- }
76
- src.push("gl_Position = clipPos;");
77
- src.push("vColor = vec4(color.r, color.g, color.b, color.a);");
78
- src.push("}");
79
- src.push("}");
80
- return src;
81
- }
82
-
83
- _buildFragmentShader() {
84
- const scene = this._scene;
85
- const sectionPlanesState = scene._sectionPlanesState;
86
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
87
- const src = [];
88
- src.push("#version 300 es");
89
- src.push("// VBOInstancingTrianglesEdgesRenderer fragment shader");
90
-
91
- src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
92
- src.push("precision highp float;");
93
- src.push("precision highp int;");
94
- src.push("#else");
95
- src.push("precision mediump float;");
96
- src.push("precision mediump int;");
97
- src.push("#endif");
98
- if (scene.logarithmicDepthBufferEnabled) {
99
- src.push("in float isPerspective;");
100
- src.push("uniform float logDepthBufFC;");
101
- src.push("in float vFragDepth;");
102
- }
103
- if (clipping) {
104
- src.push("in vec4 vWorldPosition;");
105
- src.push("in float vFlags;");
106
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
107
- src.push("uniform bool sectionPlaneActive" + i + ";");
108
- src.push("uniform vec3 sectionPlanePos" + i + ";");
109
- src.push("uniform vec3 sectionPlaneDir" + i + ";");
110
- }
111
- }
112
- src.push("in vec4 vColor;");
113
- src.push("out vec4 outColor;");
114
- src.push("void main(void) {");
115
- if (clipping) {
116
- src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
117
- src.push(" if (clippable) {");
118
- src.push(" float dist = 0.0;");
119
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
120
- src.push("if (sectionPlaneActive" + i + ") {");
121
- src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
122
- src.push("}");
123
- }
124
- src.push(" if (dist > 0.0) { discard; }");
125
- src.push("}");
126
- }
127
- if (scene.logarithmicDepthBufferEnabled) {
128
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
129
- }
130
- src.push("outColor = vColor;");
131
- src.push("}");
132
- return src;
133
- }
134
- }
@@ -1,244 +0,0 @@
1
- import {VBOSceneModelTriangleInstancingRenderer} from "./VBOSceneModelTriangleInstancingRenderer.js";
2
-
3
- /**
4
- * @private
5
- */
6
-
7
-
8
- export class VBOInstancingTrianglesFlatColorRenderer extends VBOSceneModelTriangleInstancingRenderer {
9
- _getHash() {
10
- const scene = this._scene;
11
- return [scene._lightsState.getHash(), scene._sectionPlanesState.getHash(), (this._withSAO ? "sao" : "nosao")].join(";");
12
- }
13
-
14
- _buildVertexShader() {
15
- const scene = this._scene;
16
- const sectionPlanesState = scene._sectionPlanesState;
17
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
18
- const src = [];
19
- src.push("#version 300 es");
20
- src.push("// Instancing geometry flat-shading drawing vertex shader");
21
-
22
- src.push("uniform int renderPass;");
23
-
24
- src.push("in vec3 position;");
25
- src.push("in vec4 color;");
26
- src.push("in float flags;");
27
-
28
- if (scene.entityOffsetsEnabled) {
29
- src.push("in vec3 offset;");
30
- }
31
-
32
- src.push("in vec4 modelMatrixCol0;"); // Modeling matrix
33
- src.push("in vec4 modelMatrixCol1;");
34
- src.push("in vec4 modelMatrixCol2;");
35
-
36
- this._addMatricesUniformBlockLines(src);
37
-
38
- if (scene.logarithmicDepthBufferEnabled) {
39
- src.push("uniform float logDepthBufFC;");
40
- src.push("out float vFragDepth;");
41
- src.push("bool isPerspectiveMatrix(mat4 m) {");
42
- src.push(" return (m[2][3] == - 1.0);");
43
- src.push("}");
44
- src.push("out float isPerspective;");
45
- }
46
-
47
- if (clipping) {
48
- src.push("out vec4 vWorldPosition;");
49
- src.push("out float vFlags;");
50
- }
51
-
52
- src.push("out vec4 vViewPosition;");
53
- src.push("out vec4 vColor;");
54
-
55
- src.push("void main(void) {");
56
-
57
- // colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
58
- // renderPass = COLOR_OPAQUE | COLOR_TRANSPARENT
59
-
60
- src.push(`int colorFlag = int(flags) & 0xF;`);
61
- src.push(`if (colorFlag != renderPass) {`);
62
- src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
63
-
64
- src.push("} else {");
65
-
66
- src.push("vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
67
- src.push("worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
68
- if (scene.entityOffsetsEnabled) {
69
- src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
70
- }
71
-
72
- src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
73
- src.push("vViewPosition = viewPosition;");
74
- src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");
75
-
76
- src.push("vec4 clipPos = projMatrix * viewPosition;");
77
- if (scene.logarithmicDepthBufferEnabled) {
78
- src.push("vFragDepth = 1.0 + clipPos.w;");
79
- src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
80
- }
81
-
82
- if (clipping) {
83
- src.push("vWorldPosition = worldPosition;");
84
- src.push("vFlags = flags;");
85
- }
86
-
87
- src.push("gl_Position = clipPos;");
88
- src.push("}");
89
- src.push("}");
90
- return src;
91
- }
92
-
93
- _buildFragmentShader() {
94
- const scene = this._scene;
95
- const sectionPlanesState = scene._sectionPlanesState;
96
- const lightsState = scene._lightsState;
97
- let i;
98
- let len;
99
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
100
- const src = [];
101
- src.push("#version 300 es");
102
- src.push("// Instancing geometry flat-shading drawing fragment shader");
103
-
104
- src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
105
- src.push("precision highp float;");
106
- src.push("precision highp int;");
107
- src.push("#else");
108
- src.push("precision mediump float;");
109
- src.push("precision mediump int;");
110
- src.push("#endif");
111
- if (scene.logarithmicDepthBufferEnabled) {
112
- src.push("in float isPerspective;");
113
- src.push("uniform float logDepthBufFC;");
114
- src.push("in float vFragDepth;");
115
- }
116
- if (this._withSAO) {
117
- src.push("uniform sampler2D uOcclusionTexture;");
118
- src.push("uniform vec4 uSAOParams;");
119
- src.push("const float packUpscale = 256. / 255.;");
120
- src.push("const float unpackDownScale = 255. / 256.;");
121
- src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");
122
- src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");
123
-
124
- src.push("float unpackRGBToFloat( const in vec4 v ) {");
125
- src.push(" return dot( v, unPackFactors );");
126
- src.push("}");
127
- }
128
-
129
- if (clipping) {
130
- src.push("in vec4 vWorldPosition;");
131
- src.push("in float vFlags;");
132
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
133
- src.push("uniform bool sectionPlaneActive" + i + ";");
134
- src.push("uniform vec3 sectionPlanePos" + i + ";");
135
- src.push("uniform vec3 sectionPlaneDir" + i + ";");
136
- }
137
- }
138
-
139
- this._addMatricesUniformBlockLines(src);
140
-
141
- src.push("uniform vec4 lightAmbient;");
142
-
143
- for (i = 0, len = lightsState.lights.length; i < len; i++) {
144
- const light = lightsState.lights[i];
145
- if (light.type === "ambient") {
146
- continue;
147
- }
148
- src.push("uniform vec4 lightColor" + i + ";");
149
- if (light.type === "dir") {
150
- src.push("uniform vec3 lightDir" + i + ";");
151
- }
152
- if (light.type === "point") {
153
- src.push("uniform vec3 lightPos" + i + ";");
154
- }
155
- if (light.type === "spot") {
156
- src.push("uniform vec3 lightPos" + i + ";");
157
- src.push("uniform vec3 lightDir" + i + ";");
158
- }
159
- }
160
-
161
- src.push("in vec4 vViewPosition;");
162
- src.push("in vec4 vColor;");
163
- src.push("out vec4 outColor;");
164
-
165
- src.push("void main(void) {");
166
-
167
- if (clipping) {
168
- src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
169
- src.push(" if (clippable) {");
170
- src.push(" float dist = 0.0;");
171
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
172
- src.push("if (sectionPlaneActive" + i + ") {");
173
- src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
174
- src.push("}");
175
- }
176
- src.push(" if (dist > 0.0) { ");
177
- src.push(" discard;")
178
- src.push(" }");
179
- src.push("}");
180
- }
181
-
182
- src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
183
- src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
184
-
185
- src.push("float lambertian = 1.0;");
186
-
187
- src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");
188
- src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");
189
- src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");
190
-
191
- for (i = 0, len = lightsState.lights.length; i < len; i++) {
192
- const light = lightsState.lights[i];
193
- if (light.type === "ambient") {
194
- continue;
195
- }
196
- if (light.type === "dir") {
197
- if (light.space === "view") {
198
- src.push("viewLightDir = normalize(lightDir" + i + ");");
199
- } else {
200
- src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
201
- }
202
- } else if (light.type === "point") {
203
- if (light.space === "view") {
204
- src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
205
- } else {
206
- src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
207
- }
208
- } else if (light.type === "spot") {
209
- if (light.space === "view") {
210
- src.push("viewLightDir = normalize(lightDir" + i + ");");
211
- } else {
212
- src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
213
- }
214
- } else {
215
- continue;
216
- }
217
- src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
218
- src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
219
- }
220
-
221
- src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
222
-
223
- if (this._withSAO) {
224
- // Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
225
- // Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
226
- src.push(" float viewportWidth = uSAOParams[0];");
227
- src.push(" float viewportHeight = uSAOParams[1];");
228
- src.push(" float blendCutoff = uSAOParams[2];");
229
- src.push(" float blendFactor = uSAOParams[3];");
230
- src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
231
- src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
232
- src.push(" outColor = vec4(fragColor.rgb * ambient, 1.0);");
233
- } else {
234
- src.push(" outColor = fragColor;");
235
- }
236
-
237
- if (scene.logarithmicDepthBufferEnabled) {
238
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
239
- }
240
-
241
- src.push("}");
242
- return src;
243
- }
244
- }
@@ -1,130 +0,0 @@
1
- import {VBOSceneModelTriangleInstancingRenderer} from "./VBOSceneModelTriangleInstancingRenderer.js";
2
-
3
-
4
- /**
5
- * @private
6
- */
7
-
8
- export class VBOInstancingTrianglesFlatNormalsRenderer extends VBOSceneModelTriangleInstancingRenderer {
9
-
10
- _buildVertexShader() {
11
- const scene = this._scene;
12
- const sectionPlanesState = scene._sectionPlanesState;
13
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
14
- const src = [];
15
- src.push("#version 300 es");
16
- src.push("// Instancing geometry flat normals drawing vertex shader");
17
-
18
- src.push("uniform int renderPass;");
19
- src.push("in vec3 position;");
20
- if (scene.entityOffsetsEnabled) {
21
- src.push("in vec3 offset;");
22
- }
23
- src.push("in vec4 color;");
24
- src.push("in float flags;");
25
- src.push("in vec4 modelMatrixCol0;");
26
- src.push("in vec4 modelMatrixCol1;");
27
- src.push("in vec4 modelMatrixCol2;");
28
-
29
- this._addMatricesUniformBlockLines(src);
30
-
31
- if (scene.logarithmicDepthBufferEnabled) {
32
- src.push("uniform float logDepthBufFC;");
33
- src.push("out float vFragDepth;");
34
- src.push("bool isPerspectiveMatrix(mat4 m) {");
35
- src.push(" return (m[2][3] == - 1.0);");
36
- src.push("}");
37
- src.push("out float isPerspective;");
38
- }
39
- if (clipping) {
40
- src.push("out vec4 vWorldPosition;");
41
- src.push("out float vFlags;");
42
- }
43
- src.push("void main(void) {");
44
- // colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
45
- // renderPass = COLOR_OPAQUE
46
-
47
- src.push(`int colorFlag = int(flags) & 0xF;`);
48
- src.push(`if (colorFlag != renderPass) {`);
49
- src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");
50
- src.push("} else {");
51
- src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
52
- src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
53
- if (scene.entityOffsetsEnabled) {
54
- src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
55
- }
56
- src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
57
- if (clipping) {
58
- src.push("vWorldPosition = worldPosition;");
59
- src.push("vFlags = flags;");
60
- }
61
- src.push(" vViewPosition = viewPosition;");
62
- src.push("vec4 clipPos = projMatrix * viewPosition;");
63
- if (scene.logarithmicDepthBufferEnabled) {
64
- src.push("vFragDepth = 1.0 + clipPos.w;");
65
- src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
66
- }
67
- src.push("gl_Position = clipPos;");
68
- src.push("}");
69
- src.push("}");
70
- return src;
71
- }
72
-
73
- _buildFragmentShader() {
74
- const scene = this._scene;
75
- const sectionPlanesState = scene._sectionPlanesState;
76
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
77
- const src = [];
78
- src.push("#version 300 es");
79
- src.push("// Instancing geometry flat nornals drawing fragment shader");
80
-
81
- src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
82
- src.push("precision highp float;");
83
- src.push("precision highp int;");
84
- src.push("#else");
85
- src.push("precision mediump float;");
86
- src.push("precision mediump int;");
87
- src.push("#endif");
88
- if (scene.logarithmicDepthBufferEnabled) {
89
- src.push("in float isPerspective;");
90
- src.push("uniform float logDepthBufFC;");
91
- src.push("in float vFragDepth;");
92
- }
93
- if (clipping) {
94
- src.push("in vec4 vWorldPosition;");
95
- src.push("in float vFlags;");
96
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
97
- src.push("uniform bool sectionPlaneActive" + i + ";");
98
- src.push("uniform vec3 sectionPlanePos" + i + ";");
99
- src.push("uniform vec3 sectionPlaneDir" + i + ";");
100
- }
101
- }
102
- src.push("in vec3 vViewPosition;");
103
- src.push("vec3 packNormalToRGB( const in vec3 normal ) {");
104
- src.push(" return normalize( normal ) * 0.5 + 0.5;");
105
- src.push("}");
106
- src.push("out vec4 outColor;");
107
- src.push("void main(void) {");
108
- if (clipping) {
109
- src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
110
- src.push(" if (clippable) {");
111
- src.push(" float dist = 0.0;");
112
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
113
- src.push("if (sectionPlaneActive" + i + ") {");
114
- src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
115
- src.push("}");
116
- }
117
- src.push("if (dist > 0.0) { discard; }");
118
- src.push("}");
119
- }
120
- if (scene.logarithmicDepthBufferEnabled) {
121
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
122
- }
123
- src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");
124
- src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");
125
- src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");
126
- src.push(" outColor = vec4(packNormalToRGB(viewNormal), 1.0); ");
127
- src.push("}");
128
- return src;
129
- }
130
- }