diff --git a/src/webgl/p5.RendererGL.Immediate.js b/src/webgl/p5.RendererGL.Immediate.js index 30f1bf8801..9c47730078 100644 --- a/src/webgl/p5.RendererGL.Immediate.js +++ b/src/webgl/p5.RendererGL.Immediate.js @@ -128,14 +128,13 @@ p5.RendererGL.prototype.vertex = function(x, y) { lineVertexColor[3] ); - if (this.textureMode === constants.IMAGE) { + if (this.textureMode === constants.IMAGE && !this.isProcessingVertices) { if (this._tex !== null) { if (this._tex.width > 0 && this._tex.height > 0) { u /= this._tex.width; v /= this._tex.height; } } else if ( - !this.isProcessingVertices && this._tex === null && arguments.length >= 4 ) { diff --git a/test/unit/webgl/p5.RendererGL.js b/test/unit/webgl/p5.RendererGL.js index 4ff0648141..1d2b0bd509 100644 --- a/test/unit/webgl/p5.RendererGL.js +++ b/test/unit/webgl/p5.RendererGL.js @@ -1364,6 +1364,31 @@ suite('p5.RendererGL', function() { done(); }); + test('TESS does not affect texture coordinates', function(done) { + var renderer = myp5.createCanvas(10, 10, myp5.WEBGL); + const texture = new p5.Image(25, 25); + + myp5.textureMode(myp5.IMAGE); + myp5.texture(texture); + renderer.beginShape(myp5.TESS); + myp5.noFill(); + renderer.vertex(-10, -10, 0, 0); + renderer.vertex(10, -10, 25, 0); + renderer.vertex(10, 10, 25, 25); + renderer.vertex(-10, 10, 0, 25); + renderer.endShape(myp5.CLOSE); + + // UVs are correctly translated through tessy + assert.deepEqual(renderer.immediateMode.geometry.uvs, [ + 0, 0, + 1, 0, + 1, 1, + 0, 1 + ]); + + done(); + }); + test('TESS interpolates vertex data at intersections', function(done) { var renderer = myp5.createCanvas(10, 10, myp5.WEBGL);