forked from pmndrs/postprocessing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBrightnessContrastEffect.js
More file actions
126 lines (87 loc) · 2.17 KB
/
BrightnessContrastEffect.js
File metadata and controls
126 lines (87 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import { Uniform } from "three";
import { BlendFunction, SRGBColorSpace } from "../enums/index.js";
import { Effect } from "./Effect.js";
import fragmentShader from "./glsl/brightness-contrast.frag";
/**
* A brightness/contrast effect.
*
* Reference: https://github.com/evanw/glfx.js
*/
export class BrightnessContrastEffect extends Effect {
/**
* Constructs a new brightness/contrast effect.
*
* @param {Object} [options] - The options.
* @param {BlendFunction} [options.blendFunction=BlendFunction.SRC] - The blend function of this effect.
* @param {Number} [options.brightness=0.0] - The brightness factor, ranging from -1 to 1, where 0 means no change.
* @param {Number} [options.contrast=0.0] - The contrast factor, ranging from -1 to 1, where 0 means no change.
*/
constructor({ blendFunction = BlendFunction.SRC, brightness = 0.0, contrast = 0.0 } = {}) {
super("BrightnessContrastEffect", fragmentShader, {
blendFunction,
uniforms: new Map([
["brightness", new Uniform(brightness)],
["contrast", new Uniform(contrast)]
])
});
this.inputColorSpace = SRGBColorSpace;
}
/**
* The brightness.
*
* @type {Number}
*/
get brightness() {
return this.uniforms.get("brightness").value;
}
set brightness(value) {
this.uniforms.get("brightness").value = value;
}
/**
* Returns the brightness.
*
* @deprecated Use brightness instead.
* @return {Number} The brightness.
*/
getBrightness() {
return this.brightness;
}
/**
* Sets the brightness.
*
* @deprecated Use brightness instead.
* @param {Number} value - The brightness.
*/
setBrightness(value) {
this.brightness = value;
}
/**
* The contrast.
*
* @type {Number}
*/
get contrast() {
return this.uniforms.get("contrast").value;
}
set contrast(value) {
this.uniforms.get("contrast").value = value;
}
/**
* Returns the contrast.
*
* @deprecated Use contrast instead.
* @return {Number} The contrast.
*/
getContrast() {
return this.contrast;
}
/**
* Sets the contrast.
*
* @deprecated Use contrast instead.
* @param {Number} value - The contrast.
*/
setContrast(value) {
this.contrast = value;
}
}