|
@@ -6213,6 +6213,7 @@ var BABYLON;
|
|
this._maxTextureChannels = 16;
|
|
this._maxTextureChannels = 16;
|
|
this._activeTexturesCache = new Array(this._maxTextureChannels);
|
|
this._activeTexturesCache = new Array(this._maxTextureChannels);
|
|
this._compiledEffects = {};
|
|
this._compiledEffects = {};
|
|
|
|
+ this._vertexAttribArraysEnabled = [];
|
|
this._uintIndicesCurrentlySet = false;
|
|
this._uintIndicesCurrentlySet = false;
|
|
this._currentBoundBuffer = new Array();
|
|
this._currentBoundBuffer = new Array();
|
|
this._currentBufferPointers = [];
|
|
this._currentBufferPointers = [];
|
|
@@ -6269,6 +6270,7 @@ var BABYLON;
|
|
this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
|
|
this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
|
|
this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
|
|
this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
|
|
this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
|
|
this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
|
|
|
|
+ this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
|
|
// Infos
|
|
// Infos
|
|
this._glVersion = this._gl.getParameter(this._gl.VERSION);
|
|
this._glVersion = this._gl.getParameter(this._gl.VERSION);
|
|
var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
|
|
var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
|
|
@@ -7003,13 +7005,28 @@ var BABYLON;
|
|
if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
|
|
if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
|
|
this._cachedVertexBuffers = vertexBuffer;
|
|
this._cachedVertexBuffers = vertexBuffer;
|
|
this._cachedEffectForVertexBuffers = effect;
|
|
this._cachedEffectForVertexBuffers = effect;
|
|
|
|
+ var attributesCount = effect.getAttributesCount();
|
|
var offset = 0;
|
|
var offset = 0;
|
|
- for (var index = 0; index < vertexDeclaration.length; index++) {
|
|
|
|
- var order = effect.getAttributeLocation(index);
|
|
|
|
- if (order >= 0) {
|
|
|
|
- this.vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
|
|
|
|
|
|
+ for (var index = 0; index < attributesCount; index++) {
|
|
|
|
+ if (index < vertexDeclaration.length) {
|
|
|
|
+ var order = effect.getAttributeLocation(index);
|
|
|
|
+ if (order >= 0) {
|
|
|
|
+ if (!this._vertexAttribArraysEnabled[order]) {
|
|
|
|
+ this._gl.enableVertexAttribArray(order);
|
|
|
|
+ this._vertexAttribArraysEnabled[order] = true;
|
|
|
|
+ }
|
|
|
|
+ this.vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
|
|
|
|
+ }
|
|
|
|
+ offset += vertexDeclaration[index] * 4;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ //disable effect attributes that have no data
|
|
|
|
+ var order = effect.getAttributeLocation(index);
|
|
|
|
+ if (this._vertexAttribArraysEnabled[order]) {
|
|
|
|
+ this._gl.disableVertexAttribArray(order);
|
|
|
|
+ this._vertexAttribArraysEnabled[order] = false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- offset += vertexDeclaration[index] * 4;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (this._cachedIndexBuffer !== indexBuffer) {
|
|
if (this._cachedIndexBuffer !== indexBuffer) {
|
|
@@ -7028,8 +7045,16 @@ var BABYLON;
|
|
if (order >= 0) {
|
|
if (order >= 0) {
|
|
var vertexBuffer = vertexBuffers[attributes[index]];
|
|
var vertexBuffer = vertexBuffers[attributes[index]];
|
|
if (!vertexBuffer) {
|
|
if (!vertexBuffer) {
|
|
|
|
+ if (this._vertexAttribArraysEnabled[order]) {
|
|
|
|
+ this._gl.disableVertexAttribArray(order);
|
|
|
|
+ this._vertexAttribArraysEnabled[order] = false;
|
|
|
|
+ }
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+ if (!this._vertexAttribArraysEnabled[order]) {
|
|
|
|
+ this._gl.enableVertexAttribArray(order);
|
|
|
|
+ this._vertexAttribArraysEnabled[order] = true;
|
|
|
|
+ }
|
|
var buffer = vertexBuffer.getBuffer();
|
|
var buffer = vertexBuffer.getBuffer();
|
|
this.vertexAttribPointer(buffer, order, vertexBuffer.getSize(), this._gl.FLOAT, false, vertexBuffer.getStrideSize() * 4, vertexBuffer.getOffset() * 4);
|
|
this.vertexAttribPointer(buffer, order, vertexBuffer.getSize(), this._gl.FLOAT, false, vertexBuffer.getStrideSize() * 4, vertexBuffer.getOffset() * 4);
|
|
if (vertexBuffer.getIsInstanced()) {
|
|
if (vertexBuffer.getIsInstanced()) {
|
|
@@ -7091,7 +7116,10 @@ var BABYLON;
|
|
}
|
|
}
|
|
for (var i = 0; i < offsetLocations.length; i++) {
|
|
for (var i = 0; i < offsetLocations.length; i++) {
|
|
var ai = offsetLocations[i];
|
|
var ai = offsetLocations[i];
|
|
- this._gl.enableVertexAttribArray(ai.index);
|
|
|
|
|
|
+ if (!this._vertexAttribArraysEnabled[ai.index]) {
|
|
|
|
+ this._gl.enableVertexAttribArray(ai.index);
|
|
|
|
+ this._vertexAttribArraysEnabled[ai.index] = true;
|
|
|
|
+ }
|
|
this.vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
|
|
this.vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
|
|
this._caps.instancedArrays.vertexAttribDivisorANGLE(ai.index, 1);
|
|
this._caps.instancedArrays.vertexAttribDivisorANGLE(ai.index, 1);
|
|
this._currentInstanceLocations.push(ai.index);
|
|
this._currentInstanceLocations.push(ai.index);
|
|
@@ -7101,7 +7129,10 @@ var BABYLON;
|
|
else {
|
|
else {
|
|
for (var index = 0; index < 4; index++) {
|
|
for (var index = 0; index < 4; index++) {
|
|
var offsetLocation = offsetLocations[index];
|
|
var offsetLocation = offsetLocations[index];
|
|
- this._gl.enableVertexAttribArray(offsetLocation);
|
|
|
|
|
|
+ if (!this._vertexAttribArraysEnabled[offsetLocation]) {
|
|
|
|
+ this._gl.enableVertexAttribArray(offsetLocation);
|
|
|
|
+ this._vertexAttribArraysEnabled[offsetLocation] = true;
|
|
|
|
+ }
|
|
this.vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
|
|
this.vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
|
|
this._caps.instancedArrays.vertexAttribDivisorANGLE(offsetLocation, 1);
|
|
this._caps.instancedArrays.vertexAttribDivisorANGLE(offsetLocation, 1);
|
|
this._currentInstanceLocations.push(offsetLocation);
|
|
this._currentInstanceLocations.push(offsetLocation);
|
|
@@ -7222,35 +7253,8 @@ var BABYLON;
|
|
}
|
|
}
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- this._vertexAttribArraysToUse = this._vertexAttribArraysToUse || [];
|
|
|
|
- this._vertexAttribArraysEnabled = this._vertexAttribArraysEnabled || [];
|
|
|
|
// Use program
|
|
// Use program
|
|
this.setProgram(effect.getProgram());
|
|
this.setProgram(effect.getProgram());
|
|
- var i, ul;
|
|
|
|
- for (i = 0, ul = this._vertexAttribArraysToUse.length; i < ul; i++) {
|
|
|
|
- this._vertexAttribArraysToUse[i] = false;
|
|
|
|
- }
|
|
|
|
- var attributesCount = effect.getAttributesCount();
|
|
|
|
- for (i = 0; i < attributesCount; i++) {
|
|
|
|
- // Attributes
|
|
|
|
- var order = effect.getAttributeLocation(i);
|
|
|
|
- if (order >= 0) {
|
|
|
|
- this._vertexAttribArraysToUse[order] = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for (i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
|
|
|
|
- if (i > this._gl.VERTEX_ATTRIB_ARRAY_ENABLED || !this._vertexAttribArraysEnabled[i] || this._vertexAttribArraysToUse[i]) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- this._vertexAttribArraysEnabled[i] = false;
|
|
|
|
- this._gl.disableVertexAttribArray(i);
|
|
|
|
- }
|
|
|
|
- for (i = 0, ul = this._vertexAttribArraysToUse.length; i < ul; i++) {
|
|
|
|
- if (this._vertexAttribArraysToUse[i] && !this._vertexAttribArraysEnabled[i]) {
|
|
|
|
- this._vertexAttribArraysEnabled[i] = true;
|
|
|
|
- this._gl.enableVertexAttribArray(i);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
this._currentEffect = effect;
|
|
this._currentEffect = effect;
|
|
if (effect.onBind) {
|
|
if (effect.onBind) {
|
|
effect.onBind(effect);
|
|
effect.onBind(effect);
|
|
@@ -8320,13 +8324,11 @@ var BABYLON;
|
|
this._gl.deleteProgram(this._compiledEffects[name]._program);
|
|
this._gl.deleteProgram(this._compiledEffects[name]._program);
|
|
}
|
|
}
|
|
// Unbind
|
|
// Unbind
|
|
- if (this._vertexAttribArraysEnabled) {
|
|
|
|
- for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
|
|
|
|
- if (i > this._gl.VERTEX_ATTRIB_ARRAY_ENABLED || !this._vertexAttribArraysEnabled[i]) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- this._gl.disableVertexAttribArray(i);
|
|
|
|
|
|
+ for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
|
|
|
|
+ if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
|
|
+ this._gl.disableVertexAttribArray(i);
|
|
}
|
|
}
|
|
this._gl = null;
|
|
this._gl = null;
|
|
// Events
|
|
// Events
|
|
@@ -42149,7 +42151,7 @@ var BABYLON;
|
|
this.groupInsanceInfo = null;
|
|
this.groupInsanceInfo = null;
|
|
this.startZ = 0;
|
|
this.startZ = 0;
|
|
this.endZ = 0;
|
|
this.endZ = 0;
|
|
- this.startDataIndex = 0;
|
|
|
|
|
|
+ this.startDataIndex = BABYLON.Prim2DBase._bigInt;
|
|
this.endDataIndex = 0;
|
|
this.endDataIndex = 0;
|
|
this.partBuffers = null;
|
|
this.partBuffers = null;
|
|
}
|
|
}
|
|
@@ -43005,21 +43007,8 @@ var BABYLON;
|
|
minOff = Math.min(minOff, el.offset);
|
|
minOff = Math.min(minOff, el.offset);
|
|
maxOff = Math.max(maxOff, el.offset);
|
|
maxOff = Math.max(maxOff, el.offset);
|
|
}
|
|
}
|
|
- ts.startDataIndex = minOff / part.dataBuffer.stride;
|
|
|
|
- ts.endDataIndex = (maxOff / part.dataBuffer.stride) + 1; // +1 for exclusive
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- RenderablePrim2D.prototype._getPrimitiveLastIndex = function () {
|
|
|
|
- var maxOff = 0;
|
|
|
|
- for (var _i = 0, _a = this._instanceDataParts; _i < _a.length; _i++) {
|
|
|
|
- var part = _a[_i];
|
|
|
|
- if (part) {
|
|
|
|
- for (var _b = 0, _c = part.dataElements; _b < _c.length; _b++) {
|
|
|
|
- var el = _c[_b];
|
|
|
|
- maxOff = Math.max(maxOff, el.offset);
|
|
|
|
- }
|
|
|
|
- return (maxOff / part.dataBuffer.stride) + 1; // +1 for exclusive
|
|
|
|
|
|
+ ts.startDataIndex = Math.min(ts.startDataIndex, minOff / part.dataBuffer.stride);
|
|
|
|
+ ts.endDataIndex = Math.max(ts.endDataIndex, (maxOff / part.dataBuffer.stride) + 1); // +1 for exclusive
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -43924,7 +43913,7 @@ var BABYLON;
|
|
//let tpiZ = tpi._primitive.actualZOffset;
|
|
//let tpiZ = tpi._primitive.actualZOffset;
|
|
// We've made it so far, the tpi can be part of the segment, add it
|
|
// We've made it so far, the tpi can be part of the segment, add it
|
|
tpi._transparentSegment = seg;
|
|
tpi._transparentSegment = seg;
|
|
- seg.endDataIndex = tpi._primitive._getPrimitiveLastIndex();
|
|
|
|
|
|
+ tpi._primitive._updateTransparentSegmentIndices(seg);
|
|
return true;
|
|
return true;
|
|
};
|
|
};
|
|
// Free the existing TransparentSegments
|
|
// Free the existing TransparentSegments
|