@onerjs/core 8.54.5 → 8.54.7
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/Engines/Native/nativeHelpers.js +5 -0
- package/Engines/Native/nativeHelpers.js.map +1 -1
- package/Engines/abstractEngine.pure.js +2 -2
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/engineCapabilities.d.ts +5 -0
- package/Engines/engineCapabilities.js.map +1 -1
- package/Engines/thinNativeEngine.pure.js +23 -4
- package/Engines/thinNativeEngine.pure.js.map +1 -1
- package/Engines/webgpuEngine.pure.js +1 -0
- package/Engines/webgpuEngine.pure.js.map +1 -1
- package/Materials/Node/nodeMaterial.pure.d.ts +3 -1
- package/Materials/Node/nodeMaterial.pure.js +18 -1
- package/Materials/Node/nodeMaterial.pure.js.map +1 -1
- package/Materials/Textures/envCubeTexture.pure.js +7 -2
- package/Materials/Textures/envCubeTexture.pure.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +14 -0
- package/Materials/materialHelper.functions.js +67 -0
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Maths/math.vector.pure.d.ts +1 -1
- package/Maths/math.vector.pure.js.map +1 -1
- package/Meshes/abstractMesh.pure.js +1 -0
- package/Meshes/abstractMesh.pure.js.map +1 -1
- package/Meshes/mesh.pure.js +11 -0
- package/Meshes/mesh.pure.js.map +1 -1
- package/Meshes/transformNode.pure.js +1 -0
- package/Meshes/transformNode.pure.js.map +1 -1
- package/Misc/areaLightsTextureTools.js +1 -1
- package/Misc/areaLightsTextureTools.js.map +1 -1
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/fsr1RenderingPipeline.d.ts +79 -0
- package/PostProcesses/RenderPipeline/Pipelines/fsr1RenderingPipeline.js +171 -0
- package/PostProcesses/RenderPipeline/Pipelines/fsr1RenderingPipeline.js.map +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.d.ts +5 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.js +6 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/pure.d.ts +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/pure.js +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/pure.js.map +1 -1
- package/PostProcesses/thinFSR1SharpenPostProcess.d.ts +32 -0
- package/PostProcesses/thinFSR1SharpenPostProcess.js +58 -0
- package/PostProcesses/thinFSR1SharpenPostProcess.js.map +1 -0
- package/PostProcesses/thinFSR1UpscalePostProcess.d.ts +37 -0
- package/PostProcesses/thinFSR1UpscalePostProcess.js +68 -0
- package/PostProcesses/thinFSR1UpscalePostProcess.js.map +1 -0
- package/Shaders/ShadersInclude/ffxFunctions.d.ts +5 -0
- package/Shaders/ShadersInclude/ffxFunctions.js +18 -0
- package/Shaders/ShadersInclude/ffxFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +2 -2
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrIblFunctions.js +1 -6
- package/Shaders/ShadersInclude/openpbrIblFunctions.js.map +1 -1
- package/Shaders/fsr1Sharpen.fragment.d.ts +5 -0
- package/Shaders/fsr1Sharpen.fragment.js +26 -0
- package/Shaders/fsr1Sharpen.fragment.js.map +1 -0
- package/Shaders/fsr1Upscale.fragment.d.ts +5 -0
- package/Shaders/fsr1Upscale.fragment.js +77 -0
- package/Shaders/fsr1Upscale.fragment.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/ffxFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/ffxFunctions.js +18 -0
- package/ShadersWGSL/ShadersInclude/ffxFunctions.js.map +1 -0
- package/ShadersWGSL/fsr1Sharpen.fragment.d.ts +5 -0
- package/ShadersWGSL/fsr1Sharpen.fragment.js +34 -0
- package/ShadersWGSL/fsr1Sharpen.fragment.js.map +1 -0
- package/ShadersWGSL/fsr1Upscale.fragment.d.ts +5 -0
- package/ShadersWGSL/fsr1Upscale.fragment.js +68 -0
- package/ShadersWGSL/fsr1Upscale.fragment.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type Scene } from "../../../scene.js";
|
|
2
|
+
import { PostProcessRenderPipeline } from "../postProcessRenderPipeline.js";
|
|
3
|
+
/**
|
|
4
|
+
* FidelityFX Super Resolution (FSR) 1 render pipeline.
|
|
5
|
+
* This can be used to render the scene at a lower resolution and upscale it.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FSR1RenderingPipeline extends PostProcessRenderPipeline {
|
|
8
|
+
/**
|
|
9
|
+
* AMD's recommended `scaleFactor` for an "Ultra Quality" preset (equal to 1.3)
|
|
10
|
+
*/
|
|
11
|
+
static readonly SCALE_ULTRA_QUALITY = 1.3;
|
|
12
|
+
/**
|
|
13
|
+
* AMD's recommended `scaleFactor` for a "Quality" preset (equal to 1.5)
|
|
14
|
+
*/
|
|
15
|
+
static readonly SCALE_QUALITY = 1.5;
|
|
16
|
+
/**
|
|
17
|
+
* AMD's recommended `scaleFactor` for a "Balanced" preset (equal to 1.7)
|
|
18
|
+
*/
|
|
19
|
+
static readonly SCALE_BALANCED = 1.7;
|
|
20
|
+
/**
|
|
21
|
+
* AMD's recommended `scaleFactor` for a "Performance" preset (equal to 2)
|
|
22
|
+
*/
|
|
23
|
+
static readonly SCALE_PERFORMANCE = 2;
|
|
24
|
+
private readonly _scene;
|
|
25
|
+
/**
|
|
26
|
+
* Returns true if FSR is supported by the running hardware
|
|
27
|
+
*/
|
|
28
|
+
get isSupported(): boolean;
|
|
29
|
+
private _samples;
|
|
30
|
+
/**
|
|
31
|
+
* MSAA sample count (default: 4).
|
|
32
|
+
* Disabling MSAA is not recommended since aliased edges will be exaggerated by the FSR pass.
|
|
33
|
+
* Always have at least one AA solution enabled, whether that be MSAA with this setting or a post-process effect like FXAA or TAA.
|
|
34
|
+
*/
|
|
35
|
+
get samples(): number;
|
|
36
|
+
set samples(samples: number);
|
|
37
|
+
private _scaleFactor;
|
|
38
|
+
/**
|
|
39
|
+
* How much smaller to render the scene at (default: 1.5).
|
|
40
|
+
* For example, a value of 2 will render the scene at half resolution.
|
|
41
|
+
*/
|
|
42
|
+
get scaleFactor(): number;
|
|
43
|
+
set scaleFactor(factor: number);
|
|
44
|
+
private _sharpnessStops;
|
|
45
|
+
/**
|
|
46
|
+
* The number of stops (halving) of the reduction of sharpness (default: 0.2).
|
|
47
|
+
* A value of 0 indicates a maximum sharpness.
|
|
48
|
+
*/
|
|
49
|
+
get sharpnessStops(): number;
|
|
50
|
+
set sharpnessStops(stops: number);
|
|
51
|
+
/**
|
|
52
|
+
* The FSR upscale PostProcess ID in the pipeline
|
|
53
|
+
*/
|
|
54
|
+
FSR1UpscaleEffect: string;
|
|
55
|
+
private readonly _thinUpscalePostProcess;
|
|
56
|
+
private _upscalePostProcess;
|
|
57
|
+
/**
|
|
58
|
+
* The FSR sharpen PostProcess ID in the pipeline
|
|
59
|
+
*/
|
|
60
|
+
FSR1SharpenEffect: string;
|
|
61
|
+
private readonly _thinSharpenPostProcess;
|
|
62
|
+
private _sharpenPostProcess;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a new FSR 1 rendering pipeline
|
|
65
|
+
* @param name The rendering pipeline name
|
|
66
|
+
* @param scene The scene linked to this pipeline
|
|
67
|
+
* @param cameras The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
|
|
68
|
+
*/
|
|
69
|
+
constructor(name: string, scene: Scene, cameras?: import("../../../index.js").Camera[]);
|
|
70
|
+
private _buildPipeline;
|
|
71
|
+
/**
|
|
72
|
+
* Disposes of the pipeline
|
|
73
|
+
*/
|
|
74
|
+
dispose(): void;
|
|
75
|
+
private _createUpscalePostProcess;
|
|
76
|
+
private _disposeUpscalePostProcess;
|
|
77
|
+
private _createSharpenPostProcess;
|
|
78
|
+
private _disposeSharpenPostProcess;
|
|
79
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { PostProcessRenderEffect } from "../postProcessRenderEffect.js";
|
|
2
|
+
import { PostProcessRenderPipeline } from "../postProcessRenderPipeline.js";
|
|
3
|
+
import { PostProcess } from "../../postProcess.pure.js";
|
|
4
|
+
import { ThinFSR1UpscalePostProcess } from "../../thinFSR1UpscalePostProcess.js";
|
|
5
|
+
import { ThinFSR1SharpenPostProcess } from "../../thinFSR1SharpenPostProcess.js";
|
|
6
|
+
/**
|
|
7
|
+
* FidelityFX Super Resolution (FSR) 1 render pipeline.
|
|
8
|
+
* This can be used to render the scene at a lower resolution and upscale it.
|
|
9
|
+
*/
|
|
10
|
+
export class FSR1RenderingPipeline extends PostProcessRenderPipeline {
|
|
11
|
+
/**
|
|
12
|
+
* Returns true if FSR is supported by the running hardware
|
|
13
|
+
*/
|
|
14
|
+
get isSupported() {
|
|
15
|
+
// FSR 1 needs integer texel fetch (texelFetch/textureSize) and bit-cast intrinsics.
|
|
16
|
+
// These are available on WebGPU, WebGL2 and Babylon Native (all report version >= 2 or isWebGPU),
|
|
17
|
+
// but not WebGL1. Note caps.texelFetch cannot be used here because Babylon Native reports it as
|
|
18
|
+
// false even though the underlying backend supports the required operations.
|
|
19
|
+
return this.engine.isWebGPU || this.engine.version >= 2;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* MSAA sample count (default: 4).
|
|
23
|
+
* Disabling MSAA is not recommended since aliased edges will be exaggerated by the FSR pass.
|
|
24
|
+
* Always have at least one AA solution enabled, whether that be MSAA with this setting or a post-process effect like FXAA or TAA.
|
|
25
|
+
*/
|
|
26
|
+
get samples() {
|
|
27
|
+
return this._samples;
|
|
28
|
+
}
|
|
29
|
+
set samples(samples) {
|
|
30
|
+
if (this._samples === samples) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this._samples = samples;
|
|
34
|
+
if (this._upscalePostProcess) {
|
|
35
|
+
this._upscalePostProcess.samples = this._samples;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* How much smaller to render the scene at (default: 1.5).
|
|
40
|
+
* For example, a value of 2 will render the scene at half resolution.
|
|
41
|
+
*/
|
|
42
|
+
get scaleFactor() {
|
|
43
|
+
return this._scaleFactor;
|
|
44
|
+
}
|
|
45
|
+
set scaleFactor(factor) {
|
|
46
|
+
if (this._scaleFactor === factor) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
this._scaleFactor = factor;
|
|
50
|
+
this._buildPipeline();
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The number of stops (halving) of the reduction of sharpness (default: 0.2).
|
|
54
|
+
* A value of 0 indicates a maximum sharpness.
|
|
55
|
+
*/
|
|
56
|
+
get sharpnessStops() {
|
|
57
|
+
return this._sharpnessStops;
|
|
58
|
+
}
|
|
59
|
+
set sharpnessStops(stops) {
|
|
60
|
+
if (this._sharpnessStops === stops) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this._sharpnessStops = stops;
|
|
64
|
+
// The value is applied to the effect every frame in the sharpen post-process onApply callback.
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Creates a new FSR 1 rendering pipeline
|
|
68
|
+
* @param name The rendering pipeline name
|
|
69
|
+
* @param scene The scene linked to this pipeline
|
|
70
|
+
* @param cameras The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
|
|
71
|
+
*/
|
|
72
|
+
constructor(name, scene, cameras = scene.cameras) {
|
|
73
|
+
super(scene.getEngine(), name);
|
|
74
|
+
this._samples = 4;
|
|
75
|
+
this._scaleFactor = FSR1RenderingPipeline.SCALE_QUALITY;
|
|
76
|
+
this._sharpnessStops = 0.2;
|
|
77
|
+
/**
|
|
78
|
+
* The FSR upscale PostProcess ID in the pipeline
|
|
79
|
+
*/
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
81
|
+
this.FSR1UpscaleEffect = "FSR1UpscaleEffect";
|
|
82
|
+
/**
|
|
83
|
+
* The FSR sharpen PostProcess ID in the pipeline
|
|
84
|
+
*/
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
86
|
+
this.FSR1SharpenEffect = "FSR1SharpenEffect";
|
|
87
|
+
this._scene = scene;
|
|
88
|
+
this._cameras = cameras.slice();
|
|
89
|
+
this._thinUpscalePostProcess = new ThinFSR1UpscalePostProcess(name + "Upscale", this.engine);
|
|
90
|
+
this._thinSharpenPostProcess = new ThinFSR1SharpenPostProcess(name + "Sharpen", this.engine);
|
|
91
|
+
this._createSharpenPostProcess();
|
|
92
|
+
if (this.isSupported) {
|
|
93
|
+
scene.postProcessRenderPipelineManager.addPipeline(this);
|
|
94
|
+
this._buildPipeline();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
_buildPipeline() {
|
|
98
|
+
if (!this.isSupported) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const cameras = this._cameras.slice();
|
|
102
|
+
this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, cameras);
|
|
103
|
+
this._reset();
|
|
104
|
+
this._disposeUpscalePostProcess();
|
|
105
|
+
this._createUpscalePostProcess();
|
|
106
|
+
this.addEffect(new PostProcessRenderEffect(this.engine, this.FSR1UpscaleEffect, () => this._upscalePostProcess));
|
|
107
|
+
this.addEffect(new PostProcessRenderEffect(this.engine, this.FSR1SharpenEffect, () => this._sharpenPostProcess));
|
|
108
|
+
this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this.name, cameras);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Disposes of the pipeline
|
|
112
|
+
*/
|
|
113
|
+
dispose() {
|
|
114
|
+
this._disposeSharpenPostProcess();
|
|
115
|
+
this._thinSharpenPostProcess.dispose();
|
|
116
|
+
this._disposeUpscalePostProcess();
|
|
117
|
+
this._thinUpscalePostProcess.dispose();
|
|
118
|
+
super.dispose();
|
|
119
|
+
}
|
|
120
|
+
_createUpscalePostProcess() {
|
|
121
|
+
const postProcess = new PostProcess(this._thinUpscalePostProcess.name, ThinFSR1UpscalePostProcess.FragmentUrl, {
|
|
122
|
+
uniforms: ThinFSR1UpscalePostProcess.Uniforms,
|
|
123
|
+
size: 1 / this._scaleFactor,
|
|
124
|
+
engine: this.engine,
|
|
125
|
+
effectWrapper: this._thinUpscalePostProcess,
|
|
126
|
+
});
|
|
127
|
+
postProcess.samples = this._samples;
|
|
128
|
+
postProcess.onApplyObservable.add((effect) => {
|
|
129
|
+
this._thinUpscalePostProcess.updateConstants(effect, postProcess.width, postProcess.height, postProcess.width, postProcess.height, this.engine.getRenderWidth(), this.engine.getRenderHeight());
|
|
130
|
+
});
|
|
131
|
+
this._upscalePostProcess = postProcess;
|
|
132
|
+
}
|
|
133
|
+
_disposeUpscalePostProcess() {
|
|
134
|
+
for (const camera of this._cameras) {
|
|
135
|
+
this._upscalePostProcess?.dispose(camera);
|
|
136
|
+
}
|
|
137
|
+
this._upscalePostProcess = null;
|
|
138
|
+
}
|
|
139
|
+
_createSharpenPostProcess() {
|
|
140
|
+
this._sharpenPostProcess = new PostProcess(this._thinSharpenPostProcess.name, ThinFSR1SharpenPostProcess.FragmentUrl, {
|
|
141
|
+
uniforms: ThinFSR1SharpenPostProcess.Uniforms,
|
|
142
|
+
engine: this.engine,
|
|
143
|
+
effectWrapper: this._thinSharpenPostProcess,
|
|
144
|
+
});
|
|
145
|
+
this._sharpenPostProcess.onApplyObservable.add((effect) => {
|
|
146
|
+
this._thinSharpenPostProcess.updateConstants(effect, this._sharpnessStops);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
_disposeSharpenPostProcess() {
|
|
150
|
+
for (const camera of this._cameras) {
|
|
151
|
+
this._sharpenPostProcess.dispose(camera);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* AMD's recommended `scaleFactor` for an "Ultra Quality" preset (equal to 1.3)
|
|
157
|
+
*/
|
|
158
|
+
FSR1RenderingPipeline.SCALE_ULTRA_QUALITY = 1.3;
|
|
159
|
+
/**
|
|
160
|
+
* AMD's recommended `scaleFactor` for a "Quality" preset (equal to 1.5)
|
|
161
|
+
*/
|
|
162
|
+
FSR1RenderingPipeline.SCALE_QUALITY = 1.5;
|
|
163
|
+
/**
|
|
164
|
+
* AMD's recommended `scaleFactor` for a "Balanced" preset (equal to 1.7)
|
|
165
|
+
*/
|
|
166
|
+
FSR1RenderingPipeline.SCALE_BALANCED = 1.7;
|
|
167
|
+
/**
|
|
168
|
+
* AMD's recommended `scaleFactor` for a "Performance" preset (equal to 2)
|
|
169
|
+
*/
|
|
170
|
+
FSR1RenderingPipeline.SCALE_PERFORMANCE = 2;
|
|
171
|
+
//# sourceMappingURL=fsr1RenderingPipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fsr1RenderingPipeline.js","sourceRoot":"","sources":["../../../../../../dev/core/src/PostProcesses/RenderPipeline/Pipelines/fsr1RenderingPipeline.ts"],"names":[],"mappings":"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","sourcesContent":["import { type Scene } from \"core/scene\";\nimport { type Nullable } from \"core/types\";\n\nimport { PostProcessRenderEffect } from \"../postProcessRenderEffect\";\nimport { PostProcessRenderPipeline } from \"../postProcessRenderPipeline\";\nimport { PostProcess } from \"../../postProcess.pure\";\nimport { ThinFSR1UpscalePostProcess } from \"../../thinFSR1UpscalePostProcess\";\nimport { ThinFSR1SharpenPostProcess } from \"../../thinFSR1SharpenPostProcess\";\n\n/**\n * FidelityFX Super Resolution (FSR) 1 render pipeline.\n * This can be used to render the scene at a lower resolution and upscale it.\n */\nexport class FSR1RenderingPipeline extends PostProcessRenderPipeline {\n /**\n * AMD's recommended `scaleFactor` for an \"Ultra Quality\" preset (equal to 1.3)\n */\n public static readonly SCALE_ULTRA_QUALITY = 1.3;\n /**\n * AMD's recommended `scaleFactor` for a \"Quality\" preset (equal to 1.5)\n */\n public static readonly SCALE_QUALITY = 1.5;\n /**\n * AMD's recommended `scaleFactor` for a \"Balanced\" preset (equal to 1.7)\n */\n public static readonly SCALE_BALANCED = 1.7;\n /**\n * AMD's recommended `scaleFactor` for a \"Performance\" preset (equal to 2)\n */\n public static readonly SCALE_PERFORMANCE = 2;\n\n private readonly _scene: Scene;\n\n /**\n * Returns true if FSR is supported by the running hardware\n */\n public override get isSupported(): boolean {\n // FSR 1 needs integer texel fetch (texelFetch/textureSize) and bit-cast intrinsics.\n // These are available on WebGPU, WebGL2 and Babylon Native (all report version >= 2 or isWebGPU),\n // but not WebGL1. Note caps.texelFetch cannot be used here because Babylon Native reports it as\n // false even though the underlying backend supports the required operations.\n return this.engine.isWebGPU || this.engine.version >= 2;\n }\n\n private _samples = 4;\n /**\n * MSAA sample count (default: 4).\n * Disabling MSAA is not recommended since aliased edges will be exaggerated by the FSR pass.\n * Always have at least one AA solution enabled, whether that be MSAA with this setting or a post-process effect like FXAA or TAA.\n */\n public get samples(): number {\n return this._samples;\n }\n\n public set samples(samples: number) {\n if (this._samples === samples) {\n return;\n }\n this._samples = samples;\n if (this._upscalePostProcess) {\n this._upscalePostProcess.samples = this._samples;\n }\n }\n\n private _scaleFactor = FSR1RenderingPipeline.SCALE_QUALITY;\n /**\n * How much smaller to render the scene at (default: 1.5).\n * For example, a value of 2 will render the scene at half resolution.\n */\n public get scaleFactor(): number {\n return this._scaleFactor;\n }\n\n public set scaleFactor(factor: number) {\n if (this._scaleFactor === factor) {\n return;\n }\n this._scaleFactor = factor;\n this._buildPipeline();\n }\n\n private _sharpnessStops = 0.2;\n /**\n * The number of stops (halving) of the reduction of sharpness (default: 0.2).\n * A value of 0 indicates a maximum sharpness.\n */\n public get sharpnessStops(): number {\n return this._sharpnessStops;\n }\n\n public set sharpnessStops(stops: number) {\n if (this._sharpnessStops === stops) {\n return;\n }\n this._sharpnessStops = stops;\n // The value is applied to the effect every frame in the sharpen post-process onApply callback.\n }\n\n /**\n * The FSR upscale PostProcess ID in the pipeline\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public FSR1UpscaleEffect = \"FSR1UpscaleEffect\";\n private readonly _thinUpscalePostProcess: ThinFSR1UpscalePostProcess;\n private _upscalePostProcess: Nullable<PostProcess>;\n\n /**\n * The FSR sharpen PostProcess ID in the pipeline\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public FSR1SharpenEffect = \"FSR1SharpenEffect\";\n private readonly _thinSharpenPostProcess: ThinFSR1SharpenPostProcess;\n private _sharpenPostProcess: PostProcess;\n\n /**\n * Creates a new FSR 1 rendering pipeline\n * @param name The rendering pipeline name\n * @param scene The scene linked to this pipeline\n * @param cameras The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)\n */\n constructor(name: string, scene: Scene, cameras = scene.cameras) {\n super(scene.getEngine(), name);\n this._scene = scene;\n this._cameras = cameras.slice();\n\n this._thinUpscalePostProcess = new ThinFSR1UpscalePostProcess(name + \"Upscale\", this.engine);\n this._thinSharpenPostProcess = new ThinFSR1SharpenPostProcess(name + \"Sharpen\", this.engine);\n this._createSharpenPostProcess();\n\n if (this.isSupported) {\n scene.postProcessRenderPipelineManager.addPipeline(this);\n this._buildPipeline();\n }\n }\n\n private _buildPipeline(): void {\n if (!this.isSupported) {\n return;\n }\n const cameras = this._cameras.slice();\n this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, cameras);\n this._reset();\n\n this._disposeUpscalePostProcess();\n this._createUpscalePostProcess();\n\n this.addEffect(new PostProcessRenderEffect(this.engine, this.FSR1UpscaleEffect, () => this._upscalePostProcess));\n this.addEffect(new PostProcessRenderEffect(this.engine, this.FSR1SharpenEffect, () => this._sharpenPostProcess));\n\n this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this.name, cameras);\n }\n\n /**\n * Disposes of the pipeline\n */\n public override dispose(): void {\n this._disposeSharpenPostProcess();\n this._thinSharpenPostProcess.dispose();\n this._disposeUpscalePostProcess();\n this._thinUpscalePostProcess.dispose();\n super.dispose();\n }\n\n private _createUpscalePostProcess(): void {\n const postProcess = new PostProcess(this._thinUpscalePostProcess.name, ThinFSR1UpscalePostProcess.FragmentUrl, {\n uniforms: ThinFSR1UpscalePostProcess.Uniforms,\n size: 1 / this._scaleFactor,\n engine: this.engine,\n effectWrapper: this._thinUpscalePostProcess,\n });\n postProcess.samples = this._samples;\n\n postProcess.onApplyObservable.add((effect) => {\n this._thinUpscalePostProcess.updateConstants(\n effect,\n postProcess.width,\n postProcess.height,\n postProcess.width,\n postProcess.height,\n this.engine.getRenderWidth(),\n this.engine.getRenderHeight()\n );\n });\n\n this._upscalePostProcess = postProcess;\n }\n\n private _disposeUpscalePostProcess(): void {\n for (const camera of this._cameras) {\n this._upscalePostProcess?.dispose(camera);\n }\n this._upscalePostProcess = null;\n }\n\n private _createSharpenPostProcess(): void {\n this._sharpenPostProcess = new PostProcess(this._thinSharpenPostProcess.name, ThinFSR1SharpenPostProcess.FragmentUrl, {\n uniforms: ThinFSR1SharpenPostProcess.Uniforms,\n engine: this.engine,\n effectWrapper: this._thinSharpenPostProcess,\n });\n this._sharpenPostProcess.onApplyObservable.add((effect) => {\n this._thinSharpenPostProcess.updateConstants(effect, this._sharpnessStops);\n });\n }\n\n private _disposeSharpenPostProcess(): void {\n for (const camera of this._cameras) {\n this._sharpenPostProcess.dispose(camera);\n }\n }\n}\n"]}
|
|
@@ -5,6 +5,7 @@ export * from "./ssaoRenderingPipeline.js";
|
|
|
5
5
|
export * from "./standardRenderingPipeline.js";
|
|
6
6
|
export * from "./ssrRenderingPipeline.js";
|
|
7
7
|
export * from "./taaRenderingPipeline.js";
|
|
8
|
+
export * from "./fsr1RenderingPipeline.js";
|
|
8
9
|
import "../../../Shaders/ssao2.fragment.js";
|
|
9
10
|
import "../../../Shaders/ssaoCombine.fragment.js";
|
|
10
11
|
import "../../../ShadersWGSL/ssao2.fragment.js";
|
|
@@ -17,3 +18,7 @@ import "../../../ShadersWGSL/screenSpaceReflection2Blur.fragment.js";
|
|
|
17
18
|
import "../../../ShadersWGSL/screenSpaceReflection2BlurCombiner.fragment.js";
|
|
18
19
|
import "../../../Shaders/taa.fragment.js";
|
|
19
20
|
import "../../../ShadersWGSL/taa.fragment.js";
|
|
21
|
+
import "../../../Shaders/fsr1Upscale.fragment.js";
|
|
22
|
+
import "../../../Shaders/fsr1Sharpen.fragment.js";
|
|
23
|
+
import "../../../ShadersWGSL/fsr1Upscale.fragment.js";
|
|
24
|
+
import "../../../ShadersWGSL/fsr1Sharpen.fragment.js";
|
|
@@ -5,6 +5,7 @@ export * from "./ssaoRenderingPipeline.js";
|
|
|
5
5
|
export * from "./standardRenderingPipeline.js";
|
|
6
6
|
export * from "./ssrRenderingPipeline.js";
|
|
7
7
|
export * from "./taaRenderingPipeline.js";
|
|
8
|
+
export * from "./fsr1RenderingPipeline.js";
|
|
8
9
|
// SSAO2 shaders
|
|
9
10
|
import "../../../Shaders/ssao2.fragment.js";
|
|
10
11
|
import "../../../Shaders/ssaoCombine.fragment.js";
|
|
@@ -20,4 +21,9 @@ import "../../../ShadersWGSL/screenSpaceReflection2BlurCombiner.fragment.js";
|
|
|
20
21
|
// TAA shaders
|
|
21
22
|
import "../../../Shaders/taa.fragment.js";
|
|
22
23
|
import "../../../ShadersWGSL/taa.fragment.js";
|
|
24
|
+
// FSR 1 shaders
|
|
25
|
+
import "../../../Shaders/fsr1Upscale.fragment.js";
|
|
26
|
+
import "../../../Shaders/fsr1Sharpen.fragment.js";
|
|
27
|
+
import "../../../ShadersWGSL/fsr1Upscale.fragment.js";
|
|
28
|
+
import "../../../ShadersWGSL/fsr1Sharpen.fragment.js";
|
|
23
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -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;AACvC,cAAc,wBAAwB,CAAC;
|
|
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;AACvC,cAAc,yBAAyB,CAAC;AAExC,gBAAgB;AAChB,OAAO,iCAAiC,CAAC;AACzC,OAAO,uCAAuC,CAAC;AAC/C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,2CAA2C,CAAC;AAEnD,cAAc;AACd,OAAO,kDAAkD,CAAC;AAC1D,OAAO,sDAAsD,CAAC;AAC9D,OAAO,8DAA8D,CAAC;AACtE,OAAO,sDAAsD,CAAC;AAC9D,OAAO,0DAA0D,CAAC;AAClE,OAAO,kEAAkE,CAAC;AAE1E,cAAc;AACd,OAAO,+BAA+B,CAAC;AACvC,OAAO,mCAAmC,CAAC;AAE3C,gBAAgB;AAChB,OAAO,uCAAuC,CAAC;AAC/C,OAAO,uCAAuC,CAAC;AAC/C,OAAO,2CAA2C,CAAC;AACnD,OAAO,2CAA2C,CAAC","sourcesContent":["export * from \"./defaultRenderingPipeline\";\nexport * from \"./lensRenderingPipeline\";\nexport * from \"./ssao2RenderingPipeline\";\nexport * from \"./ssaoRenderingPipeline\";\nexport * from \"./standardRenderingPipeline\";\nexport * from \"./ssrRenderingPipeline\";\nexport * from \"./taaRenderingPipeline\";\nexport * from \"./fsr1RenderingPipeline\";\n\n// SSAO2 shaders\nimport \"../../../Shaders/ssao2.fragment\";\nimport \"../../../Shaders/ssaoCombine.fragment\";\nimport \"../../../ShadersWGSL/ssao2.fragment\";\nimport \"../../../ShadersWGSL/ssaoCombine.fragment\";\n\n// SSR shaders\nimport \"../../../Shaders/screenSpaceReflection2.fragment\";\nimport \"../../../Shaders/screenSpaceReflection2Blur.fragment\";\nimport \"../../../Shaders/screenSpaceReflection2BlurCombiner.fragment\";\nimport \"../../../ShadersWGSL/screenSpaceReflection2.fragment\";\nimport \"../../../ShadersWGSL/screenSpaceReflection2Blur.fragment\";\nimport \"../../../ShadersWGSL/screenSpaceReflection2BlurCombiner.fragment\";\n\n// TAA shaders\nimport \"../../../Shaders/taa.fragment\";\nimport \"../../../ShadersWGSL/taa.fragment\";\n\n// FSR 1 shaders\nimport \"../../../Shaders/fsr1Upscale.fragment\";\nimport \"../../../Shaders/fsr1Sharpen.fragment\";\nimport \"../../../ShadersWGSL/fsr1Upscale.fragment\";\nimport \"../../../ShadersWGSL/fsr1Sharpen.fragment\";\n"]}
|
|
@@ -6,4 +6,5 @@ export * from "./ssaoRenderingPipeline.pure.js";
|
|
|
6
6
|
export * from "./standardRenderingPipeline.pure.js";
|
|
7
7
|
export * from "./ssrRenderingPipeline.pure.js";
|
|
8
8
|
export * from "./taaRenderingPipeline.pure.js";
|
|
9
|
+
export * from "./fsr1RenderingPipeline.js";
|
|
9
10
|
export * from "./taaMaterialManager.pure.js";
|
|
@@ -6,5 +6,6 @@ export * from "./ssaoRenderingPipeline.pure.js";
|
|
|
6
6
|
export * from "./standardRenderingPipeline.pure.js";
|
|
7
7
|
export * from "./ssrRenderingPipeline.pure.js";
|
|
8
8
|
export * from "./taaRenderingPipeline.pure.js";
|
|
9
|
+
export * from "./fsr1RenderingPipeline.js";
|
|
9
10
|
export * from "./taaMaterialManager.pure.js";
|
|
10
11
|
//# sourceMappingURL=pure.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pure.js","sourceRoot":"","sources":["../../../../../../dev/core/src/PostProcesses/RenderPipeline/Pipelines/pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC","sourcesContent":["/** Pure barrel — re-exports only side-effect-free modules */\nexport * from \"./defaultRenderingPipeline.pure\";\nexport * from \"./lensRenderingPipeline.pure\";\nexport * from \"./ssao2RenderingPipeline.pure\";\nexport * from \"./ssaoRenderingPipeline.pure\";\nexport * from \"./standardRenderingPipeline.pure\";\nexport * from \"./ssrRenderingPipeline.pure\";\nexport * from \"./taaRenderingPipeline.pure\";\nexport * from \"./taaMaterialManager.pure\";\n"]}
|
|
1
|
+
{"version":3,"file":"pure.js","sourceRoot":"","sources":["../../../../../../dev/core/src/PostProcesses/RenderPipeline/Pipelines/pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC","sourcesContent":["/** Pure barrel — re-exports only side-effect-free modules */\nexport * from \"./defaultRenderingPipeline.pure\";\nexport * from \"./lensRenderingPipeline.pure\";\nexport * from \"./ssao2RenderingPipeline.pure\";\nexport * from \"./ssaoRenderingPipeline.pure\";\nexport * from \"./standardRenderingPipeline.pure\";\nexport * from \"./ssrRenderingPipeline.pure\";\nexport * from \"./taaRenderingPipeline.pure\";\nexport * from \"./fsr1RenderingPipeline\";\nexport * from \"./taaMaterialManager.pure\";\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type AbstractEngine } from "../Engines/abstractEngine.js";
|
|
2
|
+
import { type Effect } from "../Materials/effect.js";
|
|
3
|
+
import { EffectWrapper, type EffectWrapperCreationOptions } from "../Materials/effectRenderer.pure.js";
|
|
4
|
+
import { type Nullable } from "../types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Robust Contrast Adaptive Sharpening (RCAS) post-process used by FSR 1
|
|
7
|
+
*/
|
|
8
|
+
export declare class ThinFSR1SharpenPostProcess extends EffectWrapper {
|
|
9
|
+
/**
|
|
10
|
+
* The fragment shader URL
|
|
11
|
+
*/
|
|
12
|
+
static readonly FragmentUrl = "fsr1Sharpen";
|
|
13
|
+
/**
|
|
14
|
+
* The list of uniforms used by the effect
|
|
15
|
+
*/
|
|
16
|
+
static readonly Uniforms: string[];
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new FSR 1 sharpen post process
|
|
19
|
+
* @param name Name of the effect
|
|
20
|
+
* @param engine Engine to use to render the effect. If not provided, the last created engine will be used
|
|
21
|
+
* @param options Options to configure the effect
|
|
22
|
+
*/
|
|
23
|
+
constructor(name: string, engine?: Nullable<AbstractEngine>, options?: EffectWrapperCreationOptions);
|
|
24
|
+
protected _gatherImports(useWebGPU: boolean | undefined, list: Promise<any>[]): void;
|
|
25
|
+
/**
|
|
26
|
+
* Sets the required constant value on the effect. Plain uniforms are used (rather than a uniform
|
|
27
|
+
* buffer) so this works on every backend, including Babylon Native, which disables uniform buffers.
|
|
28
|
+
* @param effect The effect to set the constant on (typically the one provided by onApplyObservable).
|
|
29
|
+
* @param sharpness The number of stops (halving) of the reduction of sharpness (0 = maximum sharpness)
|
|
30
|
+
*/
|
|
31
|
+
updateConstants(effect: Effect, sharpness: number): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { EngineStore } from "../Engines/engineStore.js";
|
|
2
|
+
import { EffectWrapper } from "../Materials/effectRenderer.pure.js";
|
|
3
|
+
/**
|
|
4
|
+
* Robust Contrast Adaptive Sharpening (RCAS) post-process used by FSR 1
|
|
5
|
+
*/
|
|
6
|
+
export class ThinFSR1SharpenPostProcess extends EffectWrapper {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new FSR 1 sharpen post process
|
|
9
|
+
* @param name Name of the effect
|
|
10
|
+
* @param engine Engine to use to render the effect. If not provided, the last created engine will be used
|
|
11
|
+
* @param options Options to configure the effect
|
|
12
|
+
*/
|
|
13
|
+
constructor(name, engine, options) {
|
|
14
|
+
engine ?? (engine = EngineStore.LastCreatedEngine);
|
|
15
|
+
super({
|
|
16
|
+
...options,
|
|
17
|
+
name,
|
|
18
|
+
engine,
|
|
19
|
+
useShaderStore: true,
|
|
20
|
+
useAsPostProcess: true,
|
|
21
|
+
fragmentShader: ThinFSR1SharpenPostProcess.FragmentUrl,
|
|
22
|
+
uniforms: ThinFSR1SharpenPostProcess.Uniforms,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
_gatherImports(useWebGPU, list) {
|
|
26
|
+
if (useWebGPU) {
|
|
27
|
+
this._webGPUReady = true;
|
|
28
|
+
list.push(import("../ShadersWGSL/fsr1Sharpen.fragment.js"));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
list.push(import("../Shaders/fsr1Sharpen.fragment.js"));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Sets the required constant value on the effect. Plain uniforms are used (rather than a uniform
|
|
36
|
+
* buffer) so this works on every backend, including Babylon Native, which disables uniform buffers.
|
|
37
|
+
* @param effect The effect to set the constant on (typically the one provided by onApplyObservable).
|
|
38
|
+
* @param sharpness The number of stops (halving) of the reduction of sharpness (0 = maximum sharpness)
|
|
39
|
+
*/
|
|
40
|
+
updateConstants(effect, sharpness) {
|
|
41
|
+
// Code based on FsrRcasCon from FSR 1:
|
|
42
|
+
// https://github.com/GPUOpen-Effects/FidelityFX-FSR/blob/a21ffb8f6c13233ba336352bdff293894c706575/ffx-fsr/ffx_fsr1.h#L662
|
|
43
|
+
sharpness = Math.pow(2, -sharpness);
|
|
44
|
+
// Upstream FSR packs this as a uint and bitcasts it in the shader; this port declares it
|
|
45
|
+
// as a float on both the GLSL and WGSL sides, so it is sent as one.
|
|
46
|
+
// Since we haven't added the half-float shader yet, we don't need the second constant, which would require JS half-float calculation
|
|
47
|
+
effect.setFloat4("con", sharpness, 0, 0, 0);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The fragment shader URL
|
|
52
|
+
*/
|
|
53
|
+
ThinFSR1SharpenPostProcess.FragmentUrl = "fsr1Sharpen";
|
|
54
|
+
/**
|
|
55
|
+
* The list of uniforms used by the effect
|
|
56
|
+
*/
|
|
57
|
+
ThinFSR1SharpenPostProcess.Uniforms = ["con"];
|
|
58
|
+
//# sourceMappingURL=thinFSR1SharpenPostProcess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinFSR1SharpenPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/thinFSR1SharpenPostProcess.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAqC,MAAM,oCAAoC,CAAC;AAGtG;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,aAAa;IAWzD;;;;;OAKG;IACH,YAAY,IAAY,EAAE,MAAiC,EAAE,OAAsC;QAC/F,MAAM,KAAN,MAAM,GAAK,WAAW,CAAC,iBAAkB,EAAC;QAC1C,KAAK,CAAC;YACF,GAAG,OAAO;YACV,IAAI;YACJ,MAAM;YACN,cAAc,EAAE,IAAI;YACpB,gBAAgB,EAAE,IAAI;YACtB,cAAc,EAAE,0BAA0B,CAAC,WAAW;YACtD,QAAQ,EAAE,0BAA0B,CAAC,QAAQ;SAChD,CAAC,CAAC;IACP,CAAC;IAEkB,cAAc,CAAC,SAA8B,EAAE,IAAoB;QAClF,IAAI,SAAS,EAAE,CAAC;YACZ,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC,CAAC;QAC7D,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,iCAAiC,CAAC,CAAC,CAAC;QACzD,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,eAAe,CAAC,MAAc,EAAE,SAAiB;QACpD,uCAAuC;QACvC,0HAA0H;QAC1H,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;QAEpC,yFAAyF;QACzF,oEAAoE;QACpE,qIAAqI;QACrI,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;;AArDD;;GAEG;AACoB,sCAAW,GAAG,aAAa,CAAC;AAEnD;;GAEG;AACoB,mCAAQ,GAAG,CAAC,KAAK,CAAC,CAAC","sourcesContent":["import { type AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport { type Effect } from \"core/Materials/effect\";\r\nimport { EngineStore } from \"core/Engines/engineStore\";\r\nimport { EffectWrapper, type EffectWrapperCreationOptions } from \"core/Materials/effectRenderer.pure\";\r\nimport { type Nullable } from \"core/types\";\r\n\r\n/**\r\n * Robust Contrast Adaptive Sharpening (RCAS) post-process used by FSR 1\r\n */\r\nexport class ThinFSR1SharpenPostProcess extends EffectWrapper {\r\n /**\r\n * The fragment shader URL\r\n */\r\n public static readonly FragmentUrl = \"fsr1Sharpen\";\r\n\r\n /**\r\n * The list of uniforms used by the effect\r\n */\r\n public static readonly Uniforms = [\"con\"];\r\n\r\n /**\r\n * Creates a new FSR 1 sharpen post process\r\n * @param name Name of the effect\r\n * @param engine Engine to use to render the effect. If not provided, the last created engine will be used\r\n * @param options Options to configure the effect\r\n */\r\n constructor(name: string, engine?: Nullable<AbstractEngine>, options?: EffectWrapperCreationOptions) {\r\n engine ??= EngineStore.LastCreatedEngine!;\r\n super({\r\n ...options,\r\n name,\r\n engine,\r\n useShaderStore: true,\r\n useAsPostProcess: true,\r\n fragmentShader: ThinFSR1SharpenPostProcess.FragmentUrl,\r\n uniforms: ThinFSR1SharpenPostProcess.Uniforms,\r\n });\r\n }\r\n\r\n protected override _gatherImports(useWebGPU: boolean | undefined, list: Promise<any>[]): void {\r\n if (useWebGPU) {\r\n this._webGPUReady = true;\r\n list.push(import(\"../ShadersWGSL/fsr1Sharpen.fragment\"));\r\n } else {\r\n list.push(import(\"../Shaders/fsr1Sharpen.fragment\"));\r\n }\r\n }\r\n\r\n /**\r\n * Sets the required constant value on the effect. Plain uniforms are used (rather than a uniform\r\n * buffer) so this works on every backend, including Babylon Native, which disables uniform buffers.\r\n * @param effect The effect to set the constant on (typically the one provided by onApplyObservable).\r\n * @param sharpness The number of stops (halving) of the reduction of sharpness (0 = maximum sharpness)\r\n */\r\n public updateConstants(effect: Effect, sharpness: number): void {\r\n // Code based on FsrRcasCon from FSR 1:\r\n // https://github.com/GPUOpen-Effects/FidelityFX-FSR/blob/a21ffb8f6c13233ba336352bdff293894c706575/ffx-fsr/ffx_fsr1.h#L662\r\n sharpness = Math.pow(2, -sharpness);\r\n\r\n // Upstream FSR packs this as a uint and bitcasts it in the shader; this port declares it\r\n // as a float on both the GLSL and WGSL sides, so it is sent as one.\r\n // Since we haven't added the half-float shader yet, we don't need the second constant, which would require JS half-float calculation\r\n effect.setFloat4(\"con\", sharpness, 0, 0, 0);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type AbstractEngine } from "../Engines/abstractEngine.js";
|
|
2
|
+
import { type Effect } from "../Materials/effect.js";
|
|
3
|
+
import { EffectWrapper, type EffectWrapperCreationOptions } from "../Materials/effectRenderer.pure.js";
|
|
4
|
+
import { type Nullable } from "../types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Edge Adaptive Spatial Upsampling (EASU) post-process used by FSR 1
|
|
7
|
+
*/
|
|
8
|
+
export declare class ThinFSR1UpscalePostProcess extends EffectWrapper {
|
|
9
|
+
/**
|
|
10
|
+
* The fragment shader URL
|
|
11
|
+
*/
|
|
12
|
+
static readonly FragmentUrl = "fsr1Upscale";
|
|
13
|
+
/**
|
|
14
|
+
* The list of uniforms used by the effect
|
|
15
|
+
*/
|
|
16
|
+
static readonly Uniforms: string[];
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new FSR 1 upscale post process
|
|
19
|
+
* @param name Name of the effect
|
|
20
|
+
* @param engine Engine to use to render the effect. If not provided, the last created engine will be used
|
|
21
|
+
* @param options Options to configure the effect
|
|
22
|
+
*/
|
|
23
|
+
constructor(name: string, engine?: Nullable<AbstractEngine>, options?: EffectWrapperCreationOptions);
|
|
24
|
+
protected _gatherImports(useWebGPU: boolean | undefined, list: Promise<any>[]): void;
|
|
25
|
+
/**
|
|
26
|
+
* Sets the required constant values on the effect. Plain uniforms are used (rather than a uniform
|
|
27
|
+
* buffer) so this works on every backend, including Babylon Native, which disables uniform buffers.
|
|
28
|
+
* @param effect The effect to set the constants on (typically the one provided by onApplyObservable).
|
|
29
|
+
* @param viewportWidth The rendered input width being upscaled
|
|
30
|
+
* @param viewportHeight The rendered input height being upscaled
|
|
31
|
+
* @param inputWidth The width of the texture containing the input viewport
|
|
32
|
+
* @param inputHeight The height of the texture containing the input viewport
|
|
33
|
+
* @param outputWidth The display width which the input image gets upscaled to
|
|
34
|
+
* @param outputHeight The display height which the input image gets upscaled to
|
|
35
|
+
*/
|
|
36
|
+
updateConstants(effect: Effect, viewportWidth: number, viewportHeight: number, inputWidth: number, inputHeight: number, outputWidth: number, outputHeight: number): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { EngineStore } from "../Engines/engineStore.js";
|
|
2
|
+
import { EffectWrapper } from "../Materials/effectRenderer.pure.js";
|
|
3
|
+
/**
|
|
4
|
+
* Edge Adaptive Spatial Upsampling (EASU) post-process used by FSR 1
|
|
5
|
+
*/
|
|
6
|
+
export class ThinFSR1UpscalePostProcess extends EffectWrapper {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new FSR 1 upscale post process
|
|
9
|
+
* @param name Name of the effect
|
|
10
|
+
* @param engine Engine to use to render the effect. If not provided, the last created engine will be used
|
|
11
|
+
* @param options Options to configure the effect
|
|
12
|
+
*/
|
|
13
|
+
constructor(name, engine, options) {
|
|
14
|
+
engine ?? (engine = EngineStore.LastCreatedEngine);
|
|
15
|
+
super({
|
|
16
|
+
...options,
|
|
17
|
+
name,
|
|
18
|
+
engine,
|
|
19
|
+
useShaderStore: true,
|
|
20
|
+
useAsPostProcess: true,
|
|
21
|
+
fragmentShader: ThinFSR1UpscalePostProcess.FragmentUrl,
|
|
22
|
+
uniforms: ThinFSR1UpscalePostProcess.Uniforms,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
_gatherImports(useWebGPU, list) {
|
|
26
|
+
if (useWebGPU) {
|
|
27
|
+
this._webGPUReady = true;
|
|
28
|
+
list.push(import("../ShadersWGSL/fsr1Upscale.fragment.js"));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
list.push(import("../Shaders/fsr1Upscale.fragment.js"));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Sets the required constant values on the effect. Plain uniforms are used (rather than a uniform
|
|
36
|
+
* buffer) so this works on every backend, including Babylon Native, which disables uniform buffers.
|
|
37
|
+
* @param effect The effect to set the constants on (typically the one provided by onApplyObservable).
|
|
38
|
+
* @param viewportWidth The rendered input width being upscaled
|
|
39
|
+
* @param viewportHeight The rendered input height being upscaled
|
|
40
|
+
* @param inputWidth The width of the texture containing the input viewport
|
|
41
|
+
* @param inputHeight The height of the texture containing the input viewport
|
|
42
|
+
* @param outputWidth The display width which the input image gets upscaled to
|
|
43
|
+
* @param outputHeight The display height which the input image gets upscaled to
|
|
44
|
+
*/
|
|
45
|
+
updateConstants(effect, viewportWidth, viewportHeight, inputWidth, inputHeight, outputWidth, outputHeight) {
|
|
46
|
+
// Code based on FsrEasuCon from FSR 1:
|
|
47
|
+
// https://github.com/GPUOpen-Effects/FidelityFX-FSR/blob/a21ffb8f6c13233ba336352bdff293894c706575/ffx-fsr/ffx_fsr1.h#L156
|
|
48
|
+
const rcpInputWidth = 1 / inputWidth;
|
|
49
|
+
const rcpInputHeight = 1 / inputHeight;
|
|
50
|
+
const rcpOutputWidth = 1 / outputWidth;
|
|
51
|
+
const rcpOutputHeight = 1 / outputHeight;
|
|
52
|
+
// Upstream FSR packs these as uints and bitcasts them in the shader; this port declares
|
|
53
|
+
// them as floats on both the GLSL and WGSL sides, so they are sent as floats.
|
|
54
|
+
effect.setFloat4("con0", viewportWidth * rcpOutputWidth, viewportHeight * rcpOutputHeight, 0.5 * viewportWidth * rcpOutputWidth - 0.5, 0.5 * viewportHeight * rcpOutputHeight - 0.5);
|
|
55
|
+
effect.setFloat4("con1", rcpInputWidth, rcpInputHeight, 1 * rcpInputWidth, -1 * rcpInputHeight);
|
|
56
|
+
effect.setFloat4("con2", -1 * rcpInputWidth, 2 * rcpInputHeight, 1 * rcpInputWidth, 2 * rcpInputHeight);
|
|
57
|
+
effect.setFloat4("con3", 0 * rcpInputWidth, 4 * rcpInputHeight, 0, 0);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The fragment shader URL
|
|
62
|
+
*/
|
|
63
|
+
ThinFSR1UpscalePostProcess.FragmentUrl = "fsr1Upscale";
|
|
64
|
+
/**
|
|
65
|
+
* The list of uniforms used by the effect
|
|
66
|
+
*/
|
|
67
|
+
ThinFSR1UpscalePostProcess.Uniforms = ["con0", "con1", "con2", "con3"];
|
|
68
|
+
//# sourceMappingURL=thinFSR1UpscalePostProcess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinFSR1UpscalePostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/thinFSR1UpscalePostProcess.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAqC,MAAM,oCAAoC,CAAC;AAGtG;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,aAAa;IAWzD;;;;;OAKG;IACH,YAAY,IAAY,EAAE,MAAiC,EAAE,OAAsC;QAC/F,MAAM,KAAN,MAAM,GAAK,WAAW,CAAC,iBAAkB,EAAC;QAC1C,KAAK,CAAC;YACF,GAAG,OAAO;YACV,IAAI;YACJ,MAAM;YACN,cAAc,EAAE,IAAI;YACpB,gBAAgB,EAAE,IAAI;YACtB,cAAc,EAAE,0BAA0B,CAAC,WAAW;YACtD,QAAQ,EAAE,0BAA0B,CAAC,QAAQ;SAChD,CAAC,CAAC;IACP,CAAC;IAEkB,cAAc,CAAC,SAA8B,EAAE,IAAoB;QAClF,IAAI,SAAS,EAAE,CAAC;YACZ,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC,CAAC;QAC7D,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,iCAAiC,CAAC,CAAC,CAAC;QACzD,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACI,eAAe,CAClB,MAAc,EACd,aAAqB,EACrB,cAAsB,EACtB,UAAkB,EAClB,WAAmB,EACnB,WAAmB,EACnB,YAAoB;QAEpB,uCAAuC;QACvC,0HAA0H;QAC1H,MAAM,aAAa,GAAG,CAAC,GAAG,UAAU,CAAC;QACrC,MAAM,cAAc,GAAG,CAAC,GAAG,WAAW,CAAC;QACvC,MAAM,cAAc,GAAG,CAAC,GAAG,WAAW,CAAC;QACvC,MAAM,eAAe,GAAG,CAAC,GAAG,YAAY,CAAC;QAEzC,wFAAwF;QACxF,8EAA8E;QAC9E,MAAM,CAAC,SAAS,CACZ,MAAM,EACN,aAAa,GAAG,cAAc,EAC9B,cAAc,GAAG,eAAe,EAChC,GAAG,GAAG,aAAa,GAAG,cAAc,GAAG,GAAG,EAC1C,GAAG,GAAG,cAAc,GAAG,eAAe,GAAG,GAAG,CAC/C,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC,GAAG,aAAa,EAAE,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC;QAChG,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,aAAa,EAAE,CAAC,GAAG,cAAc,EAAE,CAAC,GAAG,aAAa,EAAE,CAAC,GAAG,cAAc,CAAC,CAAC;QACxG,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,aAAa,EAAE,CAAC,GAAG,cAAc,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;;AA7ED;;GAEG;AACoB,sCAAW,GAAG,aAAa,CAAC;AAEnD;;GAEG;AACoB,mCAAQ,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC","sourcesContent":["import { type AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport { type Effect } from \"core/Materials/effect\";\r\nimport { EngineStore } from \"core/Engines/engineStore\";\r\nimport { EffectWrapper, type EffectWrapperCreationOptions } from \"core/Materials/effectRenderer.pure\";\r\nimport { type Nullable } from \"core/types\";\r\n\r\n/**\r\n * Edge Adaptive Spatial Upsampling (EASU) post-process used by FSR 1\r\n */\r\nexport class ThinFSR1UpscalePostProcess extends EffectWrapper {\r\n /**\r\n * The fragment shader URL\r\n */\r\n public static readonly FragmentUrl = \"fsr1Upscale\";\r\n\r\n /**\r\n * The list of uniforms used by the effect\r\n */\r\n public static readonly Uniforms = [\"con0\", \"con1\", \"con2\", \"con3\"];\r\n\r\n /**\r\n * Creates a new FSR 1 upscale post process\r\n * @param name Name of the effect\r\n * @param engine Engine to use to render the effect. If not provided, the last created engine will be used\r\n * @param options Options to configure the effect\r\n */\r\n constructor(name: string, engine?: Nullable<AbstractEngine>, options?: EffectWrapperCreationOptions) {\r\n engine ??= EngineStore.LastCreatedEngine!;\r\n super({\r\n ...options,\r\n name,\r\n engine,\r\n useShaderStore: true,\r\n useAsPostProcess: true,\r\n fragmentShader: ThinFSR1UpscalePostProcess.FragmentUrl,\r\n uniforms: ThinFSR1UpscalePostProcess.Uniforms,\r\n });\r\n }\r\n\r\n protected override _gatherImports(useWebGPU: boolean | undefined, list: Promise<any>[]): void {\r\n if (useWebGPU) {\r\n this._webGPUReady = true;\r\n list.push(import(\"../ShadersWGSL/fsr1Upscale.fragment\"));\r\n } else {\r\n list.push(import(\"../Shaders/fsr1Upscale.fragment\"));\r\n }\r\n }\r\n\r\n /**\r\n * Sets the required constant values on the effect. Plain uniforms are used (rather than a uniform\r\n * buffer) so this works on every backend, including Babylon Native, which disables uniform buffers.\r\n * @param effect The effect to set the constants on (typically the one provided by onApplyObservable).\r\n * @param viewportWidth The rendered input width being upscaled\r\n * @param viewportHeight The rendered input height being upscaled\r\n * @param inputWidth The width of the texture containing the input viewport\r\n * @param inputHeight The height of the texture containing the input viewport\r\n * @param outputWidth The display width which the input image gets upscaled to\r\n * @param outputHeight The display height which the input image gets upscaled to\r\n */\r\n public updateConstants(\r\n effect: Effect,\r\n viewportWidth: number,\r\n viewportHeight: number,\r\n inputWidth: number,\r\n inputHeight: number,\r\n outputWidth: number,\r\n outputHeight: number\r\n ): void {\r\n // Code based on FsrEasuCon from FSR 1:\r\n // https://github.com/GPUOpen-Effects/FidelityFX-FSR/blob/a21ffb8f6c13233ba336352bdff293894c706575/ffx-fsr/ffx_fsr1.h#L156\r\n const rcpInputWidth = 1 / inputWidth;\r\n const rcpInputHeight = 1 / inputHeight;\r\n const rcpOutputWidth = 1 / outputWidth;\r\n const rcpOutputHeight = 1 / outputHeight;\r\n\r\n // Upstream FSR packs these as uints and bitcasts them in the shader; this port declares\r\n // them as floats on both the GLSL and WGSL sides, so they are sent as floats.\r\n effect.setFloat4(\r\n \"con0\",\r\n viewportWidth * rcpOutputWidth,\r\n viewportHeight * rcpOutputHeight,\r\n 0.5 * viewportWidth * rcpOutputWidth - 0.5,\r\n 0.5 * viewportHeight * rcpOutputHeight - 0.5\r\n );\r\n effect.setFloat4(\"con1\", rcpInputWidth, rcpInputHeight, 1 * rcpInputWidth, -1 * rcpInputHeight);\r\n effect.setFloat4(\"con2\", -1 * rcpInputWidth, 2 * rcpInputHeight, 1 * rcpInputWidth, 2 * rcpInputHeight);\r\n effect.setFloat4(\"con3\", 0 * rcpInputWidth, 4 * rcpInputHeight, 0, 0);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
const name = "ffxFunctions";
|
|
4
|
+
const shader = `float AMax3F1(float x,float y,float z) {return max(x,max(y,z));}
|
|
5
|
+
vec3 AMax3F3(vec3 x,vec3 y,vec3 z) {return max(x,max(y,z));}
|
|
6
|
+
float AMin3F1(float x,float y,float z) {return min(x,min(y,z));}
|
|
7
|
+
vec3 AMin3F3(vec3 x,vec3 y,vec3 z) {return min(x,min(y,z));}
|
|
8
|
+
float APrxLoRcpF1(float a) {return uintBitsToFloat(0x7ef07ebbu-floatBitsToUint(a));}
|
|
9
|
+
float APrxMedRcpF1(float a) {float b=uintBitsToFloat(0x7ef19fffu-floatBitsToUint(a));return b*(-b*a+2.0);}
|
|
10
|
+
float APrxLoRsqF1(float a) {return uintBitsToFloat(0x5f347d74u-(floatBitsToUint(a)>>1u));}
|
|
11
|
+
`;
|
|
12
|
+
// Sideeffect
|
|
13
|
+
if (!ShaderStore.IncludesShadersStore[name]) {
|
|
14
|
+
ShaderStore.IncludesShadersStore[name] = shader;
|
|
15
|
+
}
|
|
16
|
+
/** @internal */
|
|
17
|
+
export const ffxFunctions = { name, shader };
|
|
18
|
+
//# sourceMappingURL=ffxFunctions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ffxFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/ffxFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,MAAM,IAAI,GAAG,cAAc,CAAC;AAC5B,MAAM,MAAM,GAAG;;;;;;;CAOd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1C,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\nconst name = \"ffxFunctions\";\nconst shader = `float AMax3F1(float x,float y,float z) {return max(x,max(y,z));}\nvec3 AMax3F3(vec3 x,vec3 y,vec3 z) {return max(x,max(y,z));}\nfloat AMin3F1(float x,float y,float z) {return min(x,min(y,z));}\nvec3 AMin3F3(vec3 x,vec3 y,vec3 z) {return min(x,min(y,z));}\nfloat APrxLoRcpF1(float a) {return uintBitsToFloat(0x7ef07ebbu-floatBitsToUint(a));}\nfloat APrxMedRcpF1(float a) {float b=uintBitsToFloat(0x7ef19fffu-floatBitsToUint(a));return b*(-b*a+2.0);}\nfloat APrxLoRsqF1(float a) {return uintBitsToFloat(0x5f347d74u-(floatBitsToUint(a)>>1u));}\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const ffxFunctions = { name, shader };\n"]}
|
|
@@ -127,13 +127,13 @@ vec2 noiseInput,
|
|
|
127
127
|
bool isRefraction,
|
|
128
128
|
float ior
|
|
129
129
|
)
|
|
130
|
-
{vec3 V=inputView;vec3 N=inputNormal;vec3 T=inputTangent;vec3 B=inputBitangent;vec3 result=vec3(0.);float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float clampedAlphaT=max(alphaTangent,MINIMUMVARIANCE);float clampedAlphaB=max(alphaBitangent,MINIMUMVARIANCE);float effectiveDim=dim0*sqrt(clampedAlphaT*clampedAlphaB);float omegaP=(4.*PI)/(6.*effectiveDim*effectiveDim);const float noiseScale=clamp(log2(float(NUM_SAMPLES))/12.
|
|
130
|
+
{vec3 V=inputView;vec3 N=inputNormal;vec3 T=inputTangent;vec3 B=inputBitangent;vec3 result=vec3(0.);float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float clampedAlphaT=max(alphaTangent,MINIMUMVARIANCE);float clampedAlphaB=max(alphaBitangent,MINIMUMVARIANCE);float effectiveDim=dim0*sqrt(clampedAlphaT*clampedAlphaB);float omegaP=(4.*PI)/(6.*effectiveDim*effectiveDim);const float noiseScale=clamp(log2(float(NUM_SAMPLES))/12.0,0.0,1.0);float weight=0.;
|
|
131
131
|
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
|
132
132
|
for(uint i=0u; i<NUM_SAMPLES; ++i)
|
|
133
133
|
#else
|
|
134
134
|
for(int i=0; i<NUM_SAMPLES; ++i)
|
|
135
135
|
#endif
|
|
136
|
-
{vec2 Xi=hammersley(i,NUM_SAMPLES);Xi=fract(Xi+noiseInput*mix(0.
|
|
136
|
+
{vec2 Xi=hammersley(i,NUM_SAMPLES);Xi=fract(Xi+noiseInput*mix(0.5,0.015,noiseScale));
|
|
137
137
|
vec3 H_tangent=hemisphereImportanceSampleDggxAnisotropic(Xi,clampedAlphaT,clampedAlphaB);vec3 H=normalize(H_tangent.x*T+H_tangent.y*B+H_tangent.z*N);vec3 L;if (isRefraction) {L=refract(-V,H,1.0/ior);} else {L=reflect(-V,H);}
|
|
138
138
|
float NoH=max(dot(N,H),0.001);float VoH=max(dot(V,H),0.001);float NoL=max(dot(N,L),0.001);if (NoL>0.) {float pdf_inversed=4./normalDistributionFunction_BurleyGGX_Anisotropic(
|
|
139
139
|
H_tangent.z,H_tangent.x,H_tangent.y,vec2(clampedAlphaT,clampedAlphaB)
|