File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { AlwaysDepth , Texture , Uniform } from "three" ;
1+ import { AlwaysDepth , Texture , Uniform , Vector4 } from "three" ;
22import { FullscreenMaterial } from "./FullscreenMaterial.js" ;
33
44import fragmentShader from "./shaders/copy.frag" ;
@@ -27,7 +27,8 @@ export class CopyMaterial extends FullscreenMaterial {
2727 COLOR_WRITE : true
2828 } ,
2929 uniforms : {
30- depthBuffer : new Uniform ( null )
30+ depthBuffer : new Uniform ( null ) ,
31+ channelWeights : new Uniform ( null )
3132 }
3233 } ) ;
3334
@@ -132,4 +133,33 @@ export class CopyMaterial extends FullscreenMaterial {
132133
133134 }
134135
136+ /**
137+ * Color channel weights that modulate texels from the input buffer.
138+ *
139+ * Set to `null` to disable.
140+ */
141+
142+ get channelWeights ( ) : Vector4 | null {
143+
144+ return this . uniforms . channelWeights . value as Vector4 ;
145+
146+ }
147+
148+ set channelWeights ( value : Vector4 | null ) {
149+
150+ if ( value !== null ) {
151+
152+ this . defines . USE_WEIGHTS = true ;
153+ this . uniforms . channelWeights . value = value ;
154+
155+ } else {
156+
157+ delete this . defines . USE_WEIGHTS ;
158+
159+ }
160+
161+ this . needsUpdate = true ;
162+
163+ }
164+
135165}
Original file line number Diff line number Diff line change 1414
1515#endif
1616
17+ #ifdef USE_WEIGHTS
18+
19+ uniform vec4 channelWeights;
20+
21+ #endif
22+
1723in vec2 vUv;
1824
1925void main() {
2026
2127 #ifdef COLOR_WRITE
2228
23- out_Color = texture(inputBuffer, vUv);
29+ vec4 texel = texture2D (inputBuffer, vUv);
30+
31+ #ifdef USE_WEIGHTS
32+
33+ texel *= channelWeights;
34+
35+ #endif
36+
37+ out_Color = texel;
2438
2539 #ifdef COLOR_SPACE_CONVERSION
2640
You can’t perform that action at this time.
0 commit comments