Skip to content

Commit f368d08

Browse files
committed
Remove bias
1 parent c7795c4 commit f368d08

File tree

3 files changed

+12
-38
lines changed

3 files changed

+12
-38
lines changed

manual/assets/js/src/demos/tilt-shift.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ window.addEventListener("load", () => load().then((assets) => {
9898
offset: 0.25,
9999
rotation: 3.01,
100100
focusArea: 0.3,
101-
feather: 0.25,
102-
bias: 0.05
101+
feather: 0.25
103102
});
104103

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

src/effects/TiltShiftEffect.js

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { sRGBEncoding, Uniform, Vector2, Vector4, WebGLRenderTarget } from "three";
1+
import { sRGBEncoding, Uniform, Vector2, WebGLRenderTarget } from "three";
22
import { Resolution } from "../core";
33
import { KernelSize } from "../enums";
44
import { TiltShiftBlurPass } from "../passes";
@@ -22,7 +22,7 @@ export class TiltShiftEffect extends Effect {
2222
* @param {Number} [options.rotation=0.0] - The rotation of the focus area in radians.
2323
* @param {Number} [options.focusArea=0.4] - The relative size of the focus area.
2424
* @param {Number} [options.feather=0.3] - The softness of the focus area edges.
25-
* @param {Number} [options.bias=0.06] - A blend bias.
25+
* @param {Number} [options.bias=0.06] - Deprecated.
2626
* @param {KernelSize} [options.kernelSize=KernelSize.MEDIUM] - The blur kernel size.
2727
* @param {Number} [options.resolutionScale=0.5] - The resolution scale.
2828
* @param {Number} [options.resolutionX=Resolution.AUTO_SIZE] - The horizontal resolution.
@@ -35,7 +35,6 @@ export class TiltShiftEffect extends Effect {
3535
rotation = 0.0,
3636
focusArea = 0.4,
3737
feather = 0.3,
38-
bias = 0.06,
3938
kernelSize = KernelSize.MEDIUM,
4039
resolutionScale = 0.5,
4140
resolutionX = Resolution.AUTO_SIZE,
@@ -47,7 +46,7 @@ export class TiltShiftEffect extends Effect {
4746
blendFunction,
4847
uniforms: new Map([
4948
["rotation", new Uniform(new Vector2())],
50-
["maskParams", new Uniform(new Vector4())],
49+
["maskParams", new Uniform(new Vector2())],
5150
["map", new Uniform(null)]
5251
])
5352
});
@@ -76,14 +75,6 @@ export class TiltShiftEffect extends Effect {
7675

7776
this._feather = feather;
7877

79-
/**
80-
* @see {@link bias}
81-
* @type {Number}
82-
* @private
83-
*/
84-
85-
this._bias = bias;
86-
8778
/**
8879
* A render target.
8980
*
@@ -129,21 +120,16 @@ export class TiltShiftEffect extends Effect {
129120
}
130121

131122
/**
132-
* The relative offset of the focus area.
123+
* Updates the mask params.
133124
*
134125
* @private
135126
*/
136127

137128
updateParams() {
138129

139130
const params = this.uniforms.get("maskParams").value;
140-
const a = Math.max(this.focusArea - this.bias, 0.0);
141-
const b = Math.max(a - Math.max(this.feather - this.bias, 0.0), 0.0);
142-
143-
params.set(
144-
this.offset - a, this.offset - b,
145-
this.offset + a, this.offset + b
146-
);
131+
const x = Math.max(this.focusArea - this.feather, 0.0);
132+
params.set(this.offset - x, this.offset + x);
147133

148134
}
149135

@@ -230,20 +216,11 @@ export class TiltShiftEffect extends Effect {
230216
* A blend bias.
231217
*
232218
* @type {Number}
219+
* @deprecated
233220
*/
234221

235-
get bias() {
236-
237-
return this._bias;
238-
239-
}
240-
241-
set bias(value) {
242-
243-
this._bias = value;
244-
this.updateParams();
245-
246-
}
222+
get bias() { return 0; }
223+
set bias(value) {}
247224

248225
/**
249226
* Updates this effect.

src/effects/glsl/tilt-shift.frag

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88

99
#endif
1010

11-
uniform vec4 maskParams;
11+
uniform vec2 maskParams;
1212
varying vec2 vUv2;
1313

1414
float linearGradientMask(const in float x) {
1515

16-
return smoothstep(maskParams.x, maskParams.y, x) -
17-
smoothstep(maskParams.w, maskParams.z, x);
16+
return step(maskParams.x, x) - step(maskParams.y, x);
1817

1918
}
2019

0 commit comments

Comments
 (0)