@babylonjs/procedural-textures 6.14.2 → 6.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
// Do not edit.
|
|
2
2
|
import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
|
|
3
3
|
const name = "marbleProceduralTexturePixelShader";
|
|
4
|
-
const shader = `precision highp float;
|
|
4
|
+
const shader = `precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform float numberOfTilesHeight;uniform float numberOfTilesWidth;uniform float amplitude;uniform vec3 marbleColor;uniform vec3 jointColor;const vec3 tileSize=vec3(1.1,1.0,1.1);const vec3 tilePct=vec3(0.98,1.0,0.98);float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}
|
|
5
|
+
float noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}
|
|
6
|
+
float turbulence(vec2 P)
|
|
7
|
+
{float val=0.0;float freq=1.0;for (int i=0; i<4; i++)
|
|
8
|
+
{val+=abs(noise(P*freq)/freq);freq*=2.07;}
|
|
9
|
+
return val;}
|
|
10
|
+
float roundF(float number){return sign(number)*floor(abs(number)+0.5);}
|
|
11
|
+
vec3 marble_color(float x)
|
|
12
|
+
{vec3 col;x=0.5*(x+1.);x=sqrt(x);
|
|
13
|
+
x=sqrt(x);x=sqrt(x);col=vec3(.2+.75*x);
|
|
14
|
+
col.b*=0.95;
|
|
15
|
+
return col;}
|
|
16
|
+
void main()
|
|
17
|
+
{float brickW=1.0/numberOfTilesWidth;float brickH=1.0/numberOfTilesHeight;float jointWPercentage=0.01;float jointHPercentage=0.01;vec3 color=marbleColor;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;}
|
|
18
|
+
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);}
|
|
19
|
+
else if (xi<nxi+jointWPercentage && xi>nxi-jointWPercentage){color=mix(jointColor,vec3(0.44,0.44,0.44),(xi-nxi)/jointWPercentage+0.2);}
|
|
20
|
+
else {float t=6.28*brickvUV.x/(tileSize.x+noise(vec2(vUV)*6.0));t+=amplitude*turbulence(brickvUV.xy);t=sin(t);color=marble_color(t);}
|
|
21
|
+
gl_FragColor=vec4(color,0.0);}`;
|
|
5
22
|
// Sideeffect
|
|
6
23
|
ShaderStore.ShadersStore[name] = shader;
|
|
7
24
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marbleProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/marble/marbleProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD,MAAM,IAAI,GAAG,oCAAoC,CAAC;AAClD,MAAM,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"marbleProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/marble/marbleProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD,MAAM,IAAI,GAAG,oCAAoC,CAAC;AAClD,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;+BAiBgB,CAAC;AAChC,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,kCAAkC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"marbleProceduralTexturePixelShader\";\nconst shader = `precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform float numberOfTilesHeight;uniform float numberOfTilesWidth;uniform float amplitude;uniform vec3 marbleColor;uniform vec3 jointColor;const vec3 tileSize=vec3(1.1,1.0,1.1);const vec3 tilePct=vec3(0.98,1.0,0.98);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 turbulence(vec2 P)\n{float val=0.0;float freq=1.0;for (int i=0; i<4; i++)\n{val+=abs(noise(P*freq)/freq);freq*=2.07;}\nreturn val;}\nfloat roundF(float number){return sign(number)*floor(abs(number)+0.5);}\nvec3 marble_color(float x)\n{vec3 col;x=0.5*(x+1.);x=sqrt(x); \nx=sqrt(x);x=sqrt(x);col=vec3(.2+.75*x); \ncol.b*=0.95; \nreturn col;}\nvoid main()\n{float brickW=1.0/numberOfTilesWidth;float brickH=1.0/numberOfTilesHeight;float jointWPercentage=0.01;float jointHPercentage=0.01;vec3 color=marbleColor;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 t=6.28*brickvUV.x/(tileSize.x+noise(vec2(vUV)*6.0));t+=amplitude*turbulence(brickvUV.xy);t=sin(t);color=marble_color(t);}\ngl_FragColor=vec4(color,0.0);}`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @internal */\nexport const marbleProceduralTexturePixelShader = { name, shader };\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babylonjs/procedural-textures",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.16.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@babylonjs/core": "^6.
|
|
21
|
+
"@babylonjs/core": "^6.16.0",
|
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
|
23
23
|
"@lts/procedural-textures": "^1.0.0"
|
|
24
24
|
},
|
|
@@ -18,20 +18,30 @@ float perlinNoise(vec3 p)
|
|
|
18
18
|
mix(
|
|
19
19
|
mix(
|
|
20
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))),
|
|
22
|
-
|
|
21
|
+
dot(pf-vec3(1,0,0),hash33(pi+vec3(1,0,0))),
|
|
22
|
+
w.x
|
|
23
|
+
),
|
|
24
|
+
mix(
|
|
23
25
|
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))),
|
|
25
|
-
|
|
26
|
-
),
|
|
26
|
+
dot(pf-vec3(1,0,1),hash33(pi+vec3(1,0,1))),
|
|
27
|
+
w.x
|
|
28
|
+
),
|
|
29
|
+
w.z
|
|
30
|
+
),
|
|
31
|
+
mix(
|
|
27
32
|
mix(
|
|
28
33
|
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))),
|
|
30
|
-
|
|
34
|
+
dot(pf-vec3(1,1,0),hash33(pi+vec3(1,1,0))),
|
|
35
|
+
w.x
|
|
36
|
+
),
|
|
37
|
+
mix(
|
|
31
38
|
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))),
|
|
33
|
-
|
|
34
|
-
),
|
|
39
|
+
dot(pf-vec3(1,1,1),hash33(pi+vec3(1,1,1))),
|
|
40
|
+
w.x
|
|
41
|
+
),
|
|
42
|
+
w.z
|
|
43
|
+
),
|
|
44
|
+
w.y
|
|
35
45
|
);}
|
|
36
46
|
#define CUSTOM_FRAGMENT_DEFINITIONS
|
|
37
47
|
void main(void)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perlinNoiseProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/perlinNoise/perlinNoiseProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD,MAAM,IAAI,GAAG,yCAAyC,CAAC;AACvD,MAAM,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"perlinNoiseProceduralTexture.fragment.js","sourceRoot":"","sources":["../../../../dev/proceduralTextures/src/perlinNoise/perlinNoiseProceduralTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD,MAAM,IAAI,GAAG,yCAAyC,CAAC;AACvD,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,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))),\nw.x\n),\nmix(\ndot(pf-vec3(0,0,1),hash33(pi+vec3(0,0,1))),\ndot(pf-vec3(1,0,1),hash33(pi+vec3(1,0,1))),\nw.x\n),\nw.z\n),\nmix(\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))),\nw.x\n),\nmix(\ndot(pf-vec3(0,1,1),hash33(pi+vec3(0,1,1))),\ndot(pf-vec3(1,1,1),hash33(pi+vec3(1,1,1))),\nw.x\n),\nw.z\n),\nw.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/** @internal */\nexport const perlinNoiseProceduralTexturePixelShader = { name, shader };\n"]}
|