@babylonjs/core 6.41.2 → 6.42.0
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.
- package/Culling/ray.d.ts +2 -2
- package/Culling/ray.js +3 -2
- package/Culling/ray.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Maths/halton2DSequence.d.ts +47 -0
- package/Maths/halton2DSequence.js +80 -0
- package/Maths/halton2DSequence.js.map +1 -0
- package/Maths/index.d.ts +1 -0
- package/Maths/index.js +1 -0
- package/Maths/index.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/index.d.ts +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.js +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.d.ts +111 -0
- package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js +295 -0
- package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js.map +1 -0
- package/Shaders/taa.fragment.d.ts +5 -0
- package/Shaders/taa.fragment.js +10 -0
- package/Shaders/taa.fragment.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class for generating 2D Halton sequences.
|
|
3
|
+
* From https://observablehq.com/@jrus/halton
|
|
4
|
+
*/
|
|
5
|
+
export declare class Halton2DSequence {
|
|
6
|
+
private _curIndex;
|
|
7
|
+
private _sequence;
|
|
8
|
+
private _numSamples;
|
|
9
|
+
private _width;
|
|
10
|
+
private _height;
|
|
11
|
+
private _baseX;
|
|
12
|
+
private _baseY;
|
|
13
|
+
/**
|
|
14
|
+
* The x coordinate of the current sample.
|
|
15
|
+
*/
|
|
16
|
+
readonly x = 0;
|
|
17
|
+
/**
|
|
18
|
+
* The y coordinate of the current sample.
|
|
19
|
+
*/
|
|
20
|
+
readonly y = 0;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new Halton2DSequence.
|
|
23
|
+
* @param numSamples Number of samples in the sequence.
|
|
24
|
+
* @param baseX The base for the x coordinate (default: 2).
|
|
25
|
+
* @param baseY The base for the y coordinate (default: 3).
|
|
26
|
+
* @param width Factor to scale the x coordinate by (default: 1). The scaling factor is 1/width.
|
|
27
|
+
* @param height Factor to scale the y coordinate by (default: 1). The scaling factor is 1/height.
|
|
28
|
+
*/
|
|
29
|
+
constructor(numSamples: number, baseX?: number, baseY?: number, width?: number, height?: number);
|
|
30
|
+
/**
|
|
31
|
+
* Regenerates the sequence with a new number of samples.
|
|
32
|
+
* @param numSamples Number of samples in the sequence.
|
|
33
|
+
*/
|
|
34
|
+
regenerate(numSamples: number): void;
|
|
35
|
+
/**
|
|
36
|
+
* Sets the dimensions of the sequence.
|
|
37
|
+
* @param width Factor to scale the x coordinate by. The scaling factor is 1/width.
|
|
38
|
+
* @param height Factor to scale the y coordinate by. The scaling factor is 1/height.
|
|
39
|
+
*/
|
|
40
|
+
setDimensions(width: number, height: number): void;
|
|
41
|
+
/**
|
|
42
|
+
* Advances to the next sample in the sequence.
|
|
43
|
+
*/
|
|
44
|
+
next(): void;
|
|
45
|
+
private _generateSequence;
|
|
46
|
+
private _halton;
|
|
47
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class for generating 2D Halton sequences.
|
|
3
|
+
* From https://observablehq.com/@jrus/halton
|
|
4
|
+
*/
|
|
5
|
+
export class Halton2DSequence {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new Halton2DSequence.
|
|
8
|
+
* @param numSamples Number of samples in the sequence.
|
|
9
|
+
* @param baseX The base for the x coordinate (default: 2).
|
|
10
|
+
* @param baseY The base for the y coordinate (default: 3).
|
|
11
|
+
* @param width Factor to scale the x coordinate by (default: 1). The scaling factor is 1/width.
|
|
12
|
+
* @param height Factor to scale the y coordinate by (default: 1). The scaling factor is 1/height.
|
|
13
|
+
*/
|
|
14
|
+
constructor(numSamples, baseX = 2, baseY = 3, width = 1, height = 1) {
|
|
15
|
+
this._curIndex = 0;
|
|
16
|
+
this._sequence = [];
|
|
17
|
+
this._numSamples = 0;
|
|
18
|
+
/**
|
|
19
|
+
* The x coordinate of the current sample.
|
|
20
|
+
*/
|
|
21
|
+
this.x = 0;
|
|
22
|
+
/**
|
|
23
|
+
* The y coordinate of the current sample.
|
|
24
|
+
*/
|
|
25
|
+
this.y = 0;
|
|
26
|
+
this._width = width;
|
|
27
|
+
this._height = height;
|
|
28
|
+
this._baseX = baseX;
|
|
29
|
+
this._baseY = baseY;
|
|
30
|
+
this._generateSequence(numSamples);
|
|
31
|
+
this.next();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Regenerates the sequence with a new number of samples.
|
|
35
|
+
* @param numSamples Number of samples in the sequence.
|
|
36
|
+
*/
|
|
37
|
+
regenerate(numSamples) {
|
|
38
|
+
this._generateSequence(numSamples);
|
|
39
|
+
this.next();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Sets the dimensions of the sequence.
|
|
43
|
+
* @param width Factor to scale the x coordinate by. The scaling factor is 1/width.
|
|
44
|
+
* @param height Factor to scale the y coordinate by. The scaling factor is 1/height.
|
|
45
|
+
*/
|
|
46
|
+
setDimensions(width, height) {
|
|
47
|
+
this._width = width;
|
|
48
|
+
this._height = height;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Advances to the next sample in the sequence.
|
|
52
|
+
*/
|
|
53
|
+
next() {
|
|
54
|
+
this.x = this._sequence[this._curIndex] / this._width;
|
|
55
|
+
this.y = this._sequence[this._curIndex + 1] / this._height;
|
|
56
|
+
this._curIndex += 2;
|
|
57
|
+
if (this._curIndex >= this._numSamples * 2) {
|
|
58
|
+
this._curIndex = 0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
_generateSequence(numSamples) {
|
|
62
|
+
this._sequence = [];
|
|
63
|
+
this._curIndex = 0;
|
|
64
|
+
this._numSamples = numSamples;
|
|
65
|
+
for (let i = 1; i <= numSamples; ++i) {
|
|
66
|
+
this._sequence.push(this._halton(i, this._baseX) - 0.5, this._halton(i, this._baseY) - 0.5);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
_halton(index, base) {
|
|
70
|
+
let fraction = 1;
|
|
71
|
+
let result = 0;
|
|
72
|
+
while (index > 0) {
|
|
73
|
+
fraction /= base;
|
|
74
|
+
result += fraction * (index % base);
|
|
75
|
+
index = ~~(index / base); // floor division
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=halton2DSequence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"halton2DSequence.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/halton2DSequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAmBzB;;;;;;;OAOG;IACH,YAAY,UAAkB,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC;QA1BnE,cAAS,GAAG,CAAC,CAAC;QACd,cAAS,GAAa,EAAE,CAAC;QACzB,gBAAW,GAAG,CAAC,CAAC;QAMxB;;WAEG;QACa,MAAC,GAAG,CAAC,CAAC;QAEtB;;WAEG;QACa,MAAC,GAAG,CAAC,CAAC;QAWlB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,UAAU,CAAC,UAAkB;QAChC,IAAI,CAAC,iB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O,KAAK,GAAG,CAAC,EAAE;YACd,QAAQ,IAAI,IAAI,CAAC;YACjB,MAAM,IAAI,QAAQ,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;YACpC,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,iBAAiB;SAC9C;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["/**\r\n * Class for generating 2D Halton sequences.\r\n * From https://observablehq.com/@jrus/halton\r\n */\r\nexport class Halton2DSequence {\r\n private _curIndex = 0;\r\n private _sequence: number[] = [];\r\n private _numSamples = 0;\r\n private _width: number;\r\n private _height: number;\r\n private _baseX;\r\n private _baseY;\r\n\r\n /**\r\n * The x coordinate of the current sample.\r\n */\r\n public readonly x = 0;\r\n\r\n /**\r\n * The y coordinate of the current sample.\r\n */\r\n public readonly y = 0;\r\n\r\n /**\r\n * Creates a new Halton2DSequence.\r\n * @param numSamples Number of samples in the sequence.\r\n * @param baseX The base for the x coordinate (default: 2).\r\n * @param baseY The base for the y coordinate (default: 3).\r\n * @param width Factor to scale the x coordinate by (default: 1). The scaling factor is 1/width.\r\n * @param height Factor to scale the y coordinate by (default: 1). The scaling factor is 1/height.\r\n */\r\n constructor(numSamples: number, baseX = 2, baseY = 3, width = 1, height = 1) {\r\n this._width = width;\r\n this._height = height;\r\n this._baseX = baseX;\r\n this._baseY = baseY;\r\n\r\n this._generateSequence(numSamples);\r\n this.next();\r\n }\r\n\r\n /**\r\n * Regenerates the sequence with a new number of samples.\r\n * @param numSamples Number of samples in the sequence.\r\n */\r\n public regenerate(numSamples: number) {\r\n this._generateSequence(numSamples);\r\n this.next();\r\n }\r\n\r\n /**\r\n * Sets the dimensions of the sequence.\r\n * @param width Factor to scale the x coordinate by. The scaling factor is 1/width.\r\n * @param height Factor to scale the y coordinate by. The scaling factor is 1/height.\r\n */\r\n public setDimensions(width: number, height: number) {\r\n this._width = width;\r\n this._height = height;\r\n }\r\n\r\n /**\r\n * Advances to the next sample in the sequence.\r\n */\r\n public next() {\r\n (this.x as number) = this._sequence[this._curIndex] / this._width;\r\n (this.y as number) = this._sequence[this._curIndex + 1] / this._height;\r\n\r\n this._curIndex += 2;\r\n\r\n if (this._curIndex >= this._numSamples * 2) {\r\n this._curIndex = 0;\r\n }\r\n }\r\n\r\n private _generateSequence(numSamples: number) {\r\n this._sequence = [];\r\n this._curIndex = 0;\r\n this._numSamples = numSamples;\r\n\r\n for (let i = 1; i <= numSamples; ++i) {\r\n this._sequence.push(this._halton(i, this._baseX) - 0.5, this._halton(i, this._baseY) - 0.5);\r\n }\r\n }\r\n\r\n private _halton(index: number, base: number) {\r\n let fraction = 1;\r\n let result = 0;\r\n while (index > 0) {\r\n fraction /= base;\r\n result += fraction * (index % base);\r\n index = ~~(index / base); // floor division\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
|
package/Maths/index.d.ts
CHANGED
package/Maths/index.js
CHANGED
package/Maths/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,uBAAuB,CAAC","sourcesContent":["export * from \"./math.scalar\";\r\nexport * from \"./math.functions\";\r\nexport * from \"./math.polar\";\r\nexport * from \"./math\";\r\nexport * from \"./sphericalPolynomial\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./math.scalar\";\r\nexport * from \"./math.functions\";\r\nexport * from \"./math.polar\";\r\nexport * from \"./math\";\r\nexport * from \"./sphericalPolynomial\";\r\nexport * from \"./halton2DSequence\";\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/core/src/PostProcesses/RenderPipeline/Pipelines/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC","sourcesContent":["export * from \"./defaultRenderingPipeline\";\r\nexport * from \"./lensRenderingPipeline\";\r\nexport * from \"./ssao2RenderingPipeline\";\r\nexport * from \"./ssaoRenderingPipeline\";\r\nexport * from \"./standardRenderingPipeline\";\r\nexport * from \"./ssrRenderingPipeline\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/core/src/PostProcesses/RenderPipeline/Pipelines/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC","sourcesContent":["export * from \"./defaultRenderingPipeline\";\r\nexport * from \"./lensRenderingPipeline\";\r\nexport * from \"./ssao2RenderingPipeline\";\r\nexport * from \"./ssaoRenderingPipeline\";\r\nexport * from \"./standardRenderingPipeline\";\r\nexport * from \"./ssrRenderingPipeline\";\r\nexport * from \"./taaRenderingPipeline\";\r\n"]}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Camera } from "../../../Cameras/camera";
|
|
2
|
+
import { PostProcessRenderPipeline } from "../postProcessRenderPipeline";
|
|
3
|
+
import type { Scene } from "../../../scene";
|
|
4
|
+
import "../postProcessRenderPipelineManagerSceneComponent";
|
|
5
|
+
import "../../../Shaders/taa.fragment";
|
|
6
|
+
/**
|
|
7
|
+
* Simple implementation of Temporal Anti-Aliasing (TAA).
|
|
8
|
+
* This can be used to improve image quality for still pictures (screenshots for e.g.).
|
|
9
|
+
*/
|
|
10
|
+
export declare class TAARenderingPipeline extends PostProcessRenderPipeline {
|
|
11
|
+
/**
|
|
12
|
+
* The TAA PostProcess effect id in the pipeline
|
|
13
|
+
*/
|
|
14
|
+
TAARenderEffect: string;
|
|
15
|
+
/**
|
|
16
|
+
* The pass PostProcess effect id in the pipeline
|
|
17
|
+
*/
|
|
18
|
+
TAAPassEffect: string;
|
|
19
|
+
private _samples;
|
|
20
|
+
/**
|
|
21
|
+
* Number of accumulated samples (default: 16)
|
|
22
|
+
*/
|
|
23
|
+
set samples(samples: number);
|
|
24
|
+
get samples(): number;
|
|
25
|
+
private _msaaSamples;
|
|
26
|
+
/**
|
|
27
|
+
* MSAA samples (default: 1)
|
|
28
|
+
*/
|
|
29
|
+
set msaaSamples(samples: number);
|
|
30
|
+
get msaaSamples(): number;
|
|
31
|
+
/**
|
|
32
|
+
* The factor used to blend the history frame with current frame (default: 0.05)
|
|
33
|
+
*/
|
|
34
|
+
factor: number;
|
|
35
|
+
/**
|
|
36
|
+
* Disable TAA on camera move (default: true).
|
|
37
|
+
* You generally want to keep this enabled, otherwise you will get a ghost effect when the camera moves (but if it's what you want, go for it!)
|
|
38
|
+
*/
|
|
39
|
+
disableOnCameraMove: boolean;
|
|
40
|
+
private _isEnabled;
|
|
41
|
+
/**
|
|
42
|
+
* Gets or sets a boolean indicating if the render pipeline is enabled (default: true).
|
|
43
|
+
*/
|
|
44
|
+
get isEnabled(): boolean;
|
|
45
|
+
set isEnabled(value: boolean);
|
|
46
|
+
/**
|
|
47
|
+
* Gets active scene
|
|
48
|
+
*/
|
|
49
|
+
get scene(): Scene;
|
|
50
|
+
private _scene;
|
|
51
|
+
private _isDirty;
|
|
52
|
+
private _camerasToBeAttached;
|
|
53
|
+
private _textureType;
|
|
54
|
+
private _taaPostProcess;
|
|
55
|
+
private _passPostProcess;
|
|
56
|
+
private _ping;
|
|
57
|
+
private _pong;
|
|
58
|
+
private _pingpong;
|
|
59
|
+
private _hs;
|
|
60
|
+
private _firstUpdate;
|
|
61
|
+
/**
|
|
62
|
+
* Returns true if TAA is supported by the running hardware
|
|
63
|
+
*/
|
|
64
|
+
get isSupported(): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Constructor of the TAA rendering pipeline
|
|
67
|
+
* @param name The rendering pipeline name
|
|
68
|
+
* @param scene The scene linked to this pipeline
|
|
69
|
+
* @param cameras The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
|
|
70
|
+
* @param textureType The type of texture where the scene will be rendered (default: Constants.TEXTURETYPE_UNSIGNED_BYTE)
|
|
71
|
+
*/
|
|
72
|
+
constructor(name: string, scene: Scene, cameras?: Camera[], textureType?: number);
|
|
73
|
+
/**
|
|
74
|
+
* Get the class name
|
|
75
|
+
* @returns "TAARenderingPipeline"
|
|
76
|
+
*/
|
|
77
|
+
getClassName(): string;
|
|
78
|
+
/**
|
|
79
|
+
* Adds a camera to the pipeline
|
|
80
|
+
* @param camera the camera to be added
|
|
81
|
+
*/
|
|
82
|
+
addCamera(camera: Camera): void;
|
|
83
|
+
/**
|
|
84
|
+
* Removes a camera from the pipeline
|
|
85
|
+
* @param camera the camera to remove
|
|
86
|
+
*/
|
|
87
|
+
removeCamera(camera: Camera): void;
|
|
88
|
+
/**
|
|
89
|
+
* Removes the internal pipeline assets and detaches the pipeline from the scene cameras
|
|
90
|
+
*/
|
|
91
|
+
dispose(): void;
|
|
92
|
+
private _createPingPongTextures;
|
|
93
|
+
private _updateEffectDefines;
|
|
94
|
+
private _buildPipeline;
|
|
95
|
+
private _disposePostProcesses;
|
|
96
|
+
private _createTAAPostProcess;
|
|
97
|
+
private _createPassPostProcess;
|
|
98
|
+
/**
|
|
99
|
+
* Serializes the rendering pipeline (Used when exporting)
|
|
100
|
+
* @returns the serialized object
|
|
101
|
+
*/
|
|
102
|
+
serialize(): any;
|
|
103
|
+
/**
|
|
104
|
+
* Parse the serialized pipeline
|
|
105
|
+
* @param source Source pipeline.
|
|
106
|
+
* @param scene The scene to load the pipeline to.
|
|
107
|
+
* @param rootUrl The URL of the serialized pipeline.
|
|
108
|
+
* @returns An instantiated pipeline from the serialized object.
|
|
109
|
+
*/
|
|
110
|
+
static Parse(source: any, scene: Scene, rootUrl: string): TAARenderingPipeline;
|
|
111
|
+
}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { __decorate } from "../../../tslib.es6.js";
|
|
2
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
|
+
import { serialize, SerializationHelper } from "../../../Misc/decorators.js";
|
|
4
|
+
import { PostProcess } from "../../postProcess.js";
|
|
5
|
+
import { PostProcessRenderPipeline } from "../postProcessRenderPipeline.js";
|
|
6
|
+
import { PostProcessRenderEffect } from "../postProcessRenderEffect.js";
|
|
7
|
+
import { RegisterClass } from "../../../Misc/typeStore.js";
|
|
8
|
+
|
|
9
|
+
import { PassPostProcess } from "../../passPostProcess.js";
|
|
10
|
+
import { Halton2DSequence } from "../../../Maths/halton2DSequence.js";
|
|
11
|
+
import "../postProcessRenderPipelineManagerSceneComponent.js";
|
|
12
|
+
import "../../../Shaders/taa.fragment.js";
|
|
13
|
+
/**
|
|
14
|
+
* Simple implementation of Temporal Anti-Aliasing (TAA).
|
|
15
|
+
* This can be used to improve image quality for still pictures (screenshots for e.g.).
|
|
16
|
+
*/
|
|
17
|
+
export class TAARenderingPipeline extends PostProcessRenderPipeline {
|
|
18
|
+
/**
|
|
19
|
+
* Number of accumulated samples (default: 16)
|
|
20
|
+
*/
|
|
21
|
+
set samples(samples) {
|
|
22
|
+
if (this._samples === samples) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
this._samples = samples;
|
|
26
|
+
this._hs.regenerate(samples);
|
|
27
|
+
}
|
|
28
|
+
get samples() {
|
|
29
|
+
return this._samples;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* MSAA samples (default: 1)
|
|
33
|
+
*/
|
|
34
|
+
set msaaSamples(samples) {
|
|
35
|
+
if (this._msaaSamples === samples) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this._msaaSamples = samples;
|
|
39
|
+
if (this._taaPostProcess) {
|
|
40
|
+
this._taaPostProcess.samples = samples;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
get msaaSamples() {
|
|
44
|
+
return this._msaaSamples;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Gets or sets a boolean indicating if the render pipeline is enabled (default: true).
|
|
48
|
+
*/
|
|
49
|
+
get isEnabled() {
|
|
50
|
+
return this._isEnabled;
|
|
51
|
+
}
|
|
52
|
+
set isEnabled(value) {
|
|
53
|
+
if (this._isEnabled === value) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this._isEnabled = value;
|
|
57
|
+
if (!value) {
|
|
58
|
+
if (this._cameras !== null) {
|
|
59
|
+
this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
|
|
60
|
+
this._cameras = this._camerasToBeAttached.slice();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else if (value) {
|
|
64
|
+
if (!this._isDirty) {
|
|
65
|
+
if (this._cameras !== null) {
|
|
66
|
+
this._firstUpdate = true;
|
|
67
|
+
this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this._buildPipeline();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Gets active scene
|
|
77
|
+
*/
|
|
78
|
+
get scene() {
|
|
79
|
+
return this._scene;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Returns true if TAA is supported by the running hardware
|
|
83
|
+
*/
|
|
84
|
+
get isSupported() {
|
|
85
|
+
const caps = this._scene.getEngine().getCaps();
|
|
86
|
+
return caps.texelFetch;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Constructor of the TAA rendering pipeline
|
|
90
|
+
* @param name The rendering pipeline name
|
|
91
|
+
* @param scene The scene linked to this pipeline
|
|
92
|
+
* @param cameras The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
|
|
93
|
+
* @param textureType The type of texture where the scene will be rendered (default: 0)
|
|
94
|
+
*/
|
|
95
|
+
constructor(name, scene, cameras, textureType = 0) {
|
|
96
|
+
const engine = scene.getEngine();
|
|
97
|
+
super(engine, name);
|
|
98
|
+
/**
|
|
99
|
+
* The TAA PostProcess effect id in the pipeline
|
|
100
|
+
*/
|
|
101
|
+
this.TAARenderEffect = "TAARenderEffect";
|
|
102
|
+
/**
|
|
103
|
+
* The pass PostProcess effect id in the pipeline
|
|
104
|
+
*/
|
|
105
|
+
this.TAAPassEffect = "TAAPassEffect";
|
|
106
|
+
this._samples = 8;
|
|
107
|
+
this._msaaSamples = 1;
|
|
108
|
+
/**
|
|
109
|
+
* The factor used to blend the history frame with current frame (default: 0.05)
|
|
110
|
+
*/
|
|
111
|
+
this.factor = 0.05;
|
|
112
|
+
/**
|
|
113
|
+
* Disable TAA on camera move (default: true).
|
|
114
|
+
* You generally want to keep this enabled, otherwise you will get a ghost effect when the camera moves (but if it's what you want, go for it!)
|
|
115
|
+
*/
|
|
116
|
+
this.disableOnCameraMove = true;
|
|
117
|
+
this._isEnabled = true;
|
|
118
|
+
this._isDirty = false;
|
|
119
|
+
this._camerasToBeAttached = [];
|
|
120
|
+
this._pingpong = 0;
|
|
121
|
+
this._firstUpdate = true;
|
|
122
|
+
this._cameras = cameras || scene.cameras;
|
|
123
|
+
this._cameras = this._cameras.slice();
|
|
124
|
+
this._camerasToBeAttached = this._cameras.slice();
|
|
125
|
+
this._scene = scene;
|
|
126
|
+
this._textureType = textureType;
|
|
127
|
+
this._hs = new Halton2DSequence(this.samples);
|
|
128
|
+
if (this.isSupported) {
|
|
129
|
+
this._createPingPongTextures(engine.getRenderWidth(), engine.getRenderHeight());
|
|
130
|
+
scene.postProcessRenderPipelineManager.addPipeline(this);
|
|
131
|
+
this._buildPipeline();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Get the class name
|
|
136
|
+
* @returns "TAARenderingPipeline"
|
|
137
|
+
*/
|
|
138
|
+
getClassName() {
|
|
139
|
+
return "TAARenderingPipeline";
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Adds a camera to the pipeline
|
|
143
|
+
* @param camera the camera to be added
|
|
144
|
+
*/
|
|
145
|
+
addCamera(camera) {
|
|
146
|
+
this._camerasToBeAttached.push(camera);
|
|
147
|
+
this._buildPipeline();
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Removes a camera from the pipeline
|
|
151
|
+
* @param camera the camera to remove
|
|
152
|
+
*/
|
|
153
|
+
removeCamera(camera) {
|
|
154
|
+
const index = this._camerasToBeAttached.indexOf(camera);
|
|
155
|
+
this._camerasToBeAttached.splice(index, 1);
|
|
156
|
+
this._buildPipeline();
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Removes the internal pipeline assets and detaches the pipeline from the scene cameras
|
|
160
|
+
*/
|
|
161
|
+
dispose() {
|
|
162
|
+
this._disposePostProcesses();
|
|
163
|
+
this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
|
|
164
|
+
this._ping.dispose();
|
|
165
|
+
this._pong.dispose();
|
|
166
|
+
super.dispose();
|
|
167
|
+
}
|
|
168
|
+
_createPingPongTextures(width, height) {
|
|
169
|
+
const engine = this._scene.getEngine();
|
|
170
|
+
this._ping?.dispose();
|
|
171
|
+
this._pong?.dispose();
|
|
172
|
+
this._ping = engine.createRenderTargetTexture({ width, height }, { generateMipMaps: false, generateDepthBuffer: false, type: 2, samplingMode: 1 });
|
|
173
|
+
this._pong = engine.createRenderTargetTexture({ width, height }, { generateMipMaps: false, generateDepthBuffer: false, type: 2, samplingMode: 1 });
|
|
174
|
+
this._hs.setDimensions(width / 2, height / 2);
|
|
175
|
+
this._firstUpdate = true;
|
|
176
|
+
}
|
|
177
|
+
_updateEffectDefines() {
|
|
178
|
+
const defines = [];
|
|
179
|
+
this._taaPostProcess?.updateEffect(defines.join("\n"));
|
|
180
|
+
}
|
|
181
|
+
_buildPipeline() {
|
|
182
|
+
if (!this.isSupported) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (!this._isEnabled) {
|
|
186
|
+
this._isDirty = true;
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
this._isDirty = false;
|
|
190
|
+
const engine = this._scene.getEngine();
|
|
191
|
+
this._disposePostProcesses();
|
|
192
|
+
if (this._cameras !== null) {
|
|
193
|
+
this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
|
|
194
|
+
// get back cameras to be used to reattach pipeline
|
|
195
|
+
this._cameras = this._camerasToBeAttached.slice();
|
|
196
|
+
}
|
|
197
|
+
this._reset();
|
|
198
|
+
this._createTAAPostProcess();
|
|
199
|
+
this.addEffect(new PostProcessRenderEffect(engine, this.TAARenderEffect, () => {
|
|
200
|
+
return this._taaPostProcess;
|
|
201
|
+
}, true));
|
|
202
|
+
this._createPassPostProcess();
|
|
203
|
+
this.addEffect(new PostProcessRenderEffect(engine, this.TAAPassEffect, () => {
|
|
204
|
+
return this._passPostProcess;
|
|
205
|
+
}, true));
|
|
206
|
+
if (this._cameras !== null) {
|
|
207
|
+
this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
_disposePostProcesses() {
|
|
211
|
+
for (let i = 0; i < this._cameras.length; i++) {
|
|
212
|
+
const camera = this._cameras[i];
|
|
213
|
+
this._taaPostProcess?.dispose(camera);
|
|
214
|
+
this._passPostProcess?.dispose(camera);
|
|
215
|
+
camera.getProjectionMatrix(true); // recompute the projection matrix
|
|
216
|
+
}
|
|
217
|
+
this._taaPostProcess = null;
|
|
218
|
+
this._passPostProcess = null;
|
|
219
|
+
}
|
|
220
|
+
_createTAAPostProcess() {
|
|
221
|
+
this._taaPostProcess = new PostProcess("TAA", "taa", {
|
|
222
|
+
uniforms: ["factor"],
|
|
223
|
+
samplers: ["historySampler"],
|
|
224
|
+
size: 1.0,
|
|
225
|
+
engine: this._scene.getEngine(),
|
|
226
|
+
textureType: this._textureType,
|
|
227
|
+
});
|
|
228
|
+
this._taaPostProcess.samples = this._msaaSamples;
|
|
229
|
+
this._updateEffectDefines();
|
|
230
|
+
this._taaPostProcess.onActivateObservable.add(() => {
|
|
231
|
+
const camera = this._scene.activeCamera;
|
|
232
|
+
if (this._taaPostProcess?.width !== this._ping.width || this._taaPostProcess?.height !== this._ping.height) {
|
|
233
|
+
const engine = this._scene.getEngine();
|
|
234
|
+
this._createPingPongTextures(engine.getRenderWidth(), engine.getRenderHeight());
|
|
235
|
+
}
|
|
236
|
+
if (camera && !camera.hasMoved) {
|
|
237
|
+
const projMat = camera.getProjectionMatrix();
|
|
238
|
+
projMat.setRowFromFloats(2, this._hs.x, this._hs.y, projMat.m[10], projMat.m[11]);
|
|
239
|
+
}
|
|
240
|
+
if (this._passPostProcess) {
|
|
241
|
+
this._passPostProcess.inputTexture = this._pingpong ? this._ping : this._pong;
|
|
242
|
+
}
|
|
243
|
+
this._pingpong = this._pingpong ^ 1;
|
|
244
|
+
this._hs.next();
|
|
245
|
+
});
|
|
246
|
+
this._taaPostProcess.onApplyObservable.add((effect) => {
|
|
247
|
+
const camera = this._scene.activeCamera;
|
|
248
|
+
effect._bindTexture("historySampler", this._pingpong ? this._ping.texture : this._pong.texture);
|
|
249
|
+
effect.setFloat("factor", (camera?.hasMoved && this.disableOnCameraMove) || this._firstUpdate ? 1 : this.factor);
|
|
250
|
+
this._firstUpdate = false;
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
_createPassPostProcess() {
|
|
254
|
+
const engine = this._scene.getEngine();
|
|
255
|
+
this._passPostProcess = new PassPostProcess("TAAPass", 1, null, 1, engine);
|
|
256
|
+
this._passPostProcess.inputTexture = this._ping;
|
|
257
|
+
this._passPostProcess.autoClear = false;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Serializes the rendering pipeline (Used when exporting)
|
|
261
|
+
* @returns the serialized object
|
|
262
|
+
*/
|
|
263
|
+
serialize() {
|
|
264
|
+
const serializationObject = SerializationHelper.Serialize(this);
|
|
265
|
+
serializationObject.customType = "TAARenderingPipeline";
|
|
266
|
+
return serializationObject;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Parse the serialized pipeline
|
|
270
|
+
* @param source Source pipeline.
|
|
271
|
+
* @param scene The scene to load the pipeline to.
|
|
272
|
+
* @param rootUrl The URL of the serialized pipeline.
|
|
273
|
+
* @returns An instantiated pipeline from the serialized object.
|
|
274
|
+
*/
|
|
275
|
+
static Parse(source, scene, rootUrl) {
|
|
276
|
+
return SerializationHelper.Parse(() => new TAARenderingPipeline(source._name, scene, source._ratio), source, scene, rootUrl);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
__decorate([
|
|
280
|
+
serialize("samples")
|
|
281
|
+
], TAARenderingPipeline.prototype, "_samples", void 0);
|
|
282
|
+
__decorate([
|
|
283
|
+
serialize("msaaSamples")
|
|
284
|
+
], TAARenderingPipeline.prototype, "_msaaSamples", void 0);
|
|
285
|
+
__decorate([
|
|
286
|
+
serialize()
|
|
287
|
+
], TAARenderingPipeline.prototype, "factor", void 0);
|
|
288
|
+
__decorate([
|
|
289
|
+
serialize()
|
|
290
|
+
], TAARenderingPipeline.prototype, "disableOnCameraMove", void 0);
|
|
291
|
+
__decorate([
|
|
292
|
+
serialize("isEnabled")
|
|
293
|
+
], TAARenderingPipeline.prototype, "_isEnabled", void 0);
|
|
294
|
+
RegisterClass("BABYLON.TAARenderingPipeline", TAARenderingPipeline);
|
|
295
|
+
//# sourceMappingURL=taaRenderingPipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taaRenderingPipeline.js","sourceRoot":"","sources":["../../../../../../dev/core/src/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.ts"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG1E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,iCAA2C;AAErE,OAAO,EAAE,gBAAgB,EAAE,2CAAoC;AAE/D,OAAO,mDAAmD,CAAC;AAE3D,OAAO,+BAA+B,CAAC;AAEvC;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,yBAAyB;IAY/D;;OAEG;IACH,IAAW,OAAO,CAAC,OAAe;QAC9B,IAAI,IAAI,CAAC,QAAQ,KAAK,OAAO,EAAE;YAC3B,OAAO;SACV;QAED,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAID;;OAEG;IACH,IAAW,WAAW,CAAC,OAAe;QAClC,IAAI,IAAI,CAAC,YAAY,KAAK,OAAO,EAAE;YAC/B,OAAO;SACV;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BAAsB,CAAC;QAExD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,MAAW,EAAE,KAAY,EAAE,OAAe;QAC1D,OAAO,mBAAmB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,oBAAoB,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACjI,CAAC;CACJ;AAxVW;IADP,SAAS,CAAC,SAAS,CAAC;sDACA;AAkBb;IADP,SAAS,CAAC,aAAa,CAAC;0DACA;AAuBlB;IADN,SAAS,EAAE;oDACS;AAOd;IADN,SAAS,EAAE;iEACsB;AAG1B;IADP,SAAS,CAAC,WAAW,CAAC;wDACG;AAuS9B,aAAa,CAAC,8BAA8B,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { serialize, SerializationHelper } from \"../../../Misc/decorators\";\r\nimport type { Camera } from \"../../../Cameras/camera\";\r\nimport type { Effect } from \"../../../Materials/effect\";\r\nimport { PostProcess } from \"../../postProcess\";\r\nimport { PostProcessRenderPipeline } from \"../postProcessRenderPipeline\";\r\nimport { PostProcessRenderEffect } from \"../postProcessRenderEffect\";\r\nimport type { Scene } from \"../../../scene\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { Constants } from \"../../../Engines/constants\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { PassPostProcess } from \"core/PostProcesses/passPostProcess\";\r\nimport type { RenderTargetWrapper } from \"core/Engines/renderTargetWrapper\";\r\nimport { Halton2DSequence } from \"core/Maths/halton2DSequence\";\r\n\r\nimport \"../postProcessRenderPipelineManagerSceneComponent\";\r\n\r\nimport \"../../../Shaders/taa.fragment\";\r\n\r\n/**\r\n * Simple implementation of Temporal Anti-Aliasing (TAA).\r\n * This can be used to improve image quality for still pictures (screenshots for e.g.).\r\n */\r\nexport class TAARenderingPipeline extends PostProcessRenderPipeline {\r\n /**\r\n * The TAA PostProcess effect id in the pipeline\r\n */\r\n public TAARenderEffect: string = \"TAARenderEffect\";\r\n /**\r\n * The pass PostProcess effect id in the pipeline\r\n */\r\n public TAAPassEffect: string = \"TAAPassEffect\";\r\n\r\n @serialize(\"samples\")\r\n private _samples = 8;\r\n /**\r\n * Number of accumulated samples (default: 16)\r\n */\r\n public set samples(samples: number) {\r\n if (this._samples === samples) {\r\n return;\r\n }\r\n\r\n this._samples = samples;\r\n this._hs.regenerate(samples);\r\n }\r\n\r\n public get samples(): number {\r\n return this._samples;\r\n }\r\n\r\n @serialize(\"msaaSamples\")\r\n private _msaaSamples = 1;\r\n /**\r\n * MSAA samples (default: 1)\r\n */\r\n public set msaaSamples(samples: number) {\r\n if (this._msaaSamples === samples) {\r\n return;\r\n }\r\n\r\n this._msaaSamples = samples;\r\n if (this._taaPostProcess) {\r\n this._taaPostProcess.samples = samples;\r\n }\r\n }\r\n\r\n public get msaaSamples(): number {\r\n return this._msaaSamples;\r\n }\r\n\r\n /**\r\n * The factor used to blend the history frame with current frame (default: 0.05)\r\n */\r\n @serialize()\r\n public factor = 0.05;\r\n\r\n /**\r\n * Disable TAA on camera move (default: true).\r\n * You generally want to keep this enabled, otherwise you will get a ghost effect when the camera moves (but if it's what you want, go for it!)\r\n */\r\n @serialize()\r\n public disableOnCameraMove = true;\r\n\r\n @serialize(\"isEnabled\")\r\n private _isEnabled = true;\r\n /**\r\n * Gets or sets a boolean indicating if the render pipeline is enabled (default: true).\r\n */\r\n public get isEnabled(): boolean {\r\n return this._isEnabled;\r\n }\r\n\r\n public set isEnabled(value: boolean) {\r\n if (this._isEnabled === value) {\r\n return;\r\n }\r\n\r\n this._isEnabled = value;\r\n\r\n if (!value) {\r\n if (this._cameras !== null) {\r\n this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);\r\n this._cameras = this._camerasToBeAttached.slice();\r\n }\r\n } else if (value) {\r\n if (!this._isDirty) {\r\n if (this._cameras !== null) {\r\n this._firstUpdate = true;\r\n this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);\r\n }\r\n } else {\r\n this._buildPipeline();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets active scene\r\n */\r\n public get scene(): Scene {\r\n return this._scene;\r\n }\r\n\r\n private _scene: Scene;\r\n private _isDirty = false;\r\n private _camerasToBeAttached: Array<Camera> = [];\r\n private _textureType: number;\r\n private _taaPostProcess: Nullable<PostProcess>;\r\n private _passPostProcess: Nullable<PassPostProcess>;\r\n private _ping: RenderTargetWrapper;\r\n private _pong: RenderTargetWrapper;\r\n private _pingpong = 0;\r\n private _hs: Halton2DSequence;\r\n private _firstUpdate = true;\r\n\r\n /**\r\n * Returns true if TAA is supported by the running hardware\r\n */\r\n public get isSupported(): boolean {\r\n const caps = this._scene.getEngine().getCaps();\r\n\r\n return caps.texelFetch;\r\n }\r\n\r\n /**\r\n * Constructor of the TAA rendering pipeline\r\n * @param name The rendering pipeline name\r\n * @param scene The scene linked to this pipeline\r\n * @param cameras The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)\r\n * @param textureType The type of texture where the scene will be rendered (default: Constants.TEXTURETYPE_UNSIGNED_BYTE)\r\n */\r\n constructor(name: string, scene: Scene, cameras?: Camera[], textureType = Constants.TEXTURETYPE_UNSIGNED_BYTE) {\r\n const engine = scene.getEngine();\r\n\r\n super(engine, name);\r\n\r\n this._cameras = cameras || scene.cameras;\r\n this._cameras = this._cameras.slice();\r\n this._camerasToBeAttached = this._cameras.slice();\r\n\r\n this._scene = scene;\r\n this._textureType = textureType;\r\n this._hs = new Halton2DSequence(this.samples);\r\n\r\n if (this.isSupported) {\r\n this._createPingPongTextures(engine.getRenderWidth(), engine.getRenderHeight());\r\n\r\n scene.postProcessRenderPipelineManager.addPipeline(this);\r\n\r\n this._buildPipeline();\r\n }\r\n }\r\n\r\n /**\r\n * Get the class name\r\n * @returns \"TAARenderingPipeline\"\r\n */\r\n public getClassName(): string {\r\n return \"TAARenderingPipeline\";\r\n }\r\n\r\n /**\r\n * Adds a camera to the pipeline\r\n * @param camera the camera to be added\r\n */\r\n public addCamera(camera: Camera): void {\r\n this._camerasToBeAttached.push(camera);\r\n this._buildPipeline();\r\n }\r\n\r\n /**\r\n * Removes a camera from the pipeline\r\n * @param camera the camera to remove\r\n */\r\n public removeCamera(camera: Camera): void {\r\n const index = this._camerasToBeAttached.indexOf(camera);\r\n this._camerasToBeAttached.splice(index, 1);\r\n this._buildPipeline();\r\n }\r\n\r\n /**\r\n * Removes the internal pipeline assets and detaches the pipeline from the scene cameras\r\n */\r\n public dispose(): void {\r\n this._disposePostProcesses();\r\n\r\n this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);\r\n\r\n this._ping.dispose();\r\n this._pong.dispose();\r\n\r\n super.dispose();\r\n }\r\n\r\n private _createPingPongTextures(width: number, height: number) {\r\n const engine = this._scene.getEngine();\r\n\r\n this._ping?.dispose();\r\n this._pong?.dispose();\r\n\r\n this._ping = engine.createRenderTargetTexture(\r\n { width, height },\r\n { generateMipMaps: false, generateDepthBuffer: false, type: Constants.TEXTURETYPE_HALF_FLOAT, samplingMode: Constants.TEXTURE_NEAREST_NEAREST }\r\n );\r\n\r\n this._pong = engine.createRenderTargetTexture(\r\n { width, height },\r\n { generateMipMaps: false, generateDepthBuffer: false, type: Constants.TEXTURETYPE_HALF_FLOAT, samplingMode: Constants.TEXTURE_NEAREST_NEAREST }\r\n );\r\n\r\n this._hs.setDimensions(width / 2, height / 2);\r\n this._firstUpdate = true;\r\n }\r\n\r\n private _updateEffectDefines(): void {\r\n const defines: string[] = [];\r\n\r\n this._taaPostProcess?.updateEffect(defines.join(\"\\n\"));\r\n }\r\n\r\n private _buildPipeline() {\r\n if (!this.isSupported) {\r\n return;\r\n }\r\n\r\n if (!this._isEnabled) {\r\n this._isDirty = true;\r\n return;\r\n }\r\n\r\n this._isDirty = false;\r\n\r\n const engine = this._scene.getEngine();\r\n\r\n this._disposePostProcesses();\r\n if (this._cameras !== null) {\r\n this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);\r\n // get back cameras to be used to reattach pipeline\r\n this._cameras = this._camerasToBeAttached.slice();\r\n }\r\n this._reset();\r\n\r\n this._createTAAPostProcess();\r\n this.addEffect(\r\n new PostProcessRenderEffect(\r\n engine,\r\n this.TAARenderEffect,\r\n () => {\r\n return this._taaPostProcess;\r\n },\r\n true\r\n )\r\n );\r\n\r\n this._createPassPostProcess();\r\n this.addEffect(\r\n new PostProcessRenderEffect(\r\n engine,\r\n this.TAAPassEffect,\r\n () => {\r\n return this._passPostProcess;\r\n },\r\n true\r\n )\r\n );\r\n\r\n if (this._cameras !== null) {\r\n this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);\r\n }\r\n }\r\n\r\n private _disposePostProcesses(): void {\r\n for (let i = 0; i < this._cameras.length; i++) {\r\n const camera = this._cameras[i];\r\n\r\n this._taaPostProcess?.dispose(camera);\r\n this._passPostProcess?.dispose(camera);\r\n\r\n camera.getProjectionMatrix(true); // recompute the projection matrix\r\n }\r\n\r\n this._taaPostProcess = null;\r\n this._passPostProcess = null;\r\n }\r\n\r\n private _createTAAPostProcess(): void {\r\n this._taaPostProcess = new PostProcess(\"TAA\", \"taa\", {\r\n uniforms: [\"factor\"],\r\n samplers: [\"historySampler\"],\r\n size: 1.0,\r\n engine: this._scene.getEngine(),\r\n textureType: this._textureType,\r\n });\r\n\r\n this._taaPostProcess.samples = this._msaaSamples;\r\n\r\n this._updateEffectDefines();\r\n\r\n this._taaPostProcess.onActivateObservable.add(() => {\r\n const camera = this._scene.activeCamera;\r\n\r\n if (this._taaPostProcess?.width !== this._ping.width || this._taaPostProcess?.height !== this._ping.height) {\r\n const engine = this._scene.getEngine();\r\n this._createPingPongTextures(engine.getRenderWidth(), engine.getRenderHeight());\r\n }\r\n\r\n if (camera && !camera.hasMoved) {\r\n const projMat = camera.getProjectionMatrix();\r\n projMat.setRowFromFloats(2, this._hs.x, this._hs.y, projMat.m[10], projMat.m[11]);\r\n }\r\n\r\n if (this._passPostProcess) {\r\n this._passPostProcess.inputTexture = this._pingpong ? this._ping : this._pong;\r\n }\r\n this._pingpong = this._pingpong ^ 1;\r\n this._hs.next();\r\n });\r\n\r\n this._taaPostProcess.onApplyObservable.add((effect: Effect) => {\r\n const camera = this._scene.activeCamera;\r\n\r\n effect._bindTexture(\"historySampler\", this._pingpong ? this._ping.texture : this._pong.texture);\r\n effect.setFloat(\"factor\", (camera?.hasMoved && this.disableOnCameraMove) || this._firstUpdate ? 1 : this.factor);\r\n\r\n this._firstUpdate = false;\r\n });\r\n }\r\n\r\n private _createPassPostProcess() {\r\n const engine = this._scene.getEngine();\r\n\r\n this._passPostProcess = new PassPostProcess(\"TAAPass\", 1, null, Constants.TEXTURE_NEAREST_NEAREST, engine);\r\n this._passPostProcess.inputTexture = this._ping;\r\n this._passPostProcess.autoClear = false;\r\n }\r\n\r\n /**\r\n * Serializes the rendering pipeline (Used when exporting)\r\n * @returns the serialized object\r\n */\r\n public serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this);\r\n serializationObject.customType = \"TAARenderingPipeline\";\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse the serialized pipeline\r\n * @param source Source pipeline.\r\n * @param scene The scene to load the pipeline to.\r\n * @param rootUrl The URL of the serialized pipeline.\r\n * @returns An instantiated pipeline from the serialized object.\r\n */\r\n public static Parse(source: any, scene: Scene, rootUrl: string): TAARenderingPipeline {\r\n return SerializationHelper.Parse(() => new TAARenderingPipeline(source._name, scene, source._ratio), source, scene, rootUrl);\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.TAARenderingPipeline\", TAARenderingPipeline);\r\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../Engines/shaderStore.js";
|
|
3
|
+
const name = "taaPixelShader";
|
|
4
|
+
const shader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D historySampler;uniform float factor;void main() {vec4 c=texelFetch(textureSampler,ivec2(gl_FragCoord.xy),0);vec4 h=texelFetch(historySampler,ivec2(gl_FragCoord.xy),0);gl_FragColor=mix(h,c,factor);}
|
|
5
|
+
`;
|
|
6
|
+
// Sideeffect
|
|
7
|
+
ShaderStore.ShadersStore[name] = shader;
|
|
8
|
+
/** @internal */
|
|
9
|
+
export const taaPixelShader = { name, shader };
|
|
10
|
+
//# sourceMappingURL=taa.fragment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taa.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/taa.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,IAAI,GAAG,gBAAgB,CAAC;AAC9B,MAAM,MAAM,GAAG;CACd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\n\nconst name = \"taaPixelShader\";\nconst shader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D historySampler;uniform float factor;void main() {vec4 c=texelFetch(textureSampler,ivec2(gl_FragCoord.xy),0);vec4 h=texelFetch(historySampler,ivec2(gl_FragCoord.xy),0);gl_FragColor=mix(h,c,factor);}\n`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @internal */\nexport const taaPixelShader = { name, shader };\n"]}
|