@babylonjs/core 7.25.2 → 7.26.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/Engines/Extensions/engine.prefilteredCubeTexture.d.ts +0 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.js +0 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.alpha.js +3 -3
- package/Engines/WebGPU/Extensions/engine.alpha.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.cubeTexture.js +5 -5
- package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.js +10 -10
- package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.readTexture.js +3 -3
- package/Engines/WebGPU/Extensions/engine.readTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +6 -6
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTargetCube.js +2 -2
- package/Engines/WebGPU/Extensions/engine.renderTargetCube.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTargetTexture.js +2 -2
- package/Engines/WebGPU/Extensions/engine.renderTargetTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuRenderTargetWrapper.d.ts +2 -2
- package/Engines/WebGPU/webgpuRenderTargetWrapper.js.map +1 -1
- package/Engines/abstractEngine.d.ts +2 -0
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.d.ts +5 -5
- package/Engines/engine.js +5 -0
- package/Engines/engine.js.map +1 -1
- package/Engines/thinWebGPUEngine.d.ts +66 -0
- package/Engines/thinWebGPUEngine.js +120 -0
- package/Engines/thinWebGPUEngine.js.map +1 -0
- package/Engines/webgpuEngine.d.ts +9 -58
- package/Engines/webgpuEngine.js +9 -108
- package/Engines/webgpuEngine.js.map +1 -1
- package/Materials/Node/Blocks/colorConverterBlock.d.ts +36 -0
- package/Materials/Node/Blocks/colorConverterBlock.js +192 -0
- package/Materials/Node/Blocks/colorConverterBlock.js.map +1 -0
- package/Materials/Node/Blocks/index.d.ts +1 -0
- package/Materials/Node/Blocks/index.js +1 -0
- package/Materials/Node/Blocks/index.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.d.ts +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.d.ts +0 -1
- package/Materials/Textures/Filtering/hdrFiltering.js +0 -1
- package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
- package/Materials/Textures/Loaders/basisTextureLoader.d.ts +0 -1
- package/Materials/Textures/Loaders/basisTextureLoader.js +0 -1
- package/Materials/Textures/Loaders/basisTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/ddsTextureLoader.d.ts +0 -1
- package/Materials/Textures/Loaders/ddsTextureLoader.js +0 -1
- package/Materials/Textures/Loaders/ddsTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/ktxTextureLoader.d.ts +0 -1
- package/Materials/Textures/Loaders/ktxTextureLoader.js +0 -1
- package/Materials/Textures/Loaders/ktxTextureLoader.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.d.ts +0 -2
- package/Materials/Textures/Procedurals/proceduralTexture.js +0 -2
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +0 -1
- package/Materials/Textures/baseTexture.js +0 -1
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/colorGradingTexture.d.ts +0 -1
- package/Materials/Textures/colorGradingTexture.js +0 -2
- package/Materials/Textures/colorGradingTexture.js.map +1 -1
- package/Materials/Textures/cubeTexture.d.ts +0 -1
- package/Materials/Textures/cubeTexture.js +0 -1
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/Textures/equiRectangularCubeTexture.d.ts +0 -1
- package/Materials/Textures/equiRectangularCubeTexture.js +0 -1
- package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
- package/Materials/Textures/hdrCubeTexture.d.ts +0 -1
- package/Materials/Textures/hdrCubeTexture.js +0 -1
- package/Materials/Textures/hdrCubeTexture.js.map +1 -1
- package/Materials/Textures/rawCubeTexture.d.ts +0 -1
- package/Materials/Textures/rawCubeTexture.js +0 -1
- package/Materials/Textures/rawCubeTexture.js.map +1 -1
- package/Materials/Textures/rawTexture.d.ts +0 -1
- package/Materials/Textures/rawTexture.js +0 -1
- package/Materials/Textures/rawTexture.js.map +1 -1
- package/Materials/Textures/rawTexture2DArray.d.ts +0 -1
- package/Materials/Textures/rawTexture2DArray.js +0 -1
- package/Materials/Textures/rawTexture2DArray.js.map +1 -1
- package/Materials/Textures/rawTexture3D.d.ts +0 -1
- package/Materials/Textures/rawTexture3D.js +0 -1
- package/Materials/Textures/rawTexture3D.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +0 -3
- package/Materials/Textures/renderTargetTexture.js +0 -3
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/material.detailMapConfiguration.d.ts +2 -2
- package/Materials/material.detailMapConfiguration.js.map +1 -1
- package/Misc/basis.d.ts +3 -3
- package/Misc/basis.js.map +1 -1
- package/Misc/dds.d.ts +0 -1
- package/Misc/dds.js +0 -1
- package/Misc/dds.js.map +1 -1
- package/Misc/environmentTextureTools.d.ts +0 -2
- package/Misc/environmentTextureTools.js +0 -2
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/minMaxReducer.d.ts +0 -1
- package/Misc/minMaxReducer.js +0 -1
- package/Misc/minMaxReducer.js.map +1 -1
- package/Misc/rgbdTextureTools.d.ts +0 -2
- package/Misc/rgbdTextureTools.js +5 -10
- package/Misc/rgbdTextureTools.js.map +1 -1
- package/Misc/screenshotTools.d.ts +0 -1
- package/Misc/screenshotTools.js +0 -1
- package/Misc/screenshotTools.js.map +1 -1
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.js.map +1 -1
- package/PostProcesses/anaglyphPostProcess.d.ts +2 -2
- package/PostProcesses/anaglyphPostProcess.js.map +1 -1
- package/PostProcesses/highlightsPostProcess.d.ts +2 -2
- package/PostProcesses/highlightsPostProcess.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +0 -1
- package/PostProcesses/postProcess.js +0 -1
- package/PostProcesses/postProcess.js.map +1 -1
- package/PostProcesses/stereoscopicInterlacePostProcess.d.ts +3 -3
- package/PostProcesses/stereoscopicInterlacePostProcess.js.map +1 -1
- package/PostProcesses/tonemapPostProcess.d.ts +2 -2
- package/PostProcesses/tonemapPostProcess.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { NodeMaterialBlock } from "../nodeMaterialBlock";
|
|
2
|
+
import type { NodeMaterialBuildState } from "../nodeMaterialBuildState";
|
|
3
|
+
import type { NodeMaterialConnectionPoint } from "../nodeMaterialBlockConnectionPoint";
|
|
4
|
+
/**
|
|
5
|
+
* Block used to apply rgb/hsl convertions
|
|
6
|
+
*/
|
|
7
|
+
export declare class ColorConverterBlock extends NodeMaterialBlock {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new ColorConverterBlock
|
|
10
|
+
* @param name defines the block name
|
|
11
|
+
*/
|
|
12
|
+
constructor(name: string);
|
|
13
|
+
/**
|
|
14
|
+
* Gets the current class name
|
|
15
|
+
* @returns the class name
|
|
16
|
+
*/
|
|
17
|
+
getClassName(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the rgb value (input)
|
|
20
|
+
*/
|
|
21
|
+
get rgbIn(): NodeMaterialConnectionPoint;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the hsl value (input)
|
|
24
|
+
*/
|
|
25
|
+
get hslIn(): NodeMaterialConnectionPoint;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the rgb value (output)
|
|
28
|
+
*/
|
|
29
|
+
get rgbOut(): NodeMaterialConnectionPoint;
|
|
30
|
+
/**
|
|
31
|
+
* Gets the hsl value (output)
|
|
32
|
+
*/
|
|
33
|
+
get hslOut(): NodeMaterialConnectionPoint;
|
|
34
|
+
protected _inputRename(name: string): string;
|
|
35
|
+
protected _buildBlock(state: NodeMaterialBuildState): this;
|
|
36
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { NodeMaterialBlock } from "../nodeMaterialBlock.js";
|
|
2
|
+
import { NodeMaterialBlockConnectionPointTypes } from "../Enums/nodeMaterialBlockConnectionPointTypes.js";
|
|
3
|
+
import { NodeMaterialBlockTargets } from "../Enums/nodeMaterialBlockTargets.js";
|
|
4
|
+
import { RegisterClass } from "../../../Misc/typeStore.js";
|
|
5
|
+
/**
|
|
6
|
+
* Block used to apply rgb/hsl convertions
|
|
7
|
+
*/
|
|
8
|
+
export class ColorConverterBlock extends NodeMaterialBlock {
|
|
9
|
+
/**
|
|
10
|
+
* Create a new ColorConverterBlock
|
|
11
|
+
* @param name defines the block name
|
|
12
|
+
*/
|
|
13
|
+
constructor(name) {
|
|
14
|
+
super(name, NodeMaterialBlockTargets.Neutral);
|
|
15
|
+
this.registerInput("rgb ", NodeMaterialBlockConnectionPointTypes.Color3, true);
|
|
16
|
+
this.registerInput("hsl ", NodeMaterialBlockConnectionPointTypes.Color3, true);
|
|
17
|
+
this.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3);
|
|
18
|
+
this.registerOutput("hsl", NodeMaterialBlockConnectionPointTypes.Color3);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Gets the current class name
|
|
22
|
+
* @returns the class name
|
|
23
|
+
*/
|
|
24
|
+
getClassName() {
|
|
25
|
+
return "ColorConverterBlock";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Gets the rgb value (input)
|
|
29
|
+
*/
|
|
30
|
+
get rgbIn() {
|
|
31
|
+
return this._inputs[0];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Gets the hsl value (input)
|
|
35
|
+
*/
|
|
36
|
+
get hslIn() {
|
|
37
|
+
return this._inputs[1];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Gets the rgb value (output)
|
|
41
|
+
*/
|
|
42
|
+
get rgbOut() {
|
|
43
|
+
return this._outputs[0];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets the hsl value (output)
|
|
47
|
+
*/
|
|
48
|
+
get hslOut() {
|
|
49
|
+
return this._outputs[1];
|
|
50
|
+
}
|
|
51
|
+
_inputRename(name) {
|
|
52
|
+
if (name === "rgb ") {
|
|
53
|
+
return "rgbIn";
|
|
54
|
+
}
|
|
55
|
+
if (name === "hsl ") {
|
|
56
|
+
return "hslIn";
|
|
57
|
+
}
|
|
58
|
+
return name;
|
|
59
|
+
}
|
|
60
|
+
_buildBlock(state) {
|
|
61
|
+
super._buildBlock(state);
|
|
62
|
+
const rgbInput = this.rgbIn;
|
|
63
|
+
const hslInput = this.hslIn;
|
|
64
|
+
const rbgOutput = this._outputs[0];
|
|
65
|
+
const hslOutput = this._outputs[1];
|
|
66
|
+
const vec3 = state._getShaderType(NodeMaterialBlockConnectionPointTypes.Vector3);
|
|
67
|
+
let rgb2hsl = `
|
|
68
|
+
vec3 rgb2hsl(vec3 color) {
|
|
69
|
+
float r = color.r;
|
|
70
|
+
float g = color.g;
|
|
71
|
+
float b = color.b;
|
|
72
|
+
|
|
73
|
+
float maxc = max(r, max(g, b));
|
|
74
|
+
float minc = min(r, min(g, b));
|
|
75
|
+
float h = 0.0;
|
|
76
|
+
float s = 0.0;
|
|
77
|
+
float l = (maxc + minc) / 2.0;
|
|
78
|
+
|
|
79
|
+
if (maxc != minc) {
|
|
80
|
+
float d = maxc - minc;
|
|
81
|
+
if (l > 0.5) {
|
|
82
|
+
s = d / (2.0 - maxc - minc);
|
|
83
|
+
} else {
|
|
84
|
+
s = d / (maxc + minc);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (maxc == r) {
|
|
88
|
+
float add = 0.0;
|
|
89
|
+
if (g < b) {
|
|
90
|
+
add = 6.0;
|
|
91
|
+
}
|
|
92
|
+
h = (g - b) / d + add;
|
|
93
|
+
} else if (maxc == g) {
|
|
94
|
+
h = (b - r) / d + 2.0;
|
|
95
|
+
} else if (maxc == b) {
|
|
96
|
+
h = (r - g) / d + 4.0;
|
|
97
|
+
}
|
|
98
|
+
h /= 6.0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return vec3(h, s, l);
|
|
102
|
+
}`;
|
|
103
|
+
let hue2rgb = `
|
|
104
|
+
float hue2rgb(float p, float q, float tt) {
|
|
105
|
+
float t = tt;
|
|
106
|
+
if (t < 0.0) {
|
|
107
|
+
t += 1.0;
|
|
108
|
+
}
|
|
109
|
+
if (t > 1.0) {
|
|
110
|
+
t -= 1.0;
|
|
111
|
+
}
|
|
112
|
+
if (t < 1.0/6.0) {
|
|
113
|
+
return p + (q - p) * 6.0 * t;
|
|
114
|
+
}
|
|
115
|
+
if (t < 1.0/2.0) {
|
|
116
|
+
return q;
|
|
117
|
+
}
|
|
118
|
+
if (t < 2.0/3.0) {
|
|
119
|
+
return p + (q - p) * (2.0/3.0 - t) * 6.0;
|
|
120
|
+
}
|
|
121
|
+
return p;
|
|
122
|
+
}`;
|
|
123
|
+
let hsl2rgb = `
|
|
124
|
+
vec3 hsl2rgb(vec3 hsl) {
|
|
125
|
+
float h = hsl.x;
|
|
126
|
+
float s = hsl.y;
|
|
127
|
+
float l = hsl.z;
|
|
128
|
+
|
|
129
|
+
float r;
|
|
130
|
+
float g;
|
|
131
|
+
float b;
|
|
132
|
+
|
|
133
|
+
if (s == 0.0) {
|
|
134
|
+
// Achromatic (grey)
|
|
135
|
+
r = l;
|
|
136
|
+
g = l;
|
|
137
|
+
b = l;
|
|
138
|
+
} else {
|
|
139
|
+
float q;
|
|
140
|
+
|
|
141
|
+
if (l < 0.5) {
|
|
142
|
+
q = l * (1.0 + s);
|
|
143
|
+
} else {
|
|
144
|
+
q = (l + s - l * s);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
float p = 2.0 * l - q;
|
|
148
|
+
|
|
149
|
+
r = hue2rgb(p, q, h + 1.0/3.0);
|
|
150
|
+
g = hue2rgb(p, q, h);
|
|
151
|
+
b = hue2rgb(p, q, h - 1.0/3.0);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return vec3(r, g, b);
|
|
155
|
+
}`;
|
|
156
|
+
if (state.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
|
|
157
|
+
rgb2hsl = state._babylonSLtoWGSL(rgb2hsl);
|
|
158
|
+
hue2rgb = state._babylonSLtoWGSL(hue2rgb);
|
|
159
|
+
hsl2rgb = state._babylonSLtoWGSL(hsl2rgb);
|
|
160
|
+
}
|
|
161
|
+
state._emitFunction("rgb2hsl", rgb2hsl, "");
|
|
162
|
+
state._emitFunction("hue2rgb", hue2rgb, "");
|
|
163
|
+
state._emitFunction("hsl2rgb", hsl2rgb, "");
|
|
164
|
+
if (rgbInput.isConnected) {
|
|
165
|
+
if (rbgOutput.hasEndpoints) {
|
|
166
|
+
state.compilationString += state._declareOutput(rbgOutput) + ` = ${rgbInput.associatedVariableName};\n`;
|
|
167
|
+
}
|
|
168
|
+
if (hslOutput.hasEndpoints) {
|
|
169
|
+
state.compilationString += state._declareOutput(hslOutput) + ` = rgb2hsl(${rgbInput.associatedVariableName});\n`;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else if (hslInput.isConnected) {
|
|
173
|
+
if (rbgOutput.hasEndpoints) {
|
|
174
|
+
state.compilationString += state._declareOutput(rbgOutput) + ` = hsl2rgb(${hslInput.associatedVariableName});\n`;
|
|
175
|
+
}
|
|
176
|
+
if (hslOutput.hasEndpoints) {
|
|
177
|
+
state.compilationString += state._declareOutput(hslOutput) + ` = ${hslInput.associatedVariableName};\n`;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
if (rbgOutput.hasEndpoints) {
|
|
182
|
+
state.compilationString += state._declareOutput(rbgOutput) + ` = ${vec3}(0.);\n`;
|
|
183
|
+
}
|
|
184
|
+
if (hslOutput.hasEndpoints) {
|
|
185
|
+
state.compilationString += state._declareOutput(hslOutput) + ` = ${vec3}(0.);\n`;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
RegisterClass("BABYLON.ColorConverterBlock", ColorConverterBlock);
|
|
192
|
+
//# sourceMappingURL=colorConverterBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorConverterBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Node/Blocks/colorConverterBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAEvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAE7E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACtD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC;QAE9C,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,qCAAqC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,qCAAqC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAE/E,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,qCAAqC,CAAC,MAAM,CAAC,CAAC;QACzE,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,qCAAqC,CAAC,MAAM,CAAC,CAAC;IAC7E,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,qBAAqB,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AC,cAAc,CAAC,SAAS,CAAC,GAAG,OAAO,IAAI,SAAS,CAAC;aACrF;YAED,IAAI,SAAS,CAAC,YAAY,EAAE;gBACxB,KAAK,CAAC,iBAAiB,IAAI,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,GAAG,OAAO,IAAI,SAAS,CAAC;aACrF;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../nodeMaterialBuildState\";\r\nimport { NodeMaterialBlockTargets } from \"../Enums/nodeMaterialBlockTargets\";\r\nimport type { NodeMaterialConnectionPoint } from \"../nodeMaterialBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Block used to apply rgb/hsl convertions\r\n */\r\nexport class ColorConverterBlock extends NodeMaterialBlock {\r\n /**\r\n * Create a new ColorConverterBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Neutral);\r\n\r\n this.registerInput(\"rgb \", NodeMaterialBlockConnectionPointTypes.Color3, true);\r\n this.registerInput(\"hsl \", NodeMaterialBlockConnectionPointTypes.Color3, true);\r\n\r\n this.registerOutput(\"rgb\", NodeMaterialBlockConnectionPointTypes.Color3);\r\n this.registerOutput(\"hsl\", NodeMaterialBlockConnectionPointTypes.Color3);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"ColorConverterBlock\";\r\n }\r\n\r\n /**\r\n * Gets the rgb value (input)\r\n */\r\n public get rgbIn(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the hsl value (input)\r\n */\r\n public get hslIn(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the rgb value (output)\r\n */\r\n public get rgbOut(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the hsl value (output)\r\n */\r\n public get hslOut(): NodeMaterialConnectionPoint {\r\n return this._outputs[1];\r\n }\r\n\r\n protected override _inputRename(name: string) {\r\n if (name === \"rgb \") {\r\n return \"rgbIn\";\r\n }\r\n if (name === \"hsl \") {\r\n return \"hslIn\";\r\n }\r\n return name;\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n const rgbInput = this.rgbIn;\r\n const hslInput = this.hslIn;\r\n\r\n const rbgOutput = this._outputs[0];\r\n const hslOutput = this._outputs[1];\r\n\r\n const vec3 = state._getShaderType(NodeMaterialBlockConnectionPointTypes.Vector3);\r\n\r\n let rgb2hsl = `\r\n vec3 rgb2hsl(vec3 color) {\r\n float r = color.r;\r\n float g = color.g;\r\n float b = color.b;\r\n\r\n float maxc = max(r, max(g, b));\r\n float minc = min(r, min(g, b));\r\n float h = 0.0;\r\n float s = 0.0;\r\n float l = (maxc + minc) / 2.0;\r\n\r\n if (maxc != minc) {\r\n float d = maxc - minc;\r\n if (l > 0.5) {\r\n s = d / (2.0 - maxc - minc);\r\n } else {\r\n s = d / (maxc + minc);\r\n }\r\n\r\n if (maxc == r) {\r\n float add = 0.0;\r\n if (g < b) {\r\n add = 6.0;\r\n }\r\n h = (g - b) / d + add;\r\n } else if (maxc == g) {\r\n h = (b - r) / d + 2.0;\r\n } else if (maxc == b) {\r\n h = (r - g) / d + 4.0;\r\n }\r\n h /= 6.0;\r\n }\r\n\r\n return vec3(h, s, l);\r\n }`;\r\n\r\n let hue2rgb = `\r\n float hue2rgb(float p, float q, float tt) {\r\n float t = tt;\r\n if (t < 0.0) {\r\n t += 1.0;\r\n }\r\n if (t > 1.0) {\r\n t -= 1.0;\r\n }\r\n if (t < 1.0/6.0) {\r\n return p + (q - p) * 6.0 * t;\r\n }\r\n if (t < 1.0/2.0) {\r\n return q;\r\n }\r\n if (t < 2.0/3.0) {\r\n return p + (q - p) * (2.0/3.0 - t) * 6.0;\r\n }\r\n return p;\r\n }`;\r\n\r\n let hsl2rgb = `\r\n vec3 hsl2rgb(vec3 hsl) {\r\n float h = hsl.x;\r\n float s = hsl.y;\r\n float l = hsl.z;\r\n\r\n float r;\r\n float g;\r\n float b;\r\n\r\n if (s == 0.0) {\r\n // Achromatic (grey)\r\n r = l;\r\n g = l;\r\n b = l; \r\n } else {\r\n float q;\r\n \r\n if (l < 0.5) {\r\n q = l * (1.0 + s);\r\n } else {\r\n q = (l + s - l * s);\r\n }\r\n\r\n float p = 2.0 * l - q;\r\n\r\n r = hue2rgb(p, q, h + 1.0/3.0);\r\n g = hue2rgb(p, q, h);\r\n b = hue2rgb(p, q, h - 1.0/3.0);\r\n }\r\n\r\n return vec3(r, g, b);\r\n }`;\r\n\r\n if (state.shaderLanguage === ShaderLanguage.WGSL) {\r\n rgb2hsl = state._babylonSLtoWGSL(rgb2hsl);\r\n hue2rgb = state._babylonSLtoWGSL(hue2rgb);\r\n hsl2rgb = state._babylonSLtoWGSL(hsl2rgb);\r\n }\r\n\r\n state._emitFunction(\"rgb2hsl\", rgb2hsl, \"\");\r\n state._emitFunction(\"hue2rgb\", hue2rgb, \"\");\r\n state._emitFunction(\"hsl2rgb\", hsl2rgb, \"\");\r\n\r\n if (rgbInput.isConnected) {\r\n if (rbgOutput.hasEndpoints) {\r\n state.compilationString += state._declareOutput(rbgOutput) + ` = ${rgbInput.associatedVariableName};\\n`;\r\n }\r\n\r\n if (hslOutput.hasEndpoints) {\r\n state.compilationString += state._declareOutput(hslOutput) + ` = rgb2hsl(${rgbInput.associatedVariableName});\\n`;\r\n }\r\n } else if (hslInput.isConnected) {\r\n if (rbgOutput.hasEndpoints) {\r\n state.compilationString += state._declareOutput(rbgOutput) + ` = hsl2rgb(${hslInput.associatedVariableName});\\n`;\r\n }\r\n if (hslOutput.hasEndpoints) {\r\n state.compilationString += state._declareOutput(hslOutput) + ` = ${hslInput.associatedVariableName};\\n`;\r\n }\r\n } else {\r\n if (rbgOutput.hasEndpoints) {\r\n state.compilationString += state._declareOutput(rbgOutput) + ` = ${vec3}(0.);\\n`;\r\n }\r\n\r\n if (hslOutput.hasEndpoints) {\r\n state.compilationString += state._declareOutput(hslOutput) + ` = ${vec3}(0.);\\n`;\r\n }\r\n }\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ColorConverterBlock\", ColorConverterBlock);\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Node/Blocks/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,cAAc,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./Vertex/index\";\r\nexport * from \"./Fragment/index\";\r\nexport * from \"./Dual/index\";\r\nexport * from \"./Input/index\";\r\nexport * from \"./Teleport/index\";\r\nexport * from \"./multiplyBlock\";\r\nexport * from \"./addBlock\";\r\nexport * from \"./scaleBlock\";\r\nexport * from \"./clampBlock\";\r\nexport * from \"./crossBlock\";\r\nexport * from \"./customBlock\";\r\nexport * from \"./dotBlock\";\r\nexport * from \"./transformBlock\";\r\nexport * from \"./remapBlock\";\r\nexport * from \"./normalizeBlock\";\r\nexport * from \"./trigonometryBlock\";\r\nexport * from \"./colorMergerBlock\";\r\nexport * from \"./vectorMergerBlock\";\r\nexport * from \"./colorSplitterBlock\";\r\nexport * from \"./vectorSplitterBlock\";\r\nexport * from \"./lerpBlock\";\r\nexport * from \"./divideBlock\";\r\nexport * from \"./subtractBlock\";\r\nexport * from \"./stepBlock\";\r\nexport * from \"./oneMinusBlock\";\r\nexport * from \"./viewDirectionBlock\";\r\nexport * from \"./fresnelBlock\";\r\nexport * from \"./maxBlock\";\r\nexport * from \"./minBlock\";\r\nexport * from \"./distanceBlock\";\r\nexport * from \"./lengthBlock\";\r\nexport * from \"./negateBlock\";\r\nexport * from \"./powBlock\";\r\nexport * from \"./randomNumberBlock\";\r\nexport * from \"./arcTan2Block\";\r\nexport * from \"./smoothStepBlock\";\r\nexport * from \"./reciprocalBlock\";\r\nexport * from \"./replaceColorBlock\";\r\nexport * from \"./posterizeBlock\";\r\nexport * from \"./waveBlock\";\r\nexport * from \"./gradientBlock\";\r\nexport * from \"./nLerpBlock\";\r\nexport * from \"./worleyNoise3DBlock\";\r\nexport * from \"./simplexPerlin3DBlock\";\r\nexport * from \"./normalBlendBlock\";\r\nexport * from \"./rotate2dBlock\";\r\nexport * from \"./reflectBlock\";\r\nexport * from \"./refractBlock\";\r\nexport * from \"./desaturateBlock\";\r\nexport * from \"./PBR/index\";\r\nexport * from \"./Particle/index\";\r\nexport * from \"./modBlock\";\r\nexport * from \"./matrixBuilderBlock\";\r\nexport * from \"./conditionalBlock\";\r\nexport * from \"./cloudBlock\";\r\nexport * from \"./voronoiNoiseBlock\";\r\nexport * from \"./elbowBlock\";\r\nexport * from \"./triPlanarBlock\";\r\nexport * from \"./biPlanarBlock\";\r\nexport * from \"./matrixDeterminantBlock\";\r\nexport * from \"./matrixTransposeBlock\";\r\nexport * from \"./meshAttributeExistsBlock\";\r\nexport * from \"./curveBlock\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Node/Blocks/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./Vertex/index\";\r\nexport * from \"./Fragment/index\";\r\nexport * from \"./Dual/index\";\r\nexport * from \"./Input/index\";\r\nexport * from \"./Teleport/index\";\r\nexport * from \"./multiplyBlock\";\r\nexport * from \"./addBlock\";\r\nexport * from \"./scaleBlock\";\r\nexport * from \"./clampBlock\";\r\nexport * from \"./crossBlock\";\r\nexport * from \"./customBlock\";\r\nexport * from \"./dotBlock\";\r\nexport * from \"./transformBlock\";\r\nexport * from \"./remapBlock\";\r\nexport * from \"./normalizeBlock\";\r\nexport * from \"./trigonometryBlock\";\r\nexport * from \"./colorMergerBlock\";\r\nexport * from \"./vectorMergerBlock\";\r\nexport * from \"./colorSplitterBlock\";\r\nexport * from \"./vectorSplitterBlock\";\r\nexport * from \"./lerpBlock\";\r\nexport * from \"./divideBlock\";\r\nexport * from \"./subtractBlock\";\r\nexport * from \"./stepBlock\";\r\nexport * from \"./oneMinusBlock\";\r\nexport * from \"./viewDirectionBlock\";\r\nexport * from \"./fresnelBlock\";\r\nexport * from \"./maxBlock\";\r\nexport * from \"./minBlock\";\r\nexport * from \"./distanceBlock\";\r\nexport * from \"./lengthBlock\";\r\nexport * from \"./negateBlock\";\r\nexport * from \"./powBlock\";\r\nexport * from \"./randomNumberBlock\";\r\nexport * from \"./arcTan2Block\";\r\nexport * from \"./smoothStepBlock\";\r\nexport * from \"./reciprocalBlock\";\r\nexport * from \"./replaceColorBlock\";\r\nexport * from \"./posterizeBlock\";\r\nexport * from \"./waveBlock\";\r\nexport * from \"./gradientBlock\";\r\nexport * from \"./nLerpBlock\";\r\nexport * from \"./worleyNoise3DBlock\";\r\nexport * from \"./simplexPerlin3DBlock\";\r\nexport * from \"./normalBlendBlock\";\r\nexport * from \"./rotate2dBlock\";\r\nexport * from \"./reflectBlock\";\r\nexport * from \"./refractBlock\";\r\nexport * from \"./desaturateBlock\";\r\nexport * from \"./PBR/index\";\r\nexport * from \"./Particle/index\";\r\nexport * from \"./modBlock\";\r\nexport * from \"./matrixBuilderBlock\";\r\nexport * from \"./conditionalBlock\";\r\nexport * from \"./cloudBlock\";\r\nexport * from \"./voronoiNoiseBlock\";\r\nexport * from \"./elbowBlock\";\r\nexport * from \"./triPlanarBlock\";\r\nexport * from \"./biPlanarBlock\";\r\nexport * from \"./matrixDeterminantBlock\";\r\nexport * from \"./matrixTransposeBlock\";\r\nexport * from \"./meshAttributeExistsBlock\";\r\nexport * from \"./curveBlock\";\r\nexport * from \"./colorConverterBlock\";\r\n"]}
|
|
@@ -122,7 +122,7 @@ export declare class NodeMaterialBuildState {
|
|
|
122
122
|
/**
|
|
123
123
|
* @internal
|
|
124
124
|
*/
|
|
125
|
-
_getShaderType(type: NodeMaterialBlockConnectionPointTypes): "" | "float" | "
|
|
125
|
+
_getShaderType(type: NodeMaterialBlockConnectionPointTypes): "" | "float" | "i32" | "int" | "mat4" | "mat4x4f" | "f32" | "vec2" | "vec4" | "vec3" | "vec2f" | "vec3f" | "vec4f";
|
|
126
126
|
/**
|
|
127
127
|
* @internal
|
|
128
128
|
*/
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { BaseTexture } from "../baseTexture";
|
|
2
2
|
import type { AbstractEngine } from "../../../Engines/abstractEngine";
|
|
3
3
|
import type { Nullable } from "../../../types";
|
|
4
|
-
import "../../../Engines/Extensions/engine.renderTargetCube";
|
|
5
4
|
/**
|
|
6
5
|
* Options for texture filtering
|
|
7
6
|
*/
|
|
@@ -3,7 +3,6 @@ import { ILog2 } from "../../../Maths/math.scalar.functions.js";
|
|
|
3
3
|
|
|
4
4
|
import { EffectWrapper, EffectRenderer } from "../../../Materials/effectRenderer.js";
|
|
5
5
|
import { Logger } from "../../../Misc/logger.js";
|
|
6
|
-
import "../../../Engines/Extensions/engine.renderTargetCube.js";
|
|
7
6
|
/**
|
|
8
7
|
* Filters HDR maps to get correct renderings of PBR reflections
|
|
9
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hdrFiltering.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Filtering/hdrFiltering.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAI7D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAGlF,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,qDAAqD,CAAC;AAkB7D;;GAEG;AACH,MAAM,OAAO,YAAY;IAmBrB;;;;;OAKG;IACH,YAAY,MAAsB,EAAE,UAAgC,EAAE;QApB9D,yBAAoB,GAAW,CAAC,CAAC;QACjC,wBAAmB,GAAW,GAAG,CAAC;QAE1C;;;WAGG;QACI,YAAO,GAAW,SAAS,CAAC,iCAAiC,CAAC;Q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AAM,CAAC,wCAAwC,CAAC,CAAC,CAAC,CAAC;iBACzH;YACL,CAAC;SACJ,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACI,OAAO,CAAC,OAAoB;QAC/B,OAAO,OAAO,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IACrE,CAAC;IAED;;;;;;;;OAQG;IACI,SAAS,CAAC,OAAoB,EAAE,aAAmC,IAAI;QAC1E,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,wBAAwB,EAAE;YAClD,MAAM,CAAC,IAAI,CAAC,yFAAyF,CAAC,CAAC;YACvG,OAAO,OAAO,CAAC,MAAM,CAAC,yFAAyF,CAAC,CAAC;SACpH;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,IAAI,CAAC,eAAe,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACxD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAClD,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE;gBAChD,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;gBACjC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;gBAC/B,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;gBAC9B,OAAO,EAAE,CAAC;gBACV,IAAI,UAAU,EAAE;oBACZ,UAAU,EAAE,CAAC;iBAChB;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import { Vector3 } from \"../../../Maths/math\";\r\nimport { ILog2 } from \"../../../Maths/math.scalar.functions\";\r\nimport type { BaseTexture } from \"../baseTexture\";\r\nimport type { AbstractEngine } from \"../../../Engines/abstractEngine\";\r\nimport type { Effect } from \"../../../Materials/effect\";\r\nimport { Constants } from \"../../../Engines/constants\";\r\nimport { EffectWrapper, EffectRenderer } from \"../../../Materials/effectRenderer\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport type { RenderTargetWrapper } from \"../../../Engines/renderTargetWrapper\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\n\r\nimport \"../../../Engines/Extensions/engine.renderTargetCube\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Options for texture filtering\r\n */\r\ninterface IHDRFilteringOptions {\r\n /**\r\n * Scales pixel intensity for the input HDR map.\r\n */\r\n hdrScale?: number;\r\n\r\n /**\r\n * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering\r\n */\r\n quality?: number;\r\n}\r\n\r\n/**\r\n * Filters HDR maps to get correct renderings of PBR reflections\r\n */\r\nexport class HDRFiltering {\r\n private _engine: AbstractEngine;\r\n private _effectRenderer: EffectRenderer;\r\n private _effectWrapper: EffectWrapper;\r\n\r\n private _lodGenerationOffset: number = 0;\r\n private _lodGenerationScale: number = 0.8;\r\n\r\n /**\r\n * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless\r\n * you care about baking speed.\r\n */\r\n public quality: number = Constants.TEXTURE_FILTERING_QUALITY_OFFLINE;\r\n\r\n /**\r\n * Scales pixel intensity for the input HDR map.\r\n */\r\n public hdrScale: number = 1;\r\n\r\n /**\r\n * Instantiates HDR filter for reflection maps\r\n *\r\n * @param engine Thin engine\r\n * @param options Options\r\n */\r\n constructor(engine: AbstractEngine, options: IHDRFilteringOptions = {}) {\r\n // pass\r\n this._engine = engine;\r\n this.hdrScale = options.hdrScale || this.hdrScale;\r\n this.quality = options.quality || this.quality;\r\n }\r\n\r\n private _createRenderTarget(size: number): RenderTargetWrapper {\r\n let textureType = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n if (this._engine.getCaps().textureHalfFloatRender) {\r\n textureType = Constants.TEXTURETYPE_HALF_FLOAT;\r\n } else if (this._engine.getCaps().textureFloatRender) {\r\n textureType = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n\r\n const rtWrapper = this._engine.createRenderTargetCubeTexture(size, {\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n type: textureType,\r\n createMipMaps: true,\r\n generateMipMaps: false,\r\n generateDepthBuffer: false,\r\n generateStencilBuffer: false,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n });\r\n this._engine.updateTextureWrappingMode(rtWrapper.texture!, Constants.TEXTURE_CLAMP_ADDRESSMODE, Constants.TEXTURE_CLAMP_ADDRESSMODE, Constants.TEXTURE_CLAMP_ADDRESSMODE);\r\n\r\n this._engine.updateTextureSamplingMode(Constants.TEXTURE_TRILINEAR_SAMPLINGMODE, rtWrapper.texture!, true);\r\n\r\n return rtWrapper;\r\n }\r\n\r\n private _prefilterInternal(texture: BaseTexture): BaseTexture {\r\n const width = texture.getSize().width;\r\n const mipmapsCount = ILog2(width) + 1;\r\n\r\n const effect = this._effectWrapper.effect;\r\n const outputTexture = this._createRenderTarget(width);\r\n this._effectRenderer.saveStates();\r\n this._effectRenderer.setViewport();\r\n\r\n const intTexture = texture.getInternalTexture();\r\n if (intTexture) {\r\n // Just in case generate fresh clean mips.\r\n this._engine.updateTextureSamplingMode(Constants.TEXTURE_TRILINEAR_SAMPLINGMODE, intTexture, true);\r\n }\r\n\r\n this._effectRenderer.applyEffectWrapper(this._effectWrapper);\r\n\r\n const directions = [\r\n [new Vector3(0, 0, -1), new Vector3(0, -1, 0), new Vector3(1, 0, 0)], // PositiveX\r\n [new Vector3(0, 0, 1), new Vector3(0, -1, 0), new Vector3(-1, 0, 0)], // NegativeX\r\n [new Vector3(1, 0, 0), new Vector3(0, 0, 1), new Vector3(0, 1, 0)], // PositiveY\r\n [new Vector3(1, 0, 0), new Vector3(0, 0, -1), new Vector3(0, -1, 0)], // NegativeY\r\n [new Vector3(1, 0, 0), new Vector3(0, -1, 0), new Vector3(0, 0, 1)], // PositiveZ\r\n [new Vector3(-1, 0, 0), new Vector3(0, -1, 0), new Vector3(0, 0, -1)], // NegativeZ\r\n ];\r\n\r\n effect.setFloat(\"hdrScale\", this.hdrScale);\r\n effect.setFloat2(\"vFilteringInfo\", texture.getSize().width, mipmapsCount);\r\n effect.setTexture(\"inputTexture\", texture);\r\n\r\n for (let face = 0; face < 6; face++) {\r\n effect.setVector3(\"up\", directions[face][0]);\r\n effect.setVector3(\"right\", directions[face][1]);\r\n effect.setVector3(\"front\", directions[face][2]);\r\n\r\n for (let lod = 0; lod < mipmapsCount; lod++) {\r\n this._engine.bindFramebuffer(outputTexture, face, undefined, undefined, true, lod);\r\n this._effectRenderer.applyEffectWrapper(this._effectWrapper);\r\n\r\n let alpha = Math.pow(2, (lod - this._lodGenerationOffset) / this._lodGenerationScale) / width;\r\n if (lod === 0) {\r\n alpha = 0;\r\n }\r\n\r\n effect.setFloat(\"alphaG\", alpha);\r\n\r\n this._effectRenderer.draw();\r\n }\r\n }\r\n\r\n // Cleanup\r\n this._effectRenderer.restoreStates();\r\n this._engine.restoreDefaultFramebuffer();\r\n this._engine._releaseTexture(texture._texture!);\r\n\r\n // Internal Swap\r\n const type = outputTexture.texture!.type;\r\n const format = outputTexture.texture!.format;\r\n\r\n outputTexture._swapAndDie(texture._texture!);\r\n\r\n texture._texture!.type = type;\r\n texture._texture!.format = format;\r\n\r\n // New settings\r\n texture.gammaSpace = false;\r\n texture.lodGenerationOffset = this._lodGenerationOffset;\r\n texture.lodGenerationScale = this._lodGenerationScale;\r\n texture._prefiltered = true;\r\n\r\n return texture;\r\n }\r\n\r\n private _createEffect(texture: BaseTexture, onCompiled?: Nullable<(effect: Effect) => void>): EffectWrapper {\r\n const defines = [];\r\n if (texture.gammaSpace) {\r\n defines.push(\"#define GAMMA_INPUT\");\r\n }\r\n\r\n defines.push(\"#define NUM_SAMPLES \" + this.quality + \"u\"); // unsigned int\r\n\r\n const isWebGPU = this._engine.isWebGPU;\r\n\r\n const effectWrapper = new EffectWrapper({\r\n engine: this._engine,\r\n name: \"hdrFiltering\",\r\n vertexShader: \"hdrFiltering\",\r\n fragmentShader: \"hdrFiltering\",\r\n samplerNames: [\"inputTexture\"],\r\n uniformNames: [\"vSampleDirections\", \"vWeights\", \"up\", \"right\", \"front\", \"vFilteringInfo\", \"hdrScale\", \"alphaG\"],\r\n useShaderStore: true,\r\n defines,\r\n onCompiled: onCompiled,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../../ShadersWGSL/hdrFiltering.vertex\"), import(\"../../../ShadersWGSL/hdrFiltering.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../../../Shaders/hdrFiltering.vertex\"), import(\"../../../Shaders/hdrFiltering.fragment\")]);\r\n }\r\n },\r\n });\r\n\r\n return effectWrapper;\r\n }\r\n\r\n /**\r\n * Get a value indicating if the filter is ready to be used\r\n * @param texture Texture to filter\r\n * @returns true if the filter is ready\r\n */\r\n public isReady(texture: BaseTexture) {\r\n return texture.isReady() && this._effectWrapper.effect.isReady();\r\n }\r\n\r\n /**\r\n * Prefilters a cube texture to have mipmap levels representing roughness values.\r\n * Prefiltering will be invoked at the end of next rendering pass.\r\n * This has to be done once the map is loaded, and has not been prefiltered by a third party software.\r\n * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information\r\n * @param texture Texture to filter\r\n * @param onFinished Callback when filtering is done\r\n * @returns Promise called when prefiltering is done\r\n */\r\n public prefilter(texture: BaseTexture, onFinished: Nullable<() => void> = null): Promise<void> {\r\n if (!this._engine._features.allowTexturePrefiltering) {\r\n Logger.Warn(\"HDR prefiltering is not available in WebGL 1., you can use real time filtering instead.\");\r\n return Promise.reject(\"HDR prefiltering is not available in WebGL 1., you can use real time filtering instead.\");\r\n }\r\n\r\n return new Promise((resolve) => {\r\n this._effectRenderer = new EffectRenderer(this._engine);\r\n this._effectWrapper = this._createEffect(texture);\r\n this._effectWrapper.effect.executeWhenCompiled(() => {\r\n this._prefilterInternal(texture);\r\n this._effectRenderer.dispose();\r\n this._effectWrapper.dispose();\r\n resolve();\r\n if (onFinished) {\r\n onFinished();\r\n }\r\n });\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"hdrFiltering.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Filtering/hdrFiltering.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAI7D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAGlF,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAmB9C;;GAEG;AACH,MAAM,OAAO,YAAY;IAmBrB;;;;;OAKG;IACH,YAAY,MAAsB,EAAE,UAAgC,EAAE;QApB9D,yBAAoB,GAAW,CAAC,CAAC;QACjC,wBAAmB,GAAW,GAAG,CAAC;QAE1C;;;WAGG;QACI,YAAO,GAAW,SAAS,CAAC,iCAAiC,CAAC;QAErE;;WAEG;QACI,aAAQ,GAAW,CAAC,CAAC;QASxB,OAAO;QACP,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;QAClD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC;IACnD,CAAC;IAEO,mBAAmB,CAAC,IAAY;QACpC,IAAI,WAAW,GAAG,SAAS,CAAC,yBAAyB,CAAC;QACtD,IAAI,IAAI,CAAC,OAAO,C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CAAC,wBAAwB,EAAE;YAClD,MAAM,CAAC,IAAI,CAAC,yFAAyF,CAAC,CAAC;YACvG,OAAO,OAAO,CAAC,MAAM,CAAC,yFAAyF,CAAC,CAAC;SACpH;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,IAAI,CAAC,eAAe,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACxD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAClD,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE;gBAChD,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;gBACjC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;gBAC/B,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;gBAC9B,OAAO,EAAE,CAAC;gBACV,IAAI,UAAU,EAAE;oBACZ,UAAU,EAAE,CAAC;iBAChB;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import { Vector3 } from \"../../../Maths/math\";\r\nimport { ILog2 } from \"../../../Maths/math.scalar.functions\";\r\nimport type { BaseTexture } from \"../baseTexture\";\r\nimport type { AbstractEngine } from \"../../../Engines/abstractEngine\";\r\nimport type { Effect } from \"../../../Materials/effect\";\r\nimport { Constants } from \"../../../Engines/constants\";\r\nimport { EffectWrapper, EffectRenderer } from \"../../../Materials/effectRenderer\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport type { RenderTargetWrapper } from \"../../../Engines/renderTargetWrapper\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Options for texture filtering\r\n */\r\ninterface IHDRFilteringOptions {\r\n /**\r\n * Scales pixel intensity for the input HDR map.\r\n */\r\n hdrScale?: number;\r\n\r\n /**\r\n * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering\r\n */\r\n quality?: number;\r\n}\r\n\r\n/**\r\n * Filters HDR maps to get correct renderings of PBR reflections\r\n */\r\nexport class HDRFiltering {\r\n private _engine: AbstractEngine;\r\n private _effectRenderer: EffectRenderer;\r\n private _effectWrapper: EffectWrapper;\r\n\r\n private _lodGenerationOffset: number = 0;\r\n private _lodGenerationScale: number = 0.8;\r\n\r\n /**\r\n * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless\r\n * you care about baking speed.\r\n */\r\n public quality: number = Constants.TEXTURE_FILTERING_QUALITY_OFFLINE;\r\n\r\n /**\r\n * Scales pixel intensity for the input HDR map.\r\n */\r\n public hdrScale: number = 1;\r\n\r\n /**\r\n * Instantiates HDR filter for reflection maps\r\n *\r\n * @param engine Thin engine\r\n * @param options Options\r\n */\r\n constructor(engine: AbstractEngine, options: IHDRFilteringOptions = {}) {\r\n // pass\r\n this._engine = engine;\r\n this.hdrScale = options.hdrScale || this.hdrScale;\r\n this.quality = options.quality || this.quality;\r\n }\r\n\r\n private _createRenderTarget(size: number): RenderTargetWrapper {\r\n let textureType = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n if (this._engine.getCaps().textureHalfFloatRender) {\r\n textureType = Constants.TEXTURETYPE_HALF_FLOAT;\r\n } else if (this._engine.getCaps().textureFloatRender) {\r\n textureType = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n\r\n const rtWrapper = this._engine.createRenderTargetCubeTexture(size, {\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n type: textureType,\r\n createMipMaps: true,\r\n generateMipMaps: false,\r\n generateDepthBuffer: false,\r\n generateStencilBuffer: false,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n });\r\n this._engine.updateTextureWrappingMode(rtWrapper.texture!, Constants.TEXTURE_CLAMP_ADDRESSMODE, Constants.TEXTURE_CLAMP_ADDRESSMODE, Constants.TEXTURE_CLAMP_ADDRESSMODE);\r\n\r\n this._engine.updateTextureSamplingMode(Constants.TEXTURE_TRILINEAR_SAMPLINGMODE, rtWrapper.texture!, true);\r\n\r\n return rtWrapper;\r\n }\r\n\r\n private _prefilterInternal(texture: BaseTexture): BaseTexture {\r\n const width = texture.getSize().width;\r\n const mipmapsCount = ILog2(width) + 1;\r\n\r\n const effect = this._effectWrapper.effect;\r\n const outputTexture = this._createRenderTarget(width);\r\n this._effectRenderer.saveStates();\r\n this._effectRenderer.setViewport();\r\n\r\n const intTexture = texture.getInternalTexture();\r\n if (intTexture) {\r\n // Just in case generate fresh clean mips.\r\n this._engine.updateTextureSamplingMode(Constants.TEXTURE_TRILINEAR_SAMPLINGMODE, intTexture, true);\r\n }\r\n\r\n this._effectRenderer.applyEffectWrapper(this._effectWrapper);\r\n\r\n const directions = [\r\n [new Vector3(0, 0, -1), new Vector3(0, -1, 0), new Vector3(1, 0, 0)], // PositiveX\r\n [new Vector3(0, 0, 1), new Vector3(0, -1, 0), new Vector3(-1, 0, 0)], // NegativeX\r\n [new Vector3(1, 0, 0), new Vector3(0, 0, 1), new Vector3(0, 1, 0)], // PositiveY\r\n [new Vector3(1, 0, 0), new Vector3(0, 0, -1), new Vector3(0, -1, 0)], // NegativeY\r\n [new Vector3(1, 0, 0), new Vector3(0, -1, 0), new Vector3(0, 0, 1)], // PositiveZ\r\n [new Vector3(-1, 0, 0), new Vector3(0, -1, 0), new Vector3(0, 0, -1)], // NegativeZ\r\n ];\r\n\r\n effect.setFloat(\"hdrScale\", this.hdrScale);\r\n effect.setFloat2(\"vFilteringInfo\", texture.getSize().width, mipmapsCount);\r\n effect.setTexture(\"inputTexture\", texture);\r\n\r\n for (let face = 0; face < 6; face++) {\r\n effect.setVector3(\"up\", directions[face][0]);\r\n effect.setVector3(\"right\", directions[face][1]);\r\n effect.setVector3(\"front\", directions[face][2]);\r\n\r\n for (let lod = 0; lod < mipmapsCount; lod++) {\r\n this._engine.bindFramebuffer(outputTexture, face, undefined, undefined, true, lod);\r\n this._effectRenderer.applyEffectWrapper(this._effectWrapper);\r\n\r\n let alpha = Math.pow(2, (lod - this._lodGenerationOffset) / this._lodGenerationScale) / width;\r\n if (lod === 0) {\r\n alpha = 0;\r\n }\r\n\r\n effect.setFloat(\"alphaG\", alpha);\r\n\r\n this._effectRenderer.draw();\r\n }\r\n }\r\n\r\n // Cleanup\r\n this._effectRenderer.restoreStates();\r\n this._engine.restoreDefaultFramebuffer();\r\n this._engine._releaseTexture(texture._texture!);\r\n\r\n // Internal Swap\r\n const type = outputTexture.texture!.type;\r\n const format = outputTexture.texture!.format;\r\n\r\n outputTexture._swapAndDie(texture._texture!);\r\n\r\n texture._texture!.type = type;\r\n texture._texture!.format = format;\r\n\r\n // New settings\r\n texture.gammaSpace = false;\r\n texture.lodGenerationOffset = this._lodGenerationOffset;\r\n texture.lodGenerationScale = this._lodGenerationScale;\r\n texture._prefiltered = true;\r\n\r\n return texture;\r\n }\r\n\r\n private _createEffect(texture: BaseTexture, onCompiled?: Nullable<(effect: Effect) => void>): EffectWrapper {\r\n const defines = [];\r\n if (texture.gammaSpace) {\r\n defines.push(\"#define GAMMA_INPUT\");\r\n }\r\n\r\n defines.push(\"#define NUM_SAMPLES \" + this.quality + \"u\"); // unsigned int\r\n\r\n const isWebGPU = this._engine.isWebGPU;\r\n\r\n const effectWrapper = new EffectWrapper({\r\n engine: this._engine,\r\n name: \"hdrFiltering\",\r\n vertexShader: \"hdrFiltering\",\r\n fragmentShader: \"hdrFiltering\",\r\n samplerNames: [\"inputTexture\"],\r\n uniformNames: [\"vSampleDirections\", \"vWeights\", \"up\", \"right\", \"front\", \"vFilteringInfo\", \"hdrScale\", \"alphaG\"],\r\n useShaderStore: true,\r\n defines,\r\n onCompiled: onCompiled,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../../ShadersWGSL/hdrFiltering.vertex\"), import(\"../../../ShadersWGSL/hdrFiltering.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../../../Shaders/hdrFiltering.vertex\"), import(\"../../../Shaders/hdrFiltering.fragment\")]);\r\n }\r\n },\r\n });\r\n\r\n return effectWrapper;\r\n }\r\n\r\n /**\r\n * Get a value indicating if the filter is ready to be used\r\n * @param texture Texture to filter\r\n * @returns true if the filter is ready\r\n */\r\n public isReady(texture: BaseTexture) {\r\n return texture.isReady() && this._effectWrapper.effect.isReady();\r\n }\r\n\r\n /**\r\n * Prefilters a cube texture to have mipmap levels representing roughness values.\r\n * Prefiltering will be invoked at the end of next rendering pass.\r\n * This has to be done once the map is loaded, and has not been prefiltered by a third party software.\r\n * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information\r\n * @param texture Texture to filter\r\n * @param onFinished Callback when filtering is done\r\n * @returns Promise called when prefiltering is done\r\n */\r\n public prefilter(texture: BaseTexture, onFinished: Nullable<() => void> = null): Promise<void> {\r\n if (!this._engine._features.allowTexturePrefiltering) {\r\n Logger.Warn(\"HDR prefiltering is not available in WebGL 1., you can use real time filtering instead.\");\r\n return Promise.reject(\"HDR prefiltering is not available in WebGL 1., you can use real time filtering instead.\");\r\n }\r\n\r\n return new Promise((resolve) => {\r\n this._effectRenderer = new EffectRenderer(this._engine);\r\n this._effectWrapper = this._createEffect(texture);\r\n this._effectWrapper.effect.executeWhenCompiled(() => {\r\n this._prefilterInternal(texture);\r\n this._effectRenderer.dispose();\r\n this._effectWrapper.dispose();\r\n resolve();\r\n if (onFinished) {\r\n onFinished();\r\n }\r\n });\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Nullable } from "../../../types";
|
|
2
2
|
import type { InternalTexture } from "../../../Materials/Textures/internalTexture";
|
|
3
3
|
import type { IInternalTextureLoader } from "./internalTextureLoader";
|
|
4
|
-
import "../../../Engines/Extensions/engine.cubeTexture";
|
|
5
4
|
/**
|
|
6
5
|
* Loader for .basis file format
|
|
7
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basisTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/basisTextureLoader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,8BAA8B,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"basisTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/basisTextureLoader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,8BAA8B,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,mBAAmB;IAAhC;QACI;;WAEG;QACa,oBAAe,GAAG,KAAK,CAAC;IAyF5C,CAAC;IAvFG;;;;;;;OAOG;IACI,YAAY,CACf,IAAyC,EACzC,OAAwB,EACxB,iBAA0B,EAC1B,MAAsC,EACtC,OAA8D;QAE9D,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACrB,OAAO;SACV;QACD,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,CAAC;QAC3C,MAAM,eAAe,GAAG;YACpB,2BAA2B,EAAE;gBACzB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;gBAC9B,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;gBAC9B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CA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AAC,IAAI,CAAC,iFAAiF,CAAC,CAAC;YAC9F,KAAK,CAAC,IAAI,CAAC,mCAAmC,GAAG,EAAE,CAAC,CAAC;YACrD,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACX,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../../types\";\r\nimport type { InternalTexture } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { IInternalTextureLoader } from \"./internalTextureLoader\";\r\nimport { LoadTextureFromTranscodeResult, TranscodeAsync } from \"../../../Misc/basis\";\r\nimport { Tools } from \"../../../Misc/tools\";\r\n\r\n/**\r\n * Loader for .basis file format\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class _BasisTextureLoader implements IInternalTextureLoader {\r\n /**\r\n * Defines whether the loader supports cascade loading the different faces.\r\n */\r\n public readonly supportCascades = false;\r\n\r\n /**\r\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\r\n * @param data contains the texture data\r\n * @param texture defines the BabylonJS internal texture\r\n * @param createPolynomials will be true if polynomials have been requested\r\n * @param onLoad defines the callback to trigger once the texture is ready\r\n * @param onError defines the callback to trigger in case of error\r\n */\r\n public loadCubeData(\r\n data: ArrayBufferView | ArrayBufferView[],\r\n texture: InternalTexture,\r\n createPolynomials: boolean,\r\n onLoad: Nullable<(data?: any) => void>,\r\n onError: Nullable<(message?: string, exception?: any) => void>\r\n ): void {\r\n if (Array.isArray(data)) {\r\n return;\r\n }\r\n const caps = texture.getEngine().getCaps();\r\n const transcodeConfig = {\r\n supportedCompressionFormats: {\r\n etc1: caps.etc1 ? true : false,\r\n s3tc: caps.s3tc ? true : false,\r\n pvrtc: caps.pvrtc ? true : false,\r\n etc2: caps.etc2 ? true : false,\r\n astc: caps.astc ? true : false,\r\n bc7: caps.bptc ? true : false,\r\n },\r\n };\r\n TranscodeAsync(data, transcodeConfig)\r\n .then((result) => {\r\n const hasMipmap = result.fileInfo.images[0].levels.length > 1 && texture.generateMipMaps;\r\n LoadTextureFromTranscodeResult(texture, result);\r\n texture.getEngine()._setCubeMapTextureParams(texture, hasMipmap);\r\n texture.isReady = true;\r\n texture.onLoadedObservable.notifyObservers(texture);\r\n texture.onLoadedObservable.clear();\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n })\r\n .catch((err) => {\r\n const errorMessage = \"Failed to transcode Basis file, transcoding may not be supported on this device\";\r\n Tools.Warn(errorMessage);\r\n texture.isReady = true;\r\n if (onError) {\r\n onError(err);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.\r\n * @param data contains the texture data\r\n * @param texture defines the BabylonJS internal texture\r\n * @param callback defines the method to call once ready to upload\r\n */\r\n public loadData(\r\n data: ArrayBufferView,\r\n texture: InternalTexture,\r\n callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, failedLoading?: boolean) => void\r\n ): void {\r\n const caps = texture.getEngine().getCaps();\r\n const transcodeConfig = {\r\n supportedCompressionFormats: {\r\n etc1: caps.etc1 ? true : false,\r\n s3tc: caps.s3tc ? true : false,\r\n pvrtc: caps.pvrtc ? true : false,\r\n etc2: caps.etc2 ? true : false,\r\n astc: caps.astc ? true : false,\r\n bc7: caps.bptc ? true : false,\r\n },\r\n };\r\n TranscodeAsync(data, transcodeConfig)\r\n .then((result) => {\r\n const rootImage = result.fileInfo.images[0].levels[0];\r\n const hasMipmap = result.fileInfo.images[0].levels.length > 1 && texture.generateMipMaps;\r\n callback(rootImage.width, rootImage.height, hasMipmap, result.format !== -1, () => {\r\n LoadTextureFromTranscodeResult(texture, result);\r\n });\r\n })\r\n .catch((err) => {\r\n Tools.Warn(\"Failed to transcode Basis file, transcoding may not be supported on this device\");\r\n Tools.Warn(`Failed to transcode Basis file: ${err}`);\r\n callback(0, 0, false, false, () => {}, true);\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Nullable } from "../../../types";
|
|
2
2
|
import type { InternalTexture } from "../../../Materials/Textures/internalTexture";
|
|
3
3
|
import type { IInternalTextureLoader } from "./internalTextureLoader";
|
|
4
|
-
import "../../../Engines/Extensions/engine.cubeTexture";
|
|
5
4
|
/**
|
|
6
5
|
* Implementation of the DDS Texture Loader.
|
|
7
6
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ddsTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/ddsTextureLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAIzE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ddsTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/ddsTextureLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAIzE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,iBAAiB;IAA9B;QACI;;WAEG;QACa,oBAAe,GAAG,IAAI,CAAC;IAqF3C,CAAC;IAnFG;;;;;;OAMG;IACI,YAAY,CAAC,IAAyC,EAAE,OAAwB,EAAE,iBAA0B,EAAE,MAAsC;QACvJ,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAY,CAAC;QAC7C,IAAI,IAAyB,CAAC;QAC9B,IAAI,UAAU,GAAY,KAAK,CAAC;QAChC,IAAI,QAAQ,GAAW,IAAI,CAAC;QAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACrB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EA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AI,CAAC,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;QAC5K,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE;YAC9D,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;QACtF,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../../types\";\r\nimport { SphericalPolynomial } from \"../../../Maths/sphericalPolynomial\";\r\nimport type { InternalTexture } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { IInternalTextureLoader } from \"./internalTextureLoader\";\r\nimport type { DDSInfo } from \"../../../Misc/dds\";\r\nimport { DDSTools } from \"../../../Misc/dds\";\r\n\r\nimport type { Engine } from \"core/Engines/engine\";\r\n\r\n/**\r\n * Implementation of the DDS Texture Loader.\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class _DDSTextureLoader implements IInternalTextureLoader {\r\n /**\r\n * Defines whether the loader supports cascade loading the different faces.\r\n */\r\n public readonly supportCascades = true;\r\n\r\n /**\r\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\r\n * @param imgs contains the cube maps\r\n * @param texture defines the BabylonJS internal texture\r\n * @param createPolynomials will be true if polynomials have been requested\r\n * @param onLoad defines the callback to trigger once the texture is ready\r\n */\r\n public loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>): void {\r\n const engine = texture.getEngine() as Engine;\r\n let info: DDSInfo | undefined;\r\n let loadMipmap: boolean = false;\r\n let maxLevel: number = 1000;\r\n if (Array.isArray(imgs)) {\r\n for (let index = 0; index < imgs.length; index++) {\r\n const data = imgs[index];\r\n info = DDSTools.GetDDSInfo(data);\r\n\r\n texture.width = info.width;\r\n texture.height = info.height;\r\n\r\n loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;\r\n\r\n engine._unpackFlipY(info.isCompressed);\r\n\r\n DDSTools.UploadDDSLevels(engine, texture, data, info, loadMipmap, 6, -1, index);\r\n\r\n if (!info.isFourCC && info.mipmapCount === 1) {\r\n engine.generateMipMapsForCubemap(texture);\r\n } else {\r\n maxLevel = info.mipmapCount - 1;\r\n }\r\n }\r\n } else {\r\n const data = imgs;\r\n info = DDSTools.GetDDSInfo(data);\r\n\r\n texture.width = info.width;\r\n texture.height = info.height;\r\n\r\n if (createPolynomials) {\r\n info.sphericalPolynomial = new SphericalPolynomial();\r\n }\r\n\r\n loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;\r\n engine._unpackFlipY(info.isCompressed);\r\n\r\n DDSTools.UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);\r\n\r\n if (!info.isFourCC && info.mipmapCount === 1) {\r\n // Do not unbind as we still need to set the parameters.\r\n engine.generateMipMapsForCubemap(texture, false);\r\n } else {\r\n maxLevel = info.mipmapCount - 1;\r\n }\r\n }\r\n engine._setCubeMapTextureParams(texture, loadMipmap, maxLevel);\r\n texture.isReady = true;\r\n texture.onLoadedObservable.notifyObservers(texture);\r\n texture.onLoadedObservable.clear();\r\n\r\n if (onLoad) {\r\n onLoad({ isDDS: true, width: texture.width, info, data: imgs, texture });\r\n }\r\n }\r\n\r\n /**\r\n * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.\r\n * @param data contains the texture data\r\n * @param texture defines the BabylonJS internal texture\r\n * @param callback defines the method to call once ready to upload\r\n */\r\n public loadData(\r\n data: ArrayBufferView,\r\n texture: InternalTexture,\r\n callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void\r\n ): void {\r\n const info = DDSTools.GetDDSInfo(data);\r\n\r\n const loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && Math.max(info.width, info.height) >> (info.mipmapCount - 1) === 1;\r\n callback(info.width, info.height, loadMipmap, info.isFourCC, () => {\r\n DDSTools.UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Nullable } from "../../../types";
|
|
2
2
|
import type { InternalTexture } from "../../../Materials/Textures/internalTexture";
|
|
3
3
|
import type { IInternalTextureLoader } from "./internalTextureLoader";
|
|
4
|
-
import "../../../Engines/Extensions/engine.cubeTexture";
|
|
5
4
|
/**
|
|
6
5
|
* Implementation of the KTX Texture Loader.
|
|
7
6
|
* @internal
|
|
@@ -2,7 +2,6 @@ import { KhronosTextureContainer } from "../../../Misc/khronosTextureContainer.j
|
|
|
2
2
|
import { KhronosTextureContainer2 } from "../../../Misc/khronosTextureContainer2.js";
|
|
3
3
|
import { Logger } from "../../../Misc/logger.js";
|
|
4
4
|
|
|
5
|
-
import "../../../Engines/Extensions/engine.cubeTexture.js";
|
|
6
5
|
function mapSRGBToLinear(format) {
|
|
7
6
|
switch (format) {
|
|
8
7
|
case 35916:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ktxTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/ktxTextureLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAIlF,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD,
|
|
1
|
+
{"version":3,"file":"ktxTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/ktxTextureLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBA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AC,CAAC;SAChD;IACL,CAAC;CACJ","sourcesContent":["import { KhronosTextureContainer } from \"../../../Misc/khronosTextureContainer\";\r\nimport { KhronosTextureContainer2 } from \"../../../Misc/khronosTextureContainer2\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport type { InternalTexture } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { IInternalTextureLoader } from \"./internalTextureLoader\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\nimport { Constants } from \"../../../Engines/constants\";\r\n\r\nfunction mapSRGBToLinear(format: number): Nullable<number> {\r\n switch (format) {\r\n case Constants.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT:\r\n return Constants.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1;\r\n case Constants.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:\r\n return Constants.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3;\r\n case Constants.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:\r\n return Constants.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5;\r\n case Constants.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2:\r\n return Constants.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2;\r\n case Constants.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:\r\n return Constants.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC;\r\n case Constants.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:\r\n return Constants.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;\r\n case Constants.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:\r\n return Constants.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4;\r\n case Constants.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:\r\n return Constants.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM;\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Implementation of the KTX Texture Loader.\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class _KTXTextureLoader implements IInternalTextureLoader {\r\n /**\r\n * Defines whether the loader supports cascade loading the different faces.\r\n */\r\n public readonly supportCascades = false;\r\n\r\n /**\r\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\r\n * @param data contains the texture data\r\n * @param texture defines the BabylonJS internal texture\r\n * @param createPolynomials will be true if polynomials have been requested\r\n * @param onLoad defines the callback to trigger once the texture is ready\r\n */\r\n public loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>): void {\r\n if (Array.isArray(data)) {\r\n return;\r\n }\r\n\r\n // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture\r\n texture._invertVScale = !texture.invertY;\r\n const engine = texture.getEngine();\r\n const ktx = new KhronosTextureContainer(data, 6);\r\n\r\n const loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;\r\n\r\n engine._unpackFlipY(true);\r\n\r\n ktx.uploadLevels(texture, texture.generateMipMaps);\r\n\r\n texture.width = ktx.pixelWidth;\r\n texture.height = ktx.pixelHeight;\r\n\r\n engine._setCubeMapTextureParams(texture, loadMipmap, ktx.numberOfMipmapLevels - 1);\r\n texture.isReady = true;\r\n texture.onLoadedObservable.notifyObservers(texture);\r\n texture.onLoadedObservable.clear();\r\n\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n }\r\n\r\n /**\r\n * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.\r\n * @param data contains the texture data\r\n * @param texture defines the BabylonJS internal texture\r\n * @param callback defines the method to call once ready to upload\r\n * @param options\r\n */\r\n public loadData(\r\n data: ArrayBufferView,\r\n texture: InternalTexture,\r\n callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void,\r\n options?: any\r\n ): void {\r\n if (KhronosTextureContainer.IsValid(data)) {\r\n // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture\r\n texture._invertVScale = !texture.invertY;\r\n const ktx = new KhronosTextureContainer(data, 1);\r\n\r\n const mappedFormat = mapSRGBToLinear(ktx.glInternalFormat);\r\n if (mappedFormat) {\r\n texture.format = mappedFormat;\r\n texture._useSRGBBuffer = texture.getEngine()._getUseSRGBBuffer(true, texture.generateMipMaps);\r\n texture._gammaSpace = true;\r\n } else {\r\n texture.format = ktx.glInternalFormat;\r\n }\r\n\r\n callback(\r\n ktx.pixelWidth,\r\n ktx.pixelHeight,\r\n texture.generateMipMaps,\r\n true,\r\n () => {\r\n ktx.uploadLevels(texture, texture.generateMipMaps);\r\n },\r\n ktx.isInvalid\r\n );\r\n } else if (KhronosTextureContainer2.IsValid(data)) {\r\n const ktx2 = new KhronosTextureContainer2(texture.getEngine());\r\n ktx2._uploadAsync(data, texture, options).then(\r\n () => {\r\n callback(texture.width, texture.height, texture.generateMipMaps, true, () => {}, false);\r\n },\r\n (error) => {\r\n Logger.Warn(`Failed to load KTX2 texture data: ${error.message}`);\r\n callback(0, 0, false, false, () => {}, true);\r\n }\r\n );\r\n } else {\r\n Logger.Error(\"texture missing KTX identifier\");\r\n callback(0, 0, false, false, () => {}, true);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -6,8 +6,6 @@ import type { Color4, Color3 } from "../../../Maths/math.color";
|
|
|
6
6
|
import type { Effect } from "../../../Materials/effect";
|
|
7
7
|
import { Texture } from "../../../Materials/Textures/texture";
|
|
8
8
|
import type { RenderTargetTextureOptions } from "../../../Materials/Textures/renderTargetTexture";
|
|
9
|
-
import "../../../Engines/Extensions/engine.renderTarget";
|
|
10
|
-
import "../../../Engines/Extensions/engine.renderTargetCube";
|
|
11
9
|
import type { NodeMaterial } from "../../Node/nodeMaterial";
|
|
12
10
|
import type { TextureSize } from "../../../Materials/Textures/textureCreationOptions";
|
|
13
11
|
import { ShaderLanguage } from "../../shaderLanguage.js";
|
|
@@ -7,8 +7,6 @@ import { Material } from "../../../Materials/material.js";
|
|
|
7
7
|
import { Texture } from "../../../Materials/Textures/texture.js";
|
|
8
8
|
import { RenderTargetTexture } from "../../../Materials/Textures/renderTargetTexture.js";
|
|
9
9
|
import { ProceduralTextureSceneComponent } from "./proceduralTextureSceneComponent.js";
|
|
10
|
-
import "../../../Engines/Extensions/engine.renderTarget.js";
|
|
11
|
-
import "../../../Engines/Extensions/engine.renderTargetCube.js";
|
|
12
10
|
import { RegisterClass } from "../../../Misc/typeStore.js";
|
|
13
11
|
import { EngineStore } from "../../../Engines/engineStore.js";
|
|
14
12
|
|