@xeokit/xeokit-sdk 2.3.0-beta-15 → 2.3.0-beta-18
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 +188 -244
- package/dist/xeokit-sdk.es.js +188 -244
- package/dist/xeokit-sdk.min.cjs.js +1 -1
- package/dist/xeokit-sdk.min.es.js +1 -1
- package/package.json +1 -1
package/dist/xeokit-sdk.es.js
CHANGED
|
@@ -12102,34 +12102,27 @@ class Canvas extends Component {
|
|
|
12102
12102
|
|
|
12103
12103
|
let lastParent = null;
|
|
12104
12104
|
|
|
12105
|
-
let tickCount = 0;
|
|
12105
|
+
let tickCount = 0;
|
|
12106
12106
|
|
|
12107
12107
|
this._tick = this.scene.on("tick", () => {
|
|
12108
12108
|
|
|
12109
|
-
tickCount++;
|
|
12109
|
+
tickCount++;
|
|
12110
12110
|
|
|
12111
12111
|
self._canvasSizeChanged = false;
|
|
12112
12112
|
|
|
12113
|
-
if (self.optimizeResizeDetection)
|
|
12114
|
-
|
|
12115
|
-
|
|
12116
|
-
|
|
12117
|
-
return; // chipmunk
|
|
12118
|
-
} // chipmunk
|
|
12113
|
+
if (self.optimizeResizeDetection) {
|
|
12114
|
+
if (tickCount < 10) {
|
|
12115
|
+
return;
|
|
12116
|
+
}
|
|
12119
12117
|
}
|
|
12120
12118
|
|
|
12121
|
-
tickCount = 0;
|
|
12119
|
+
tickCount = 0;
|
|
12122
12120
|
|
|
12123
12121
|
const canvas = this.canvas;
|
|
12124
12122
|
|
|
12125
12123
|
const newResolutionScale = (this._resolutionScale !== lastResolutionScale);
|
|
12126
12124
|
const newWindowSize = (window.innerWidth !== lastWindowWidth || window.innerHeight !== lastWindowHeight);
|
|
12127
12125
|
|
|
12128
|
-
if (!newWindowSize) // chipmunk
|
|
12129
|
-
{ // chipmunk
|
|
12130
|
-
return; // chipmunk
|
|
12131
|
-
} // chipmunk
|
|
12132
|
-
|
|
12133
12126
|
const newCanvasSize = (canvas.clientWidth !== lastCanvasWidth || canvas.clientHeight !== lastCanvasHeight);
|
|
12134
12127
|
const newCanvasPos = (canvas.offsetLeft !== lastCanvasOffsetLeft || canvas.offsetTop !== lastCanvasOffsetTop);
|
|
12135
12128
|
|
|
@@ -14605,7 +14598,8 @@ class SAODepthLimitedBlurRenderer {
|
|
|
14605
14598
|
}
|
|
14606
14599
|
|
|
14607
14600
|
outColor = packFloatToRGBA(occlusionSum / weightSum);
|
|
14608
|
-
}`
|
|
14601
|
+
}`
|
|
14602
|
+
]
|
|
14609
14603
|
});
|
|
14610
14604
|
|
|
14611
14605
|
if (this._program.errors) {
|
|
@@ -14695,7 +14689,7 @@ class SAODepthLimitedBlurRenderer {
|
|
|
14695
14689
|
|
|
14696
14690
|
gl.uniform1fv(this._uSampleWeights, sampleWeights);
|
|
14697
14691
|
|
|
14698
|
-
const depthTexture =
|
|
14692
|
+
const depthTexture = depthRenderBuffer.getDepthTexture();
|
|
14699
14693
|
const occlusionTexture = occlusionRenderBuffer.getTexture();
|
|
14700
14694
|
|
|
14701
14695
|
program.bindTexture(this._uDepthTexture, depthTexture, 0); // TODO: use FrameCtx.textureUnit
|
|
@@ -15995,22 +15989,6 @@ const Renderer = function (scene, options) {
|
|
|
15995
15989
|
gl.depthMask(false);
|
|
15996
15990
|
}
|
|
15997
15991
|
|
|
15998
|
-
// Transparent X-ray edges
|
|
15999
|
-
|
|
16000
|
-
if (xrayEdgesTransparentBinLen > 0) {
|
|
16001
|
-
for (i = 0; i < xrayEdgesTransparentBinLen; i++) {
|
|
16002
|
-
xrayEdgesTransparentBin[i].drawEdgesXRayed(frameCtx);
|
|
16003
|
-
}
|
|
16004
|
-
}
|
|
16005
|
-
|
|
16006
|
-
// Transparent X-ray fill
|
|
16007
|
-
|
|
16008
|
-
if (xrayedFillTransparentBinLen > 0) {
|
|
16009
|
-
for (i = 0; i < xrayedFillTransparentBinLen; i++) {
|
|
16010
|
-
xrayedFillTransparentBin[i].drawSilhouetteXRayed(frameCtx);
|
|
16011
|
-
}
|
|
16012
|
-
}
|
|
16013
|
-
|
|
16014
15992
|
// Transparent color edges
|
|
16015
15993
|
|
|
16016
15994
|
if (normalFillTransparentBinLen > 0 || normalEdgesTransparentBinLen > 0) {
|
|
@@ -16031,6 +16009,23 @@ const Renderer = function (scene, options) {
|
|
|
16031
16009
|
drawable.drawColorTransparent(frameCtx);
|
|
16032
16010
|
}
|
|
16033
16011
|
}
|
|
16012
|
+
|
|
16013
|
+
// Transparent X-ray edges
|
|
16014
|
+
|
|
16015
|
+
if (xrayEdgesTransparentBinLen > 0) {
|
|
16016
|
+
for (i = 0; i < xrayEdgesTransparentBinLen; i++) {
|
|
16017
|
+
xrayEdgesTransparentBin[i].drawEdgesXRayed(frameCtx);
|
|
16018
|
+
}
|
|
16019
|
+
}
|
|
16020
|
+
|
|
16021
|
+
// Transparent X-ray fill
|
|
16022
|
+
|
|
16023
|
+
if (xrayedFillTransparentBinLen > 0) {
|
|
16024
|
+
for (i = 0; i < xrayedFillTransparentBinLen; i++) {
|
|
16025
|
+
xrayedFillTransparentBin[i].drawSilhouetteXRayed(frameCtx);
|
|
16026
|
+
}
|
|
16027
|
+
}
|
|
16028
|
+
|
|
16034
16029
|
gl.disable(gl.BLEND);
|
|
16035
16030
|
if (!alphaDepthMask) {
|
|
16036
16031
|
gl.depthMask(true);
|
|
@@ -45603,10 +45598,7 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45603
45598
|
gl.uniform1i(this._uRenderPass, renderPass);
|
|
45604
45599
|
|
|
45605
45600
|
gl.uniformMatrix4fv(this._uViewMatrix, false, (origin) ? createRTCViewMat(camera.viewMatrix, origin) : camera.viewMatrix);
|
|
45606
|
-
gl.uniformMatrix4fv(this._uViewNormalMatrix, false, camera.viewNormalMatrix);
|
|
45607
|
-
|
|
45608
45601
|
gl.uniformMatrix4fv(this._uWorldMatrix, false, model.worldMatrix);
|
|
45609
|
-
gl.uniformMatrix4fv(this._uWorldNormalMatrix, false, model.worldNormalMatrix);
|
|
45610
45602
|
|
|
45611
45603
|
const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
|
|
45612
45604
|
if (numSectionPlanes > 0) {
|
|
@@ -45640,10 +45632,6 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45640
45632
|
|
|
45641
45633
|
this._aPosition.bindArrayBuffer(state.positionsBuf);
|
|
45642
45634
|
|
|
45643
|
-
if (this._aNormal) {
|
|
45644
|
-
this._aNormal.bindArrayBuffer(state.normalsBuf);
|
|
45645
|
-
}
|
|
45646
|
-
|
|
45647
45635
|
if (this._aUV) {
|
|
45648
45636
|
this._aUV.bindArrayBuffer(state.uvBuf);
|
|
45649
45637
|
}
|
|
@@ -45714,9 +45702,7 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45714
45702
|
this._uPositionsDecodeMatrix = program.getLocation("positionsDecodeMatrix");
|
|
45715
45703
|
this._uUVDecodeMatrix = program.getLocation("uvDecodeMatrix");
|
|
45716
45704
|
this._uWorldMatrix = program.getLocation("worldMatrix");
|
|
45717
|
-
this._uWorldNormalMatrix = program.getLocation("worldNormalMatrix");
|
|
45718
45705
|
this._uViewMatrix = program.getLocation("viewMatrix");
|
|
45719
|
-
this._uViewNormalMatrix = program.getLocation("viewNormalMatrix");
|
|
45720
45706
|
this._uProjMatrix = program.getLocation("projMatrix");
|
|
45721
45707
|
|
|
45722
45708
|
this._uLightAmbient = program.getLocation("lightAmbient");
|
|
@@ -45763,7 +45749,6 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45763
45749
|
|
|
45764
45750
|
this._aPosition = program.getAttribute("position");
|
|
45765
45751
|
this._aOffset = program.getAttribute("offset");
|
|
45766
|
-
this._aNormal = program.getAttribute("normal");
|
|
45767
45752
|
this._aUV = program.getAttribute("uv");
|
|
45768
45753
|
this._aColor = program.getAttribute("color");
|
|
45769
45754
|
this._aFlags = program.getAttribute("flags");
|
|
@@ -45830,9 +45815,7 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45830
45815
|
|
|
45831
45816
|
const scene = this._scene;
|
|
45832
45817
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
45833
|
-
const lightsState = scene._lightsState;
|
|
45834
45818
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
45835
|
-
let light;
|
|
45836
45819
|
const src = [];
|
|
45837
45820
|
src.push("#version 300 es");
|
|
45838
45821
|
src.push("// Triangles batching color texture vertex shader");
|
|
@@ -45840,7 +45823,6 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45840
45823
|
src.push("uniform int renderPass;");
|
|
45841
45824
|
|
|
45842
45825
|
src.push("in vec3 position;");
|
|
45843
|
-
src.push("in vec3 normal;");
|
|
45844
45826
|
src.push("in vec4 color;");
|
|
45845
45827
|
src.push("in vec2 uv;");
|
|
45846
45828
|
src.push("in vec4 flags;");
|
|
@@ -45851,11 +45833,9 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45851
45833
|
}
|
|
45852
45834
|
|
|
45853
45835
|
src.push("uniform mat4 worldMatrix;");
|
|
45854
|
-
src.push("uniform mat4 worldNormalMatrix;");
|
|
45855
45836
|
|
|
45856
45837
|
src.push("uniform mat4 viewMatrix;");
|
|
45857
45838
|
src.push("uniform mat4 projMatrix;");
|
|
45858
|
-
src.push("uniform mat4 viewNormalMatrix;");
|
|
45859
45839
|
src.push("uniform mat4 positionsDecodeMatrix;");
|
|
45860
45840
|
src.push("uniform mat3 uvDecodeMatrix;");
|
|
45861
45841
|
|
|
@@ -45868,38 +45848,11 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45868
45848
|
src.push("out float isPerspective;");
|
|
45869
45849
|
}
|
|
45870
45850
|
|
|
45871
|
-
src.push("uniform vec4 lightAmbient;");
|
|
45872
|
-
|
|
45873
|
-
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
45874
|
-
light = lightsState.lights[i];
|
|
45875
|
-
if (light.type === "ambient") {
|
|
45876
|
-
continue;
|
|
45877
|
-
}
|
|
45878
|
-
src.push("uniform vec4 lightColor" + i + ";");
|
|
45879
|
-
if (light.type === "dir") {
|
|
45880
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
45881
|
-
}
|
|
45882
|
-
if (light.type === "point") {
|
|
45883
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
45884
|
-
}
|
|
45885
|
-
if (light.type === "spot") {
|
|
45886
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
45887
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
45888
|
-
}
|
|
45889
|
-
}
|
|
45890
|
-
|
|
45891
|
-
src.push("vec3 octDecode(vec2 oct) {");
|
|
45892
|
-
src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
|
|
45893
|
-
src.push(" if (v.z < 0.0) {");
|
|
45894
|
-
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);");
|
|
45895
|
-
src.push(" }");
|
|
45896
|
-
src.push(" return normalize(v);");
|
|
45897
|
-
src.push("}");
|
|
45898
|
-
|
|
45899
45851
|
if (clipping) {
|
|
45900
45852
|
src.push("out vec4 vWorldPosition;");
|
|
45901
45853
|
src.push("out vec4 vFlags2;");
|
|
45902
45854
|
}
|
|
45855
|
+
src.push("out vec4 vViewPosition;");
|
|
45903
45856
|
src.push("out vec4 vColor;");
|
|
45904
45857
|
src.push("out vec2 vUV;");
|
|
45905
45858
|
|
|
@@ -45918,45 +45871,8 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45918
45871
|
src.push("worldPosition.xyz = worldPosition.xyz + offset;");
|
|
45919
45872
|
}
|
|
45920
45873
|
src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
45921
|
-
src.push("
|
|
45922
|
-
src.push("
|
|
45923
|
-
|
|
45924
|
-
src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
|
|
45925
|
-
src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
|
|
45926
|
-
|
|
45927
|
-
src.push("float lambertian = 1.0;");
|
|
45928
|
-
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
45929
|
-
light = lightsState.lights[i];
|
|
45930
|
-
if (light.type === "ambient") {
|
|
45931
|
-
continue;
|
|
45932
|
-
}
|
|
45933
|
-
if (light.type === "dir") {
|
|
45934
|
-
if (light.space === "view") {
|
|
45935
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
45936
|
-
} else {
|
|
45937
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
45938
|
-
}
|
|
45939
|
-
} else if (light.type === "point") {
|
|
45940
|
-
if (light.space === "view") {
|
|
45941
|
-
src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
|
|
45942
|
-
} else {
|
|
45943
|
-
src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
|
|
45944
|
-
}
|
|
45945
|
-
} else if (light.type === "spot") {
|
|
45946
|
-
if (light.space === "view") {
|
|
45947
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
45948
|
-
} else {
|
|
45949
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
45950
|
-
}
|
|
45951
|
-
} else {
|
|
45952
|
-
continue;
|
|
45953
|
-
}
|
|
45954
|
-
src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
|
|
45955
|
-
src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
|
|
45956
|
-
}
|
|
45957
|
-
|
|
45958
|
-
src.push("vec3 rgb = (vec3(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0));");
|
|
45959
|
-
src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");
|
|
45874
|
+
src.push("vViewPosition = viewPosition;");
|
|
45875
|
+
src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");
|
|
45960
45876
|
src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");
|
|
45961
45877
|
|
|
45962
45878
|
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
@@ -45976,6 +45892,7 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45976
45892
|
|
|
45977
45893
|
_buildFragmentShader() {
|
|
45978
45894
|
const scene = this._scene;
|
|
45895
|
+
const lightsState = scene._lightsState;
|
|
45979
45896
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
45980
45897
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
45981
45898
|
const src = [];
|
|
@@ -45995,9 +45912,7 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
45995
45912
|
src.push("uniform float logDepthBufFC;");
|
|
45996
45913
|
src.push("in float vFragDepth;");
|
|
45997
45914
|
}
|
|
45998
|
-
|
|
45999
45915
|
src.push("uniform sampler2D uColorMap;");
|
|
46000
|
-
|
|
46001
45916
|
if (this._withSAO) {
|
|
46002
45917
|
src.push("uniform sampler2D uOcclusionTexture;");
|
|
46003
45918
|
src.push("uniform vec4 uSAOParams;");
|
|
@@ -46011,7 +45926,6 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
46011
45926
|
src.push(" return dot( v, unPackFactors );");
|
|
46012
45927
|
src.push("}");
|
|
46013
45928
|
}
|
|
46014
|
-
|
|
46015
45929
|
if (clipping) {
|
|
46016
45930
|
src.push("in vec4 vWorldPosition;");
|
|
46017
45931
|
src.push("in vec4 vFlags2;");
|
|
@@ -46021,7 +45935,27 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
46021
45935
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
46022
45936
|
}
|
|
46023
45937
|
}
|
|
45938
|
+
src.push("uniform mat4 viewMatrix;");
|
|
45939
|
+
src.push("uniform vec4 lightAmbient;");
|
|
45940
|
+
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
45941
|
+
const light = lightsState.lights[i];
|
|
45942
|
+
if (light.type === "ambient") {
|
|
45943
|
+
continue;
|
|
45944
|
+
}
|
|
45945
|
+
src.push("uniform vec4 lightColor" + i + ";");
|
|
45946
|
+
if (light.type === "dir") {
|
|
45947
|
+
src.push("uniform vec3 lightDir" + i + ";");
|
|
45948
|
+
}
|
|
45949
|
+
if (light.type === "point") {
|
|
45950
|
+
src.push("uniform vec3 lightPos" + i + ";");
|
|
45951
|
+
}
|
|
45952
|
+
if (light.type === "spot") {
|
|
45953
|
+
src.push("uniform vec3 lightPos" + i + ";");
|
|
45954
|
+
src.push("uniform vec3 lightDir" + i + ";");
|
|
45955
|
+
}
|
|
45956
|
+
}
|
|
46024
45957
|
|
|
45958
|
+
src.push("in vec4 vViewPosition;");
|
|
46025
45959
|
src.push("in vec4 vColor;");
|
|
46026
45960
|
src.push("in vec2 vUV;");
|
|
46027
45961
|
src.push("out vec4 outColor;");
|
|
@@ -46043,12 +45977,49 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
46043
45977
|
src.push("}");
|
|
46044
45978
|
}
|
|
46045
45979
|
|
|
46046
|
-
|
|
46047
|
-
|
|
45980
|
+
src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
|
|
45981
|
+
src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
|
|
45982
|
+
|
|
45983
|
+
src.push("float lambertian = 1.0;");
|
|
45984
|
+
|
|
45985
|
+
src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");
|
|
45986
|
+
src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");
|
|
45987
|
+
src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");
|
|
45988
|
+
|
|
45989
|
+
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
45990
|
+
const light = lightsState.lights[i];
|
|
45991
|
+
if (light.type === "ambient") {
|
|
45992
|
+
continue;
|
|
45993
|
+
}
|
|
45994
|
+
if (light.type === "dir") {
|
|
45995
|
+
if (light.space === "view") {
|
|
45996
|
+
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
45997
|
+
} else {
|
|
45998
|
+
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
45999
|
+
}
|
|
46000
|
+
} else if (light.type === "point") {
|
|
46001
|
+
if (light.space === "view") {
|
|
46002
|
+
src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
|
|
46003
|
+
} else {
|
|
46004
|
+
src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
|
|
46005
|
+
}
|
|
46006
|
+
} else if (light.type === "spot") {
|
|
46007
|
+
if (light.space === "view") {
|
|
46008
|
+
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
46009
|
+
} else {
|
|
46010
|
+
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
46011
|
+
}
|
|
46012
|
+
} else {
|
|
46013
|
+
continue;
|
|
46014
|
+
}
|
|
46015
|
+
|
|
46016
|
+
src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
|
|
46017
|
+
src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
|
|
46048
46018
|
}
|
|
46049
46019
|
|
|
46050
|
-
src.push("vec4
|
|
46051
|
-
src.push("
|
|
46020
|
+
src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
|
|
46021
|
+
src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
|
|
46022
|
+
src.push("float opacity = color.a;");
|
|
46052
46023
|
|
|
46053
46024
|
if (this._withSAO) {
|
|
46054
46025
|
// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
|
|
@@ -46065,6 +46036,10 @@ class TrianglesBatchingColorTextureRenderer {
|
|
|
46065
46036
|
src.push(" outColor = vec4(colorTexel.rgb, opacity);");
|
|
46066
46037
|
}
|
|
46067
46038
|
|
|
46039
|
+
if (scene.logarithmicDepthBufferEnabled) {
|
|
46040
|
+
src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
46041
|
+
}
|
|
46042
|
+
|
|
46068
46043
|
src.push("}");
|
|
46069
46044
|
return src;
|
|
46070
46045
|
}
|
|
@@ -46451,6 +46426,11 @@ function quantizePositions(positions, aabb, positionsDecodeMatrix) { // http://c
|
|
|
46451
46426
|
*/
|
|
46452
46427
|
function transformAndOctEncodeNormals(worldNormalMatrix, normals, lenNormals, compressedNormals, lenCompressedNormals) {
|
|
46453
46428
|
// http://jcgt.org/published/0003/02/01/
|
|
46429
|
+
|
|
46430
|
+
function dot(array, vec3) {
|
|
46431
|
+
return array[0] * vec3[0] + array[1] * vec3[1] + array[2] * vec3[2];
|
|
46432
|
+
}
|
|
46433
|
+
|
|
46454
46434
|
let oct, dec, best, currentCos, bestCos;
|
|
46455
46435
|
let i;
|
|
46456
46436
|
let localNormal = new Float32Array([0, 0, 0, 0]);
|
|
@@ -46502,29 +46482,29 @@ function transformAndOctEncodeNormals(worldNormalMatrix, normals, lenNormals, co
|
|
|
46502
46482
|
function octEncodeNormals(normals) { // http://jcgt.org/published/0003/02/01/
|
|
46503
46483
|
const lenNormals = normals.length;
|
|
46504
46484
|
const compressedNormals = new Int8Array(lenNormals);
|
|
46505
|
-
let oct, best, currentCos, bestCos;
|
|
46485
|
+
let oct, dec, best, currentCos, bestCos;
|
|
46506
46486
|
for (let i = 0; i < lenNormals; i += 3) {
|
|
46507
46487
|
// Test various combinations of ceil and floor to minimize rounding errors
|
|
46508
46488
|
best = oct = octEncodeNormal(normals, i, "floor", "floor");
|
|
46509
|
-
octDecodeVec2(oct);
|
|
46510
|
-
currentCos = bestCos = dot(normals, i);
|
|
46489
|
+
dec = octDecodeVec2(oct);
|
|
46490
|
+
currentCos = bestCos = dot(normals, i, dec);
|
|
46511
46491
|
oct = octEncodeNormal(normals, i, "ceil", "floor");
|
|
46512
|
-
octDecodeVec2(oct);
|
|
46513
|
-
currentCos = dot(normals, i);
|
|
46492
|
+
dec = octDecodeVec2(oct);
|
|
46493
|
+
currentCos = dot(normals, i, dec);
|
|
46514
46494
|
if (currentCos > bestCos) {
|
|
46515
46495
|
best = oct;
|
|
46516
46496
|
bestCos = currentCos;
|
|
46517
46497
|
}
|
|
46518
46498
|
oct = octEncodeNormal(normals, i, "floor", "ceil");
|
|
46519
|
-
octDecodeVec2(oct);
|
|
46520
|
-
currentCos = dot(normals, i);
|
|
46499
|
+
dec = octDecodeVec2(oct);
|
|
46500
|
+
currentCos = dot(normals, i, dec);
|
|
46521
46501
|
if (currentCos > bestCos) {
|
|
46522
46502
|
best = oct;
|
|
46523
46503
|
bestCos = currentCos;
|
|
46524
46504
|
}
|
|
46525
46505
|
oct = octEncodeNormal(normals, i, "ceil", "ceil");
|
|
46526
|
-
octDecodeVec2(oct);
|
|
46527
|
-
currentCos = dot(normals, i);
|
|
46506
|
+
dec = octDecodeVec2(oct);
|
|
46507
|
+
currentCos = dot(normals, i, dec);
|
|
46528
46508
|
if (currentCos > bestCos) {
|
|
46529
46509
|
best = oct;
|
|
46530
46510
|
bestCos = currentCos;
|
|
@@ -46598,8 +46578,8 @@ function octDecodeVec2(oct) { // Decode an oct-encoded normal
|
|
|
46598
46578
|
/**
|
|
46599
46579
|
* @private
|
|
46600
46580
|
*/
|
|
46601
|
-
function dot(
|
|
46602
|
-
return
|
|
46581
|
+
function dot(array, i, vec3) {
|
|
46582
|
+
return array[i] * vec3[0] + array[i + 1] * vec3[1] + array[i + 2] * vec3[2];
|
|
46603
46583
|
}
|
|
46604
46584
|
|
|
46605
46585
|
const tempMat4$2 = math.mat4();
|
|
@@ -47128,7 +47108,6 @@ class TrianglesBatchingLayer {
|
|
|
47128
47108
|
|
|
47129
47109
|
this._state.colorTextureSupported
|
|
47130
47110
|
= !!state.uvBuf
|
|
47131
|
-
&& !!state.normalsBuf
|
|
47132
47111
|
&& !!state.textureSet
|
|
47133
47112
|
&& !!state.textureSet.colorTexture;
|
|
47134
47113
|
|
|
@@ -48871,8 +48850,8 @@ class TrianglesInstancingFlatColorRenderer {
|
|
|
48871
48850
|
|
|
48872
48851
|
src.push("in vec4 vViewPosition;");
|
|
48873
48852
|
src.push("in vec4 vColor;");
|
|
48874
|
-
|
|
48875
48853
|
src.push("out vec4 outColor;");
|
|
48854
|
+
|
|
48876
48855
|
src.push("void main(void) {");
|
|
48877
48856
|
|
|
48878
48857
|
if (clipping) {
|
|
@@ -53545,10 +53524,7 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53545
53524
|
gl.uniform1i(this._uRenderPass, renderPass);
|
|
53546
53525
|
|
|
53547
53526
|
gl.uniformMatrix4fv(this._uViewMatrix, false, (origin) ? createRTCViewMat(camera.viewMatrix, origin) : camera.viewMatrix);
|
|
53548
|
-
gl.uniformMatrix4fv(this._uViewNormalMatrix, false, camera.viewNormalMatrix);
|
|
53549
|
-
|
|
53550
53527
|
gl.uniformMatrix4fv(this._uWorldMatrix, false, model.worldMatrix);
|
|
53551
|
-
gl.uniformMatrix4fv(this._uWorldNormalMatrix, false, model.worldNormalMatrix);
|
|
53552
53528
|
|
|
53553
53529
|
const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
|
|
53554
53530
|
if (numSectionPlanes > 0) {
|
|
@@ -53588,16 +53564,7 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53588
53564
|
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 1);
|
|
53589
53565
|
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 1);
|
|
53590
53566
|
|
|
53591
|
-
this._aModelNormalMatrixCol0.bindArrayBuffer(state.modelNormalMatrixCol0Buf);
|
|
53592
|
-
this._aModelNormalMatrixCol1.bindArrayBuffer(state.modelNormalMatrixCol1Buf);
|
|
53593
|
-
this._aModelNormalMatrixCol2.bindArrayBuffer(state.modelNormalMatrixCol2Buf);
|
|
53594
|
-
|
|
53595
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol0.location, 1);
|
|
53596
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol1.location, 1);
|
|
53597
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol2.location, 1);
|
|
53598
|
-
|
|
53599
53567
|
this._aPosition.bindArrayBuffer(geometry.positionsBuf);
|
|
53600
|
-
this._aNormal.bindArrayBuffer(geometry.normalsBuf);
|
|
53601
53568
|
this._aUV.bindArrayBuffer(geometry.uvBuf);
|
|
53602
53569
|
|
|
53603
53570
|
this._aColor.bindArrayBuffer(state.colorsBuf);
|
|
@@ -53625,9 +53592,6 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53625
53592
|
gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 0);
|
|
53626
53593
|
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 0);
|
|
53627
53594
|
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 0);
|
|
53628
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol0.location, 0);
|
|
53629
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol1.location, 0);
|
|
53630
|
-
gl.vertexAttribDivisor(this._aModelNormalMatrixCol2.location, 0);
|
|
53631
53595
|
gl.vertexAttribDivisor(this._aColor.location, 0);
|
|
53632
53596
|
gl.vertexAttribDivisor(this._aFlags.location, 0);
|
|
53633
53597
|
|
|
@@ -53683,10 +53647,8 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53683
53647
|
this._uUVDecodeMatrix = program.getLocation("uvDecodeMatrix");
|
|
53684
53648
|
|
|
53685
53649
|
this._uWorldMatrix = program.getLocation("worldMatrix");
|
|
53686
|
-
this._uWorldNormalMatrix = program.getLocation("worldNormalMatrix");
|
|
53687
53650
|
|
|
53688
53651
|
this._uViewMatrix = program.getLocation("viewMatrix");
|
|
53689
|
-
this._uViewNormalMatrix = program.getLocation("viewNormalMatrix");
|
|
53690
53652
|
this._uProjMatrix = program.getLocation("projMatrix");
|
|
53691
53653
|
|
|
53692
53654
|
this._uLightAmbient = program.getLocation("lightAmbient");
|
|
@@ -53732,7 +53694,6 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53732
53694
|
}
|
|
53733
53695
|
|
|
53734
53696
|
this._aPosition = program.getAttribute("position");
|
|
53735
|
-
this._aNormal = program.getAttribute("normal");
|
|
53736
53697
|
this._aColor = program.getAttribute("color");
|
|
53737
53698
|
this._aUV = program.getAttribute("uv");
|
|
53738
53699
|
this._aFlags = program.getAttribute("flags");
|
|
@@ -53743,10 +53704,6 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53743
53704
|
this._aModelMatrixCol1 = program.getAttribute("modelMatrixCol1");
|
|
53744
53705
|
this._aModelMatrixCol2 = program.getAttribute("modelMatrixCol2");
|
|
53745
53706
|
|
|
53746
|
-
this._aModelNormalMatrixCol0 = program.getAttribute("modelNormalMatrixCol0");
|
|
53747
|
-
this._aModelNormalMatrixCol1 = program.getAttribute("modelNormalMatrixCol1");
|
|
53748
|
-
this._aModelNormalMatrixCol2 = program.getAttribute("modelNormalMatrixCol2");
|
|
53749
|
-
|
|
53750
53707
|
this._uColorMap = "uColorMap";
|
|
53751
53708
|
|
|
53752
53709
|
this._uOcclusionTexture = "uOcclusionTexture";
|
|
@@ -53805,11 +53762,7 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53805
53762
|
_buildVertexShader() {
|
|
53806
53763
|
const scene = this._scene;
|
|
53807
53764
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
53808
|
-
const lightsState = scene._lightsState;
|
|
53809
53765
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
53810
|
-
let i;
|
|
53811
|
-
let len;
|
|
53812
|
-
let light;
|
|
53813
53766
|
const src = [];
|
|
53814
53767
|
src.push("#version 300 es");
|
|
53815
53768
|
src.push("// Instancing geometry drawing vertex shader");
|
|
@@ -53817,7 +53770,6 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53817
53770
|
src.push("uniform int renderPass;");
|
|
53818
53771
|
|
|
53819
53772
|
src.push("in vec3 position;");
|
|
53820
|
-
src.push("in vec3 normal;");
|
|
53821
53773
|
src.push("in vec4 color;");
|
|
53822
53774
|
src.push("in vec2 uv;");
|
|
53823
53775
|
src.push("in vec4 flags;");
|
|
@@ -53831,14 +53783,8 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53831
53783
|
src.push("in vec4 modelMatrixCol1;");
|
|
53832
53784
|
src.push("in vec4 modelMatrixCol2;");
|
|
53833
53785
|
|
|
53834
|
-
src.push("in vec4 modelNormalMatrixCol0;");
|
|
53835
|
-
src.push("in vec4 modelNormalMatrixCol1;");
|
|
53836
|
-
src.push("in vec4 modelNormalMatrixCol2;");
|
|
53837
|
-
|
|
53838
53786
|
src.push("uniform mat4 worldMatrix;");
|
|
53839
|
-
src.push("uniform mat4 worldNormalMatrix;");
|
|
53840
53787
|
src.push("uniform mat4 viewMatrix;");
|
|
53841
|
-
src.push("uniform mat4 viewNormalMatrix;");
|
|
53842
53788
|
src.push("uniform mat4 projMatrix;");
|
|
53843
53789
|
src.push("uniform mat4 positionsDecodeMatrix;");
|
|
53844
53790
|
src.push("uniform mat3 uvDecodeMatrix;");
|
|
@@ -53852,38 +53798,11 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53852
53798
|
src.push("out float isPerspective;");
|
|
53853
53799
|
}
|
|
53854
53800
|
|
|
53855
|
-
src.push("uniform vec4 lightAmbient;");
|
|
53856
|
-
|
|
53857
|
-
for (i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
53858
|
-
light = lightsState.lights[i];
|
|
53859
|
-
if (light.type === "ambient") {
|
|
53860
|
-
continue;
|
|
53861
|
-
}
|
|
53862
|
-
src.push("uniform vec4 lightColor" + i + ";");
|
|
53863
|
-
if (light.type === "dir") {
|
|
53864
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
53865
|
-
}
|
|
53866
|
-
if (light.type === "point") {
|
|
53867
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
53868
|
-
}
|
|
53869
|
-
if (light.type === "spot") {
|
|
53870
|
-
src.push("uniform vec3 lightPos" + i + ";");
|
|
53871
|
-
src.push("uniform vec3 lightDir" + i + ";");
|
|
53872
|
-
}
|
|
53873
|
-
}
|
|
53874
|
-
|
|
53875
|
-
src.push("vec3 octDecode(vec2 oct) {");
|
|
53876
|
-
src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
|
|
53877
|
-
src.push(" if (v.z < 0.0) {");
|
|
53878
|
-
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);");
|
|
53879
|
-
src.push(" }");
|
|
53880
|
-
src.push(" return normalize(v);");
|
|
53881
|
-
src.push("}");
|
|
53882
|
-
|
|
53883
53801
|
if (clipping) {
|
|
53884
53802
|
src.push("out vec4 vWorldPosition;");
|
|
53885
53803
|
src.push("out vec4 vFlags2;");
|
|
53886
53804
|
}
|
|
53805
|
+
src.push("out vec4 vViewPosition;");
|
|
53887
53806
|
src.push("out vec4 vColor;");
|
|
53888
53807
|
src.push("out vec2 vUV;");
|
|
53889
53808
|
|
|
@@ -53904,47 +53823,8 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53904
53823
|
}
|
|
53905
53824
|
|
|
53906
53825
|
src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
|
|
53907
|
-
|
|
53908
|
-
src.push("
|
|
53909
|
-
src.push("vec4 worldNormal = worldNormalMatrix * vec4(dot(modelNormal, modelNormalMatrixCol0), dot(modelNormal, modelNormalMatrixCol1), dot(modelNormal, modelNormalMatrixCol2), 0.0);");
|
|
53910
|
-
src.push("vec3 viewNormal = normalize(vec4(viewNormalMatrix * worldNormal).xyz);");
|
|
53911
|
-
|
|
53912
|
-
src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
|
|
53913
|
-
src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
|
|
53914
|
-
|
|
53915
|
-
src.push("float lambertian = 1.0;");
|
|
53916
|
-
for (i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
53917
|
-
light = lightsState.lights[i];
|
|
53918
|
-
if (light.type === "ambient") {
|
|
53919
|
-
continue;
|
|
53920
|
-
}
|
|
53921
|
-
if (light.type === "dir") {
|
|
53922
|
-
if (light.space === "view") {
|
|
53923
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
53924
|
-
} else {
|
|
53925
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
53926
|
-
}
|
|
53927
|
-
} else if (light.type === "point") {
|
|
53928
|
-
if (light.space === "view") {
|
|
53929
|
-
src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
|
|
53930
|
-
} else {
|
|
53931
|
-
src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
|
|
53932
|
-
}
|
|
53933
|
-
} else if (light.type === "spot") {
|
|
53934
|
-
if (light.space === "view") {
|
|
53935
|
-
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
53936
|
-
} else {
|
|
53937
|
-
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
53938
|
-
}
|
|
53939
|
-
} else {
|
|
53940
|
-
continue;
|
|
53941
|
-
}
|
|
53942
|
-
src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
|
|
53943
|
-
src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
|
|
53944
|
-
}
|
|
53945
|
-
|
|
53946
|
-
src.push("vec3 rgb = (vec3(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0));");
|
|
53947
|
-
src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");
|
|
53826
|
+
src.push("vViewPosition = viewPosition;");
|
|
53827
|
+
src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");
|
|
53948
53828
|
src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");
|
|
53949
53829
|
|
|
53950
53830
|
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
|
@@ -53967,6 +53847,9 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
53967
53847
|
_buildFragmentShader() {
|
|
53968
53848
|
const scene = this._scene;
|
|
53969
53849
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
53850
|
+
const lightsState = scene._lightsState;
|
|
53851
|
+
let i;
|
|
53852
|
+
let len;
|
|
53970
53853
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
53971
53854
|
const src = [];
|
|
53972
53855
|
src.push("#version 300 es");
|
|
@@ -54008,9 +53891,31 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
54008
53891
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
54009
53892
|
}
|
|
54010
53893
|
}
|
|
53894
|
+
src.push("uniform mat4 viewMatrix;");
|
|
53895
|
+
src.push("uniform vec4 lightAmbient;");
|
|
53896
|
+
for (i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
53897
|
+
const light = lightsState.lights[i];
|
|
53898
|
+
if (light.type === "ambient") {
|
|
53899
|
+
continue;
|
|
53900
|
+
}
|
|
53901
|
+
src.push("uniform vec4 lightColor" + i + ";");
|
|
53902
|
+
if (light.type === "dir") {
|
|
53903
|
+
src.push("uniform vec3 lightDir" + i + ";");
|
|
53904
|
+
}
|
|
53905
|
+
if (light.type === "point") {
|
|
53906
|
+
src.push("uniform vec3 lightPos" + i + ";");
|
|
53907
|
+
}
|
|
53908
|
+
if (light.type === "spot") {
|
|
53909
|
+
src.push("uniform vec3 lightPos" + i + ";");
|
|
53910
|
+
src.push("uniform vec3 lightDir" + i + ";");
|
|
53911
|
+
}
|
|
53912
|
+
}
|
|
53913
|
+
|
|
53914
|
+
src.push("in vec4 vViewPosition;");
|
|
54011
53915
|
src.push("in vec4 vColor;");
|
|
54012
53916
|
src.push("in vec2 vUV;");
|
|
54013
53917
|
src.push("out vec4 outColor;");
|
|
53918
|
+
|
|
54014
53919
|
src.push("void main(void) {");
|
|
54015
53920
|
|
|
54016
53921
|
if (clipping) {
|
|
@@ -54028,17 +53933,52 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
54028
53933
|
src.push("}");
|
|
54029
53934
|
}
|
|
54030
53935
|
|
|
54031
|
-
|
|
54032
|
-
|
|
54033
|
-
}
|
|
53936
|
+
src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
|
|
53937
|
+
src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
|
|
54034
53938
|
|
|
54035
|
-
src.push("
|
|
54036
|
-
src.push("float opacity = vColor.a;");
|
|
53939
|
+
src.push("float lambertian = 1.0;");
|
|
54037
53940
|
|
|
54038
|
-
|
|
54039
|
-
|
|
53941
|
+
src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");
|
|
53942
|
+
src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");
|
|
53943
|
+
src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");
|
|
53944
|
+
|
|
53945
|
+
for (i = 0, len = lightsState.lights.length; i < len; i++) {
|
|
53946
|
+
const light = lightsState.lights[i];
|
|
53947
|
+
if (light.type === "ambient") {
|
|
53948
|
+
continue;
|
|
53949
|
+
}
|
|
53950
|
+
if (light.type === "dir") {
|
|
53951
|
+
if (light.space === "view") {
|
|
53952
|
+
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
53953
|
+
} else {
|
|
53954
|
+
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
53955
|
+
}
|
|
53956
|
+
} else if (light.type === "point") {
|
|
53957
|
+
if (light.space === "view") {
|
|
53958
|
+
src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
|
|
53959
|
+
} else {
|
|
53960
|
+
src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
|
|
53961
|
+
}
|
|
53962
|
+
} else if (light.type === "spot") {
|
|
53963
|
+
if (light.space === "view") {
|
|
53964
|
+
src.push("viewLightDir = normalize(lightDir" + i + ");");
|
|
53965
|
+
} else {
|
|
53966
|
+
src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
|
53967
|
+
}
|
|
53968
|
+
} else {
|
|
53969
|
+
continue;
|
|
53970
|
+
}
|
|
53971
|
+
src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
|
|
53972
|
+
src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
|
|
53973
|
+
}
|
|
53974
|
+
|
|
53975
|
+
src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
|
|
53976
|
+
src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
|
|
53977
|
+
src.push("float opacity = color.a;");
|
|
54040
53978
|
|
|
54041
53979
|
if (this._withSAO) {
|
|
53980
|
+
// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
|
|
53981
|
+
// Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
|
|
54042
53982
|
src.push(" float viewportWidth = uSAOParams[0];");
|
|
54043
53983
|
src.push(" float viewportHeight = uSAOParams[1];");
|
|
54044
53984
|
src.push(" float blendCutoff = uSAOParams[2];");
|
|
@@ -54049,6 +53989,11 @@ class TrianglesInstancingColorTextureRenderer {
|
|
|
54049
53989
|
} else {
|
|
54050
53990
|
src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb, opacity);");
|
|
54051
53991
|
}
|
|
53992
|
+
|
|
53993
|
+
if (scene.logarithmicDepthBufferEnabled) {
|
|
53994
|
+
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
53995
|
+
}
|
|
53996
|
+
|
|
54052
53997
|
src.push("}");
|
|
54053
53998
|
return src;
|
|
54054
53999
|
}
|
|
@@ -54704,7 +54649,6 @@ class TrianglesInstancingLayer {
|
|
|
54704
54649
|
|
|
54705
54650
|
this._state.colorTextureSupported
|
|
54706
54651
|
= !!geometry.uvBuf
|
|
54707
|
-
&& !!geometry.normalsBuf
|
|
54708
54652
|
&& !!textureSet
|
|
54709
54653
|
&& !!textureSet.colorTexture;
|
|
54710
54654
|
|