Skip to content

Commit

Permalink
Remove bias
Browse files Browse the repository at this point in the history
  • Loading branch information
vanruesc committed Dec 28, 2022
1 parent c7795c4 commit f368d08
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 38 deletions.
4 changes: 1 addition & 3 deletions manual/assets/js/src/demos/tilt-shift.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ window.addEventListener("load", () => load().then((assets) => {
offset: 0.25,
rotation: 3.01,
focusArea: 0.3,
feather: 0.25,
bias: 0.05
feather: 0.25
});

const composer = new EffectComposer(renderer);
Expand All @@ -122,7 +121,6 @@ window.addEventListener("load", () => load().then((assets) => {
subfolder.addInput(effect, "rotation", { min: 0, max: 2 * Math.PI, step: 1e-2 });
subfolder.addInput(effect, "focusArea", { min: 0, max: 1, step: 1e-2 });
subfolder.addInput(effect, "feather", { min: 0, max: 1, step: 1e-3 });
subfolder.addInput(effect, "bias", { min: 0, max: 1, step: 1e-3 });
folder.addInput(effect.blendMode.opacity, "value", { label: "opacity", min: 0, max: 1, step: 1e-2 });
folder.addInput(effect.blendMode, "blendFunction", { options: BlendFunction });

Expand Down
41 changes: 9 additions & 32 deletions src/effects/TiltShiftEffect.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sRGBEncoding, Uniform, Vector2, Vector4, WebGLRenderTarget } from "three";
import { sRGBEncoding, Uniform, Vector2, WebGLRenderTarget } from "three";
import { Resolution } from "../core";
import { KernelSize } from "../enums";
import { TiltShiftBlurPass } from "../passes";
Expand All @@ -22,7 +22,7 @@ export class TiltShiftEffect extends Effect {
* @param {Number} [options.rotation=0.0] - The rotation of the focus area in radians.
* @param {Number} [options.focusArea=0.4] - The relative size of the focus area.
* @param {Number} [options.feather=0.3] - The softness of the focus area edges.
* @param {Number} [options.bias=0.06] - A blend bias.
* @param {Number} [options.bias=0.06] - Deprecated.
* @param {KernelSize} [options.kernelSize=KernelSize.MEDIUM] - The blur kernel size.
* @param {Number} [options.resolutionScale=0.5] - The resolution scale.
* @param {Number} [options.resolutionX=Resolution.AUTO_SIZE] - The horizontal resolution.
Expand All @@ -35,7 +35,6 @@ export class TiltShiftEffect extends Effect {
rotation = 0.0,
focusArea = 0.4,
feather = 0.3,
bias = 0.06,
kernelSize = KernelSize.MEDIUM,
resolutionScale = 0.5,
resolutionX = Resolution.AUTO_SIZE,
Expand All @@ -47,7 +46,7 @@ export class TiltShiftEffect extends Effect {
blendFunction,
uniforms: new Map([
["rotation", new Uniform(new Vector2())],
["maskParams", new Uniform(new Vector4())],
["maskParams", new Uniform(new Vector2())],
["map", new Uniform(null)]
])
});
Expand Down Expand Up @@ -76,14 +75,6 @@ export class TiltShiftEffect extends Effect {

this._feather = feather;

/**
* @see {@link bias}
* @type {Number}
* @private
*/

this._bias = bias;

/**
* A render target.
*
Expand Down Expand Up @@ -129,21 +120,16 @@ export class TiltShiftEffect extends Effect {
}

/**
* The relative offset of the focus area.
* Updates the mask params.
*
* @private
*/

updateParams() {

const params = this.uniforms.get("maskParams").value;
const a = Math.max(this.focusArea - this.bias, 0.0);
const b = Math.max(a - Math.max(this.feather - this.bias, 0.0), 0.0);

params.set(
this.offset - a, this.offset - b,
this.offset + a, this.offset + b
);
const x = Math.max(this.focusArea - this.feather, 0.0);
params.set(this.offset - x, this.offset + x);

}

Expand Down Expand Up @@ -230,20 +216,11 @@ export class TiltShiftEffect extends Effect {
* A blend bias.
*
* @type {Number}
* @deprecated
*/

get bias() {

return this._bias;

}

set bias(value) {

this._bias = value;
this.updateParams();

}
get bias() { return 0; }
set bias(value) {}

/**
* Updates this effect.
Expand Down
5 changes: 2 additions & 3 deletions src/effects/glsl/tilt-shift.frag
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@

#endif

uniform vec4 maskParams;
uniform vec2 maskParams;
varying vec2 vUv2;

float linearGradientMask(const in float x) {

return smoothstep(maskParams.x, maskParams.y, x) -
smoothstep(maskParams.w, maskParams.z, x);
return step(maskParams.x, x) - step(maskParams.y, x);

}

Expand Down

0 comments on commit f368d08

Please sign in to comment.