@babylonjs/procedural-textures 5.21.0 → 5.23.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/brick/brickProceduralTexture.fragment.js +16 -3
- package/brick/brickProceduralTexture.fragment.js.map +1 -1
- package/brick/brickProceduralTexture.js +58 -79
- package/brick/brickProceduralTexture.js.map +1 -1
- package/cloud/cloudProceduralTexture.fragment.js +14 -3
- package/cloud/cloudProceduralTexture.fragment.js.map +1 -1
- package/cloud/cloudProceduralTexture.js +58 -79
- package/cloud/cloudProceduralTexture.js.map +1 -1
- package/fire/fireProceduralTexture.fragment.js +7 -3
- package/fire/fireProceduralTexture.fragment.js.map +1 -1
- package/fire/fireProceduralTexture.js +85 -126
- package/fire/fireProceduralTexture.js.map +1 -1
- package/grass/grassProceduralTexture.fragment.js +12 -3
- package/grass/grassProceduralTexture.fragment.js.map +1 -1
- package/grass/grassProceduralTexture.js +36 -49
- package/grass/grassProceduralTexture.js.map +1 -1
- package/legacy/legacy-brick.js +2 -2
- package/legacy/legacy-brick.js.map +1 -1
- package/legacy/legacy-cloud.js +2 -2
- package/legacy/legacy-cloud.js.map +1 -1
- package/legacy/legacy-fire.js +2 -2
- package/legacy/legacy-fire.js.map +1 -1
- package/legacy/legacy-grass.js +2 -2
- package/legacy/legacy-grass.js.map +1 -1
- package/legacy/legacy-marble.js +2 -2
- package/legacy/legacy-marble.js.map +1 -1
- package/legacy/legacy-normalMap.js +2 -2
- package/legacy/legacy-normalMap.js.map +1 -1
- package/legacy/legacy-perlinNoise.js +2 -2
- package/legacy/legacy-perlinNoise.js.map +1 -1
- package/legacy/legacy-road.js +2 -2
- package/legacy/legacy-road.js.map +1 -1
- package/legacy/legacy-starfield.js +2 -2
- package/legacy/legacy-starfield.js.map +1 -1
- package/legacy/legacy-wood.js +2 -2
- package/legacy/legacy-wood.js.map +1 -1
- package/legacy/legacy.js +2 -2
- package/legacy/legacy.js.map +1 -1
- package/marble/marbleProceduralTexture.fragment.js +3 -3
- package/marble/marbleProceduralTexture.fragment.js.map +1 -1
- package/marble/marbleProceduralTexture.js +58 -79
- package/marble/marbleProceduralTexture.js.map +1 -1
- package/normalMap/normalMapProceduralTexture.fragment.js +7 -3
- package/normalMap/normalMapProceduralTexture.fragment.js.map +1 -1
- package/normalMap/normalMapProceduralTexture.js +33 -42
- package/normalMap/normalMapProceduralTexture.js.map +1 -1
- package/package.json +3 -6
- package/perlinNoise/perlinNoiseProceduralTexture.fragment.js +41 -3
- package/perlinNoise/perlinNoiseProceduralTexture.fragment.js.map +1 -1
- package/perlinNoise/perlinNoiseProceduralTexture.js +35 -40
- package/perlinNoise/perlinNoiseProceduralTexture.js.map +1 -1
- package/road/roadProceduralTexture.fragment.js +13 -3
- package/road/roadProceduralTexture.fragment.js.map +1 -1
- package/road/roadProceduralTexture.js +25 -34
- package/road/roadProceduralTexture.js.map +1 -1
- package/starfield/starfieldProceduralTexture.fragment.js +18 -3
- package/starfield/starfieldProceduralTexture.fragment.js.map +1 -1
- package/starfield/starfieldProceduralTexture.js +136 -185
- package/starfield/starfieldProceduralTexture.js.map +1 -1
- package/wood/woodProceduralTexture.fragment.js +12 -3
- package/wood/woodProceduralTexture.fragment.js.map +1 -1
- package/wood/woodProceduralTexture.js +36 -49
- package/wood/woodProceduralTexture.js.map +1 -1
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
import { __decorate
|
|
1
|
+
import { __decorate } from "@babylonjs/core/tslib.es6.js";
|
|
2
2
|
import { serialize, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
|
|
3
3
|
import { ProceduralTexture } from "@babylonjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
|
|
4
4
|
import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
|
5
5
|
import "./starfieldProceduralTexture.fragment.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return _this;
|
|
24
|
-
}
|
|
25
|
-
StarfieldProceduralTexture.prototype.updateShaderUniforms = function () {
|
|
6
|
+
export class StarfieldProceduralTexture extends ProceduralTexture {
|
|
7
|
+
constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
|
|
8
|
+
super(name, size, "starfieldProceduralTexture", scene, fallbackTexture, generateMipMaps);
|
|
9
|
+
this._time = 1;
|
|
10
|
+
this._alpha = 0.5;
|
|
11
|
+
this._beta = 0.8;
|
|
12
|
+
this._zoom = 0.8;
|
|
13
|
+
this._formuparam = 0.53;
|
|
14
|
+
this._stepsize = 0.1;
|
|
15
|
+
this._tile = 0.85;
|
|
16
|
+
this._brightness = 0.0015;
|
|
17
|
+
this._darkmatter = 0.4;
|
|
18
|
+
this._distfading = 0.73;
|
|
19
|
+
this._saturation = 0.85;
|
|
20
|
+
this.updateShaderUniforms();
|
|
21
|
+
}
|
|
22
|
+
updateShaderUniforms() {
|
|
26
23
|
this.setFloat("time", this._time);
|
|
27
24
|
this.setFloat("alpha", this._alpha);
|
|
28
25
|
this.setFloat("beta", this._beta);
|
|
@@ -34,137 +31,93 @@ var StarfieldProceduralTexture = /** @class */ (function (_super) {
|
|
|
34
31
|
this.setFloat("darkmatter", this._darkmatter);
|
|
35
32
|
this.setFloat("distfading", this._distfading);
|
|
36
33
|
this.setFloat("saturation", this._saturation);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
Object.defineProperty(StarfieldProceduralTexture.prototype, "brightness", {
|
|
116
|
-
get: function () {
|
|
117
|
-
return this._brightness;
|
|
118
|
-
},
|
|
119
|
-
set: function (value) {
|
|
120
|
-
this._brightness = value;
|
|
121
|
-
this.updateShaderUniforms();
|
|
122
|
-
},
|
|
123
|
-
enumerable: false,
|
|
124
|
-
configurable: true
|
|
125
|
-
});
|
|
126
|
-
Object.defineProperty(StarfieldProceduralTexture.prototype, "darkmatter", {
|
|
127
|
-
get: function () {
|
|
128
|
-
return this._darkmatter;
|
|
129
|
-
},
|
|
130
|
-
set: function (value) {
|
|
131
|
-
this._darkmatter = value;
|
|
132
|
-
this.updateShaderUniforms();
|
|
133
|
-
},
|
|
134
|
-
enumerable: false,
|
|
135
|
-
configurable: true
|
|
136
|
-
});
|
|
137
|
-
Object.defineProperty(StarfieldProceduralTexture.prototype, "distfading", {
|
|
138
|
-
get: function () {
|
|
139
|
-
return this._distfading;
|
|
140
|
-
},
|
|
141
|
-
set: function (value) {
|
|
142
|
-
this._distfading = value;
|
|
143
|
-
this.updateShaderUniforms();
|
|
144
|
-
},
|
|
145
|
-
enumerable: false,
|
|
146
|
-
configurable: true
|
|
147
|
-
});
|
|
148
|
-
Object.defineProperty(StarfieldProceduralTexture.prototype, "saturation", {
|
|
149
|
-
get: function () {
|
|
150
|
-
return this._saturation;
|
|
151
|
-
},
|
|
152
|
-
set: function (value) {
|
|
153
|
-
this._saturation = value;
|
|
154
|
-
this.updateShaderUniforms();
|
|
155
|
-
},
|
|
156
|
-
enumerable: false,
|
|
157
|
-
configurable: true
|
|
158
|
-
});
|
|
34
|
+
}
|
|
35
|
+
get time() {
|
|
36
|
+
return this._time;
|
|
37
|
+
}
|
|
38
|
+
set time(value) {
|
|
39
|
+
this._time = value;
|
|
40
|
+
this.updateShaderUniforms();
|
|
41
|
+
}
|
|
42
|
+
get alpha() {
|
|
43
|
+
return this._alpha;
|
|
44
|
+
}
|
|
45
|
+
set alpha(value) {
|
|
46
|
+
this._alpha = value;
|
|
47
|
+
this.updateShaderUniforms();
|
|
48
|
+
}
|
|
49
|
+
get beta() {
|
|
50
|
+
return this._beta;
|
|
51
|
+
}
|
|
52
|
+
set beta(value) {
|
|
53
|
+
this._beta = value;
|
|
54
|
+
this.updateShaderUniforms();
|
|
55
|
+
}
|
|
56
|
+
get formuparam() {
|
|
57
|
+
return this._formuparam;
|
|
58
|
+
}
|
|
59
|
+
set formuparam(value) {
|
|
60
|
+
this._formuparam = value;
|
|
61
|
+
this.updateShaderUniforms();
|
|
62
|
+
}
|
|
63
|
+
get stepsize() {
|
|
64
|
+
return this._stepsize;
|
|
65
|
+
}
|
|
66
|
+
set stepsize(value) {
|
|
67
|
+
this._stepsize = value;
|
|
68
|
+
this.updateShaderUniforms();
|
|
69
|
+
}
|
|
70
|
+
get zoom() {
|
|
71
|
+
return this._zoom;
|
|
72
|
+
}
|
|
73
|
+
set zoom(value) {
|
|
74
|
+
this._zoom = value;
|
|
75
|
+
this.updateShaderUniforms();
|
|
76
|
+
}
|
|
77
|
+
get tile() {
|
|
78
|
+
return this._tile;
|
|
79
|
+
}
|
|
80
|
+
set tile(value) {
|
|
81
|
+
this._tile = value;
|
|
82
|
+
this.updateShaderUniforms();
|
|
83
|
+
}
|
|
84
|
+
get brightness() {
|
|
85
|
+
return this._brightness;
|
|
86
|
+
}
|
|
87
|
+
set brightness(value) {
|
|
88
|
+
this._brightness = value;
|
|
89
|
+
this.updateShaderUniforms();
|
|
90
|
+
}
|
|
91
|
+
get darkmatter() {
|
|
92
|
+
return this._darkmatter;
|
|
93
|
+
}
|
|
94
|
+
set darkmatter(value) {
|
|
95
|
+
this._darkmatter = value;
|
|
96
|
+
this.updateShaderUniforms();
|
|
97
|
+
}
|
|
98
|
+
get distfading() {
|
|
99
|
+
return this._distfading;
|
|
100
|
+
}
|
|
101
|
+
set distfading(value) {
|
|
102
|
+
this._distfading = value;
|
|
103
|
+
this.updateShaderUniforms();
|
|
104
|
+
}
|
|
105
|
+
get saturation() {
|
|
106
|
+
return this._saturation;
|
|
107
|
+
}
|
|
108
|
+
set saturation(value) {
|
|
109
|
+
this._saturation = value;
|
|
110
|
+
this.updateShaderUniforms();
|
|
111
|
+
}
|
|
159
112
|
/**
|
|
160
113
|
* Serializes this starfield procedural texture
|
|
161
114
|
* @returns a serialized starfield procedural texture object
|
|
162
115
|
*/
|
|
163
|
-
|
|
164
|
-
|
|
116
|
+
serialize() {
|
|
117
|
+
const serializationObject = SerializationHelper.Serialize(this, super.serialize());
|
|
165
118
|
serializationObject.customType = "BABYLON.StarfieldProceduralTexture";
|
|
166
119
|
return serializationObject;
|
|
167
|
-
}
|
|
120
|
+
}
|
|
168
121
|
/**
|
|
169
122
|
* Creates a Starfield Procedural Texture from parsed startfield procedural texture data
|
|
170
123
|
* @param parsedTexture defines parsed texture data
|
|
@@ -172,45 +125,43 @@ var StarfieldProceduralTexture = /** @class */ (function (_super) {
|
|
|
172
125
|
* @param rootUrl defines the root URL containing startfield procedural texture information
|
|
173
126
|
* @returns a parsed Starfield Procedural Texture
|
|
174
127
|
*/
|
|
175
|
-
|
|
176
|
-
|
|
128
|
+
static Parse(parsedTexture, scene, rootUrl) {
|
|
129
|
+
const texture = SerializationHelper.Parse(() => new StarfieldProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
|
|
177
130
|
return texture;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}(ProceduralTexture));
|
|
214
|
-
export { StarfieldProceduralTexture };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
__decorate([
|
|
134
|
+
serialize()
|
|
135
|
+
], StarfieldProceduralTexture.prototype, "time", null);
|
|
136
|
+
__decorate([
|
|
137
|
+
serialize()
|
|
138
|
+
], StarfieldProceduralTexture.prototype, "alpha", null);
|
|
139
|
+
__decorate([
|
|
140
|
+
serialize()
|
|
141
|
+
], StarfieldProceduralTexture.prototype, "beta", null);
|
|
142
|
+
__decorate([
|
|
143
|
+
serialize()
|
|
144
|
+
], StarfieldProceduralTexture.prototype, "formuparam", null);
|
|
145
|
+
__decorate([
|
|
146
|
+
serialize()
|
|
147
|
+
], StarfieldProceduralTexture.prototype, "stepsize", null);
|
|
148
|
+
__decorate([
|
|
149
|
+
serialize()
|
|
150
|
+
], StarfieldProceduralTexture.prototype, "zoom", null);
|
|
151
|
+
__decorate([
|
|
152
|
+
serialize()
|
|
153
|
+
], StarfieldProceduralTexture.prototype, "tile", null);
|
|
154
|
+
__decorate([
|
|
155
|
+
serialize()
|
|
156
|
+
], StarfieldProceduralTexture.prototype, "brightness", null);
|
|
157
|
+
__decorate([
|
|
158
|
+
serialize()
|
|
159
|
+
], StarfieldProceduralTexture.prototype, "darkmatter", null);
|
|
160
|
+
__decorate([
|
|
161
|
+
serialize()
|
|
162
|
+
], StarfieldProceduralTexture.prototype, "distfading", null);
|
|
163
|
+
__decorate([
|
|
164
|
+
serialize()
|
|
165
|
+
], StarfieldProceduralTexture.prototype, "saturation", null);
|
|
215
166
|
RegisterClass("BABYLON.StarfieldProceduralTexture", StarfieldProceduralTexture);
|
|
216
167
|
//# sourceMappingURL=starfieldProceduralTexture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"starfieldProceduralTexture.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/starfield/starfieldProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,2CAA6B;AAEtE,OAAO,EAAE,iBAAiB,EAAE,4EAA8D;AAE1F,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD,OAAO,uCAAuC,CAAC;AAE/C
|
|
1
|
+
{"version":3,"file":"starfieldProceduralTexture.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/starfield/starfieldProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,2CAA6B;AAEtE,OAAO,EAAE,iBAAiB,EAAE,4EAA8D;AAE1F,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD,OAAO,uCAAuC,CAAC;AAE/C,MAAM,OAAO,0BAA2B,SAAQ,iBAAiB;IAa7D,YAAY,I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I,MAAM,CAAC,KAAK,CAAC,aAAkB,EAAE,KAAY,EAAE,OAAe;QACjE,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,CACrC,GAAG,EAAE,CAAC,IAAI,0BAA0B,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAC/H,aAAa,EACb,KAAK,EACL,OAAO,CACV,CAAC;QAEF,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAzIG;IADC,SAAS,EAAE;sDAGX;AAQD;IADC,SAAS,EAAE;uDAGX;AAQD;IADC,SAAS,EAAE;sDAGX;AAQD;IADC,SAAS,EAAE;4DAGX;AAQD;IADC,SAAS,EAAE;0DAGX;AAQD;IADC,SAAS,EAAE;sDAGX;AAQD;IADC,SAAS,EAAE;sDAGX;AAQD;IADC,SAAS,EAAE;4DAGX;AAQD;IADC,SAAS,EAAE;4DAGX;AAQD;IADC,SAAS,EAAE;4DAGX;AAQD;IADC,SAAS,EAAE;4DAGX;AAqCL,aAAa,CAAC,oCAAoC,EAAE,0BAA0B,CAAC,CAAC","sourcesContent":["import { serialize, SerializationHelper } from \"core/Misc/decorators\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { ProceduralTexture } from \"core/Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport type { Nullable } from \"core/types\";\r\nimport \"./starfieldProceduralTexture.fragment\";\r\n\r\nexport class StarfieldProceduralTexture extends ProceduralTexture {\r\n private _time = 1;\r\n private _alpha = 0.5;\r\n private _beta = 0.8;\r\n private _zoom = 0.8;\r\n private _formuparam = 0.53;\r\n private _stepsize = 0.1;\r\n private _tile = 0.85;\r\n private _brightness = 0.0015;\r\n private _darkmatter = 0.4;\r\n private _distfading = 0.73;\r\n private _saturation = 0.85;\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"starfieldProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setFloat(\"time\", this._time);\r\n this.setFloat(\"alpha\", this._alpha);\r\n this.setFloat(\"beta\", this._beta);\r\n this.setFloat(\"zoom\", this._zoom);\r\n this.setFloat(\"formuparam\", this._formuparam);\r\n this.setFloat(\"stepsize\", this._stepsize);\r\n this.setFloat(\"tile\", this._tile);\r\n this.setFloat(\"brightness\", this._brightness);\r\n this.setFloat(\"darkmatter\", this._darkmatter);\r\n this.setFloat(\"distfading\", this._distfading);\r\n this.setFloat(\"saturation\", this._saturation);\r\n }\r\n\r\n @serialize()\r\n public get time(): number {\r\n return this._time;\r\n }\r\n\r\n public set time(value: number) {\r\n this._time = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get alpha(): number {\r\n return this._alpha;\r\n }\r\n\r\n public set alpha(value: number) {\r\n this._alpha = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get beta(): number {\r\n return this._beta;\r\n }\r\n\r\n public set beta(value: number) {\r\n this._beta = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get formuparam(): number {\r\n return this._formuparam;\r\n }\r\n\r\n public set formuparam(value: number) {\r\n this._formuparam = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get stepsize(): number {\r\n return this._stepsize;\r\n }\r\n\r\n public set stepsize(value: number) {\r\n this._stepsize = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get zoom(): number {\r\n return this._zoom;\r\n }\r\n\r\n public set zoom(value: number) {\r\n this._zoom = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get tile(): number {\r\n return this._tile;\r\n }\r\n\r\n public set tile(value: number) {\r\n this._tile = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get brightness(): number {\r\n return this._brightness;\r\n }\r\n\r\n public set brightness(value: number) {\r\n this._brightness = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get darkmatter(): number {\r\n return this._darkmatter;\r\n }\r\n\r\n public set darkmatter(value: number) {\r\n this._darkmatter = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get distfading(): number {\r\n return this._distfading;\r\n }\r\n\r\n public set distfading(value: number) {\r\n this._distfading = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serialize()\r\n public get saturation(): number {\r\n return this._saturation;\r\n }\r\n\r\n public set saturation(value: number) {\r\n this._saturation = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n /**\r\n * Serializes this starfield procedural texture\r\n * @returns a serialized starfield procedural texture object\r\n */\r\n public serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this, super.serialize());\r\n serializationObject.customType = \"BABYLON.StarfieldProceduralTexture\";\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Starfield Procedural Texture from parsed startfield procedural texture data\r\n * @param parsedTexture defines parsed texture data\r\n * @param scene defines the current scene\r\n * @param rootUrl defines the root URL containing startfield procedural texture information\r\n * @returns a parsed Starfield Procedural Texture\r\n */\r\n public static Parse(parsedTexture: any, scene: Scene, rootUrl: string): StarfieldProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new StarfieldProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps),\r\n parsedTexture,\r\n scene,\r\n rootUrl\r\n );\r\n\r\n return texture;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.StarfieldProceduralTexture\", StarfieldProceduralTexture);\r\n"]}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
// Do not edit.
|
|
2
2
|
import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const name = "woodProceduralTexturePixelShader";
|
|
4
|
+
const shader = `precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform float ampScale;uniform vec3 woodColor;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}
|
|
5
|
+
float noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}
|
|
6
|
+
float fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}
|
|
7
|
+
return total;}
|
|
8
|
+
#define CUSTOM_FRAGMENT_DEFINITIONS
|
|
9
|
+
void main(void) {
|
|
10
|
+
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
|
11
|
+
float ratioy=mod(vUV.x*ampScale,2.0+fbm(vUV*0.8));vec3 wood=woodColor*ratioy;gl_FragColor=vec4(wood,1.0);
|
|
12
|
+
#define CUSTOM_FRAGMENT_MAIN_END
|
|
13
|
+
}`;
|
|
5
14
|
// Sideeffect
|
|
6
15
|
ShaderStore.ShadersStore[name] = shader;
|
|
7
16
|
/** @hidden */
|
|
8
|
-
export
|
|
17
|
+
export const woodProceduralTexturePixelShader = { name, shader };
|
|
9
18
|
//# sourceMappingURL=woodProceduralTexture.fragment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"woodProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/wood/woodProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD,
|
|
1
|
+
{"version":3,"file":"woodProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/wood/woodProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD,MAAM,IAAI,GAAG,kCAAkC,CAAC;AAChD,MAAM,MAAM,GAAG;;;;;;;;;EASb,CAAC;AACH,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,cAAc;AACd,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"woodProceduralTexturePixelShader\";\nconst shader = `precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform float ampScale;uniform vec3 woodColor;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}\nreturn total;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nfloat ratioy=mod(vUV.x*ampScale,2.0+fbm(vUV*0.8));vec3 wood=woodColor*ratioy;gl_FragColor=vec4(wood,1.0);\n#define CUSTOM_FRAGMENT_MAIN_END\n}`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @hidden */\nexport const woodProceduralTexturePixelShader = { name, shader };\n"]}
|
|
@@ -1,54 +1,43 @@
|
|
|
1
|
-
import { __decorate
|
|
1
|
+
import { __decorate } from "@babylonjs/core/tslib.es6.js";
|
|
2
2
|
import { serialize, serializeAsColor3, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
|
|
3
3
|
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
|
4
4
|
import { ProceduralTexture } from "@babylonjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
|
|
5
5
|
import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
|
6
6
|
import "./woodProceduralTexture.fragment.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
_this._woodColor = new Color3(0.32, 0.17, 0.09);
|
|
14
|
-
_this.updateShaderUniforms();
|
|
15
|
-
return _this;
|
|
7
|
+
export class WoodProceduralTexture extends ProceduralTexture {
|
|
8
|
+
constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
|
|
9
|
+
super(name, size, "woodProceduralTexture", scene, fallbackTexture, generateMipMaps);
|
|
10
|
+
this._ampScale = 100.0;
|
|
11
|
+
this._woodColor = new Color3(0.32, 0.17, 0.09);
|
|
12
|
+
this.updateShaderUniforms();
|
|
16
13
|
}
|
|
17
|
-
|
|
14
|
+
updateShaderUniforms() {
|
|
18
15
|
this.setFloat("ampScale", this._ampScale);
|
|
19
16
|
this.setColor3("woodColor", this._woodColor);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
set: function (value) {
|
|
37
|
-
this._woodColor = value;
|
|
38
|
-
this.updateShaderUniforms();
|
|
39
|
-
},
|
|
40
|
-
enumerable: false,
|
|
41
|
-
configurable: true
|
|
42
|
-
});
|
|
17
|
+
}
|
|
18
|
+
get ampScale() {
|
|
19
|
+
return this._ampScale;
|
|
20
|
+
}
|
|
21
|
+
set ampScale(value) {
|
|
22
|
+
this._ampScale = value;
|
|
23
|
+
this.updateShaderUniforms();
|
|
24
|
+
}
|
|
25
|
+
get woodColor() {
|
|
26
|
+
return this._woodColor;
|
|
27
|
+
}
|
|
28
|
+
set woodColor(value) {
|
|
29
|
+
this._woodColor = value;
|
|
30
|
+
this.updateShaderUniforms();
|
|
31
|
+
}
|
|
43
32
|
/**
|
|
44
33
|
* Serializes this wood procedural texture
|
|
45
34
|
* @returns a serialized wood procedural texture object
|
|
46
35
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
serialize() {
|
|
37
|
+
const serializationObject = SerializationHelper.Serialize(this, super.serialize());
|
|
49
38
|
serializationObject.customType = "BABYLON.WoodProceduralTexture";
|
|
50
39
|
return serializationObject;
|
|
51
|
-
}
|
|
40
|
+
}
|
|
52
41
|
/**
|
|
53
42
|
* Creates a Wood Procedural Texture from parsed wood procedural texture data
|
|
54
43
|
* @param parsedTexture defines parsed texture data
|
|
@@ -56,18 +45,16 @@ var WoodProceduralTexture = /** @class */ (function (_super) {
|
|
|
56
45
|
* @param rootUrl defines the root URL containing wood procedural texture information
|
|
57
46
|
* @returns a parsed Wood Procedural Texture
|
|
58
47
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
static Parse(parsedTexture, scene, rootUrl) {
|
|
49
|
+
const texture = SerializationHelper.Parse(() => new WoodProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
|
|
61
50
|
return texture;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}(ProceduralTexture));
|
|
71
|
-
export { WoodProceduralTexture };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
__decorate([
|
|
54
|
+
serialize()
|
|
55
|
+
], WoodProceduralTexture.prototype, "ampScale", null);
|
|
56
|
+
__decorate([
|
|
57
|
+
serializeAsColor3()
|
|
58
|
+
], WoodProceduralTexture.prototype, "woodColor", null);
|
|
72
59
|
RegisterClass("BABYLON.WoodProceduralTexture", WoodProceduralTexture);
|
|
73
60
|
//# sourceMappingURL=woodProceduralTexture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"woodProceduralTexture.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/wood/woodProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,2CAA6B;AACzF,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAE/C,OAAO,EAAE,iBAAiB,EAAE,4EAA8D;AAE1F,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD,OAAO,kCAAkC,CAAC;AAE1C
|
|
1
|
+
{"version":3,"file":"woodProceduralTexture.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/wood/woodProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,2CAA6B;AACzF,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAE/C,OAAO,EAAE,iBAAiB,EAAE,4EAA8D;AAE1F,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD,OAAO,kCAAkC,CAAC;AAE1C,MAAM,OAAO,qBAAsB,SAAQ,iBAAiB;IAIxD,YAAY,IAAY,EAAE,IAAY,EAAE,QAAyB,IAAI,EAAE,eAAyB,EAAE,eAAyB;QACvH,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;QAJhF,cAAS,GAAW,KAAK,CAAC;QAC1B,eAAU,GAAW,IAAI,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAItD,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAChC,CAAC;IAEM,oBAAoB;QACvB,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IAGD,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAW,QAAQ,CAAC,KAAa;QAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAChC,CAAC;IAGD,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,SAAS,CAAC,KAAa;QAC9B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAChC,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;QACnF,mBAAmB,CAAC,UAAU,GAAG,+BAA+B,CAAC;QAEjE,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,aAAkB,EAAE,KAAY,EAAE,OAAe;QACjE,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,CACrC,GAAG,EAAE,CAAC,IAAI,qBAAqB,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAC1H,aAAa,EACb,KAAK,EACL,OAAO,CACV,CAAC;QAEF,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AA/CG;IADC,SAAS,EAAE;qDAGX;AAQD;IADC,iBAAiB,EAAE;sDAGnB;AAqCL,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { serialize, serializeAsColor3, SerializationHelper } from \"core/Misc/decorators\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { ProceduralTexture } from \"core/Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport type { Nullable } from \"core/types\";\r\nimport \"./woodProceduralTexture.fragment\";\r\n\r\nexport class WoodProceduralTexture extends ProceduralTexture {\r\n private _ampScale: number = 100.0;\r\n private _woodColor: Color3 = new Color3(0.32, 0.17, 0.09);\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"woodProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setFloat(\"ampScale\", this._ampScale);\r\n this.setColor3(\"woodColor\", this._woodColor);\r\n }\r\n\r\n @serialize()\r\n public get ampScale(): number {\r\n return this._ampScale;\r\n }\r\n\r\n public set ampScale(value: number) {\r\n this._ampScale = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n @serializeAsColor3()\r\n public get woodColor(): Color3 {\r\n return this._woodColor;\r\n }\r\n\r\n public set woodColor(value: Color3) {\r\n this._woodColor = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n /**\r\n * Serializes this wood procedural texture\r\n * @returns a serialized wood procedural texture object\r\n */\r\n public serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this, super.serialize());\r\n serializationObject.customType = \"BABYLON.WoodProceduralTexture\";\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Wood Procedural Texture from parsed wood procedural texture data\r\n * @param parsedTexture defines parsed texture data\r\n * @param scene defines the current scene\r\n * @param rootUrl defines the root URL containing wood procedural texture information\r\n * @returns a parsed Wood Procedural Texture\r\n */\r\n public static Parse(parsedTexture: any, scene: Scene, rootUrl: string): WoodProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new WoodProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps),\r\n parsedTexture,\r\n scene,\r\n rootUrl\r\n );\r\n\r\n return texture;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.WoodProceduralTexture\", WoodProceduralTexture);\r\n"]}
|