three-gpu-pathtracer 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +781 -728
  3. package/build/index.module.js +5223 -3956
  4. package/build/index.module.js.map +1 -1
  5. package/build/index.umd.cjs +5226 -3954
  6. package/build/index.umd.cjs.map +1 -1
  7. package/package.json +68 -60
  8. package/src/core/DynamicPathTracingSceneGenerator.js +119 -111
  9. package/src/core/MaterialReducer.js +256 -256
  10. package/src/core/PathTracingRenderer.js +255 -255
  11. package/src/core/PathTracingSceneGenerator.js +68 -68
  12. package/src/index.js +33 -26
  13. package/src/materials/AlphaDisplayMaterial.js +48 -48
  14. package/src/materials/AmbientOcclusionMaterial.js +197 -197
  15. package/src/materials/BlendMaterial.js +67 -67
  16. package/src/materials/LambertPathTracingMaterial.js +285 -285
  17. package/src/materials/MaterialBase.js +56 -56
  18. package/src/materials/PhysicalPathTracingMaterial.js +922 -848
  19. package/src/{core → objects}/EquirectCamera.js +13 -13
  20. package/src/{core → objects}/PhysicalCamera.js +28 -28
  21. package/src/objects/PhysicalSpotLight.js +14 -0
  22. package/src/objects/ShapedAreaLight.js +12 -0
  23. package/src/shader/shaderEnvMapSampling.js +59 -59
  24. package/src/shader/shaderGGXFunctions.js +108 -108
  25. package/src/shader/shaderIridescenceFunctions.js +130 -0
  26. package/src/shader/shaderLightSampling.js +231 -87
  27. package/src/shader/shaderMaterialSampling.js +546 -501
  28. package/src/shader/shaderSheenFunctions.js +98 -0
  29. package/src/shader/shaderStructs.js +307 -191
  30. package/src/shader/shaderUtils.js +350 -287
  31. package/src/uniforms/EquirectHdrInfoUniform.js +259 -263
  32. package/src/uniforms/IESProfilesTexture.js +100 -0
  33. package/src/uniforms/LightsInfoUniformStruct.js +162 -0
  34. package/src/uniforms/MaterialsTexture.js +406 -319
  35. package/src/uniforms/PhysicalCameraUniform.js +36 -36
  36. package/src/uniforms/RenderTarget2DArray.js +93 -93
  37. package/src/utils/BlurredEnvMapGenerator.js +113 -113
  38. package/src/utils/GeometryPreparationUtils.js +194 -194
  39. package/src/utils/IESLoader.js +325 -0
  40. package/src/utils/UVUnwrapper.js +101 -101
  41. package/src/workers/PathTracingSceneWorker.js +42 -41
  42. package/src/uniforms/LightsTexture.js +0 -83
@@ -1,263 +1,259 @@
1
- import { DataTexture, FloatType, RedFormat, LinearFilter, DataUtils, HalfFloatType, Source, RepeatWrapping } from 'three';
2
-
3
- function binarySearchFindClosestIndexOf( array, targetValue, offset = 0, count = array.length ) {
4
-
5
- let lower = 0;
6
- let upper = count;
7
- while ( lower < upper ) {
8
-
9
- const mid = ~ ~ ( 0.5 * upper + 0.5 * lower );
10
-
11
-
12
- // check if the middle array value is above or below the target and shift
13
- // which half of the array we're looking at
14
- if ( array[ offset + mid ] < targetValue ) {
15
-
16
- lower = mid + 1;
17
-
18
- } else {
19
-
20
- upper = mid;
21
-
22
- }
23
-
24
- }
25
-
26
- return lower;
27
-
28
- }
29
-
30
- function colorToLuminance( r, g, b ) {
31
-
32
- // https://en.wikipedia.org/wiki/Relative_luminance
33
- return 0.2126 * r + 0.7152 * g + 0.0722 * b;
34
-
35
- }
36
-
37
- // ensures the data is all floating point values and flipY is false
38
- function preprocessEnvMap( envMap ) {
39
-
40
- const map = envMap.clone();
41
- map.source = new Source( { ...map.image } );
42
- const { width, height, data } = map.image;
43
-
44
- // TODO: is there a simple way to avoid cloning and adjusting the env map data here?
45
- // convert the data from half float uint 16 arrays to float arrays for cdf computation
46
- let newData = data;
47
- if ( map.type === HalfFloatType ) {
48
-
49
- newData = new Float32Array( data.length );
50
- for ( const i in data ) {
51
-
52
- newData[ i ] = DataUtils.fromHalfFloat( data[ i ] );
53
-
54
- }
55
-
56
- map.image.data = newData;
57
- map.type = FloatType;
58
-
59
- }
60
-
61
- // remove any y flipping for cdf computation
62
- if ( map.flipY ) {
63
-
64
- const ogData = newData;
65
- newData = newData.slice();
66
- for ( let y = 0; y < height; y ++ ) {
67
-
68
- for ( let x = 0; x < width; x ++ ) {
69
-
70
- const newY = height - y - 1;
71
- const ogIndex = 4 * ( y * width + x );
72
- const newIndex = 4 * ( newY * width + x );
73
-
74
- newData[ newIndex + 0 ] = ogData[ ogIndex + 0 ];
75
- newData[ newIndex + 1 ] = ogData[ ogIndex + 1 ];
76
- newData[ newIndex + 2 ] = ogData[ ogIndex + 2 ];
77
- newData[ newIndex + 3 ] = ogData[ ogIndex + 3 ];
78
-
79
- }
80
-
81
- }
82
-
83
- map.flipY = false;
84
- map.image.data = newData;
85
-
86
- }
87
-
88
- return map;
89
-
90
- }
91
-
92
- export class EquirectHdrInfoUniform {
93
-
94
- constructor() {
95
-
96
- // Stores a map of [0, 1] value -> cumulative importance row & pdf
97
- // used to sampling a random value to a relevant row to sample from
98
- const marginalWeights = new DataTexture();
99
- marginalWeights.type = FloatType;
100
- marginalWeights.format = RedFormat;
101
- marginalWeights.minFilter = LinearFilter;
102
- marginalWeights.magFilter = LinearFilter;
103
- marginalWeights.generateMipmaps = false;
104
-
105
- // Stores a map of [0, 1] value -> cumulative importance column & pdf
106
- // used to sampling a random value to a relevant pixel to sample from
107
- const conditionalWeights = new DataTexture();
108
- conditionalWeights.type = FloatType;
109
- conditionalWeights.format = RedFormat;
110
- conditionalWeights.minFilter = LinearFilter;
111
- conditionalWeights.magFilter = LinearFilter;
112
- conditionalWeights.generateMipmaps = false;
113
-
114
- // store the total sum in a 1x1 tex since some android mobile devices have issues
115
- // storing large values in structs.
116
- const totalSumTex = new DataTexture();
117
- totalSumTex.type = FloatType;
118
- totalSumTex.format = RedFormat;
119
- totalSumTex.minFilter = LinearFilter;
120
- totalSumTex.magFilter = LinearFilter;
121
- totalSumTex.generateMipmaps = false;
122
-
123
- this.marginalWeights = marginalWeights;
124
- this.conditionalWeights = conditionalWeights;
125
- this.totalSum = totalSumTex;
126
- this.map = null;
127
-
128
- }
129
-
130
- dispose() {
131
-
132
- this.marginalWeights.dispose();
133
- this.conditionalWeights.dispose();
134
- this.totalSum.dispose();
135
- if ( this.map ) this.map.dispose();
136
-
137
- }
138
-
139
- updateFrom( hdr ) {
140
-
141
- // https://github.com/knightcrawler25/GLSL-PathTracer/blob/3c6fd9b6b3da47cd50c527eeb45845eef06c55c3/src/loaders/hdrloader.cpp
142
- // https://pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Sampling_Light_Sources#InfiniteAreaLights
143
- const map = preprocessEnvMap( hdr );
144
- map.wrapS = RepeatWrapping;
145
- map.wrapT = RepeatWrapping;
146
-
147
- const { width, height, data } = map.image;
148
-
149
- // "conditional" = "pixel relative to row pixels sum"
150
- // "marginal" = "row relative to row sum"
151
-
152
- // track the importance of any given pixel in the image by tracking its weight relative to other pixels in the image
153
- const pdfConditional = new Float32Array( width * height );
154
- const cdfConditional = new Float32Array( width * height );
155
-
156
- const pdfMarginal = new Float32Array( height );
157
- const cdfMarginal = new Float32Array( height );
158
-
159
- let totalSumValue = 0.0;
160
- let cumulativeWeightMarginal = 0.0;
161
- for ( let y = 0; y < height; y ++ ) {
162
-
163
- let cumulativeRowWeight = 0.0;
164
- for ( let x = 0; x < width; x ++ ) {
165
-
166
- const i = y * width + x;
167
- const r = data[ 4 * i + 0 ];
168
- const g = data[ 4 * i + 1 ];
169
- const b = data[ 4 * i + 2 ];
170
-
171
- // the probability of the pixel being selected in this row is the
172
- // scale of the luminance relative to the rest of the pixels.
173
- // TODO: this should also account for the solid angle of the pixel when sampling
174
- const weight = colorToLuminance( r, g, b );
175
- cumulativeRowWeight += weight;
176
- totalSumValue += weight;
177
-
178
- pdfConditional[ i ] = weight;
179
- cdfConditional[ i ] = cumulativeRowWeight;
180
-
181
- }
182
-
183
- // can happen if the row is all black
184
- if ( cumulativeRowWeight !== 0 ) {
185
-
186
- // scale the pdf and cdf to [0.0, 1.0]
187
- for ( let i = y * width, l = y * width + width; i < l; i ++ ) {
188
-
189
- pdfConditional[ i ] /= cumulativeRowWeight;
190
- cdfConditional[ i ] /= cumulativeRowWeight;
191
-
192
- }
193
-
194
- }
195
-
196
- cumulativeWeightMarginal += cumulativeRowWeight;
197
-
198
- // compute the marginal pdf and cdf along the height of the map.
199
- pdfMarginal[ y ] = cumulativeRowWeight;
200
- cdfMarginal[ y ] = cumulativeWeightMarginal;
201
-
202
- }
203
-
204
- // can happen if the texture is all black
205
- if ( cumulativeWeightMarginal !== 0 ) {
206
-
207
- // scale the marginal pdf and cdf to [0.0, 1.0]
208
- for ( let i = 0, l = pdfMarginal.length; i < l; i ++ ) {
209
-
210
- pdfMarginal[ i ] /= cumulativeWeightMarginal;
211
- cdfMarginal[ i ] /= cumulativeWeightMarginal;
212
-
213
- }
214
-
215
- }
216
-
217
- // compute a sorted index of distributions and the probabilities along them for both
218
- // the marginal and conditional data. These will be used to sample with a random number
219
- // to retrieve a uv value to sample in the environment map.
220
- // These values continually increase so it's okay to interpolate between them.
221
- const marginalDataArray = new Float32Array( height );
222
- const conditionalDataArray = new Float32Array( width * height );
223
-
224
- for ( let i = 0; i < height; i ++ ) {
225
-
226
- const dist = ( i + 1 ) / height;
227
- const row = binarySearchFindClosestIndexOf( cdfMarginal, dist );
228
-
229
- marginalDataArray[ i ] = row / height;
230
-
231
- }
232
-
233
- for ( let y = 0; y < height; y ++ ) {
234
-
235
- for ( let x = 0; x < width; x ++ ) {
236
-
237
- const i = y * width + x;
238
- const dist = ( x + 1 ) / width;
239
- const col = binarySearchFindClosestIndexOf( cdfConditional, dist, y * width, width );
240
-
241
- conditionalDataArray[ i ] = col / width;
242
-
243
- }
244
-
245
- }
246
-
247
- this.dispose();
248
-
249
- const { marginalWeights, conditionalWeights, totalSum } = this;
250
- marginalWeights.image = { width: height, height: 1, data: marginalDataArray };
251
- marginalWeights.needsUpdate = true;
252
-
253
- conditionalWeights.image = { width, height, data: conditionalDataArray };
254
- conditionalWeights.needsUpdate = true;
255
-
256
- totalSum.image = { width: 1, height: 1, data: new Float32Array( [ totalSumValue ] ) };
257
- totalSum.needsUpdate = true;
258
-
259
- this.map = map;
260
-
261
- }
262
-
263
- }
1
+ import { DataTexture, FloatType, RedFormat, LinearFilter, DataUtils, HalfFloatType, Source, RepeatWrapping } from 'three';
2
+
3
+ function binarySearchFindClosestIndexOf( array, targetValue, offset = 0, count = array.length ) {
4
+
5
+ let lower = 0;
6
+ let upper = count;
7
+ while ( lower < upper ) {
8
+
9
+ const mid = ~ ~ ( 0.5 * upper + 0.5 * lower );
10
+
11
+
12
+ // check if the middle array value is above or below the target and shift
13
+ // which half of the array we're looking at
14
+ if ( array[ offset + mid ] < targetValue ) {
15
+
16
+ lower = mid + 1;
17
+
18
+ } else {
19
+
20
+ upper = mid;
21
+
22
+ }
23
+
24
+ }
25
+
26
+ return lower;
27
+
28
+ }
29
+
30
+ function colorToLuminance( r, g, b ) {
31
+
32
+ // https://en.wikipedia.org/wiki/Relative_luminance
33
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
34
+
35
+ }
36
+
37
+ // ensures the data is all floating point values and flipY is false
38
+ function preprocessEnvMap( envMap ) {
39
+
40
+ const map = envMap.clone();
41
+ map.source = new Source( { ...map.image } );
42
+ const { width, height, data } = map.image;
43
+
44
+ // TODO: is there a simple way to avoid cloning and adjusting the env map data here?
45
+ // convert the data from half float uint 16 arrays to float arrays for cdf computation
46
+ let newData = data;
47
+ if ( map.type === HalfFloatType ) {
48
+
49
+ newData = new Float32Array( data.length );
50
+ for ( const i in data ) {
51
+
52
+ newData[ i ] = DataUtils.fromHalfFloat( data[ i ] );
53
+
54
+ }
55
+
56
+ map.image.data = newData;
57
+ map.type = FloatType;
58
+
59
+ }
60
+
61
+ // remove any y flipping for cdf computation
62
+ if ( map.flipY ) {
63
+
64
+ const ogData = newData;
65
+ newData = newData.slice();
66
+ for ( let y = 0; y < height; y ++ ) {
67
+
68
+ for ( let x = 0; x < width; x ++ ) {
69
+
70
+ const newY = height - y - 1;
71
+ const ogIndex = 4 * ( y * width + x );
72
+ const newIndex = 4 * ( newY * width + x );
73
+
74
+ newData[ newIndex + 0 ] = ogData[ ogIndex + 0 ];
75
+ newData[ newIndex + 1 ] = ogData[ ogIndex + 1 ];
76
+ newData[ newIndex + 2 ] = ogData[ ogIndex + 2 ];
77
+ newData[ newIndex + 3 ] = ogData[ ogIndex + 3 ];
78
+
79
+ }
80
+
81
+ }
82
+
83
+ map.flipY = false;
84
+ map.image.data = newData;
85
+
86
+ }
87
+
88
+ return map;
89
+
90
+ }
91
+
92
+ export class EquirectHdrInfoUniform {
93
+
94
+ constructor() {
95
+
96
+ // Stores a map of [0, 1] value -> cumulative importance row & pdf
97
+ // used to sampling a random value to a relevant row to sample from
98
+ const marginalWeights = new DataTexture();
99
+ marginalWeights.type = FloatType;
100
+ marginalWeights.format = RedFormat;
101
+ marginalWeights.minFilter = LinearFilter;
102
+ marginalWeights.magFilter = LinearFilter;
103
+ marginalWeights.generateMipmaps = false;
104
+
105
+ // Stores a map of [0, 1] value -> cumulative importance column & pdf
106
+ // used to sampling a random value to a relevant pixel to sample from
107
+ const conditionalWeights = new DataTexture();
108
+ conditionalWeights.type = FloatType;
109
+ conditionalWeights.format = RedFormat;
110
+ conditionalWeights.minFilter = LinearFilter;
111
+ conditionalWeights.magFilter = LinearFilter;
112
+ conditionalWeights.generateMipmaps = false;
113
+
114
+ this.marginalWeights = marginalWeights;
115
+ this.conditionalWeights = conditionalWeights;
116
+ this.map = null;
117
+
118
+ // the total sum value is separated into two values to work around low precision
119
+ // storage of floating values in structs
120
+ this.totalSumWhole = 0;
121
+ this.totalSumDecimal = 0;
122
+
123
+ }
124
+
125
+ dispose() {
126
+
127
+ this.marginalWeights.dispose();
128
+ this.conditionalWeights.dispose();
129
+ if ( this.map ) this.map.dispose();
130
+
131
+ }
132
+
133
+ updateFrom( hdr ) {
134
+
135
+ // https://github.com/knightcrawler25/GLSL-PathTracer/blob/3c6fd9b6b3da47cd50c527eeb45845eef06c55c3/src/loaders/hdrloader.cpp
136
+ // https://pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Sampling_Light_Sources#InfiniteAreaLights
137
+ const map = preprocessEnvMap( hdr );
138
+ map.wrapS = RepeatWrapping;
139
+ map.wrapT = RepeatWrapping;
140
+
141
+ const { width, height, data } = map.image;
142
+
143
+ // "conditional" = "pixel relative to row pixels sum"
144
+ // "marginal" = "row relative to row sum"
145
+
146
+ // track the importance of any given pixel in the image by tracking its weight relative to other pixels in the image
147
+ const pdfConditional = new Float32Array( width * height );
148
+ const cdfConditional = new Float32Array( width * height );
149
+
150
+ const pdfMarginal = new Float32Array( height );
151
+ const cdfMarginal = new Float32Array( height );
152
+
153
+ let totalSumValue = 0.0;
154
+ let cumulativeWeightMarginal = 0.0;
155
+ for ( let y = 0; y < height; y ++ ) {
156
+
157
+ let cumulativeRowWeight = 0.0;
158
+ for ( let x = 0; x < width; x ++ ) {
159
+
160
+ const i = y * width + x;
161
+ const r = data[ 4 * i + 0 ];
162
+ const g = data[ 4 * i + 1 ];
163
+ const b = data[ 4 * i + 2 ];
164
+
165
+ // the probability of the pixel being selected in this row is the
166
+ // scale of the luminance relative to the rest of the pixels.
167
+ // TODO: this should also account for the solid angle of the pixel when sampling
168
+ const weight = colorToLuminance( r, g, b );
169
+ cumulativeRowWeight += weight;
170
+ totalSumValue += weight;
171
+
172
+ pdfConditional[ i ] = weight;
173
+ cdfConditional[ i ] = cumulativeRowWeight;
174
+
175
+ }
176
+
177
+ // can happen if the row is all black
178
+ if ( cumulativeRowWeight !== 0 ) {
179
+
180
+ // scale the pdf and cdf to [0.0, 1.0]
181
+ for ( let i = y * width, l = y * width + width; i < l; i ++ ) {
182
+
183
+ pdfConditional[ i ] /= cumulativeRowWeight;
184
+ cdfConditional[ i ] /= cumulativeRowWeight;
185
+
186
+ }
187
+
188
+ }
189
+
190
+ cumulativeWeightMarginal += cumulativeRowWeight;
191
+
192
+ // compute the marginal pdf and cdf along the height of the map.
193
+ pdfMarginal[ y ] = cumulativeRowWeight;
194
+ cdfMarginal[ y ] = cumulativeWeightMarginal;
195
+
196
+ }
197
+
198
+ // can happen if the texture is all black
199
+ if ( cumulativeWeightMarginal !== 0 ) {
200
+
201
+ // scale the marginal pdf and cdf to [0.0, 1.0]
202
+ for ( let i = 0, l = pdfMarginal.length; i < l; i ++ ) {
203
+
204
+ pdfMarginal[ i ] /= cumulativeWeightMarginal;
205
+ cdfMarginal[ i ] /= cumulativeWeightMarginal;
206
+
207
+ }
208
+
209
+ }
210
+
211
+ // compute a sorted index of distributions and the probabilities along them for both
212
+ // the marginal and conditional data. These will be used to sample with a random number
213
+ // to retrieve a uv value to sample in the environment map.
214
+ // These values continually increase so it's okay to interpolate between them.
215
+ const marginalDataArray = new Float32Array( height );
216
+ const conditionalDataArray = new Float32Array( width * height );
217
+
218
+ for ( let i = 0; i < height; i ++ ) {
219
+
220
+ const dist = ( i + 1 ) / height;
221
+ const row = binarySearchFindClosestIndexOf( cdfMarginal, dist );
222
+
223
+ marginalDataArray[ i ] = row / height;
224
+
225
+ }
226
+
227
+ for ( let y = 0; y < height; y ++ ) {
228
+
229
+ for ( let x = 0; x < width; x ++ ) {
230
+
231
+ const i = y * width + x;
232
+ const dist = ( x + 1 ) / width;
233
+ const col = binarySearchFindClosestIndexOf( cdfConditional, dist, y * width, width );
234
+
235
+ conditionalDataArray[ i ] = col / width;
236
+
237
+ }
238
+
239
+ }
240
+
241
+ this.dispose();
242
+
243
+ const { marginalWeights, conditionalWeights } = this;
244
+ marginalWeights.image = { width: height, height: 1, data: marginalDataArray };
245
+ marginalWeights.needsUpdate = true;
246
+
247
+ conditionalWeights.image = { width, height, data: conditionalDataArray };
248
+ conditionalWeights.needsUpdate = true;
249
+
250
+ const totalSumWhole = ~ ~ totalSumValue;
251
+ const totalSumDecimal = ( totalSumValue - totalSumWhole );
252
+ this.totalSumWhole = totalSumWhole;
253
+ this.totalSumDecimal = totalSumDecimal;
254
+
255
+ this.map = map;
256
+
257
+ }
258
+
259
+ }
@@ -0,0 +1,100 @@
1
+ import {
2
+ ClampToEdgeWrapping,
3
+ Color,
4
+ FloatType,
5
+ LinearFilter,
6
+ MeshBasicMaterial,
7
+ NoToneMapping,
8
+ RGBAFormat,
9
+ WebGLArrayRenderTarget,
10
+ } from 'three';
11
+ import { FullScreenQuad } from 'three/examples/jsm/postprocessing/Pass.js';
12
+ import { IESLoader } from '../utils/IESLoader.js';
13
+
14
+ const prevColor = new Color();
15
+ export class IESProfilesTexture extends WebGLArrayRenderTarget {
16
+
17
+ constructor( ...args ) {
18
+
19
+ super( ...args );
20
+
21
+ const tex = this.texture;
22
+ tex.format = RGBAFormat;
23
+ tex.type = FloatType;
24
+ tex.minFilter = LinearFilter;
25
+ tex.magFilter = LinearFilter;
26
+ tex.wrapS = ClampToEdgeWrapping;
27
+ tex.wrapT = ClampToEdgeWrapping;
28
+ tex.generateMipmaps = false;
29
+
30
+ tex.updateFrom = ( ...args ) => {
31
+
32
+ this.updateFrom( ...args );
33
+
34
+ };
35
+
36
+ const fsQuad = new FullScreenQuad( new MeshBasicMaterial() );
37
+ this.fsQuad = fsQuad;
38
+
39
+ this.iesLoader = new IESLoader();
40
+
41
+ }
42
+
43
+ async updateFrom( renderer, textures ) {
44
+
45
+ // save previous renderer state
46
+ const prevRenderTarget = renderer.getRenderTarget();
47
+ const prevToneMapping = renderer.toneMapping;
48
+ const prevAlpha = renderer.getClearAlpha();
49
+ renderer.getClearColor( prevColor );
50
+
51
+ // resize the render target and ensure we don't have an empty texture
52
+ // render target depth must be >= 1 to avoid unbound texture error on android devices
53
+ const depth = textures.length || 1;
54
+ this.setSize( 360, 180, depth );
55
+ renderer.setClearColor( 0, 0 );
56
+ renderer.toneMapping = NoToneMapping;
57
+
58
+ // render each texture into each layer of the target
59
+ const fsQuad = this.fsQuad;
60
+ for ( let i = 0, l = depth; i < l; i ++ ) {
61
+
62
+ const texture = textures[ i ];
63
+ if ( texture ) {
64
+
65
+ // revert to default texture transform before rendering
66
+ texture.matrixAutoUpdate = false;
67
+ texture.matrix.identity();
68
+
69
+ fsQuad.material.map = texture;
70
+ fsQuad.material.transparent = true;
71
+
72
+ renderer.setRenderTarget( this, i );
73
+ fsQuad.render( renderer );
74
+
75
+ // restore custom texture transform
76
+ texture.updateMatrix();
77
+ texture.matrixAutoUpdate = true;
78
+
79
+ }
80
+
81
+ }
82
+
83
+ // reset the renderer
84
+ fsQuad.material.map = null;
85
+ renderer.setClearColor( prevColor, prevAlpha );
86
+ renderer.setRenderTarget( prevRenderTarget );
87
+ renderer.toneMapping = prevToneMapping;
88
+
89
+ fsQuad.dispose();
90
+
91
+ }
92
+
93
+ dispose() {
94
+
95
+ super.dispose();
96
+ this.fsQuad.dispose();
97
+
98
+ }
99
+
100
+ }