babylonjs-procedural-textures 6.11.1 → 6.11.2
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/babylon.brickProceduralTexture.js +82 -75
- package/babylon.brickProceduralTexture.js.map +1 -1
- package/babylon.brickProceduralTexture.min.js +1 -1
- package/babylon.brickProceduralTexture.min.js.map +1 -1
- package/babylon.cloudProceduralTexture.js +82 -73
- package/babylon.cloudProceduralTexture.js.map +1 -1
- package/babylon.cloudProceduralTexture.min.js +1 -1
- package/babylon.cloudProceduralTexture.min.js.map +1 -1
- package/babylon.fireProceduralTexture.js +128 -92
- package/babylon.fireProceduralTexture.js.map +1 -1
- package/babylon.fireProceduralTexture.min.js +1 -1
- package/babylon.fireProceduralTexture.min.js.map +1 -1
- package/babylon.grassProceduralTexture.js +52 -49
- package/babylon.grassProceduralTexture.js.map +1 -1
- package/babylon.grassProceduralTexture.min.js +1 -1
- package/babylon.grassProceduralTexture.min.js.map +1 -1
- package/babylon.marbleProceduralTexture.js +82 -62
- package/babylon.marbleProceduralTexture.js.map +1 -1
- package/babylon.marbleProceduralTexture.min.js +1 -1
- package/babylon.marbleProceduralTexture.min.js.map +1 -1
- package/babylon.normalMapProceduralTexture.js +45 -41
- package/babylon.normalMapProceduralTexture.js.map +1 -1
- package/babylon.normalMapProceduralTexture.min.js +1 -1
- package/babylon.normalMapProceduralTexture.min.js.map +1 -1
- package/babylon.perlinNoiseProceduralTexture.js +43 -77
- package/babylon.perlinNoiseProceduralTexture.js.map +1 -1
- package/babylon.perlinNoiseProceduralTexture.min.js +1 -1
- package/babylon.perlinNoiseProceduralTexture.min.js.map +1 -1
- package/babylon.roadProceduralTexture.js +37 -39
- package/babylon.roadProceduralTexture.js.map +1 -1
- package/babylon.roadProceduralTexture.min.js +1 -1
- package/babylon.roadProceduralTexture.min.js.map +1 -1
- package/babylon.starfieldProceduralTexture.js +187 -154
- package/babylon.starfieldProceduralTexture.js.map +1 -1
- package/babylon.starfieldProceduralTexture.min.js +1 -1
- package/babylon.starfieldProceduralTexture.min.js.map +1 -1
- package/babylon.woodProceduralTexture.js +52 -49
- package/babylon.woodProceduralTexture.js.map +1 -1
- package/babylon.woodProceduralTexture.min.js +1 -1
- package/babylon.woodProceduralTexture.min.js.map +1 -1
- package/babylonjs.proceduralTextures.js +772 -693
- package/babylonjs.proceduralTextures.js.map +1 -1
- package/babylonjs.proceduralTextures.min.js +1 -1
- package/babylonjs.proceduralTextures.min.js.map +1 -1
- package/package.json +2 -2
- package/tsconfig.build.json +1 -0
|
@@ -26,25 +26,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
|
|
27
27
|
// Do not edit.
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
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);}
|
|
32
|
-
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;}
|
|
33
|
-
return total;}
|
|
34
|
-
float roundF(float number){return sign(number)*floor(abs(number)+0.5);}
|
|
35
|
-
#define CUSTOM_FRAGMENT_DEFINITIONS
|
|
36
|
-
void main(void)
|
|
37
|
-
{float brickW=1.0/numberOfBricksWidth;float brickH=1.0/numberOfBricksHeight;float jointWPercentage=0.01;float jointHPercentage=0.05;vec3 color=brickColor;float yi=vUV.y/brickH;float nyi=roundF(yi);float xi=vUV.x/brickW;if (mod(floor(yi),2.0)==0.0){xi=xi-0.5;}
|
|
38
|
-
float nxi=roundF(xi);vec2 brickvUV=vec2((xi-floor(xi))/brickH,(yi-floor(yi))/ brickW);if (yi<nyi+jointHPercentage && yi>nyi-jointHPercentage){color=mix(jointColor,vec3(0.37,0.25,0.25),(yi-nyi)/jointHPercentage+0.2);}
|
|
39
|
-
else if (xi<nxi+jointWPercentage && xi>nxi-jointWPercentage){color=mix(jointColor,vec3(0.44,0.44,0.44),(xi-nxi)/jointWPercentage+0.2);}
|
|
40
|
-
else {float brickColorSwitch=mod(floor(yi)+floor(xi),3.0);if (brickColorSwitch==0.0)
|
|
41
|
-
color=mix(color,vec3(0.33,0.33,0.33),0.3);else if (brickColorSwitch==2.0)
|
|
42
|
-
color=mix(color,vec3(0.11,0.11,0.11),0.3);}
|
|
43
|
-
gl_FragColor=vec4(color,1.0);}`;
|
|
29
|
+
var name = "brickProceduralTexturePixelShader";
|
|
30
|
+
var shader = "precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform float numberOfBricksHeight;uniform float numberOfBricksWidth;uniform vec3 brickColor;uniform vec3 jointColor;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;}\nfloat roundF(float number){return sign(number)*floor(abs(number)+0.5);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float brickW=1.0/numberOfBricksWidth;float brickH=1.0/numberOfBricksHeight;float jointWPercentage=0.01;float jointHPercentage=0.05;vec3 color=brickColor;float yi=vUV.y/brickH;float nyi=roundF(yi);float xi=vUV.x/brickW;if (mod(floor(yi),2.0)==0.0){xi=xi-0.5;}\nfloat nxi=roundF(xi);vec2 brickvUV=vec2((xi-floor(xi))/brickH,(yi-floor(yi))/ brickW);if (yi<nyi+jointHPercentage && yi>nyi-jointHPercentage){color=mix(jointColor,vec3(0.37,0.25,0.25),(yi-nyi)/jointHPercentage+0.2);}\nelse if (xi<nxi+jointWPercentage && xi>nxi-jointWPercentage){color=mix(jointColor,vec3(0.44,0.44,0.44),(xi-nxi)/jointWPercentage+0.2);}\nelse {float brickColorSwitch=mod(floor(yi)+floor(xi),3.0);if (brickColorSwitch==0.0)\ncolor=mix(color,vec3(0.33,0.33,0.33),0.3);else if (brickColorSwitch==2.0)\ncolor=mix(color,vec3(0.11,0.11,0.11),0.3);}\ngl_FragColor=vec4(color,1.0);}";
|
|
44
31
|
// Sideeffect
|
|
45
32
|
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__.ShaderStore.ShadersStore[name] = shader;
|
|
46
33
|
/** @internal */
|
|
47
|
-
|
|
34
|
+
var brickProceduralTexturePixelShader = { name: name, shader: shader };
|
|
48
35
|
|
|
49
36
|
|
|
50
37
|
/***/ }),
|
|
@@ -69,58 +56,77 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
69
56
|
|
|
70
57
|
|
|
71
58
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
var BrickProceduralTexture = /** @class */ (function (_super) {
|
|
60
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(BrickProceduralTexture, _super);
|
|
61
|
+
function BrickProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
|
|
62
|
+
if (scene === void 0) { scene = null; }
|
|
63
|
+
var _this = _super.call(this, name, size, "brickProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
|
|
64
|
+
_this._numberOfBricksHeight = 15;
|
|
65
|
+
_this._numberOfBricksWidth = 5;
|
|
66
|
+
_this._jointColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.72, 0.72, 0.72);
|
|
67
|
+
_this._brickColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.77, 0.47, 0.4);
|
|
68
|
+
_this.updateShaderUniforms();
|
|
69
|
+
return _this;
|
|
80
70
|
}
|
|
81
|
-
updateShaderUniforms() {
|
|
71
|
+
BrickProceduralTexture.prototype.updateShaderUniforms = function () {
|
|
82
72
|
this.setFloat("numberOfBricksHeight", this._numberOfBricksHeight);
|
|
83
73
|
this.setFloat("numberOfBricksWidth", this._numberOfBricksWidth);
|
|
84
74
|
this.setColor3("brickColor", this._brickColor);
|
|
85
75
|
this.setColor3("jointColor", this._jointColor);
|
|
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
|
-
|
|
76
|
+
};
|
|
77
|
+
Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksHeight", {
|
|
78
|
+
get: function () {
|
|
79
|
+
return this._numberOfBricksHeight;
|
|
80
|
+
},
|
|
81
|
+
set: function (value) {
|
|
82
|
+
this._numberOfBricksHeight = value;
|
|
83
|
+
this.updateShaderUniforms();
|
|
84
|
+
},
|
|
85
|
+
enumerable: false,
|
|
86
|
+
configurable: true
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksWidth", {
|
|
89
|
+
get: function () {
|
|
90
|
+
return this._numberOfBricksWidth;
|
|
91
|
+
},
|
|
92
|
+
set: function (value) {
|
|
93
|
+
this._numberOfBricksWidth = value;
|
|
94
|
+
this.updateShaderUniforms();
|
|
95
|
+
},
|
|
96
|
+
enumerable: false,
|
|
97
|
+
configurable: true
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(BrickProceduralTexture.prototype, "jointColor", {
|
|
100
|
+
get: function () {
|
|
101
|
+
return this._jointColor;
|
|
102
|
+
},
|
|
103
|
+
set: function (value) {
|
|
104
|
+
this._jointColor = value;
|
|
105
|
+
this.updateShaderUniforms();
|
|
106
|
+
},
|
|
107
|
+
enumerable: false,
|
|
108
|
+
configurable: true
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(BrickProceduralTexture.prototype, "brickColor", {
|
|
111
|
+
get: function () {
|
|
112
|
+
return this._brickColor;
|
|
113
|
+
},
|
|
114
|
+
set: function (value) {
|
|
115
|
+
this._brickColor = value;
|
|
116
|
+
this.updateShaderUniforms();
|
|
117
|
+
},
|
|
118
|
+
enumerable: false,
|
|
119
|
+
configurable: true
|
|
120
|
+
});
|
|
115
121
|
/**
|
|
116
122
|
* Serializes this brick procedural texture
|
|
117
123
|
* @returns a serialized brick procedural texture object
|
|
118
124
|
*/
|
|
119
|
-
serialize() {
|
|
120
|
-
|
|
125
|
+
BrickProceduralTexture.prototype.serialize = function () {
|
|
126
|
+
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
|
|
121
127
|
serializationObject.customType = "BABYLON.BrickProceduralTexture";
|
|
122
128
|
return serializationObject;
|
|
123
|
-
}
|
|
129
|
+
};
|
|
124
130
|
/**
|
|
125
131
|
* Creates a Brick Procedural Texture from parsed brick procedural texture data
|
|
126
132
|
* @param parsedTexture defines parsed texture data
|
|
@@ -128,23 +134,24 @@ class BrickProceduralTexture extends babylonjs_Misc_decorators__WEBPACK_IMPORTED
|
|
|
128
134
|
* @param rootUrl defines the root URL containing brick procedural texture information
|
|
129
135
|
* @returns a parsed Brick Procedural Texture
|
|
130
136
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
137
|
+
BrickProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
|
|
138
|
+
var texture = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Parse(function () { return new BrickProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
|
|
133
139
|
return texture;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
(0,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
(0,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
(0,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
(0,
|
|
146
|
-
|
|
147
|
-
|
|
140
|
+
};
|
|
141
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
142
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
143
|
+
], BrickProceduralTexture.prototype, "numberOfBricksHeight", null);
|
|
144
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
145
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
146
|
+
], BrickProceduralTexture.prototype, "numberOfBricksWidth", null);
|
|
147
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
148
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serializeAsColor3)()
|
|
149
|
+
], BrickProceduralTexture.prototype, "jointColor", null);
|
|
150
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
151
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serializeAsColor3)()
|
|
152
|
+
], BrickProceduralTexture.prototype, "brickColor", null);
|
|
153
|
+
return BrickProceduralTexture;
|
|
154
|
+
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.ProceduralTexture));
|
|
148
155
|
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.RegisterClass)("BABYLON.BrickProceduralTexture", BrickProceduralTexture);
|
|
149
156
|
|
|
150
157
|
|
|
@@ -180,23 +187,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
180
187
|
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
|
|
181
188
|
// Do not edit.
|
|
182
189
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
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);}
|
|
186
|
-
float fbm(vec2 n) {float total=0.0,ampl=amplitude;
|
|
187
|
-
#ifdef WEBGL2
|
|
188
|
-
for (int i=0; i<numOctaves; i++) {
|
|
189
|
-
#else
|
|
190
|
-
for (int i=0; i<4; i++) {
|
|
191
|
-
#endif
|
|
192
|
-
total+=noise(n)*ampl;n+=n;ampl*=0.5;}
|
|
193
|
-
return total;}
|
|
194
|
-
void main() {vec2 p=vUV*12.0;vec4 c=mix(skyColor,cloudColor,fbm(p));gl_FragColor=c;}
|
|
195
|
-
`;
|
|
190
|
+
var name = "cloudProceduralTexturePixelShader";
|
|
191
|
+
var shader = "precision highp float;varying vec2 vUV;uniform vec4 skyColor;uniform vec4 cloudColor;uniform float amplitude;uniform int numOctaves;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,ampl=amplitude;\n#ifdef WEBGL2\nfor (int i=0; i<numOctaves; i++) {\n#else\nfor (int i=0; i<4; i++) {\n#endif\ntotal+=noise(n)*ampl;n+=n;ampl*=0.5;}\nreturn total;}\nvoid main() {vec2 p=vUV*12.0;vec4 c=mix(skyColor,cloudColor,fbm(p));gl_FragColor=c;}\n";
|
|
196
192
|
// Sideeffect
|
|
197
193
|
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__.ShaderStore.ShadersStore[name] = shader;
|
|
198
194
|
/** @internal */
|
|
199
|
-
|
|
195
|
+
var cloudProceduralTexturePixelShader = { name: name, shader: shader };
|
|
200
196
|
|
|
201
197
|
|
|
202
198
|
/***/ }),
|
|
@@ -221,58 +217,77 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
221
217
|
|
|
222
218
|
|
|
223
219
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
220
|
+
var CloudProceduralTexture = /** @class */ (function (_super) {
|
|
221
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(CloudProceduralTexture, _super);
|
|
222
|
+
function CloudProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
|
|
223
|
+
if (scene === void 0) { scene = null; }
|
|
224
|
+
var _this = _super.call(this, name, size, "cloudProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
|
|
225
|
+
_this._skyColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color4(0.15, 0.68, 1.0, 1.0);
|
|
226
|
+
_this._cloudColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color4(1, 1, 1, 1.0);
|
|
227
|
+
_this._amplitude = 1;
|
|
228
|
+
_this._numOctaves = 4;
|
|
229
|
+
_this.updateShaderUniforms();
|
|
230
|
+
return _this;
|
|
232
231
|
}
|
|
233
|
-
updateShaderUniforms() {
|
|
232
|
+
CloudProceduralTexture.prototype.updateShaderUniforms = function () {
|
|
234
233
|
this.setColor4("skyColor", this._skyColor);
|
|
235
234
|
this.setColor4("cloudColor", this._cloudColor);
|
|
236
235
|
this.setFloat("amplitude", this._amplitude);
|
|
237
236
|
this.setInt("numOctaves", this._numOctaves);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
237
|
+
};
|
|
238
|
+
Object.defineProperty(CloudProceduralTexture.prototype, "skyColor", {
|
|
239
|
+
get: function () {
|
|
240
|
+
return this._skyColor;
|
|
241
|
+
},
|
|
242
|
+
set: function (value) {
|
|
243
|
+
this._skyColor = value;
|
|
244
|
+
this.updateShaderUniforms();
|
|
245
|
+
},
|
|
246
|
+
enumerable: false,
|
|
247
|
+
configurable: true
|
|
248
|
+
});
|
|
249
|
+
Object.defineProperty(CloudProceduralTexture.prototype, "cloudColor", {
|
|
250
|
+
get: function () {
|
|
251
|
+
return this._cloudColor;
|
|
252
|
+
},
|
|
253
|
+
set: function (value) {
|
|
254
|
+
this._cloudColor = value;
|
|
255
|
+
this.updateShaderUniforms();
|
|
256
|
+
},
|
|
257
|
+
enumerable: false,
|
|
258
|
+
configurable: true
|
|
259
|
+
});
|
|
260
|
+
Object.defineProperty(CloudProceduralTexture.prototype, "amplitude", {
|
|
261
|
+
get: function () {
|
|
262
|
+
return this._amplitude;
|
|
263
|
+
},
|
|
264
|
+
set: function (value) {
|
|
265
|
+
this._amplitude = value;
|
|
266
|
+
this.updateShaderUniforms();
|
|
267
|
+
},
|
|
268
|
+
enumerable: false,
|
|
269
|
+
configurable: true
|
|
270
|
+
});
|
|
271
|
+
Object.defineProperty(CloudProceduralTexture.prototype, "numOctaves", {
|
|
272
|
+
get: function () {
|
|
273
|
+
return this._numOctaves;
|
|
274
|
+
},
|
|
275
|
+
set: function (value) {
|
|
276
|
+
this._numOctaves = value;
|
|
277
|
+
this.updateShaderUniforms();
|
|
278
|
+
},
|
|
279
|
+
enumerable: false,
|
|
280
|
+
configurable: true
|
|
281
|
+
});
|
|
267
282
|
/**
|
|
268
283
|
* Serializes this cloud procedural texture
|
|
269
284
|
* @returns a serialized cloud procedural texture object
|
|
270
285
|
*/
|
|
271
|
-
serialize() {
|
|
272
|
-
|
|
286
|
+
CloudProceduralTexture.prototype.serialize = function () {
|
|
287
|
+
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
|
|
273
288
|
serializationObject.customType = "BABYLON.CloudProceduralTexture";
|
|
274
289
|
return serializationObject;
|
|
275
|
-
}
|
|
290
|
+
};
|
|
276
291
|
/**
|
|
277
292
|
* Creates a Cloud Procedural Texture from parsed cloud procedural texture data
|
|
278
293
|
* @param parsedTexture defines parsed texture data
|
|
@@ -280,23 +295,24 @@ class CloudProceduralTexture extends babylonjs_Misc_decorators__WEBPACK_IMPORTED
|
|
|
280
295
|
* @param rootUrl defines the root URL containing cloud procedural texture information
|
|
281
296
|
* @returns a parsed Cloud Procedural Texture
|
|
282
297
|
*/
|
|
283
|
-
|
|
284
|
-
|
|
298
|
+
CloudProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
|
|
299
|
+
var texture = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Parse(function () { return new CloudProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
|
|
285
300
|
return texture;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
(0,
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
(0,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
(0,
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
(0,
|
|
298
|
-
|
|
299
|
-
|
|
301
|
+
};
|
|
302
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
303
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serializeAsColor4)()
|
|
304
|
+
], CloudProceduralTexture.prototype, "skyColor", null);
|
|
305
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
306
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serializeAsColor4)()
|
|
307
|
+
], CloudProceduralTexture.prototype, "cloudColor", null);
|
|
308
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
309
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
310
|
+
], CloudProceduralTexture.prototype, "amplitude", null);
|
|
311
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
312
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
313
|
+
], CloudProceduralTexture.prototype, "numOctaves", null);
|
|
314
|
+
return CloudProceduralTexture;
|
|
315
|
+
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.ProceduralTexture));
|
|
300
316
|
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.RegisterClass)("BABYLON.CloudProceduralTexture", CloudProceduralTexture);
|
|
301
317
|
|
|
302
318
|
|
|
@@ -332,16 +348,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
332
348
|
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
|
|
333
349
|
// Do not edit.
|
|
334
350
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
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);}
|
|
338
|
-
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;}
|
|
339
|
-
return total;}
|
|
340
|
-
void main() {vec2 p=vUV*8.0;float q=fbm(p-time*0.1);vec2 r=vec2(fbm(p+q+time*speed.x-p.x-p.y),fbm(p+q-time*speed.y));vec3 c=mix(c1,c2,fbm(p+r))+mix(c3,c4,r.x)-mix(c5,c6,r.y);vec3 color=c*cos(shift*vUV.y);float luminance=dot(color.rgb,vec3(0.3,0.59,0.11));gl_FragColor=vec4(color,luminance*alphaThreshold+(1.0-alphaThreshold));}`;
|
|
351
|
+
var name = "fireProceduralTexturePixelShader";
|
|
352
|
+
var shader = "precision highp float;uniform float time;uniform vec3 c1;uniform vec3 c2;uniform vec3 c3;uniform vec3 c4;uniform vec3 c5;uniform vec3 c6;uniform vec2 speed;uniform float shift;uniform float alphaThreshold;varying vec2 vUV;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;}\nvoid main() {vec2 p=vUV*8.0;float q=fbm(p-time*0.1);vec2 r=vec2(fbm(p+q+time*speed.x-p.x-p.y),fbm(p+q-time*speed.y));vec3 c=mix(c1,c2,fbm(p+r))+mix(c3,c4,r.x)-mix(c5,c6,r.y);vec3 color=c*cos(shift*vUV.y);float luminance=dot(color.rgb,vec3(0.3,0.59,0.11));gl_FragColor=vec4(color,luminance*alphaThreshold+(1.0-alphaThreshold));}";
|
|
341
353
|
// Sideeffect
|
|
342
354
|
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__.ShaderStore.ShadersStore[name] = shader;
|
|
343
355
|
/** @internal */
|
|
344
|
-
|
|
356
|
+
var fireProceduralTexturePixelShader = { name: name, shader: shader };
|
|
345
357
|
|
|
346
358
|
|
|
347
359
|
/***/ }),
|
|
@@ -367,17 +379,20 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
367
379
|
|
|
368
380
|
|
|
369
381
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
382
|
+
var FireProceduralTexture = /** @class */ (function (_super) {
|
|
383
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(FireProceduralTexture, _super);
|
|
384
|
+
function FireProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
|
|
385
|
+
if (scene === void 0) { scene = null; }
|
|
386
|
+
var _this = _super.call(this, name, size, "fireProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
|
|
387
|
+
_this._time = 0.0;
|
|
388
|
+
_this._speed = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Vector2(0.5, 0.3);
|
|
389
|
+
_this._autoGenerateTime = true;
|
|
390
|
+
_this._alphaThreshold = 0.5;
|
|
391
|
+
_this._fireColors = FireProceduralTexture.RedFireColors;
|
|
392
|
+
_this.updateShaderUniforms();
|
|
393
|
+
return _this;
|
|
379
394
|
}
|
|
380
|
-
updateShaderUniforms() {
|
|
395
|
+
FireProceduralTexture.prototype.updateShaderUniforms = function () {
|
|
381
396
|
this.setFloat("time", this._time);
|
|
382
397
|
this.setVector2("speed", this._speed);
|
|
383
398
|
this.setColor3("c1", this._fireColors[0]);
|
|
@@ -387,74 +402,110 @@ class FireProceduralTexture extends babylonjs_Misc_decorators__WEBPACK_IMPORTED_
|
|
|
387
402
|
this.setColor3("c5", this._fireColors[4]);
|
|
388
403
|
this.setColor3("c6", this._fireColors[5]);
|
|
389
404
|
this.setFloat("alphaThreshold", this._alphaThreshold);
|
|
390
|
-
}
|
|
391
|
-
render(useCameraPostProcess) {
|
|
392
|
-
|
|
405
|
+
};
|
|
406
|
+
FireProceduralTexture.prototype.render = function (useCameraPostProcess) {
|
|
407
|
+
var scene = this.getScene();
|
|
393
408
|
if (this._autoGenerateTime && scene) {
|
|
394
409
|
this._time += scene.getAnimationRatio() * 0.03;
|
|
395
410
|
this.updateShaderUniforms();
|
|
396
411
|
}
|
|
397
|
-
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
412
|
+
_super.prototype.render.call(this, useCameraPostProcess);
|
|
413
|
+
};
|
|
414
|
+
Object.defineProperty(FireProceduralTexture, "PurpleFireColors", {
|
|
415
|
+
get: function () {
|
|
416
|
+
return [new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.5, 0.0, 1.0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.9, 0.0, 1.0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.2, 0.0, 1.0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(1.0, 0.9, 1.0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.1, 0.1, 1.0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.9, 0.9, 1.0)];
|
|
417
|
+
},
|
|
418
|
+
enumerable: false,
|
|
419
|
+
configurable: true
|
|
420
|
+
});
|
|
421
|
+
Object.defineProperty(FireProceduralTexture, "GreenFireColors", {
|
|
422
|
+
get: function () {
|
|
423
|
+
return [new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.5, 1.0, 0.0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.5, 1.0, 0.0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.3, 0.4, 0.0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.5, 1.0, 0.0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.2, 0.0, 0.0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.5, 1.0, 0.0)];
|
|
424
|
+
},
|
|
425
|
+
enumerable: false,
|
|
426
|
+
configurable: true
|
|
427
|
+
});
|
|
428
|
+
Object.defineProperty(FireProceduralTexture, "RedFireColors", {
|
|
429
|
+
get: function () {
|
|
430
|
+
return [new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.5, 0.0, 0.1), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.9, 0.0, 0.0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.2, 0.0, 0.0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(1.0, 0.9, 0.0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.1, 0.1, 0.1), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.9, 0.9, 0.9)];
|
|
431
|
+
},
|
|
432
|
+
enumerable: false,
|
|
433
|
+
configurable: true
|
|
434
|
+
});
|
|
435
|
+
Object.defineProperty(FireProceduralTexture, "BlueFireColors", {
|
|
436
|
+
get: function () {
|
|
437
|
+
return [new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.1, 0.0, 0.5), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.0, 0.0, 0.5), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.1, 0.0, 0.2), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.0, 0.0, 1.0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.1, 0.2, 0.3), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.0, 0.2, 0.9)];
|
|
438
|
+
},
|
|
439
|
+
enumerable: false,
|
|
440
|
+
configurable: true
|
|
441
|
+
});
|
|
442
|
+
Object.defineProperty(FireProceduralTexture.prototype, "autoGenerateTime", {
|
|
443
|
+
get: function () {
|
|
444
|
+
return this._autoGenerateTime;
|
|
445
|
+
},
|
|
446
|
+
set: function (value) {
|
|
447
|
+
this._autoGenerateTime = value;
|
|
448
|
+
},
|
|
449
|
+
enumerable: false,
|
|
450
|
+
configurable: true
|
|
451
|
+
});
|
|
452
|
+
Object.defineProperty(FireProceduralTexture.prototype, "fireColors", {
|
|
453
|
+
get: function () {
|
|
454
|
+
return this._fireColors;
|
|
455
|
+
},
|
|
456
|
+
set: function (value) {
|
|
457
|
+
this._fireColors = value;
|
|
458
|
+
this.updateShaderUniforms();
|
|
459
|
+
},
|
|
460
|
+
enumerable: false,
|
|
461
|
+
configurable: true
|
|
462
|
+
});
|
|
463
|
+
Object.defineProperty(FireProceduralTexture.prototype, "time", {
|
|
464
|
+
get: function () {
|
|
465
|
+
return this._time;
|
|
466
|
+
},
|
|
467
|
+
set: function (value) {
|
|
468
|
+
this._time = value;
|
|
469
|
+
this.updateShaderUniforms();
|
|
470
|
+
},
|
|
471
|
+
enumerable: false,
|
|
472
|
+
configurable: true
|
|
473
|
+
});
|
|
474
|
+
Object.defineProperty(FireProceduralTexture.prototype, "speed", {
|
|
475
|
+
get: function () {
|
|
476
|
+
return this._speed;
|
|
477
|
+
},
|
|
478
|
+
set: function (value) {
|
|
479
|
+
this._speed = value;
|
|
480
|
+
this.updateShaderUniforms();
|
|
481
|
+
},
|
|
482
|
+
enumerable: false,
|
|
483
|
+
configurable: true
|
|
484
|
+
});
|
|
485
|
+
Object.defineProperty(FireProceduralTexture.prototype, "alphaThreshold", {
|
|
486
|
+
get: function () {
|
|
487
|
+
return this._alphaThreshold;
|
|
488
|
+
},
|
|
489
|
+
set: function (value) {
|
|
490
|
+
this._alphaThreshold = value;
|
|
491
|
+
this.updateShaderUniforms();
|
|
492
|
+
},
|
|
493
|
+
enumerable: false,
|
|
494
|
+
configurable: true
|
|
495
|
+
});
|
|
445
496
|
/**
|
|
446
497
|
* Serializes this fire procedural texture
|
|
447
498
|
* @returns a serialized fire procedural texture object
|
|
448
499
|
*/
|
|
449
|
-
serialize() {
|
|
450
|
-
|
|
500
|
+
FireProceduralTexture.prototype.serialize = function () {
|
|
501
|
+
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
|
|
451
502
|
serializationObject.customType = "BABYLON.FireProceduralTexture";
|
|
452
503
|
serializationObject.fireColors = [];
|
|
453
|
-
for (
|
|
504
|
+
for (var i = 0; i < this._fireColors.length; i++) {
|
|
454
505
|
serializationObject.fireColors.push(this._fireColors[i].asArray());
|
|
455
506
|
}
|
|
456
507
|
return serializationObject;
|
|
457
|
-
}
|
|
508
|
+
};
|
|
458
509
|
/**
|
|
459
510
|
* Creates a Fire Procedural Texture from parsed fire procedural texture data
|
|
460
511
|
* @param parsedTexture defines parsed texture data
|
|
@@ -462,28 +513,29 @@ class FireProceduralTexture extends babylonjs_Misc_decorators__WEBPACK_IMPORTED_
|
|
|
462
513
|
* @param rootUrl defines the root URL containing fire procedural texture information
|
|
463
514
|
* @returns a parsed Fire Procedural Texture
|
|
464
515
|
*/
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
for (
|
|
516
|
+
FireProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
|
|
517
|
+
var texture = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Parse(function () { return new FireProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
|
|
518
|
+
var colors = [];
|
|
519
|
+
for (var i = 0; i < parsedTexture.fireColors.length; i++) {
|
|
469
520
|
colors.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(parsedTexture.fireColors[i]));
|
|
470
521
|
}
|
|
471
522
|
texture.fireColors = colors;
|
|
472
523
|
return texture;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
(0,
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
(0,
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
(0,
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
(0,
|
|
485
|
-
|
|
486
|
-
|
|
524
|
+
};
|
|
525
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
526
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
527
|
+
], FireProceduralTexture.prototype, "autoGenerateTime", null);
|
|
528
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
529
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
530
|
+
], FireProceduralTexture.prototype, "time", null);
|
|
531
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
532
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serializeAsVector2)()
|
|
533
|
+
], FireProceduralTexture.prototype, "speed", null);
|
|
534
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
535
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
536
|
+
], FireProceduralTexture.prototype, "alphaThreshold", null);
|
|
537
|
+
return FireProceduralTexture;
|
|
538
|
+
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.ProceduralTexture));
|
|
487
539
|
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.RegisterClass)("BABYLON.FireProceduralTexture", FireProceduralTexture);
|
|
488
540
|
|
|
489
541
|
|
|
@@ -519,21 +571,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
519
571
|
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
|
|
520
572
|
// Do not edit.
|
|
521
573
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
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);}
|
|
525
|
-
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;}
|
|
526
|
-
return total;}
|
|
527
|
-
#define CUSTOM_FRAGMENT_DEFINITIONS
|
|
528
|
-
void main(void) {
|
|
529
|
-
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
|
530
|
-
vec3 color=mix(groundColor,herb1Color,rand(gl_FragCoord.xy*4.0));color=mix(color,herb2Color,rand(gl_FragCoord.xy*8.0));color=mix(color,herb3Color,rand(gl_FragCoord.xy));color=mix(color,herb1Color,fbm(gl_FragCoord.xy*16.0));gl_FragColor=vec4(color,1.0);
|
|
531
|
-
#define CUSTOM_FRAGMENT_MAIN_END
|
|
532
|
-
}`;
|
|
574
|
+
var name = "grassProceduralTexturePixelShader";
|
|
575
|
+
var shader = "precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform vec3 herb1Color;uniform vec3 herb2Color;uniform vec3 herb3Color;uniform vec3 groundColor;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\nvec3 color=mix(groundColor,herb1Color,rand(gl_FragCoord.xy*4.0));color=mix(color,herb2Color,rand(gl_FragCoord.xy*8.0));color=mix(color,herb3Color,rand(gl_FragCoord.xy));color=mix(color,herb1Color,fbm(gl_FragCoord.xy*16.0));gl_FragColor=vec4(color,1.0);\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
|
|
533
576
|
// Sideeffect
|
|
534
577
|
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__.ShaderStore.ShadersStore[name] = shader;
|
|
535
578
|
/** @internal */
|
|
536
|
-
|
|
579
|
+
var grassProceduralTexturePixelShader = { name: name, shader: shader };
|
|
537
580
|
|
|
538
581
|
|
|
539
582
|
/***/ }),
|
|
@@ -558,46 +601,57 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
558
601
|
|
|
559
602
|
|
|
560
603
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
604
|
+
var GrassProceduralTexture = /** @class */ (function (_super) {
|
|
605
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(GrassProceduralTexture, _super);
|
|
606
|
+
function GrassProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
|
|
607
|
+
if (scene === void 0) { scene = null; }
|
|
608
|
+
var _this = _super.call(this, name, size, "grassProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
|
|
609
|
+
_this._groundColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(1, 1, 1);
|
|
610
|
+
_this._grassColors = [new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.29, 0.38, 0.02), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.36, 0.49, 0.09), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.51, 0.6, 0.28)];
|
|
611
|
+
_this.updateShaderUniforms();
|
|
612
|
+
return _this;
|
|
567
613
|
}
|
|
568
|
-
updateShaderUniforms() {
|
|
614
|
+
GrassProceduralTexture.prototype.updateShaderUniforms = function () {
|
|
569
615
|
this.setColor3("herb1Color", this._grassColors[0]);
|
|
570
616
|
this.setColor3("herb2Color", this._grassColors[1]);
|
|
571
617
|
this.setColor3("herb3Color", this._grassColors[2]);
|
|
572
618
|
this.setColor3("groundColor", this._groundColor);
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
619
|
+
};
|
|
620
|
+
Object.defineProperty(GrassProceduralTexture.prototype, "grassColors", {
|
|
621
|
+
get: function () {
|
|
622
|
+
return this._grassColors;
|
|
623
|
+
},
|
|
624
|
+
set: function (value) {
|
|
625
|
+
this._grassColors = value;
|
|
626
|
+
this.updateShaderUniforms();
|
|
627
|
+
},
|
|
628
|
+
enumerable: false,
|
|
629
|
+
configurable: true
|
|
630
|
+
});
|
|
631
|
+
Object.defineProperty(GrassProceduralTexture.prototype, "groundColor", {
|
|
632
|
+
get: function () {
|
|
633
|
+
return this._groundColor;
|
|
634
|
+
},
|
|
635
|
+
set: function (value) {
|
|
636
|
+
this._groundColor = value;
|
|
637
|
+
this.updateShaderUniforms();
|
|
638
|
+
},
|
|
639
|
+
enumerable: false,
|
|
640
|
+
configurable: true
|
|
641
|
+
});
|
|
588
642
|
/**
|
|
589
643
|
* Serializes this grass procedural texture
|
|
590
644
|
* @returns a serialized grass procedural texture object
|
|
591
645
|
*/
|
|
592
|
-
serialize() {
|
|
593
|
-
|
|
646
|
+
GrassProceduralTexture.prototype.serialize = function () {
|
|
647
|
+
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
|
|
594
648
|
serializationObject.customType = "BABYLON.GrassProceduralTexture";
|
|
595
649
|
serializationObject.grassColors = [];
|
|
596
|
-
for (
|
|
650
|
+
for (var i = 0; i < this._grassColors.length; i++) {
|
|
597
651
|
serializationObject.grassColors.push(this._grassColors[i].asArray());
|
|
598
652
|
}
|
|
599
653
|
return serializationObject;
|
|
600
|
-
}
|
|
654
|
+
};
|
|
601
655
|
/**
|
|
602
656
|
* Creates a Grass Procedural Texture from parsed grass procedural texture data
|
|
603
657
|
* @param parsedTexture defines parsed texture data
|
|
@@ -605,19 +659,20 @@ class GrassProceduralTexture extends babylonjs_Misc_decorators__WEBPACK_IMPORTED
|
|
|
605
659
|
* @param rootUrl defines the root URL containing grass procedural texture information
|
|
606
660
|
* @returns a parsed Grass Procedural Texture
|
|
607
661
|
*/
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
for (
|
|
662
|
+
GrassProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
|
|
663
|
+
var texture = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Parse(function () { return new GrassProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
|
|
664
|
+
var colors = [];
|
|
665
|
+
for (var i = 0; i < parsedTexture.grassColors.length; i++) {
|
|
612
666
|
colors.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(parsedTexture.grassColors[i]));
|
|
613
667
|
}
|
|
614
668
|
texture.grassColors = colors;
|
|
615
669
|
return texture;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
(0,
|
|
619
|
-
|
|
620
|
-
|
|
670
|
+
};
|
|
671
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
672
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serializeAsColor3)()
|
|
673
|
+
], GrassProceduralTexture.prototype, "groundColor", null);
|
|
674
|
+
return GrassProceduralTexture;
|
|
675
|
+
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.ProceduralTexture));
|
|
621
676
|
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.RegisterClass)("BABYLON.GrassProceduralTexture", GrassProceduralTexture);
|
|
622
677
|
|
|
623
678
|
|
|
@@ -713,12 +768,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
713
768
|
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
|
|
714
769
|
// Do not edit.
|
|
715
770
|
|
|
716
|
-
|
|
717
|
-
|
|
771
|
+
var name = "marbleProceduralTexturePixelShader";
|
|
772
|
+
var shader = "precision highp float;\nvarying vec2 vPosition;\nvarying vec2 vUV;\nuniform float numberOfTilesHeight;\nuniform float numberOfTilesWidth;\nuniform float amplitude;\nuniform vec3 marbleColor;\nuniform vec3 jointColor;\nconst vec3 tileSize=vec3(1.1,1.0,1.1);\nconst vec3 tilePct=vec3(0.98,1.0,0.98);\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat turbulence(vec2 P)\n{\nfloat val=0.0;\nfloat freq=1.0;\nfor (int i=0; i<4; i++)\n{\nval+=abs(noise(P*freq)/freq);\nfreq*=2.07;\n}\nreturn val;\n}\nfloat roundF(float number){\nreturn sign(number)*floor(abs(number)+0.5);\n}\nvec3 marble_color(float x)\n{\nvec3 col;\nx=0.5*(x+1.);\nx=sqrt(x); \nx=sqrt(x);\nx=sqrt(x);\ncol=vec3(.2+.75*x); \ncol.b*=0.95; \nreturn col;\n}\nvoid main()\n{\nfloat brickW=1.0/numberOfTilesWidth;\nfloat brickH=1.0/numberOfTilesHeight;\nfloat jointWPercentage=0.01;\nfloat jointHPercentage=0.01;\nvec3 color=marbleColor;\nfloat yi=vUV.y/brickH;\nfloat nyi=roundF(yi);\nfloat xi=vUV.x/brickW;\nif (mod(floor(yi),2.0)==0.0){\nxi=xi-0.5;\n}\nfloat nxi=roundF(xi);\nvec2 brickvUV=vec2((xi-floor(xi))/brickH,(yi-floor(yi))/brickW);\nif (yi<nyi+jointHPercentage && yi>nyi-jointHPercentage){\ncolor=mix(jointColor,vec3(0.37,0.25,0.25),(yi-nyi)/jointHPercentage+0.2);\n}\nelse if (xi<nxi+jointWPercentage && xi>nxi-jointWPercentage){\ncolor=mix(jointColor,vec3(0.44,0.44,0.44),(xi-nxi)/jointWPercentage+0.2);\n}\nelse {\nfloat t=6.28*brickvUV.x/(tileSize.x+noise(vec2(vUV)*6.0));\nt+=amplitude*turbulence(brickvUV.xy);\nt=sin(t);\ncolor=marble_color(t);\n}\ngl_FragColor=vec4(color,0.0);\n}";
|
|
718
773
|
// Sideeffect
|
|
719
774
|
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__.ShaderStore.ShadersStore[name] = shader;
|
|
720
775
|
/** @internal */
|
|
721
|
-
|
|
776
|
+
var marbleProceduralTexturePixelShader = { name: name, shader: shader };
|
|
722
777
|
|
|
723
778
|
|
|
724
779
|
/***/ }),
|
|
@@ -743,58 +798,77 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
743
798
|
|
|
744
799
|
|
|
745
800
|
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
801
|
+
var MarbleProceduralTexture = /** @class */ (function (_super) {
|
|
802
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(MarbleProceduralTexture, _super);
|
|
803
|
+
function MarbleProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
|
|
804
|
+
if (scene === void 0) { scene = null; }
|
|
805
|
+
var _this = _super.call(this, name, size, "marbleProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
|
|
806
|
+
_this._numberOfTilesHeight = 3;
|
|
807
|
+
_this._numberOfTilesWidth = 3;
|
|
808
|
+
_this._amplitude = 9.0;
|
|
809
|
+
_this._jointColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.72, 0.72, 0.72);
|
|
810
|
+
_this.updateShaderUniforms();
|
|
811
|
+
return _this;
|
|
754
812
|
}
|
|
755
|
-
updateShaderUniforms() {
|
|
813
|
+
MarbleProceduralTexture.prototype.updateShaderUniforms = function () {
|
|
756
814
|
this.setFloat("numberOfTilesHeight", this._numberOfTilesHeight);
|
|
757
815
|
this.setFloat("numberOfTilesWidth", this._numberOfTilesWidth);
|
|
758
816
|
this.setFloat("amplitude", this._amplitude);
|
|
759
817
|
this.setColor3("jointColor", this._jointColor);
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
818
|
+
};
|
|
819
|
+
Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesHeight", {
|
|
820
|
+
get: function () {
|
|
821
|
+
return this._numberOfTilesHeight;
|
|
822
|
+
},
|
|
823
|
+
set: function (value) {
|
|
824
|
+
this._numberOfTilesHeight = value;
|
|
825
|
+
this.updateShaderUniforms();
|
|
826
|
+
},
|
|
827
|
+
enumerable: false,
|
|
828
|
+
configurable: true
|
|
829
|
+
});
|
|
830
|
+
Object.defineProperty(MarbleProceduralTexture.prototype, "amplitude", {
|
|
831
|
+
get: function () {
|
|
832
|
+
return this._amplitude;
|
|
833
|
+
},
|
|
834
|
+
set: function (value) {
|
|
835
|
+
this._amplitude = value;
|
|
836
|
+
this.updateShaderUniforms();
|
|
837
|
+
},
|
|
838
|
+
enumerable: false,
|
|
839
|
+
configurable: true
|
|
840
|
+
});
|
|
841
|
+
Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesWidth", {
|
|
842
|
+
get: function () {
|
|
843
|
+
return this._numberOfTilesWidth;
|
|
844
|
+
},
|
|
845
|
+
set: function (value) {
|
|
846
|
+
this._numberOfTilesWidth = value;
|
|
847
|
+
this.updateShaderUniforms();
|
|
848
|
+
},
|
|
849
|
+
enumerable: false,
|
|
850
|
+
configurable: true
|
|
851
|
+
});
|
|
852
|
+
Object.defineProperty(MarbleProceduralTexture.prototype, "jointColor", {
|
|
853
|
+
get: function () {
|
|
854
|
+
return this._jointColor;
|
|
855
|
+
},
|
|
856
|
+
set: function (value) {
|
|
857
|
+
this._jointColor = value;
|
|
858
|
+
this.updateShaderUniforms();
|
|
859
|
+
},
|
|
860
|
+
enumerable: false,
|
|
861
|
+
configurable: true
|
|
862
|
+
});
|
|
789
863
|
/**
|
|
790
864
|
* Serializes this marble procedural texture
|
|
791
865
|
* @returns a serialized marble procedural texture object
|
|
792
866
|
*/
|
|
793
|
-
serialize() {
|
|
794
|
-
|
|
867
|
+
MarbleProceduralTexture.prototype.serialize = function () {
|
|
868
|
+
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
|
|
795
869
|
serializationObject.customType = "BABYLON.MarbleProceduralTexture";
|
|
796
870
|
return serializationObject;
|
|
797
|
-
}
|
|
871
|
+
};
|
|
798
872
|
/**
|
|
799
873
|
* Creates a Marble Procedural Texture from parsed marble procedural texture data
|
|
800
874
|
* @param parsedTexture defines parsed texture data
|
|
@@ -802,23 +876,24 @@ class MarbleProceduralTexture extends babylonjs_Misc_decorators__WEBPACK_IMPORTE
|
|
|
802
876
|
* @param rootUrl defines the root URL containing marble procedural texture information
|
|
803
877
|
* @returns a parsed Marble Procedural Texture
|
|
804
878
|
*/
|
|
805
|
-
|
|
806
|
-
|
|
879
|
+
MarbleProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
|
|
880
|
+
var texture = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Parse(function () { return new MarbleProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
|
|
807
881
|
return texture;
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
(0,
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
(0,
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
(0,
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
(0,
|
|
820
|
-
|
|
821
|
-
|
|
882
|
+
};
|
|
883
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
884
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
885
|
+
], MarbleProceduralTexture.prototype, "numberOfTilesHeight", null);
|
|
886
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
887
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
888
|
+
], MarbleProceduralTexture.prototype, "amplitude", null);
|
|
889
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
890
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
891
|
+
], MarbleProceduralTexture.prototype, "numberOfTilesWidth", null);
|
|
892
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
893
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
894
|
+
], MarbleProceduralTexture.prototype, "jointColor", null);
|
|
895
|
+
return MarbleProceduralTexture;
|
|
896
|
+
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.ProceduralTexture));
|
|
822
897
|
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.RegisterClass)("BABYLON.MarbleProceduralTexture", MarbleProceduralTexture);
|
|
823
898
|
|
|
824
899
|
|
|
@@ -854,16 +929,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
854
929
|
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
|
|
855
930
|
// Do not edit.
|
|
856
931
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
{vec3 pixel=texture2D(baseSampler,coord).rgb;float luma=dot(pixel,LUMA_COEFFICIENT);return luma;}
|
|
860
|
-
void main()
|
|
861
|
-
{float lumaU0=lumaAtCoord(vUV+vec2(-1.0, 0.0)/size);float lumaU1=lumaAtCoord(vUV+vec2( 1.0, 0.0)/size);float lumaV0=lumaAtCoord(vUV+vec2( 0.0,-1.0)/size);float lumaV1=lumaAtCoord(vUV+vec2( 0.0, 1.0)/size);vec2 slope=(vec2(lumaU0-lumaU1,lumaV0-lumaV1)+1.0)*0.5;gl_FragColor=vec4(slope,1.0,1.0);}
|
|
862
|
-
`;
|
|
932
|
+
var name = "normalMapProceduralTexturePixelShader";
|
|
933
|
+
var shader = "precision highp float;uniform sampler2D baseSampler;uniform float size;varying vec2 vUV;const vec3 LUMA_COEFFICIENT=vec3(0.2126,0.7152,0.0722);float lumaAtCoord(vec2 coord)\n{vec3 pixel=texture2D(baseSampler,coord).rgb;float luma=dot(pixel,LUMA_COEFFICIENT);return luma;}\nvoid main()\n{float lumaU0=lumaAtCoord(vUV+vec2(-1.0, 0.0)/size);float lumaU1=lumaAtCoord(vUV+vec2( 1.0, 0.0)/size);float lumaV0=lumaAtCoord(vUV+vec2( 0.0,-1.0)/size);float lumaV1=lumaAtCoord(vUV+vec2( 0.0, 1.0)/size);vec2 slope=(vec2(lumaU0-lumaU1,lumaV0-lumaV1)+1.0)*0.5;gl_FragColor=vec4(slope,1.0,1.0);}\n";
|
|
863
934
|
// Sideeffect
|
|
864
935
|
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__.ShaderStore.ShadersStore[name] = shader;
|
|
865
936
|
/** @internal */
|
|
866
|
-
|
|
937
|
+
var normalMapProceduralTexturePixelShader = { name: name, shader: shader };
|
|
867
938
|
|
|
868
939
|
|
|
869
940
|
/***/ }),
|
|
@@ -887,45 +958,52 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
887
958
|
|
|
888
959
|
|
|
889
960
|
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
961
|
+
var NormalMapProceduralTexture = /** @class */ (function (_super) {
|
|
962
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(NormalMapProceduralTexture, _super);
|
|
963
|
+
function NormalMapProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
|
|
964
|
+
if (scene === void 0) { scene = null; }
|
|
965
|
+
var _this = _super.call(this, name, size, "normalMapProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
|
|
966
|
+
_this.updateShaderUniforms();
|
|
967
|
+
return _this;
|
|
894
968
|
}
|
|
895
|
-
updateShaderUniforms() {
|
|
969
|
+
NormalMapProceduralTexture.prototype.updateShaderUniforms = function () {
|
|
896
970
|
this.setTexture("baseSampler", this._baseTexture);
|
|
897
971
|
this.setFloat("size", this.getRenderSize());
|
|
898
|
-
}
|
|
899
|
-
render(useCameraPostProcess) {
|
|
900
|
-
|
|
901
|
-
}
|
|
902
|
-
resize(size, generateMipMaps) {
|
|
903
|
-
|
|
972
|
+
};
|
|
973
|
+
NormalMapProceduralTexture.prototype.render = function (useCameraPostProcess) {
|
|
974
|
+
_super.prototype.render.call(this, useCameraPostProcess);
|
|
975
|
+
};
|
|
976
|
+
NormalMapProceduralTexture.prototype.resize = function (size, generateMipMaps) {
|
|
977
|
+
_super.prototype.resize.call(this, size, generateMipMaps);
|
|
904
978
|
// We need to update the "size" uniform
|
|
905
979
|
this.updateShaderUniforms();
|
|
906
|
-
}
|
|
907
|
-
isReady() {
|
|
980
|
+
};
|
|
981
|
+
NormalMapProceduralTexture.prototype.isReady = function () {
|
|
908
982
|
if (!this._baseTexture || !this._baseTexture.isReady()) {
|
|
909
983
|
return false;
|
|
910
984
|
}
|
|
911
|
-
return
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
985
|
+
return _super.prototype.isReady.call(this);
|
|
986
|
+
};
|
|
987
|
+
Object.defineProperty(NormalMapProceduralTexture.prototype, "baseTexture", {
|
|
988
|
+
get: function () {
|
|
989
|
+
return this._baseTexture;
|
|
990
|
+
},
|
|
991
|
+
set: function (texture) {
|
|
992
|
+
this._baseTexture = texture;
|
|
993
|
+
this.updateShaderUniforms();
|
|
994
|
+
},
|
|
995
|
+
enumerable: false,
|
|
996
|
+
configurable: true
|
|
997
|
+
});
|
|
920
998
|
/**
|
|
921
999
|
* Serializes this normal map procedural texture
|
|
922
1000
|
* @returns a serialized normal map procedural texture object
|
|
923
1001
|
*/
|
|
924
|
-
serialize() {
|
|
925
|
-
|
|
1002
|
+
NormalMapProceduralTexture.prototype.serialize = function () {
|
|
1003
|
+
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
|
|
926
1004
|
serializationObject.customType = "BABYLON.NormalMapProceduralTexture";
|
|
927
1005
|
return serializationObject;
|
|
928
|
-
}
|
|
1006
|
+
};
|
|
929
1007
|
/**
|
|
930
1008
|
* Creates a Normal Map Procedural Texture from parsed normal map procedural texture data
|
|
931
1009
|
* @param parsedTexture defines parsed texture data
|
|
@@ -933,14 +1011,15 @@ class NormalMapProceduralTexture extends babylonjs_Misc_decorators__WEBPACK_IMPO
|
|
|
933
1011
|
* @param rootUrl defines the root URL containing normal map procedural texture information
|
|
934
1012
|
* @returns a parsed Normal Map Procedural Texture
|
|
935
1013
|
*/
|
|
936
|
-
|
|
937
|
-
|
|
1014
|
+
NormalMapProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
|
|
1015
|
+
var texture = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Parse(function () { return new NormalMapProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
|
|
938
1016
|
return texture;
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
(0,
|
|
942
|
-
|
|
943
|
-
|
|
1017
|
+
};
|
|
1018
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1019
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serializeAsTexture)()
|
|
1020
|
+
], NormalMapProceduralTexture.prototype, "baseTexture", null);
|
|
1021
|
+
return NormalMapProceduralTexture;
|
|
1022
|
+
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.ProceduralTexture));
|
|
944
1023
|
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.RegisterClass)("BABYLON.NormalMapProceduralTexture", NormalMapProceduralTexture);
|
|
945
1024
|
|
|
946
1025
|
|
|
@@ -976,50 +1055,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
976
1055
|
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
|
|
977
1056
|
// Do not edit.
|
|
978
1057
|
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
{return fract(cos(n*89.42)*343.42);}
|
|
982
|
-
vec2 r(vec2 n)
|
|
983
|
-
{return vec2(r(n.x*23.62-300.0+n.y*34.35),r(n.x*45.13+256.0+n.y*38.89)); }
|
|
984
|
-
float worley(vec2 n,float s)
|
|
985
|
-
{float dis=1.0;for(int x=-1; x<=1; x++)
|
|
986
|
-
{for(int y=-1; y<=1; y++)
|
|
987
|
-
{vec2 p=floor(n/s)+vec2(x,y);float d=length(r(p)+vec2(x,y)-fract(n/s));if (dis>d)
|
|
988
|
-
dis=d;}}
|
|
989
|
-
return 1.0-dis;}
|
|
990
|
-
vec3 hash33(vec3 p3)
|
|
991
|
-
{p3=fract(p3*vec3(0.1031,0.11369,0.13787));p3+=dot(p3,p3.yxz+19.19);return -1.0+2.0*fract(vec3((p3.x+p3.y)*p3.z,(p3.x+p3.z)*p3.y,(p3.y+p3.z)*p3.x));}
|
|
992
|
-
float perlinNoise(vec3 p)
|
|
993
|
-
{vec3 pi=floor(p);vec3 pf=p-pi;vec3 w=pf*pf*(3.0-2.0*pf);return mix(
|
|
994
|
-
mix(
|
|
995
|
-
mix(
|
|
996
|
-
dot(pf-vec3(0,0,0),hash33(pi+vec3(0,0,0))),
|
|
997
|
-
dot(pf-vec3(1,0,0),hash33(pi+vec3(1,0,0))),w.x
|
|
998
|
-
),mix(
|
|
999
|
-
dot(pf-vec3(0,0,1),hash33(pi+vec3(0,0,1))),
|
|
1000
|
-
dot(pf-vec3(1,0,1),hash33(pi+vec3(1,0,1))),w.x
|
|
1001
|
-
),w.z
|
|
1002
|
-
),mix(
|
|
1003
|
-
mix(
|
|
1004
|
-
dot(pf-vec3(0,1,0),hash33(pi+vec3(0,1,0))),
|
|
1005
|
-
dot(pf-vec3(1,1,0),hash33(pi+vec3(1,1,0))),w.x
|
|
1006
|
-
),mix(
|
|
1007
|
-
dot(pf-vec3(0,1,1),hash33(pi+vec3(0,1,1))),
|
|
1008
|
-
dot(pf-vec3(1,1,1),hash33(pi+vec3(1,1,1))),w.x
|
|
1009
|
-
),w.z
|
|
1010
|
-
),w.y
|
|
1011
|
-
);}
|
|
1012
|
-
#define CUSTOM_FRAGMENT_DEFINITIONS
|
|
1013
|
-
void main(void)
|
|
1014
|
-
{vec2 uv=gl_FragCoord.xy+translationSpeed;float dis=(
|
|
1015
|
-
1.0+perlinNoise(vec3(uv/vec2(size,size),time*0.05)*8.0))
|
|
1016
|
-
* (1.0+(worley(uv,32.0)+ 0.5*worley(2.0*uv,32.0)+0.25*worley(4.0*uv,32.0))
|
|
1017
|
-
);gl_FragColor=vec4(vec3(dis/4.0),1.0);}
|
|
1018
|
-
`;
|
|
1058
|
+
var name = "perlinNoiseProceduralTexturePixelShader";
|
|
1059
|
+
var shader = "precision highp float;uniform float size;uniform float time;uniform float translationSpeed;varying vec2 vUV;float r(float n)\n{return fract(cos(n*89.42)*343.42);}\nvec2 r(vec2 n)\n{return vec2(r(n.x*23.62-300.0+n.y*34.35),r(n.x*45.13+256.0+n.y*38.89)); }\nfloat worley(vec2 n,float s)\n{float dis=1.0;for(int x=-1; x<=1; x++)\n{for(int y=-1; y<=1; y++)\n{vec2 p=floor(n/s)+vec2(x,y);float d=length(r(p)+vec2(x,y)-fract(n/s));if (dis>d)\ndis=d;}}\nreturn 1.0-dis;}\nvec3 hash33(vec3 p3)\n{p3=fract(p3*vec3(0.1031,0.11369,0.13787));p3+=dot(p3,p3.yxz+19.19);return -1.0+2.0*fract(vec3((p3.x+p3.y)*p3.z,(p3.x+p3.z)*p3.y,(p3.y+p3.z)*p3.x));}\nfloat perlinNoise(vec3 p)\n{vec3 pi=floor(p);vec3 pf=p-pi;vec3 w=pf*pf*(3.0-2.0*pf);return mix(\nmix(\nmix(\ndot(pf-vec3(0,0,0),hash33(pi+vec3(0,0,0))),\ndot(pf-vec3(1,0,0),hash33(pi+vec3(1,0,0))),w.x\n),mix(\ndot(pf-vec3(0,0,1),hash33(pi+vec3(0,0,1))),\ndot(pf-vec3(1,0,1),hash33(pi+vec3(1,0,1))),w.x\n),w.z\n),mix(\nmix(\ndot(pf-vec3(0,1,0),hash33(pi+vec3(0,1,0))),\ndot(pf-vec3(1,1,0),hash33(pi+vec3(1,1,0))),w.x\n),mix(\ndot(pf-vec3(0,1,1),hash33(pi+vec3(0,1,1))),\ndot(pf-vec3(1,1,1),hash33(pi+vec3(1,1,1))),w.x\n),w.z\n),w.y\n);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec2 uv=gl_FragCoord.xy+translationSpeed;float dis=(\n1.0+perlinNoise(vec3(uv/vec2(size,size),time*0.05)*8.0))\n* (1.0+(worley(uv,32.0)+ 0.5*worley(2.0*uv,32.0)+0.25*worley(4.0*uv,32.0))\n);gl_FragColor=vec4(vec3(dis/4.0),1.0);}\n";
|
|
1019
1060
|
// Sideeffect
|
|
1020
1061
|
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__.ShaderStore.ShadersStore[name] = shader;
|
|
1021
1062
|
/** @internal */
|
|
1022
|
-
|
|
1063
|
+
var perlinNoiseProceduralTexturePixelShader = { name: name, shader: shader };
|
|
1023
1064
|
|
|
1024
1065
|
|
|
1025
1066
|
/***/ }),
|
|
@@ -1043,43 +1084,46 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1043
1084
|
|
|
1044
1085
|
|
|
1045
1086
|
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1087
|
+
var PerlinNoiseProceduralTexture = /** @class */ (function (_super) {
|
|
1088
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(PerlinNoiseProceduralTexture, _super);
|
|
1089
|
+
function PerlinNoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
|
|
1090
|
+
if (scene === void 0) { scene = null; }
|
|
1091
|
+
var _this = _super.call(this, name, size, "perlinNoiseProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
|
|
1092
|
+
_this.time = 0.0;
|
|
1093
|
+
_this.timeScale = 1.0;
|
|
1094
|
+
_this.translationSpeed = 1.0;
|
|
1095
|
+
_this._currentTranslation = 0;
|
|
1096
|
+
_this.updateShaderUniforms();
|
|
1097
|
+
return _this;
|
|
1054
1098
|
}
|
|
1055
|
-
updateShaderUniforms() {
|
|
1099
|
+
PerlinNoiseProceduralTexture.prototype.updateShaderUniforms = function () {
|
|
1056
1100
|
this.setFloat("size", this.getRenderSize());
|
|
1057
|
-
|
|
1101
|
+
var scene = this.getScene();
|
|
1058
1102
|
if (!scene) {
|
|
1059
1103
|
return;
|
|
1060
1104
|
}
|
|
1061
|
-
|
|
1105
|
+
var deltaTime = scene.getEngine().getDeltaTime();
|
|
1062
1106
|
this.time += deltaTime;
|
|
1063
1107
|
this.setFloat("time", (this.time * this.timeScale) / 1000);
|
|
1064
1108
|
this._currentTranslation += (deltaTime * this.translationSpeed) / 1000.0;
|
|
1065
1109
|
this.setFloat("translationSpeed", this._currentTranslation);
|
|
1066
|
-
}
|
|
1067
|
-
render(useCameraPostProcess) {
|
|
1110
|
+
};
|
|
1111
|
+
PerlinNoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
|
|
1068
1112
|
this.updateShaderUniforms();
|
|
1069
|
-
|
|
1070
|
-
}
|
|
1071
|
-
resize(size, generateMipMaps) {
|
|
1072
|
-
|
|
1073
|
-
}
|
|
1113
|
+
_super.prototype.render.call(this, useCameraPostProcess);
|
|
1114
|
+
};
|
|
1115
|
+
PerlinNoiseProceduralTexture.prototype.resize = function (size, generateMipMaps) {
|
|
1116
|
+
_super.prototype.resize.call(this, size, generateMipMaps);
|
|
1117
|
+
};
|
|
1074
1118
|
/**
|
|
1075
1119
|
* Serializes this perlin noise procedural texture
|
|
1076
1120
|
* @returns a serialized perlin noise procedural texture object
|
|
1077
1121
|
*/
|
|
1078
|
-
serialize() {
|
|
1079
|
-
|
|
1122
|
+
PerlinNoiseProceduralTexture.prototype.serialize = function () {
|
|
1123
|
+
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
|
|
1080
1124
|
serializationObject.customType = "BABYLON.PerlinNoiseProceduralTexture";
|
|
1081
1125
|
return serializationObject;
|
|
1082
|
-
}
|
|
1126
|
+
};
|
|
1083
1127
|
/**
|
|
1084
1128
|
* Creates a Perlin Noise Procedural Texture from parsed perlin noise procedural texture data
|
|
1085
1129
|
* @param parsedTexture defines parsed texture data
|
|
@@ -1087,20 +1131,21 @@ class PerlinNoiseProceduralTexture extends babylonjs_Misc_decorators__WEBPACK_IM
|
|
|
1087
1131
|
* @param rootUrl defines the root URL containing perlin noise procedural texture information
|
|
1088
1132
|
* @returns a parsed Perlin Noise Procedural Texture
|
|
1089
1133
|
*/
|
|
1090
|
-
|
|
1091
|
-
|
|
1134
|
+
PerlinNoiseProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
|
|
1135
|
+
var texture = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Parse(function () { return new PerlinNoiseProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
|
|
1092
1136
|
return texture;
|
|
1093
|
-
}
|
|
1094
|
-
|
|
1095
|
-
(0,
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
(0,
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
(0,
|
|
1102
|
-
|
|
1103
|
-
|
|
1137
|
+
};
|
|
1138
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1139
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
1140
|
+
], PerlinNoiseProceduralTexture.prototype, "time", void 0);
|
|
1141
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1142
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
1143
|
+
], PerlinNoiseProceduralTexture.prototype, "timeScale", void 0);
|
|
1144
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1145
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
1146
|
+
], PerlinNoiseProceduralTexture.prototype, "translationSpeed", void 0);
|
|
1147
|
+
return PerlinNoiseProceduralTexture;
|
|
1148
|
+
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.ProceduralTexture));
|
|
1104
1149
|
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.RegisterClass)("BABYLON.PerlinNoiseProceduralTexture", PerlinNoiseProceduralTexture);
|
|
1105
1150
|
|
|
1106
1151
|
|
|
@@ -1136,22 +1181,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1136
1181
|
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
|
|
1137
1182
|
// Do not edit.
|
|
1138
1183
|
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
uniform vec3 roadColor;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}
|
|
1142
|
-
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);}
|
|
1143
|
-
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;}
|
|
1144
|
-
return total;}
|
|
1145
|
-
#define CUSTOM_FRAGMENT_DEFINITIONS
|
|
1146
|
-
void main(void) {
|
|
1147
|
-
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
|
1148
|
-
float ratioy=mod(gl_FragCoord.y*100.0 ,fbm(vUV*2.0));vec3 color=roadColor*ratioy;gl_FragColor=vec4(color,1.0);
|
|
1149
|
-
#define CUSTOM_FRAGMENT_MAIN_END
|
|
1150
|
-
}`;
|
|
1184
|
+
var name = "roadProceduralTexturePixelShader";
|
|
1185
|
+
var shader = "precision highp float;varying vec2 vUV; \nuniform vec3 roadColor;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(gl_FragCoord.y*100.0 ,fbm(vUV*2.0));vec3 color=roadColor*ratioy;gl_FragColor=vec4(color,1.0);\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
|
|
1151
1186
|
// Sideeffect
|
|
1152
1187
|
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__.ShaderStore.ShadersStore[name] = shader;
|
|
1153
1188
|
/** @internal */
|
|
1154
|
-
|
|
1189
|
+
var roadProceduralTexturePixelShader = { name: name, shader: shader };
|
|
1155
1190
|
|
|
1156
1191
|
|
|
1157
1192
|
/***/ }),
|
|
@@ -1176,31 +1211,38 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1176
1211
|
|
|
1177
1212
|
|
|
1178
1213
|
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1214
|
+
var RoadProceduralTexture = /** @class */ (function (_super) {
|
|
1215
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(RoadProceduralTexture, _super);
|
|
1216
|
+
function RoadProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
|
|
1217
|
+
if (scene === void 0) { scene = null; }
|
|
1218
|
+
var _this = _super.call(this, name, size, "roadProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
|
|
1219
|
+
_this._roadColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.53, 0.53, 0.53);
|
|
1220
|
+
_this.updateShaderUniforms();
|
|
1221
|
+
return _this;
|
|
1184
1222
|
}
|
|
1185
|
-
updateShaderUniforms() {
|
|
1223
|
+
RoadProceduralTexture.prototype.updateShaderUniforms = function () {
|
|
1186
1224
|
this.setColor3("roadColor", this._roadColor);
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1225
|
+
};
|
|
1226
|
+
Object.defineProperty(RoadProceduralTexture.prototype, "roadColor", {
|
|
1227
|
+
get: function () {
|
|
1228
|
+
return this._roadColor;
|
|
1229
|
+
},
|
|
1230
|
+
set: function (value) {
|
|
1231
|
+
this._roadColor = value;
|
|
1232
|
+
this.updateShaderUniforms();
|
|
1233
|
+
},
|
|
1234
|
+
enumerable: false,
|
|
1235
|
+
configurable: true
|
|
1236
|
+
});
|
|
1195
1237
|
/**
|
|
1196
1238
|
* Serializes this road procedural texture
|
|
1197
1239
|
* @returns a serialized road procedural texture object
|
|
1198
1240
|
*/
|
|
1199
|
-
serialize() {
|
|
1200
|
-
|
|
1241
|
+
RoadProceduralTexture.prototype.serialize = function () {
|
|
1242
|
+
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
|
|
1201
1243
|
serializationObject.customType = "BABYLON.RoadProceduralTexture";
|
|
1202
1244
|
return serializationObject;
|
|
1203
|
-
}
|
|
1245
|
+
};
|
|
1204
1246
|
/**
|
|
1205
1247
|
* Creates a Road Procedural Texture from parsed road procedural texture data
|
|
1206
1248
|
* @param parsedTexture defines parsed texture data
|
|
@@ -1208,14 +1250,15 @@ class RoadProceduralTexture extends babylonjs_Misc_decorators__WEBPACK_IMPORTED_
|
|
|
1208
1250
|
* @param rootUrl defines the root URL containing road procedural texture information
|
|
1209
1251
|
* @returns a parsed Road Procedural Texture
|
|
1210
1252
|
*/
|
|
1211
|
-
|
|
1212
|
-
|
|
1253
|
+
RoadProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
|
|
1254
|
+
var texture = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Parse(function () { return new RoadProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
|
|
1213
1255
|
return texture;
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
(0,
|
|
1217
|
-
|
|
1218
|
-
|
|
1256
|
+
};
|
|
1257
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1258
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serializeAsColor3)()
|
|
1259
|
+
], RoadProceduralTexture.prototype, "roadColor", null);
|
|
1260
|
+
return RoadProceduralTexture;
|
|
1261
|
+
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.ProceduralTexture));
|
|
1219
1262
|
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.RegisterClass)("BABYLON.RoadProceduralTexture", RoadProceduralTexture);
|
|
1220
1263
|
|
|
1221
1264
|
|
|
@@ -1251,27 +1294,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1251
1294
|
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
|
|
1252
1295
|
// Do not edit.
|
|
1253
1296
|
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
#define volsteps 20
|
|
1257
|
-
#define iterations 15
|
|
1258
|
-
varying vec2 vPosition;varying vec2 vUV;uniform float time;uniform float alpha;uniform float beta;uniform float zoom;uniform float formuparam;uniform float stepsize;uniform float tile;uniform float brightness;uniform float darkmatter;uniform float distfading;uniform float saturation;void main()
|
|
1259
|
-
{vec3 dir=vec3(vUV*zoom,1.);float localTime=time*0.0001;mat2 rot1=mat2(cos(alpha),sin(alpha),-sin(alpha),cos(alpha));mat2 rot2=mat2(cos(beta),sin(beta),-sin(beta),cos(beta));dir.xz*=rot1;dir.xy*=rot2;vec3 from_=vec3(1.,.5,0.5);from_+=vec3(-2.,localTime*2.,localTime);from_.xz*=rot1;from_.xy*=rot2;float s=0.1,fade=1.;vec3 v=vec3(0.);for (int r=0; r<volsteps; r++) {vec3 p=from_+s*dir*.5;p=abs(vec3(tile)-mod(p,vec3(tile*2.)));
|
|
1260
|
-
float pa,a=pa=0.;for (int i=0; i<iterations; i++) {p=abs(p)/dot(p,p)-formuparam;
|
|
1261
|
-
a+=abs(length(p)-pa);
|
|
1262
|
-
pa=length(p);}
|
|
1263
|
-
float dm=max(0.,darkmatter-a*a*.001);
|
|
1264
|
-
a*=a*a;
|
|
1265
|
-
if (r>6) fade*=1.-dm;
|
|
1266
|
-
v+=fade;v+=vec3(s,s*s,s*s*s*s)*a*brightness*fade;
|
|
1267
|
-
fade*=distfading;
|
|
1268
|
-
s+=stepsize;}
|
|
1269
|
-
v=mix(vec3(length(v)),v,saturation);
|
|
1270
|
-
gl_FragColor=vec4(v*.01,1.);}`;
|
|
1297
|
+
var name = "starfieldProceduralTexturePixelShader";
|
|
1298
|
+
var shader = "precision highp float;\n#define volsteps 20\n#define iterations 15\nvarying vec2 vPosition;varying vec2 vUV;uniform float time;uniform float alpha;uniform float beta;uniform float zoom;uniform float formuparam;uniform float stepsize;uniform float tile;uniform float brightness;uniform float darkmatter;uniform float distfading;uniform float saturation;void main()\n{vec3 dir=vec3(vUV*zoom,1.);float localTime=time*0.0001;mat2 rot1=mat2(cos(alpha),sin(alpha),-sin(alpha),cos(alpha));mat2 rot2=mat2(cos(beta),sin(beta),-sin(beta),cos(beta));dir.xz*=rot1;dir.xy*=rot2;vec3 from_=vec3(1.,.5,0.5);from_+=vec3(-2.,localTime*2.,localTime);from_.xz*=rot1;from_.xy*=rot2;float s=0.1,fade=1.;vec3 v=vec3(0.);for (int r=0; r<volsteps; r++) {vec3 p=from_+s*dir*.5;p=abs(vec3(tile)-mod(p,vec3(tile*2.))); \nfloat pa,a=pa=0.;for (int i=0; i<iterations; i++) {p=abs(p)/dot(p,p)-formuparam; \na+=abs(length(p)-pa); \npa=length(p);}\nfloat dm=max(0.,darkmatter-a*a*.001); \na*=a*a; \nif (r>6) fade*=1.-dm; \nv+=fade;v+=vec3(s,s*s,s*s*s*s)*a*brightness*fade; \nfade*=distfading; \ns+=stepsize;}\nv=mix(vec3(length(v)),v,saturation); \ngl_FragColor=vec4(v*.01,1.);}";
|
|
1271
1299
|
// Sideeffect
|
|
1272
1300
|
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__.ShaderStore.ShadersStore[name] = shader;
|
|
1273
1301
|
/** @internal */
|
|
1274
|
-
|
|
1302
|
+
var starfieldProceduralTexturePixelShader = { name: name, shader: shader };
|
|
1275
1303
|
|
|
1276
1304
|
|
|
1277
1305
|
/***/ }),
|
|
@@ -1295,23 +1323,26 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1295
1323
|
|
|
1296
1324
|
|
|
1297
1325
|
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1326
|
+
var StarfieldProceduralTexture = /** @class */ (function (_super) {
|
|
1327
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(StarfieldProceduralTexture, _super);
|
|
1328
|
+
function StarfieldProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
|
|
1329
|
+
if (scene === void 0) { scene = null; }
|
|
1330
|
+
var _this = _super.call(this, name, size, "starfieldProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
|
|
1331
|
+
_this._time = 1;
|
|
1332
|
+
_this._alpha = 0.5;
|
|
1333
|
+
_this._beta = 0.8;
|
|
1334
|
+
_this._zoom = 0.8;
|
|
1335
|
+
_this._formuparam = 0.53;
|
|
1336
|
+
_this._stepsize = 0.1;
|
|
1337
|
+
_this._tile = 0.85;
|
|
1338
|
+
_this._brightness = 0.0015;
|
|
1339
|
+
_this._darkmatter = 0.4;
|
|
1340
|
+
_this._distfading = 0.73;
|
|
1341
|
+
_this._saturation = 0.85;
|
|
1342
|
+
_this.updateShaderUniforms();
|
|
1343
|
+
return _this;
|
|
1313
1344
|
}
|
|
1314
|
-
updateShaderUniforms() {
|
|
1345
|
+
StarfieldProceduralTexture.prototype.updateShaderUniforms = function () {
|
|
1315
1346
|
this.setFloat("time", this._time);
|
|
1316
1347
|
this.setFloat("alpha", this._alpha);
|
|
1317
1348
|
this.setFloat("beta", this._beta);
|
|
@@ -1323,93 +1354,137 @@ class StarfieldProceduralTexture extends babylonjs_Misc_decorators__WEBPACK_IMPO
|
|
|
1323
1354
|
this.setFloat("darkmatter", this._darkmatter);
|
|
1324
1355
|
this.setFloat("distfading", this._distfading);
|
|
1325
1356
|
this.setFloat("saturation", this._saturation);
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
}
|
|
1357
|
+
};
|
|
1358
|
+
Object.defineProperty(StarfieldProceduralTexture.prototype, "time", {
|
|
1359
|
+
get: function () {
|
|
1360
|
+
return this._time;
|
|
1361
|
+
},
|
|
1362
|
+
set: function (value) {
|
|
1363
|
+
this._time = value;
|
|
1364
|
+
this.updateShaderUniforms();
|
|
1365
|
+
},
|
|
1366
|
+
enumerable: false,
|
|
1367
|
+
configurable: true
|
|
1368
|
+
});
|
|
1369
|
+
Object.defineProperty(StarfieldProceduralTexture.prototype, "alpha", {
|
|
1370
|
+
get: function () {
|
|
1371
|
+
return this._alpha;
|
|
1372
|
+
},
|
|
1373
|
+
set: function (value) {
|
|
1374
|
+
this._alpha = value;
|
|
1375
|
+
this.updateShaderUniforms();
|
|
1376
|
+
},
|
|
1377
|
+
enumerable: false,
|
|
1378
|
+
configurable: true
|
|
1379
|
+
});
|
|
1380
|
+
Object.defineProperty(StarfieldProceduralTexture.prototype, "beta", {
|
|
1381
|
+
get: function () {
|
|
1382
|
+
return this._beta;
|
|
1383
|
+
},
|
|
1384
|
+
set: function (value) {
|
|
1385
|
+
this._beta = value;
|
|
1386
|
+
this.updateShaderUniforms();
|
|
1387
|
+
},
|
|
1388
|
+
enumerable: false,
|
|
1389
|
+
configurable: true
|
|
1390
|
+
});
|
|
1391
|
+
Object.defineProperty(StarfieldProceduralTexture.prototype, "formuparam", {
|
|
1392
|
+
get: function () {
|
|
1393
|
+
return this._formuparam;
|
|
1394
|
+
},
|
|
1395
|
+
set: function (value) {
|
|
1396
|
+
this._formuparam = value;
|
|
1397
|
+
this.updateShaderUniforms();
|
|
1398
|
+
},
|
|
1399
|
+
enumerable: false,
|
|
1400
|
+
configurable: true
|
|
1401
|
+
});
|
|
1402
|
+
Object.defineProperty(StarfieldProceduralTexture.prototype, "stepsize", {
|
|
1403
|
+
get: function () {
|
|
1404
|
+
return this._stepsize;
|
|
1405
|
+
},
|
|
1406
|
+
set: function (value) {
|
|
1407
|
+
this._stepsize = value;
|
|
1408
|
+
this.updateShaderUniforms();
|
|
1409
|
+
},
|
|
1410
|
+
enumerable: false,
|
|
1411
|
+
configurable: true
|
|
1412
|
+
});
|
|
1413
|
+
Object.defineProperty(StarfieldProceduralTexture.prototype, "zoom", {
|
|
1414
|
+
get: function () {
|
|
1415
|
+
return this._zoom;
|
|
1416
|
+
},
|
|
1417
|
+
set: function (value) {
|
|
1418
|
+
this._zoom = value;
|
|
1419
|
+
this.updateShaderUniforms();
|
|
1420
|
+
},
|
|
1421
|
+
enumerable: false,
|
|
1422
|
+
configurable: true
|
|
1423
|
+
});
|
|
1424
|
+
Object.defineProperty(StarfieldProceduralTexture.prototype, "tile", {
|
|
1425
|
+
get: function () {
|
|
1426
|
+
return this._tile;
|
|
1427
|
+
},
|
|
1428
|
+
set: function (value) {
|
|
1429
|
+
this._tile = value;
|
|
1430
|
+
this.updateShaderUniforms();
|
|
1431
|
+
},
|
|
1432
|
+
enumerable: false,
|
|
1433
|
+
configurable: true
|
|
1434
|
+
});
|
|
1435
|
+
Object.defineProperty(StarfieldProceduralTexture.prototype, "brightness", {
|
|
1436
|
+
get: function () {
|
|
1437
|
+
return this._brightness;
|
|
1438
|
+
},
|
|
1439
|
+
set: function (value) {
|
|
1440
|
+
this._brightness = value;
|
|
1441
|
+
this.updateShaderUniforms();
|
|
1442
|
+
},
|
|
1443
|
+
enumerable: false,
|
|
1444
|
+
configurable: true
|
|
1445
|
+
});
|
|
1446
|
+
Object.defineProperty(StarfieldProceduralTexture.prototype, "darkmatter", {
|
|
1447
|
+
get: function () {
|
|
1448
|
+
return this._darkmatter;
|
|
1449
|
+
},
|
|
1450
|
+
set: function (value) {
|
|
1451
|
+
this._darkmatter = value;
|
|
1452
|
+
this.updateShaderUniforms();
|
|
1453
|
+
},
|
|
1454
|
+
enumerable: false,
|
|
1455
|
+
configurable: true
|
|
1456
|
+
});
|
|
1457
|
+
Object.defineProperty(StarfieldProceduralTexture.prototype, "distfading", {
|
|
1458
|
+
get: function () {
|
|
1459
|
+
return this._distfading;
|
|
1460
|
+
},
|
|
1461
|
+
set: function (value) {
|
|
1462
|
+
this._distfading = value;
|
|
1463
|
+
this.updateShaderUniforms();
|
|
1464
|
+
},
|
|
1465
|
+
enumerable: false,
|
|
1466
|
+
configurable: true
|
|
1467
|
+
});
|
|
1468
|
+
Object.defineProperty(StarfieldProceduralTexture.prototype, "saturation", {
|
|
1469
|
+
get: function () {
|
|
1470
|
+
return this._saturation;
|
|
1471
|
+
},
|
|
1472
|
+
set: function (value) {
|
|
1473
|
+
this._saturation = value;
|
|
1474
|
+
this.updateShaderUniforms();
|
|
1475
|
+
},
|
|
1476
|
+
enumerable: false,
|
|
1477
|
+
configurable: true
|
|
1478
|
+
});
|
|
1404
1479
|
/**
|
|
1405
1480
|
* Serializes this starfield procedural texture
|
|
1406
1481
|
* @returns a serialized starfield procedural texture object
|
|
1407
1482
|
*/
|
|
1408
|
-
serialize() {
|
|
1409
|
-
|
|
1483
|
+
StarfieldProceduralTexture.prototype.serialize = function () {
|
|
1484
|
+
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
|
|
1410
1485
|
serializationObject.customType = "BABYLON.StarfieldProceduralTexture";
|
|
1411
1486
|
return serializationObject;
|
|
1412
|
-
}
|
|
1487
|
+
};
|
|
1413
1488
|
/**
|
|
1414
1489
|
* Creates a Starfield Procedural Texture from parsed startfield procedural texture data
|
|
1415
1490
|
* @param parsedTexture defines parsed texture data
|
|
@@ -1417,44 +1492,45 @@ class StarfieldProceduralTexture extends babylonjs_Misc_decorators__WEBPACK_IMPO
|
|
|
1417
1492
|
* @param rootUrl defines the root URL containing startfield procedural texture information
|
|
1418
1493
|
* @returns a parsed Starfield Procedural Texture
|
|
1419
1494
|
*/
|
|
1420
|
-
|
|
1421
|
-
|
|
1495
|
+
StarfieldProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
|
|
1496
|
+
var texture = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Parse(function () { return new StarfieldProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
|
|
1422
1497
|
return texture;
|
|
1423
|
-
}
|
|
1424
|
-
|
|
1425
|
-
(0,
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
(0,
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
(0,
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
(0,
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
(0,
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
(0,
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
(0,
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
(0,
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
(0,
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
(0,
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
(0,
|
|
1456
|
-
|
|
1457
|
-
|
|
1498
|
+
};
|
|
1499
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1500
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
1501
|
+
], StarfieldProceduralTexture.prototype, "time", null);
|
|
1502
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1503
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
1504
|
+
], StarfieldProceduralTexture.prototype, "alpha", null);
|
|
1505
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1506
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
1507
|
+
], StarfieldProceduralTexture.prototype, "beta", null);
|
|
1508
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1509
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
1510
|
+
], StarfieldProceduralTexture.prototype, "formuparam", null);
|
|
1511
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1512
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
1513
|
+
], StarfieldProceduralTexture.prototype, "stepsize", null);
|
|
1514
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1515
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
1516
|
+
], StarfieldProceduralTexture.prototype, "zoom", null);
|
|
1517
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1518
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
1519
|
+
], StarfieldProceduralTexture.prototype, "tile", null);
|
|
1520
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1521
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
1522
|
+
], StarfieldProceduralTexture.prototype, "brightness", null);
|
|
1523
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1524
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
1525
|
+
], StarfieldProceduralTexture.prototype, "darkmatter", null);
|
|
1526
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1527
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
1528
|
+
], StarfieldProceduralTexture.prototype, "distfading", null);
|
|
1529
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1530
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
1531
|
+
], StarfieldProceduralTexture.prototype, "saturation", null);
|
|
1532
|
+
return StarfieldProceduralTexture;
|
|
1533
|
+
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.ProceduralTexture));
|
|
1458
1534
|
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.RegisterClass)("BABYLON.StarfieldProceduralTexture", StarfieldProceduralTexture);
|
|
1459
1535
|
|
|
1460
1536
|
|
|
@@ -1490,21 +1566,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1490
1566
|
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
|
|
1491
1567
|
// Do not edit.
|
|
1492
1568
|
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
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);}
|
|
1496
|
-
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;}
|
|
1497
|
-
return total;}
|
|
1498
|
-
#define CUSTOM_FRAGMENT_DEFINITIONS
|
|
1499
|
-
void main(void) {
|
|
1500
|
-
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
|
1501
|
-
float ratioy=mod(vUV.x*ampScale,2.0+fbm(vUV*0.8));vec3 wood=woodColor*ratioy;gl_FragColor=vec4(wood,1.0);
|
|
1502
|
-
#define CUSTOM_FRAGMENT_MAIN_END
|
|
1503
|
-
}`;
|
|
1569
|
+
var name = "woodProceduralTexturePixelShader";
|
|
1570
|
+
var 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}";
|
|
1504
1571
|
// Sideeffect
|
|
1505
1572
|
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__.ShaderStore.ShadersStore[name] = shader;
|
|
1506
1573
|
/** @internal */
|
|
1507
|
-
|
|
1574
|
+
var woodProceduralTexturePixelShader = { name: name, shader: shader };
|
|
1508
1575
|
|
|
1509
1576
|
|
|
1510
1577
|
/***/ }),
|
|
@@ -1529,40 +1596,51 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1529
1596
|
|
|
1530
1597
|
|
|
1531
1598
|
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1599
|
+
var WoodProceduralTexture = /** @class */ (function (_super) {
|
|
1600
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(WoodProceduralTexture, _super);
|
|
1601
|
+
function WoodProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
|
|
1602
|
+
if (scene === void 0) { scene = null; }
|
|
1603
|
+
var _this = _super.call(this, name, size, "woodProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
|
|
1604
|
+
_this._ampScale = 100.0;
|
|
1605
|
+
_this._woodColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.Color3(0.32, 0.17, 0.09);
|
|
1606
|
+
_this.updateShaderUniforms();
|
|
1607
|
+
return _this;
|
|
1538
1608
|
}
|
|
1539
|
-
updateShaderUniforms() {
|
|
1609
|
+
WoodProceduralTexture.prototype.updateShaderUniforms = function () {
|
|
1540
1610
|
this.setFloat("ampScale", this._ampScale);
|
|
1541
1611
|
this.setColor3("woodColor", this._woodColor);
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1612
|
+
};
|
|
1613
|
+
Object.defineProperty(WoodProceduralTexture.prototype, "ampScale", {
|
|
1614
|
+
get: function () {
|
|
1615
|
+
return this._ampScale;
|
|
1616
|
+
},
|
|
1617
|
+
set: function (value) {
|
|
1618
|
+
this._ampScale = value;
|
|
1619
|
+
this.updateShaderUniforms();
|
|
1620
|
+
},
|
|
1621
|
+
enumerable: false,
|
|
1622
|
+
configurable: true
|
|
1623
|
+
});
|
|
1624
|
+
Object.defineProperty(WoodProceduralTexture.prototype, "woodColor", {
|
|
1625
|
+
get: function () {
|
|
1626
|
+
return this._woodColor;
|
|
1627
|
+
},
|
|
1628
|
+
set: function (value) {
|
|
1629
|
+
this._woodColor = value;
|
|
1630
|
+
this.updateShaderUniforms();
|
|
1631
|
+
},
|
|
1632
|
+
enumerable: false,
|
|
1633
|
+
configurable: true
|
|
1634
|
+
});
|
|
1557
1635
|
/**
|
|
1558
1636
|
* Serializes this wood procedural texture
|
|
1559
1637
|
* @returns a serialized wood procedural texture object
|
|
1560
1638
|
*/
|
|
1561
|
-
serialize() {
|
|
1562
|
-
|
|
1639
|
+
WoodProceduralTexture.prototype.serialize = function () {
|
|
1640
|
+
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
|
|
1563
1641
|
serializationObject.customType = "BABYLON.WoodProceduralTexture";
|
|
1564
1642
|
return serializationObject;
|
|
1565
|
-
}
|
|
1643
|
+
};
|
|
1566
1644
|
/**
|
|
1567
1645
|
* Creates a Wood Procedural Texture from parsed wood procedural texture data
|
|
1568
1646
|
* @param parsedTexture defines parsed texture data
|
|
@@ -1570,17 +1648,18 @@ class WoodProceduralTexture extends babylonjs_Misc_decorators__WEBPACK_IMPORTED_
|
|
|
1570
1648
|
* @param rootUrl defines the root URL containing wood procedural texture information
|
|
1571
1649
|
* @returns a parsed Wood Procedural Texture
|
|
1572
1650
|
*/
|
|
1573
|
-
|
|
1574
|
-
|
|
1651
|
+
WoodProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
|
|
1652
|
+
var texture = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.SerializationHelper.Parse(function () { return new WoodProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
|
|
1575
1653
|
return texture;
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
(0,
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
(0,
|
|
1582
|
-
|
|
1583
|
-
|
|
1654
|
+
};
|
|
1655
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1656
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serialize)()
|
|
1657
|
+
], WoodProceduralTexture.prototype, "ampScale", null);
|
|
1658
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([
|
|
1659
|
+
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.serializeAsColor3)()
|
|
1660
|
+
], WoodProceduralTexture.prototype, "woodColor", null);
|
|
1661
|
+
return WoodProceduralTexture;
|
|
1662
|
+
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.ProceduralTexture));
|
|
1584
1663
|
(0,babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_0__.RegisterClass)("BABYLON.WoodProceduralTexture", WoodProceduralTexture);
|
|
1585
1664
|
|
|
1586
1665
|
|
|
@@ -1614,10 +1693,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1614
1693
|
* This is the entry point for the UMD module.
|
|
1615
1694
|
* The entry point for a future ESM package should be index.ts
|
|
1616
1695
|
*/
|
|
1617
|
-
|
|
1696
|
+
var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined;
|
|
1618
1697
|
if (typeof globalObject !== "undefined") {
|
|
1619
1698
|
globalObject.BABYLON = globalObject.BABYLON || {};
|
|
1620
|
-
for (
|
|
1699
|
+
for (var mat in procedural_textures_index__WEBPACK_IMPORTED_MODULE_0__) {
|
|
1621
1700
|
globalObject.BABYLON[mat] = procedural_textures_index__WEBPACK_IMPORTED_MODULE_0__[mat];
|
|
1622
1701
|
}
|
|
1623
1702
|
}
|