Skip to content

Commit

Permalink
Fix texture binding in instancing renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Jul 29, 2023
1 parent 8ba72b2 commit 799dfe0
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,6 @@ class TrianglesInstancingColorTextureRenderer {

geometry.indicesBuf.bind();

gl.drawElementsInstanced(gl.TRIANGLES, geometry.indicesBuf.numItems, geometry.indicesBuf.itemType, 0, state.numInstances);

frameCtx.drawElements++;

gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 0);
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 0);
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 0);
gl.vertexAttribDivisor(this._aColor.location, 0);
gl.vertexAttribDivisor(this._aFlags.location, 0);

if (this._aOffset) {
gl.vertexAttribDivisor(this._aOffset.location, 0);
}

if (textureSet) {
if (textureSet.colorTexture) {
this._program.bindTexture(this._uColorMap, textureSet.colorTexture.texture, frameCtx.textureUnit);
Expand All @@ -145,6 +131,22 @@ class TrianglesInstancingColorTextureRenderer {
this._program.bindTexture(this._uOcclusionTexture, frameCtx.occlusionTexture, 0);
}
}

gl.drawElementsInstanced(gl.TRIANGLES, geometry.indicesBuf.numItems, geometry.indicesBuf.itemType, 0, state.numInstances);

frameCtx.drawElements++;

gl.vertexAttribDivisor(this._aModelMatrixCol0.location, 0);
gl.vertexAttribDivisor(this._aModelMatrixCol1.location, 0);
gl.vertexAttribDivisor(this._aModelMatrixCol2.location, 0);
gl.vertexAttribDivisor(this._aColor.location, 0);
gl.vertexAttribDivisor(this._aFlags.location, 0);

if (this._aOffset) {
gl.vertexAttribDivisor(this._aOffset.location, 0);
}


}

_allocate() {
Expand Down

0 comments on commit 799dfe0

Please sign in to comment.