@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.
- package/dist/xeokit-sdk.cjs.js +146 -132
- package/dist/xeokit-sdk.es.js +146 -132
- package/dist/xeokit-sdk.es5.js +84 -84
- package/dist/xeokit-sdk.min.cjs.js +1 -1
- package/dist/xeokit-sdk.min.es.js +1 -1
- package/dist/xeokit-sdk.min.es5.js +1 -1
- package/package.json +1 -1
- package/src/viewer/scene/model/SceneModel.js +1 -1
- package/src/viewer/scene/model/vbo/batching/triangles/VBOBatchingTrianglesLayer.js +1 -1
- package/src/viewer/scene/model/vbo/instancing/triangles/VBOInstancingTrianglesLayer.js +1 -1
- package/src/viewer/scene/webgl/Renderer.js +20 -19
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesColorRenderer.js +0 -238
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesColorTextureRenderer.js +0 -270
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesDepthRenderer.js +0 -126
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesEdgesColorRenderer.js +0 -127
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesEdgesRenderer.js +0 -133
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesFlatColorRenderer.js +0 -235
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesNormalsRenderer.js +0 -139
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesOcclusionRenderer.js +0 -125
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPBRRenderer.js +0 -561
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickDepthRenderer.js +0 -144
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickMeshRenderer.js +0 -130
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickNormalsFlatRenderer.js +0 -121
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickNormalsRenderer.js +0 -131
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesRenderer.js +0 -33
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesRenderers.js +0 -375
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesShadowRenderer.js +0 -107
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesSilhouetteRenderer.js +0 -136
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesSnapInitRenderer.js +0 -311
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesSnapRenderer.js +0 -308
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOSceneModelTriangleBatchingEdgesRenderer.js +0 -12
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesColorRenderer.js +0 -253
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesColorTextureRenderer.js +0 -278
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesDepthRenderer.js +0 -126
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesEdgesColorRenderer.js +0 -132
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesEdgesRenderer.js +0 -134
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesFlatColorRenderer.js +0 -244
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesFlatNormalsRenderer.js +0 -130
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesNormalsRenderer.js +0 -138
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesOcclusionRenderer.js +0 -128
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPBRRenderer.js +0 -561
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickDepthRenderer.js +0 -149
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickMeshRenderer.js +0 -136
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickNormalsFlatRenderer.js +0 -130
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickNormalsRenderer.js +0 -145
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesRenderers.js +0 -376
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesShadowRenderer.js +0 -113
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesSilhouetteRenderer.js +0 -139
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesSnapInitRenderer.js +0 -342
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesSnapRenderer.js +0 -325
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOSceneModelTriangleInstancingEdgesRenderer.js +0 -12
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOSceneModelTriangleInstancingRenderer.js +0 -29
package/package.json
CHANGED
|
@@ -3653,7 +3653,7 @@ export class SceneModel extends Component {
|
|
|
3653
3653
|
for (let i = 0, len = renderFlags.visibleLayers.length; i < len; i++) {
|
|
3654
3654
|
const layerIndex = renderFlags.visibleLayers[i];
|
|
3655
3655
|
this.layerList[layerIndex].drawColorOpaque(renderFlags, frameCtx);
|
|
3656
|
-
|
|
3656
|
+
}
|
|
3657
3657
|
}
|
|
3658
3658
|
|
|
3659
3659
|
/** @private */
|
|
@@ -5,7 +5,7 @@ import {math} from "../../../../math/math.js";
|
|
|
5
5
|
import {RenderState} from "../../../../webgl/RenderState.js";
|
|
6
6
|
import {ArrayBuf} from "../../../../webgl/ArrayBuf.js";
|
|
7
7
|
import {geometryCompressionUtils} from "../../../../math/geometryCompressionUtils.js";
|
|
8
|
-
import {getRenderers} from "./renderers/
|
|
8
|
+
import {getRenderers} from "./renderers/Renderers.js";
|
|
9
9
|
import {VBOBatchingTrianglesBuffer} from "./VBOBatchingTrianglesBuffer.js";
|
|
10
10
|
import {quantizePositions, transformAndOctEncodeNormals} from "../../../compression.js";
|
|
11
11
|
|
|
@@ -4,7 +4,7 @@ import {RENDER_PASSES} from '../../../RENDER_PASSES.js';
|
|
|
4
4
|
import {math} from "../../../../math/math.js";
|
|
5
5
|
import {RenderState} from "../../../../webgl/RenderState.js";
|
|
6
6
|
import {ArrayBuf} from "../../../../webgl/ArrayBuf.js";
|
|
7
|
-
import {getRenderers} from "./renderers/
|
|
7
|
+
import {getRenderers} from "./renderers/Renderers.js";
|
|
8
8
|
|
|
9
9
|
const tempUint8Vec4 = new Uint8Array(4);
|
|
10
10
|
const tempFloat32 = new Float32Array(1);
|
|
@@ -621,7 +621,7 @@ const Renderer = function (scene, options) {
|
|
|
621
621
|
selectedFillOpaqueBin[selectedFillOpaqueBinLen++] = drawable;
|
|
622
622
|
}
|
|
623
623
|
|
|
624
|
-
if (edgesEnabled) {
|
|
624
|
+
if (drawable.edges && edgesEnabled) {
|
|
625
625
|
if (renderFlags.edgesOpaque) {
|
|
626
626
|
normalEdgesOpaqueBin[normalEdgesOpaqueBinLen++] = drawable;
|
|
627
627
|
}
|
|
@@ -629,29 +629,30 @@ const Renderer = function (scene, options) {
|
|
|
629
629
|
if (renderFlags.edgesTransparent) {
|
|
630
630
|
normalEdgesTransparentBin[normalEdgesTransparentBinLen++] = drawable;
|
|
631
631
|
}
|
|
632
|
-
}
|
|
633
|
-
if (renderFlags.selectedEdgesTransparent) {
|
|
634
|
-
selectedEdgesTransparentBin[selectedEdgesTransparentBinLen++] = drawable;
|
|
635
|
-
}
|
|
636
632
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
633
|
+
if (renderFlags.selectedEdgesTransparent) {
|
|
634
|
+
selectedEdgesTransparentBin[selectedEdgesTransparentBinLen++] = drawable;
|
|
635
|
+
}
|
|
640
636
|
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
637
|
+
if (renderFlags.selectedEdgesOpaque) {
|
|
638
|
+
selectedEdgesOpaqueBin[selectedEdgesOpaqueBinLen++] = drawable;
|
|
639
|
+
}
|
|
644
640
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
641
|
+
if (renderFlags.xrayedEdgesTransparent) {
|
|
642
|
+
xrayEdgesTransparentBin[xrayEdgesTransparentBinLen++] = drawable;
|
|
643
|
+
}
|
|
648
644
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
645
|
+
if (renderFlags.xrayedEdgesOpaque) {
|
|
646
|
+
xrayEdgesOpaqueBin[xrayEdgesOpaqueBinLen++] = drawable;
|
|
647
|
+
}
|
|
652
648
|
|
|
653
|
-
|
|
654
|
-
|
|
649
|
+
if (renderFlags.highlightedEdgesTransparent) {
|
|
650
|
+
highlightedEdgesTransparentBin[highlightedEdgesTransparentBinLen++] = drawable;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
if (renderFlags.highlightedEdgesOpaque) {
|
|
654
|
+
highlightedEdgesOpaqueBin[highlightedEdgesOpaqueBinLen++] = drawable;
|
|
655
|
+
}
|
|
655
656
|
}
|
|
656
657
|
}
|
|
657
658
|
}
|
package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesColorRenderer.js
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import {VBOBatchingTrianglesRenderer} from "./VBOBatchingTrianglesRenderer.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @private
|
|
5
|
-
*/
|
|
6
|
-
export class VBOBatchingTrianglesColorRenderer extends VBOBatchingTrianglesRenderer {
|
|
7
|
-
_getHash() {
|
|
8
|
-
const scene = this._scene;
|
|
9
|
-
return [scene._lightsState.getHash(), scene._sectionPlanesState.getHash(), (this._withSAO ? "sao" : "nosao")].join(";");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
drawLayer(frameCtx, layer, renderPass) {
|
|
13
|
-
super.drawLayer(frameCtx, layer, renderPass, { incrementDrawState: true });
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
_buildVertexShader() {
|
|
17
|
-
const scene = this._scene;
|
|
18
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
19
|
-
const lightsState = scene._lightsState;
|
|
20
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
21
|
-
let light;
|
|
22
|
-
const src = [];
|
|
23
|
-
src.push("#version 300 es");
|
|
24
|
-
src.push("// Triangles batching draw vertex shader");
|
|
25
|
-
|
|
26
|
-
src.push("uniform int renderPass;");
|
|
27
|
-
|
|
28
|
-
src.push("in vec3 position;");
|
|
29
|
-
src.push("in vec3 normal;");
|
|
30
|
-
src.push("in vec4 color;");
|
|
31
|
-
src.push("in float flags;");
|
|
32
|
-
|
|
33
|
-
if (scene.entityOffsetsEnabled) {
|
|
34
|
-
src.push("in vec3 offset;");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
this._addMatricesUniformBlockLines(src, true);
|
|
38
|
-
|
|
39
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
40
|
-
src.push("uniform float logDepthBufFC;");
|
|
41
|
-
src.push("out float vFragDepth;");
|
|
42
|
-
src.push("bool isPerspectiveMatrix(mat4 m) {");
|
|
43
|
-
src.push(" return (m[2][3] == - 1.0);");
|
|
44
|
-
src.push("}");
|
|
45
|
-
src.push("out float isPerspective;");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
src.push("uniform vec4 lightAmbient;");
|
|
49
|
-
|
|
50
|
-
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
51
|
-
light = lightsState.lights[i];
|
|
52
|
-
if (light.type === "ambient") {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
src.push("uniform vec4 lightColor" + i + ";");
|
|
56
|
-
if (light.type === "dir") {
|
|
57
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
58
|
-
}
|
|
59
|
-
if (light.type === "point") {
|
|
60
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
61
|
-
}
|
|
62
|
-
if (light.type === "spot") {
|
|
63
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
64
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
src.push("vec3 octDecode(vec2 oct) {");
|
|
69
|
-
src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
|
|
70
|
-
src.push(" if (v.z < 0.0) {");
|
|
71
|
-
src.push(" v.xy = (1.0 - abs(v.yx)) * vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);");
|
|
72
|
-
src.push(" }");
|
|
73
|
-
src.push(" return normalize(v);");
|
|
74
|
-
src.push("}");
|
|
75
|
-
|
|
76
|
-
if (clipping) {
|
|
77
|
-
src.push("out vec4 vWorldPosition;");
|
|
78
|
-
src.push("out float vFlags;");
|
|
79
|
-
}
|
|
80
|
-
src.push("out vec4 vColor;");
|
|
81
|
-
|
|
82
|
-
src.push("void main(void) {");
|
|
83
|
-
|
|
84
|
-
// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
|
|
85
|
-
// renderPass = COLOR_OPAQUE
|
|
86
|
-
|
|
87
|
-
src.push(`int colorFlag = int(flags) & 0xF;`);
|
|
88
|
-
src.push(`if (colorFlag != renderPass) {`);
|
|
89
|
-
src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
|
|
90
|
-
|
|
91
|
-
src.push("} else {");
|
|
92
|
-
|
|
93
|
-
src.push("vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");
|
|
94
|
-
if (scene.entityOffsetsEnabled) {
|
|
95
|
-
src.push("worldPosition.xyz = worldPosition.xyz + offset;");
|
|
96
|
-
}
|
|
97
|
-
src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
98
|
-
|
|
99
|
-
src.push("vec4 worldNormal = worldNormalMatrix * vec4(octDecode(normal.xy), 0.0); ");
|
|
100
|
-
|
|
101
|
-
src.push("vec3 viewNormal = normalize((viewNormalMatrix * worldNormal).xyz);");
|
|
102
|
-
|
|
103
|
-
src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
|
|
104
|
-
src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
|
|
105
|
-
|
|
106
|
-
src.push("float lambertian = 1.0;");
|
|
107
|
-
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
108
|
-
light = lightsState.lights[i];
|
|
109
|
-
if (light.type === "ambient") {
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
if (light.type === "dir") {
|
|
113
|
-
if (light.space === "view") {
|
|
114
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
115
|
-
} else {
|
|
116
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
117
|
-
}
|
|
118
|
-
} else if (light.type === "point") {
|
|
119
|
-
if (light.space === "view") {
|
|
120
|
-
src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
|
|
121
|
-
} else {
|
|
122
|
-
src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
|
|
123
|
-
}
|
|
124
|
-
} else if (light.type === "spot") {
|
|
125
|
-
if (light.space === "view") {
|
|
126
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
127
|
-
} else {
|
|
128
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
129
|
-
}
|
|
130
|
-
} else {
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
|
|
134
|
-
src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
src.push("vec3 rgb = (vec3(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0));");
|
|
138
|
-
src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");
|
|
139
|
-
|
|
140
|
-
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
141
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
142
|
-
src.push("vFragDepth = 1.0 + clipPos.w;");
|
|
143
|
-
src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
|
|
144
|
-
}
|
|
145
|
-
if (clipping) {
|
|
146
|
-
src.push("vWorldPosition = worldPosition;");
|
|
147
|
-
src.push("vFlags = flags;");
|
|
148
|
-
}
|
|
149
|
-
src.push("gl_Position = clipPos;");
|
|
150
|
-
src.push("}");
|
|
151
|
-
|
|
152
|
-
src.push("}");
|
|
153
|
-
return src;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
_buildFragmentShader() {
|
|
157
|
-
const scene = this._scene;
|
|
158
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
159
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
160
|
-
const src = [];
|
|
161
|
-
src.push("#version 300 es");
|
|
162
|
-
src.push("// Triangles batching draw fragment shader");
|
|
163
|
-
src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
|
|
164
|
-
src.push("precision highp float;");
|
|
165
|
-
src.push("precision highp int;");
|
|
166
|
-
src.push("#else");
|
|
167
|
-
src.push("precision mediump float;");
|
|
168
|
-
src.push("precision mediump int;");
|
|
169
|
-
src.push("#endif");
|
|
170
|
-
|
|
171
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
172
|
-
src.push("in float isPerspective;");
|
|
173
|
-
src.push("uniform float logDepthBufFC;");
|
|
174
|
-
src.push("in float vFragDepth;");
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (this._withSAO) {
|
|
178
|
-
src.push("uniform sampler2D uOcclusionTexture;");
|
|
179
|
-
src.push("uniform vec4 uSAOParams;");
|
|
180
|
-
src.push("const float packUpscale = 256. / 255.;");
|
|
181
|
-
src.push("const float unpackDownScale = 255. / 256.;");
|
|
182
|
-
src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");
|
|
183
|
-
src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");
|
|
184
|
-
|
|
185
|
-
src.push("float unpackRGBToFloat( const in vec4 v ) {");
|
|
186
|
-
src.push(" return dot( v, unPackFactors );");
|
|
187
|
-
src.push("}");
|
|
188
|
-
}
|
|
189
|
-
if (clipping) {
|
|
190
|
-
src.push("in vec4 vWorldPosition;");
|
|
191
|
-
src.push("in float vFlags;");
|
|
192
|
-
for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
193
|
-
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
194
|
-
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
195
|
-
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
src.push("in vec4 vColor;");
|
|
199
|
-
src.push("out vec4 outColor;");
|
|
200
|
-
src.push("void main(void) {");
|
|
201
|
-
|
|
202
|
-
if (clipping) {
|
|
203
|
-
src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
|
|
204
|
-
src.push(" if (clippable) {");
|
|
205
|
-
src.push(" float dist = 0.0;");
|
|
206
|
-
for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
207
|
-
src.push("if (sectionPlaneActive" + i + ") {");
|
|
208
|
-
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
209
|
-
src.push("}");
|
|
210
|
-
}
|
|
211
|
-
src.push(" if (dist > 0.0) { ");
|
|
212
|
-
src.push(" discard;")
|
|
213
|
-
src.push(" }");
|
|
214
|
-
src.push("}");
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
218
|
-
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (this._withSAO) {
|
|
222
|
-
// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
|
|
223
|
-
// Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
|
|
224
|
-
src.push(" float viewportWidth = uSAOParams[0];");
|
|
225
|
-
src.push(" float viewportHeight = uSAOParams[1];");
|
|
226
|
-
src.push(" float blendCutoff = uSAOParams[2];");
|
|
227
|
-
src.push(" float blendFactor = uSAOParams[3];");
|
|
228
|
-
src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
|
|
229
|
-
src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
|
|
230
|
-
src.push(" outColor = vec4(vColor.rgb * ambient, 1.0);");
|
|
231
|
-
} else {
|
|
232
|
-
src.push(" outColor = vColor;");
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
src.push("}");
|
|
236
|
-
return src;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import {VBOBatchingTrianglesRenderer} from "./VBOBatchingTrianglesRenderer.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @private
|
|
6
|
-
*/
|
|
7
|
-
export class VBOBatchingTrianglesColorTextureRenderer extends VBOBatchingTrianglesRenderer {
|
|
8
|
-
_getHash() {
|
|
9
|
-
const scene = this._scene;
|
|
10
|
-
return [scene.gammaOutput, scene._lightsState.getHash(), scene._sectionPlanesState.getHash(), (this._withSAO ? "sao" : "nosao")].join(";");
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
drawLayer(frameCtx, layer, renderPass) {
|
|
14
|
-
super.drawLayer(frameCtx, layer, renderPass, {incrementDrawState: true});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
_buildVertexShader() {
|
|
18
|
-
|
|
19
|
-
const scene = this._scene;
|
|
20
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
21
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
22
|
-
const src = [];
|
|
23
|
-
src.push("#version 300 es");
|
|
24
|
-
src.push("// Triangles batching color texture vertex shader");
|
|
25
|
-
|
|
26
|
-
src.push("uniform int renderPass;");
|
|
27
|
-
|
|
28
|
-
src.push("in vec3 position;");
|
|
29
|
-
src.push("in vec4 color;");
|
|
30
|
-
src.push("in vec2 uv;");
|
|
31
|
-
src.push("in float flags;");
|
|
32
|
-
|
|
33
|
-
if (scene.entityOffsetsEnabled) {
|
|
34
|
-
src.push("in vec3 offset;");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
this._addMatricesUniformBlockLines(src);
|
|
38
|
-
|
|
39
|
-
src.push("uniform mat3 uvDecodeMatrix;")
|
|
40
|
-
|
|
41
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
42
|
-
src.push("uniform float logDepthBufFC;");
|
|
43
|
-
src.push("out float vFragDepth;");
|
|
44
|
-
src.push("bool isPerspectiveMatrix(mat4 m) {");
|
|
45
|
-
src.push(" return (m[2][3] == - 1.0);");
|
|
46
|
-
src.push("}");
|
|
47
|
-
src.push("out float isPerspective;");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (clipping) {
|
|
51
|
-
src.push("out vec4 vWorldPosition;");
|
|
52
|
-
src.push("out float vFlags;");
|
|
53
|
-
}
|
|
54
|
-
src.push("out vec4 vViewPosition;");
|
|
55
|
-
src.push("out vec4 vColor;");
|
|
56
|
-
src.push("out vec2 vUV;");
|
|
57
|
-
|
|
58
|
-
src.push("void main(void) {");
|
|
59
|
-
|
|
60
|
-
// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
|
|
61
|
-
// renderPass = COLOR_OPAQUE
|
|
62
|
-
|
|
63
|
-
src.push(`int colorFlag = int(flags) & 0xF;`);
|
|
64
|
-
src.push(`if (colorFlag != renderPass) {`);
|
|
65
|
-
src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
|
|
66
|
-
|
|
67
|
-
src.push("} else {");
|
|
68
|
-
|
|
69
|
-
src.push("vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");
|
|
70
|
-
if (scene.entityOffsetsEnabled) {
|
|
71
|
-
src.push("worldPosition.xyz = worldPosition.xyz + offset;");
|
|
72
|
-
}
|
|
73
|
-
src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
74
|
-
src.push("vViewPosition = viewPosition;");
|
|
75
|
-
src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");
|
|
76
|
-
src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");
|
|
77
|
-
|
|
78
|
-
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
79
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
80
|
-
src.push("vFragDepth = 1.0 + clipPos.w;");
|
|
81
|
-
src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
|
|
82
|
-
}
|
|
83
|
-
if (clipping) {
|
|
84
|
-
src.push("vWorldPosition = worldPosition;");
|
|
85
|
-
src.push("vFlags = flags;");
|
|
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 gammaOutput = scene.gammaOutput; // If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
|
|
96
|
-
const lightsState = scene._lightsState;
|
|
97
|
-
const sectionPlanesState = scene._sectionPlanesState;
|
|
98
|
-
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
99
|
-
const src = [];
|
|
100
|
-
src.push("#version 300 es");
|
|
101
|
-
src.push("// Triangles batching color texture fragment shader");
|
|
102
|
-
|
|
103
|
-
src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
|
|
104
|
-
src.push("precision highp float;");
|
|
105
|
-
src.push("precision highp int;");
|
|
106
|
-
src.push("#else");
|
|
107
|
-
src.push("precision mediump float;");
|
|
108
|
-
src.push("precision mediump int;");
|
|
109
|
-
src.push("#endif");
|
|
110
|
-
|
|
111
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
112
|
-
src.push("in float isPerspective;");
|
|
113
|
-
src.push("uniform float logDepthBufFC;");
|
|
114
|
-
src.push("in float vFragDepth;");
|
|
115
|
-
}
|
|
116
|
-
src.push("uniform sampler2D uColorMap;");
|
|
117
|
-
if (this._withSAO) {
|
|
118
|
-
src.push("uniform sampler2D uOcclusionTexture;");
|
|
119
|
-
src.push("uniform vec4 uSAOParams;");
|
|
120
|
-
|
|
121
|
-
src.push("const float packUpscale = 256. / 255.;");
|
|
122
|
-
src.push("const float unpackDownScale = 255. / 256.;");
|
|
123
|
-
src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");
|
|
124
|
-
src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");
|
|
125
|
-
|
|
126
|
-
src.push("float unpackRGBToFloat( const in vec4 v ) {");
|
|
127
|
-
src.push(" return dot( v, unPackFactors );");
|
|
128
|
-
src.push("}");
|
|
129
|
-
}
|
|
130
|
-
src.push("uniform float gammaFactor;");
|
|
131
|
-
src.push("vec4 linearToLinear( in vec4 value ) {");
|
|
132
|
-
src.push(" return value;");
|
|
133
|
-
src.push("}");
|
|
134
|
-
src.push("vec4 sRGBToLinear( in vec4 value ) {");
|
|
135
|
-
src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");
|
|
136
|
-
src.push("}");
|
|
137
|
-
src.push("vec4 gammaToLinear( in vec4 value) {");
|
|
138
|
-
src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");
|
|
139
|
-
src.push("}");
|
|
140
|
-
if (gammaOutput) {
|
|
141
|
-
src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");
|
|
142
|
-
src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");
|
|
143
|
-
src.push("}");
|
|
144
|
-
}
|
|
145
|
-
if (clipping) {
|
|
146
|
-
src.push("in vec4 vWorldPosition;");
|
|
147
|
-
src.push("in float vFlags;");
|
|
148
|
-
for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
149
|
-
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
150
|
-
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
151
|
-
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
this._addMatricesUniformBlockLines(src);
|
|
155
|
-
src.push("uniform vec4 lightAmbient;");
|
|
156
|
-
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
157
|
-
const light = lightsState.lights[i];
|
|
158
|
-
if (light.type === "ambient") {
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
src.push("uniform vec4 lightColor" + i + ";");
|
|
162
|
-
if (light.type === "dir") {
|
|
163
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
164
|
-
}
|
|
165
|
-
if (light.type === "point") {
|
|
166
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
167
|
-
}
|
|
168
|
-
if (light.type === "spot") {
|
|
169
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
170
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
src.push("in vec4 vViewPosition;");
|
|
175
|
-
src.push("in vec4 vColor;");
|
|
176
|
-
src.push("in vec2 vUV;");
|
|
177
|
-
src.push("out vec4 outColor;");
|
|
178
|
-
|
|
179
|
-
src.push("void main(void) {");
|
|
180
|
-
|
|
181
|
-
if (clipping) {
|
|
182
|
-
src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
|
|
183
|
-
src.push(" if (clippable) {");
|
|
184
|
-
src.push(" float dist = 0.0;");
|
|
185
|
-
for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
186
|
-
src.push("if (sectionPlaneActive" + i + ") {");
|
|
187
|
-
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
188
|
-
src.push("}");
|
|
189
|
-
}
|
|
190
|
-
src.push(" if (dist > 0.0) { ");
|
|
191
|
-
src.push(" discard;")
|
|
192
|
-
src.push(" }");
|
|
193
|
-
src.push("}");
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
|
|
197
|
-
src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
|
|
198
|
-
|
|
199
|
-
src.push("float lambertian = 1.0;");
|
|
200
|
-
|
|
201
|
-
src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");
|
|
202
|
-
src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");
|
|
203
|
-
src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");
|
|
204
|
-
|
|
205
|
-
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
206
|
-
const light = lightsState.lights[i];
|
|
207
|
-
if (light.type === "ambient") {
|
|
208
|
-
continue;
|
|
209
|
-
}
|
|
210
|
-
if (light.type === "dir") {
|
|
211
|
-
if (light.space === "view") {
|
|
212
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
213
|
-
} else {
|
|
214
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
215
|
-
}
|
|
216
|
-
} else if (light.type === "point") {
|
|
217
|
-
if (light.space === "view") {
|
|
218
|
-
src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
|
|
219
|
-
} else {
|
|
220
|
-
src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
|
|
221
|
-
}
|
|
222
|
-
} else if (light.type === "spot") {
|
|
223
|
-
if (light.space === "view") {
|
|
224
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
225
|
-
} else {
|
|
226
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
227
|
-
}
|
|
228
|
-
} else {
|
|
229
|
-
continue;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
|
|
233
|
-
src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
|
|
237
|
-
if (gammaOutput) {
|
|
238
|
-
src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");
|
|
239
|
-
} else {
|
|
240
|
-
src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
|
|
241
|
-
}
|
|
242
|
-
src.push("float opacity = color.a;");
|
|
243
|
-
|
|
244
|
-
if (this._withSAO) {
|
|
245
|
-
// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
|
|
246
|
-
// Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
|
|
247
|
-
src.push(" float viewportWidth = uSAOParams[0];");
|
|
248
|
-
src.push(" float viewportHeight = uSAOParams[1];");
|
|
249
|
-
src.push(" float blendCutoff = uSAOParams[2];");
|
|
250
|
-
src.push(" float blendFactor = uSAOParams[3];");
|
|
251
|
-
src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
|
|
252
|
-
src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
|
|
253
|
-
|
|
254
|
-
src.push(" outColor = vec4(colorTexel.rgb * ambient, opacity);");
|
|
255
|
-
} else {
|
|
256
|
-
src.push(" outColor = vec4(colorTexel.rgb, opacity);");
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (gammaOutput) {
|
|
260
|
-
src.push("outColor = linearToGamma(outColor, gammaFactor);");
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
if (scene.logarithmicDepthBufferEnabled) {
|
|
264
|
-
src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
src.push("}");
|
|
268
|
-
return src;
|
|
269
|
-
}
|
|
270
|
-
}
|