Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/effects/TextureEffect.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ export class TextureEffect extends Effect {
if(prevTexture !== value) {

uniforms.get("map").value = value;
uniforms.get("uvTransform").value = value.matrix;
defines.delete("TEXTURE_PRECISION_HIGH");

if(value !== null) {

uniforms.get("uvTransform").value = value.matrix;

if(value.matrixAutoUpdate) {

defines.set("UV_TRANSFORM", "1");
Expand All @@ -89,6 +90,12 @@ export class TextureEffect extends Effect {

}

} else {

uniforms.get("uvTransform").value = null;
defines.delete("UV_TRANSFORM");
this.setVertexShader(null);

}

}
Expand Down
28 changes: 27 additions & 1 deletion test/effects/TextureEffect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import test from "ava";
import { TextureEffect } from "postprocessing";
import { Texture } from "three";
import { EffectPass, TextureEffect } from "postprocessing";

test("can be created and destroyed", t => {

Expand All @@ -16,3 +17,28 @@ test("can be updated", t => {
t.notThrows(() => effect.update());

});

test("can clear an existing texture", t => {

const effect = new TextureEffect({ texture: new Texture() });
t.notThrows(() => { effect.texture = null; });
t.is(effect.texture, null);

});

test("recompiles its host pass after clearing an existing texture", t => {

const texture = new Texture();
texture.matrixAutoUpdate = true;

const effect = new TextureEffect({ texture });
const pass = new EffectPass(null, effect);
pass.initialize(null, false, undefined);

t.true(pass.fullscreenMaterial.vertexShader.includes("UvTransform"));

t.notThrows(() => { effect.texture = null; });

t.false(pass.fullscreenMaterial.vertexShader.includes("UvTransform"));

});
Loading