@babylonjs/procedural-textures 5.20.0 → 5.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/brick/brickProceduralTexture.fragment.js +16 -3
- package/brick/brickProceduralTexture.fragment.js.map +1 -1
- package/brick/brickProceduralTexture.js +58 -79
- package/brick/brickProceduralTexture.js.map +1 -1
- package/cloud/cloudProceduralTexture.fragment.js +14 -3
- package/cloud/cloudProceduralTexture.fragment.js.map +1 -1
- package/cloud/cloudProceduralTexture.js +58 -79
- package/cloud/cloudProceduralTexture.js.map +1 -1
- package/fire/fireProceduralTexture.fragment.js +7 -3
- package/fire/fireProceduralTexture.fragment.js.map +1 -1
- package/fire/fireProceduralTexture.js +85 -126
- package/fire/fireProceduralTexture.js.map +1 -1
- package/grass/grassProceduralTexture.fragment.js +12 -3
- package/grass/grassProceduralTexture.fragment.js.map +1 -1
- package/grass/grassProceduralTexture.js +36 -49
- package/grass/grassProceduralTexture.js.map +1 -1
- package/legacy/legacy-brick.js +2 -2
- package/legacy/legacy-brick.js.map +1 -1
- package/legacy/legacy-cloud.js +2 -2
- package/legacy/legacy-cloud.js.map +1 -1
- package/legacy/legacy-fire.js +2 -2
- package/legacy/legacy-fire.js.map +1 -1
- package/legacy/legacy-grass.js +2 -2
- package/legacy/legacy-grass.js.map +1 -1
- package/legacy/legacy-marble.js +2 -2
- package/legacy/legacy-marble.js.map +1 -1
- package/legacy/legacy-normalMap.js +2 -2
- package/legacy/legacy-normalMap.js.map +1 -1
- package/legacy/legacy-perlinNoise.js +2 -2
- package/legacy/legacy-perlinNoise.js.map +1 -1
- package/legacy/legacy-road.js +2 -2
- package/legacy/legacy-road.js.map +1 -1
- package/legacy/legacy-starfield.js +2 -2
- package/legacy/legacy-starfield.js.map +1 -1
- package/legacy/legacy-wood.js +2 -2
- package/legacy/legacy-wood.js.map +1 -1
- package/legacy/legacy.js +2 -2
- package/legacy/legacy.js.map +1 -1
- package/marble/marbleProceduralTexture.fragment.js +3 -3
- package/marble/marbleProceduralTexture.fragment.js.map +1 -1
- package/marble/marbleProceduralTexture.js +58 -79
- package/marble/marbleProceduralTexture.js.map +1 -1
- package/normalMap/normalMapProceduralTexture.fragment.js +7 -3
- package/normalMap/normalMapProceduralTexture.fragment.js.map +1 -1
- package/normalMap/normalMapProceduralTexture.js +33 -42
- package/normalMap/normalMapProceduralTexture.js.map +1 -1
- package/package.json +3 -6
- package/perlinNoise/perlinNoiseProceduralTexture.fragment.js +41 -3
- package/perlinNoise/perlinNoiseProceduralTexture.fragment.js.map +1 -1
- package/perlinNoise/perlinNoiseProceduralTexture.js +35 -40
- package/perlinNoise/perlinNoiseProceduralTexture.js.map +1 -1
- package/road/roadProceduralTexture.fragment.js +13 -3
- package/road/roadProceduralTexture.fragment.js.map +1 -1
- package/road/roadProceduralTexture.js +25 -34
- package/road/roadProceduralTexture.js.map +1 -1
- package/starfield/starfieldProceduralTexture.fragment.js +18 -3
- package/starfield/starfieldProceduralTexture.fragment.js.map +1 -1
- package/starfield/starfieldProceduralTexture.js +136 -185
- package/starfield/starfieldProceduralTexture.js.map +1 -1
- package/wood/woodProceduralTexture.fragment.js +12 -3
- package/wood/woodProceduralTexture.fragment.js.map +1 -1
- package/wood/woodProceduralTexture.js +36 -49
- package/wood/woodProceduralTexture.js.map +1 -1
|
@@ -1,9 +1,47 @@
|
|
|
1
1
|
// Do not edit.
|
|
2
2
|
import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const name = "perlinNoiseProceduralTexturePixelShader";
|
|
4
|
+
const shader = `precision highp float;uniform float size;uniform float time;uniform float translationSpeed;varying vec2 vUV;float r(float n)
|
|
5
|
+
{return fract(cos(n*89.42)*343.42);}
|
|
6
|
+
vec2 r(vec2 n)
|
|
7
|
+
{return vec2(r(n.x*23.62-300.0+n.y*34.35),r(n.x*45.13+256.0+n.y*38.89)); }
|
|
8
|
+
float worley(vec2 n,float s)
|
|
9
|
+
{float dis=1.0;for(int x=-1; x<=1; x++)
|
|
10
|
+
{for(int y=-1; y<=1; y++)
|
|
11
|
+
{vec2 p=floor(n/s)+vec2(x,y);float d=length(r(p)+vec2(x,y)-fract(n/s));if (dis>d)
|
|
12
|
+
dis=d;}}
|
|
13
|
+
return 1.0-dis;}
|
|
14
|
+
vec3 hash33(vec3 p3)
|
|
15
|
+
{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));}
|
|
16
|
+
float perlinNoise(vec3 p)
|
|
17
|
+
{vec3 pi=floor(p);vec3 pf=p-pi;vec3 w=pf*pf*(3.0-2.0*pf);return mix(
|
|
18
|
+
mix(
|
|
19
|
+
mix(
|
|
20
|
+
dot(pf-vec3(0,0,0),hash33(pi+vec3(0,0,0))),
|
|
21
|
+
dot(pf-vec3(1,0,0),hash33(pi+vec3(1,0,0))),w.x
|
|
22
|
+
),mix(
|
|
23
|
+
dot(pf-vec3(0,0,1),hash33(pi+vec3(0,0,1))),
|
|
24
|
+
dot(pf-vec3(1,0,1),hash33(pi+vec3(1,0,1))),w.x
|
|
25
|
+
),w.z
|
|
26
|
+
),mix(
|
|
27
|
+
mix(
|
|
28
|
+
dot(pf-vec3(0,1,0),hash33(pi+vec3(0,1,0))),
|
|
29
|
+
dot(pf-vec3(1,1,0),hash33(pi+vec3(1,1,0))),w.x
|
|
30
|
+
),mix(
|
|
31
|
+
dot(pf-vec3(0,1,1),hash33(pi+vec3(0,1,1))),
|
|
32
|
+
dot(pf-vec3(1,1,1),hash33(pi+vec3(1,1,1))),w.x
|
|
33
|
+
),w.z
|
|
34
|
+
),w.y
|
|
35
|
+
);}
|
|
36
|
+
#define CUSTOM_FRAGMENT_DEFINITIONS
|
|
37
|
+
void main(void)
|
|
38
|
+
{vec2 uv=gl_FragCoord.xy+translationSpeed;float dis=(
|
|
39
|
+
1.0+perlinNoise(vec3(uv/vec2(size,size),time*0.05)*8.0))
|
|
40
|
+
* (1.0+(worley(uv,32.0)+ 0.5*worley(2.0*uv,32.0)+0.25*worley(4.0*uv,32.0))
|
|
41
|
+
);gl_FragColor=vec4(vec3(dis/4.0),1.0);}
|
|
42
|
+
`;
|
|
5
43
|
// Sideeffect
|
|
6
44
|
ShaderStore.ShadersStore[name] = shader;
|
|
7
45
|
/** @hidden */
|
|
8
|
-
export
|
|
46
|
+
export const perlinNoiseProceduralTexturePixelShader = { name, shader };
|
|
9
47
|
//# sourceMappingURL=perlinNoiseProceduralTexture.fragment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perlinNoiseProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/perlinNoise/perlinNoiseProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD,
|
|
1
|
+
{"version":3,"file":"perlinNoiseProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/perlinNoise/perlinNoiseProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD,MAAM,IAAI,GAAG,yCAAyC,CAAC;AACvD,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,cAAc;AACd,MAAM,CAAC,MAAM,uCAAuC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"perlinNoiseProceduralTexturePixelShader\";\nconst 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`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @hidden */\nexport const perlinNoiseProceduralTexturePixelShader = { name, shader };\n"]}
|
|
@@ -1,48 +1,45 @@
|
|
|
1
|
-
import { __decorate
|
|
1
|
+
import { __decorate } from "@babylonjs/core/tslib.es6.js";
|
|
2
2
|
import { serialize, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
|
|
3
3
|
import { ProceduralTexture } from "@babylonjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
|
|
4
4
|
import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
|
5
5
|
import "./perlinNoiseProceduralTexture.fragment.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
_this._currentTranslation = 0;
|
|
15
|
-
_this.updateShaderUniforms();
|
|
16
|
-
return _this;
|
|
6
|
+
export class PerlinNoiseProceduralTexture extends ProceduralTexture {
|
|
7
|
+
constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
|
|
8
|
+
super(name, size, "perlinNoiseProceduralTexture", scene, fallbackTexture, generateMipMaps);
|
|
9
|
+
this.time = 0.0;
|
|
10
|
+
this.timeScale = 1.0;
|
|
11
|
+
this.translationSpeed = 1.0;
|
|
12
|
+
this._currentTranslation = 0;
|
|
13
|
+
this.updateShaderUniforms();
|
|
17
14
|
}
|
|
18
|
-
|
|
15
|
+
updateShaderUniforms() {
|
|
19
16
|
this.setFloat("size", this.getRenderSize());
|
|
20
|
-
|
|
17
|
+
const scene = this.getScene();
|
|
21
18
|
if (!scene) {
|
|
22
19
|
return;
|
|
23
20
|
}
|
|
24
|
-
|
|
21
|
+
const deltaTime = scene.getEngine().getDeltaTime();
|
|
25
22
|
this.time += deltaTime;
|
|
26
23
|
this.setFloat("time", (this.time * this.timeScale) / 1000);
|
|
27
24
|
this._currentTranslation += (deltaTime * this.translationSpeed) / 1000.0;
|
|
28
25
|
this.setFloat("translationSpeed", this._currentTranslation);
|
|
29
|
-
}
|
|
30
|
-
|
|
26
|
+
}
|
|
27
|
+
render(useCameraPostProcess) {
|
|
31
28
|
this.updateShaderUniforms();
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
29
|
+
super.render(useCameraPostProcess);
|
|
30
|
+
}
|
|
31
|
+
resize(size, generateMipMaps) {
|
|
32
|
+
super.resize(size, generateMipMaps);
|
|
33
|
+
}
|
|
37
34
|
/**
|
|
38
35
|
* Serializes this perlin noise procedural texture
|
|
39
36
|
* @returns a serialized perlin noise procedural texture object
|
|
40
37
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
serialize() {
|
|
39
|
+
const serializationObject = SerializationHelper.Serialize(this, super.serialize());
|
|
43
40
|
serializationObject.customType = "BABYLON.PerlinNoiseProceduralTexture";
|
|
44
41
|
return serializationObject;
|
|
45
|
-
}
|
|
42
|
+
}
|
|
46
43
|
/**
|
|
47
44
|
* Creates a Perlin Noise Procedural Texture from parsed perlin noise procedural texture data
|
|
48
45
|
* @param parsedTexture defines parsed texture data
|
|
@@ -50,21 +47,19 @@ var PerlinNoiseProceduralTexture = /** @class */ (function (_super) {
|
|
|
50
47
|
* @param rootUrl defines the root URL containing perlin noise procedural texture information
|
|
51
48
|
* @returns a parsed Perlin Noise Procedural Texture
|
|
52
49
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
static Parse(parsedTexture, scene, rootUrl) {
|
|
51
|
+
const texture = SerializationHelper.Parse(() => new PerlinNoiseProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
|
|
55
52
|
return texture;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}(ProceduralTexture));
|
|
68
|
-
export { PerlinNoiseProceduralTexture };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
__decorate([
|
|
56
|
+
serialize()
|
|
57
|
+
], PerlinNoiseProceduralTexture.prototype, "time", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
serialize()
|
|
60
|
+
], PerlinNoiseProceduralTexture.prototype, "timeScale", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
serialize()
|
|
63
|
+
], PerlinNoiseProceduralTexture.prototype, "translationSpeed", void 0);
|
|
69
64
|
RegisterClass("BABYLON.PerlinNoiseProceduralTexture", PerlinNoiseProceduralTexture);
|
|
70
65
|
//# sourceMappingURL=perlinNoiseProceduralTexture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perlinNoiseProceduralTexture.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/perlinNoise/perlinNoiseProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,2CAA6B;AAEtE,OAAO,EAAE,iBAAiB,EAAE,4EAA8D;AAE1F,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD,OAAO,yCAAyC,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"perlinNoiseProceduralTexture.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/perlinNoise/perlinNoiseProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,2CAA6B;AAEtE,OAAO,EAAE,iBAAiB,EAAE,4EAA8D;AAE1F,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD,OAAO,yCAAyC,CAAC;AAEjD,MAAM,OAAO,4BAA6B,SAAQ,iBAAiB;IAY/D,YAAY,IAAY,EAAE,IAAY,EAAE,QAAyB,IAAI,EAAE,eAAyB,EAAE,eAAyB;QACvH,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,8BAA8B,EAAE,KAAK,EAAE,eAAe,EA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;QAExE,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,aAAkB,EAAE,KAAY,EAAE,OAAe;QACjE,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,CACrC,GAAG,EAAE,CAAC,IAAI,4BAA4B,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,gBAAgB,CAAC,EACjI,aAAa,EACb,KAAK,EACL,OAAO,CACV,CAAC;QAEF,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AArEG;IADC,SAAS,EAAE;0DACc;AAG1B;IADC,SAAS,EAAE;+DACmB;AAG/B;IADC,SAAS,EAAE;sEAC0B;AAiE1C,aAAa,CAAC,sCAAsC,EAAE,4BAA4B,CAAC,CAAC","sourcesContent":["import { serialize, SerializationHelper } from \"core/Misc/decorators\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { ProceduralTexture } from \"core/Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport type { Nullable } from \"core/types\";\r\nimport \"./perlinNoiseProceduralTexture.fragment\";\r\n\r\nexport class PerlinNoiseProceduralTexture extends ProceduralTexture {\r\n @serialize()\r\n public time: number = 0.0;\r\n\r\n @serialize()\r\n public timeScale: number = 1.0;\r\n\r\n @serialize()\r\n public translationSpeed: number = 1.0;\r\n\r\n private _currentTranslation: number = 0;\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"perlinNoiseProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setFloat(\"size\", this.getRenderSize() as number);\r\n\r\n const scene = this.getScene();\r\n\r\n if (!scene) {\r\n return;\r\n }\r\n const deltaTime = scene.getEngine().getDeltaTime();\r\n\r\n this.time += deltaTime;\r\n this.setFloat(\"time\", (this.time * this.timeScale) / 1000);\r\n\r\n this._currentTranslation += (deltaTime * this.translationSpeed) / 1000.0;\r\n this.setFloat(\"translationSpeed\", this._currentTranslation);\r\n }\r\n\r\n public render(useCameraPostProcess?: boolean) {\r\n this.updateShaderUniforms();\r\n super.render(useCameraPostProcess);\r\n }\r\n\r\n public resize(size: any, generateMipMaps: any): void {\r\n super.resize(size, generateMipMaps);\r\n }\r\n\r\n /**\r\n * Serializes this perlin noise procedural texture\r\n * @returns a serialized perlin noise procedural texture object\r\n */\r\n public serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this, super.serialize());\r\n serializationObject.customType = \"BABYLON.PerlinNoiseProceduralTexture\";\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Perlin Noise Procedural Texture from parsed perlin noise procedural texture data\r\n * @param parsedTexture defines parsed texture data\r\n * @param scene defines the current scene\r\n * @param rootUrl defines the root URL containing perlin noise procedural texture information\r\n * @returns a parsed Perlin Noise Procedural Texture\r\n */\r\n public static Parse(parsedTexture: any, scene: Scene, rootUrl: string): PerlinNoiseProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new PerlinNoiseProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps),\r\n parsedTexture,\r\n scene,\r\n rootUrl\r\n );\r\n\r\n return texture;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.PerlinNoiseProceduralTexture\", PerlinNoiseProceduralTexture);\r\n"]}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
// Do not edit.
|
|
2
2
|
import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const name = "roadProceduralTexturePixelShader";
|
|
4
|
+
const shader = `precision highp float;varying vec2 vUV;
|
|
5
|
+
uniform vec3 roadColor;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}
|
|
6
|
+
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);}
|
|
7
|
+
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;}
|
|
8
|
+
return total;}
|
|
9
|
+
#define CUSTOM_FRAGMENT_DEFINITIONS
|
|
10
|
+
void main(void) {
|
|
11
|
+
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
|
12
|
+
float ratioy=mod(gl_FragCoord.y*100.0 ,fbm(vUV*2.0));vec3 color=roadColor*ratioy;gl_FragColor=vec4(color,1.0);
|
|
13
|
+
#define CUSTOM_FRAGMENT_MAIN_END
|
|
14
|
+
}`;
|
|
5
15
|
// Sideeffect
|
|
6
16
|
ShaderStore.ShadersStore[name] = shader;
|
|
7
17
|
/** @hidden */
|
|
8
|
-
export
|
|
18
|
+
export const roadProceduralTexturePixelShader = { name, shader };
|
|
9
19
|
//# sourceMappingURL=roadProceduralTexture.fragment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roadProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/road/roadProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD,
|
|
1
|
+
{"version":3,"file":"roadProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/road/roadProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD,MAAM,IAAI,GAAG,kCAAkC,CAAC;AAChD,MAAM,MAAM,GAAG;;;;;;;;;;EAUb,CAAC;AACH,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,cAAc;AACd,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"roadProceduralTexturePixelShader\";\nconst 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}`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @hidden */\nexport const roadProceduralTexturePixelShader = { name, shader };\n"]}
|
|
@@ -1,41 +1,34 @@
|
|
|
1
|
-
import { __decorate
|
|
1
|
+
import { __decorate } from "@babylonjs/core/tslib.es6.js";
|
|
2
2
|
import { serializeAsColor3, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
|
|
3
3
|
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
|
4
4
|
import { ProceduralTexture } from "@babylonjs/core/Materials/Textures/Procedurals/proceduralTexture.js";
|
|
5
5
|
import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
|
6
6
|
import "./roadProceduralTexture.fragment.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
_this._roadColor = new Color3(0.53, 0.53, 0.53);
|
|
13
|
-
_this.updateShaderUniforms();
|
|
14
|
-
return _this;
|
|
7
|
+
export class RoadProceduralTexture extends ProceduralTexture {
|
|
8
|
+
constructor(name, size, scene = null, fallbackTexture, generateMipMaps) {
|
|
9
|
+
super(name, size, "roadProceduralTexture", scene, fallbackTexture, generateMipMaps);
|
|
10
|
+
this._roadColor = new Color3(0.53, 0.53, 0.53);
|
|
11
|
+
this.updateShaderUniforms();
|
|
15
12
|
}
|
|
16
|
-
|
|
13
|
+
updateShaderUniforms() {
|
|
17
14
|
this.setColor3("roadColor", this._roadColor);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
enumerable: false,
|
|
28
|
-
configurable: true
|
|
29
|
-
});
|
|
15
|
+
}
|
|
16
|
+
get roadColor() {
|
|
17
|
+
return this._roadColor;
|
|
18
|
+
}
|
|
19
|
+
set roadColor(value) {
|
|
20
|
+
this._roadColor = value;
|
|
21
|
+
this.updateShaderUniforms();
|
|
22
|
+
}
|
|
30
23
|
/**
|
|
31
24
|
* Serializes this road procedural texture
|
|
32
25
|
* @returns a serialized road procedural texture object
|
|
33
26
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
serialize() {
|
|
28
|
+
const serializationObject = SerializationHelper.Serialize(this, super.serialize());
|
|
36
29
|
serializationObject.customType = "BABYLON.RoadProceduralTexture";
|
|
37
30
|
return serializationObject;
|
|
38
|
-
}
|
|
31
|
+
}
|
|
39
32
|
/**
|
|
40
33
|
* Creates a Road Procedural Texture from parsed road procedural texture data
|
|
41
34
|
* @param parsedTexture defines parsed texture data
|
|
@@ -43,15 +36,13 @@ var RoadProceduralTexture = /** @class */ (function (_super) {
|
|
|
43
36
|
* @param rootUrl defines the root URL containing road procedural texture information
|
|
44
37
|
* @returns a parsed Road Procedural Texture
|
|
45
38
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
static Parse(parsedTexture, scene, rootUrl) {
|
|
40
|
+
const texture = SerializationHelper.Parse(() => new RoadProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
|
|
48
41
|
return texture;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}(ProceduralTexture));
|
|
55
|
-
export { RoadProceduralTexture };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
__decorate([
|
|
45
|
+
serializeAsColor3()
|
|
46
|
+
], RoadProceduralTexture.prototype, "roadColor", null);
|
|
56
47
|
RegisterClass("BABYLON.RoadProceduralTexture", RoadProceduralTexture);
|
|
57
48
|
//# sourceMappingURL=roadProceduralTexture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roadProceduralTexture.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/road/roadProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,2CAA6B;AAC9E,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAE/C,OAAO,EAAE,iBAAiB,EAAE,4EAA8D;AAE1F,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD,OAAO,kCAAkC,CAAC;AAE1C
|
|
1
|
+
{"version":3,"file":"roadProceduralTexture.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/road/roadProceduralTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,2CAA6B;AAC9E,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAE/C,OAAO,EAAE,iBAAiB,EAAE,4EAA8D;AAE1F,OAAO,EA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CAAC;IACnB,CAAC;CACJ;AArCG;IADC,iBAAiB,EAAE;sDAGnB;AAqCL,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { serializeAsColor3, SerializationHelper } from \"core/Misc/decorators\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { ProceduralTexture } from \"core/Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { Scene } from \"core/scene\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport type { Nullable } from \"core/types\";\r\nimport \"./roadProceduralTexture.fragment\";\r\n\r\nexport class RoadProceduralTexture extends ProceduralTexture {\r\n private _roadColor = new Color3(0.53, 0.53, 0.53);\r\n\r\n constructor(name: string, size: number, scene: Nullable<Scene> = null, fallbackTexture?: Texture, generateMipMaps?: boolean) {\r\n super(name, size, \"roadProceduralTexture\", scene, fallbackTexture, generateMipMaps);\r\n this.updateShaderUniforms();\r\n }\r\n\r\n public updateShaderUniforms() {\r\n this.setColor3(\"roadColor\", this._roadColor);\r\n }\r\n\r\n @serializeAsColor3()\r\n public get roadColor(): Color3 {\r\n return this._roadColor;\r\n }\r\n\r\n public set roadColor(value: Color3) {\r\n this._roadColor = value;\r\n this.updateShaderUniforms();\r\n }\r\n\r\n /**\r\n * Serializes this road procedural texture\r\n * @returns a serialized road procedural texture object\r\n */\r\n public serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this, super.serialize());\r\n serializationObject.customType = \"BABYLON.RoadProceduralTexture\";\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a Road Procedural Texture from parsed road procedural texture data\r\n * @param parsedTexture defines parsed texture data\r\n * @param scene defines the current scene\r\n * @param rootUrl defines the root URL containing road procedural texture information\r\n * @returns a parsed Road Procedural Texture\r\n */\r\n public static Parse(parsedTexture: any, scene: Scene, rootUrl: string): RoadProceduralTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => new RoadProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps),\r\n parsedTexture,\r\n scene,\r\n rootUrl\r\n );\r\n\r\n return texture;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.RoadProceduralTexture\", RoadProceduralTexture);\r\n"]}
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
// Do not edit.
|
|
2
2
|
import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const name = "starfieldProceduralTexturePixelShader";
|
|
4
|
+
const shader = `precision highp float;
|
|
5
|
+
#define volsteps 20
|
|
6
|
+
#define iterations 15
|
|
7
|
+
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()
|
|
8
|
+
{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.)));
|
|
9
|
+
float pa,a=pa=0.;for (int i=0; i<iterations; i++) {p=abs(p)/dot(p,p)-formuparam;
|
|
10
|
+
a+=abs(length(p)-pa);
|
|
11
|
+
pa=length(p);}
|
|
12
|
+
float dm=max(0.,darkmatter-a*a*.001);
|
|
13
|
+
a*=a*a;
|
|
14
|
+
if (r>6) fade*=1.-dm;
|
|
15
|
+
v+=fade;v+=vec3(s,s*s,s*s*s*s)*a*brightness*fade;
|
|
16
|
+
fade*=distfading;
|
|
17
|
+
s+=stepsize;}
|
|
18
|
+
v=mix(vec3(length(v)),v,saturation);
|
|
19
|
+
gl_FragColor=vec4(v*.01,1.);}`;
|
|
5
20
|
// Sideeffect
|
|
6
21
|
ShaderStore.ShadersStore[name] = shader;
|
|
7
22
|
/** @hidden */
|
|
8
|
-
export
|
|
23
|
+
export const starfieldProceduralTexturePixelShader = { name, shader };
|
|
9
24
|
//# sourceMappingURL=starfieldProceduralTexture.fragment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"starfieldProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/starfield/starfieldProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD,
|
|
1
|
+
{"version":3,"file":"starfieldProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../../lts/proceduralTextures/generated/starfield/starfieldProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD,MAAM,IAAI,GAAG,uCAAuC,CAAC;AACrD,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;8BAee,CAAC;AAC/B,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,cAAc;AACd,MAAM,CAAC,MAAM,qCAAqC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"starfieldProceduralTexturePixelShader\";\nconst 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.);}`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @hidden */\nexport const starfieldProceduralTexturePixelShader = { name, shader };\n"]}
|