@babylonjs/materials 5.19.0 → 5.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cell/cell.fragment.js +14 -2
- package/cell/cell.fragment.js.map +1 -1
- package/cell/cell.vertex.js +45 -3
- package/cell/cell.vertex.js.map +1 -1
- package/cell/cellMaterial.js +112 -120
- package/cell/cellMaterial.js.map +1 -1
- package/custom/customMaterial.js +69 -81
- package/custom/customMaterial.js.map +1 -1
- package/custom/pbrCustomMaterial.js +80 -89
- package/custom/pbrCustomMaterial.js.map +1 -1
- package/fire/fire.fragment.js +44 -3
- package/fire/fire.fragment.js.map +1 -1
- package/fire/fire.vertex.js +54 -3
- package/fire/fire.vertex.js.map +1 -1
- package/fire/fireMaterial.js +101 -109
- package/fire/fireMaterial.js.map +1 -1
- package/fur/fur.fragment.js +67 -3
- package/fur/fur.fragment.js.map +1 -1
- package/fur/fur.vertex.js +97 -3
- package/fur/fur.vertex.js.map +1 -1
- package/fur/furMaterial.js +181 -193
- package/fur/furMaterial.js.map +1 -1
- package/gradient/gradient.fragment.js +36 -3
- package/gradient/gradient.fragment.js.map +1 -1
- package/gradient/gradient.vertex.js +41 -3
- package/gradient/gradient.vertex.js.map +1 -1
- package/gradient/gradientMaterial.js +113 -121
- package/gradient/gradientMaterial.js.map +1 -1
- package/grid/grid.fragment.js +8 -2
- package/grid/grid.fragment.js.map +1 -1
- package/grid/grid.vertex.js +22 -3
- package/grid/grid.vertex.js.map +1 -1
- package/grid/gridMaterial.js +93 -101
- package/grid/gridMaterial.js.map +1 -1
- package/lava/lava.fragment.js +62 -3
- package/lava/lava.fragment.js.map +1 -1
- package/lava/lava.vertex.js +84 -3
- package/lava/lava.vertex.js.map +1 -1
- package/lava/lavaMaterial.js +175 -183
- package/lava/lavaMaterial.js.map +1 -1
- package/legacy/legacy-cell.js +2 -2
- package/legacy/legacy-cell.js.map +1 -1
- package/legacy/legacy-custom.js +2 -2
- package/legacy/legacy-custom.js.map +1 -1
- package/legacy/legacy-fire.js +2 -2
- package/legacy/legacy-fire.js.map +1 -1
- package/legacy/legacy-fur.js +2 -2
- package/legacy/legacy-fur.js.map +1 -1
- package/legacy/legacy-gradient.js +2 -2
- package/legacy/legacy-gradient.js.map +1 -1
- package/legacy/legacy-grid.js +2 -2
- package/legacy/legacy-grid.js.map +1 -1
- package/legacy/legacy-lava.js +2 -2
- package/legacy/legacy-lava.js.map +1 -1
- package/legacy/legacy-mix.js +2 -2
- package/legacy/legacy-mix.js.map +1 -1
- package/legacy/legacy-normal.js +2 -2
- package/legacy/legacy-normal.js.map +1 -1
- package/legacy/legacy-shadowOnly.js +2 -2
- package/legacy/legacy-shadowOnly.js.map +1 -1
- package/legacy/legacy-simple.js +2 -2
- package/legacy/legacy-simple.js.map +1 -1
- package/legacy/legacy-sky.js +2 -2
- package/legacy/legacy-sky.js.map +1 -1
- package/legacy/legacy-terrain.js +2 -2
- package/legacy/legacy-terrain.js.map +1 -1
- package/legacy/legacy-triPlanar.js +2 -2
- package/legacy/legacy-triPlanar.js.map +1 -1
- package/legacy/legacy-water.js +2 -2
- package/legacy/legacy-water.js.map +1 -1
- package/legacy/legacy.js +2 -2
- package/legacy/legacy.js.map +1 -1
- package/mix/mix.fragment.js +33 -2
- package/mix/mix.fragment.js.map +1 -1
- package/mix/mix.vertex.js +67 -3
- package/mix/mix.vertex.js.map +1 -1
- package/mix/mixMaterial.js +166 -174
- package/mix/mixMaterial.js.map +1 -1
- package/normal/normal.fragment.js +41 -3
- package/normal/normal.fragment.js.map +1 -1
- package/normal/normal.vertex.js +42 -3
- package/normal/normal.vertex.js.map +1 -1
- package/normal/normalMaterial.js +143 -151
- package/normal/normalMaterial.js.map +1 -1
- package/package.json +2 -5
- package/shadowOnly/shadowOnly.fragment.js +21 -3
- package/shadowOnly/shadowOnly.fragment.js.map +1 -1
- package/shadowOnly/shadowOnly.vertex.js +30 -3
- package/shadowOnly/shadowOnly.vertex.js.map +1 -1
- package/shadowOnly/shadowOnlyMaterial.js +73 -89
- package/shadowOnly/shadowOnlyMaterial.js.map +1 -1
- package/simple/simple.fragment.js +36 -3
- package/simple/simple.fragment.js.map +1 -1
- package/simple/simple.vertex.js +45 -3
- package/simple/simple.vertex.js.map +1 -1
- package/simple/simpleMaterial.js +102 -110
- package/simple/simpleMaterial.js.map +1 -1
- package/sky/sky.fragment.js +17 -3
- package/sky/sky.fragment.js.map +1 -1
- package/sky/sky.vertex.js +20 -3
- package/sky/sky.vertex.js.map +1 -1
- package/sky/skyMaterial.js +111 -119
- package/sky/skyMaterial.js.map +1 -1
- package/terrain/terrain.fragment.js +36 -2
- package/terrain/terrain.fragment.js.map +1 -1
- package/terrain/terrain.vertex.js +67 -3
- package/terrain/terrain.vertex.js.map +1 -1
- package/terrain/terrainMaterial.js +148 -156
- package/terrain/terrainMaterial.js.map +1 -1
- package/triPlanar/triPlanarMaterial.js +157 -165
- package/triPlanar/triPlanarMaterial.js.map +1 -1
- package/triPlanar/triplanar.fragment.js +64 -3
- package/triPlanar/triplanar.fragment.js.map +1 -1
- package/triPlanar/triplanar.vertex.js +45 -3
- package/triPlanar/triplanar.vertex.js.map +1 -1
- package/water/water.fragment.js +83 -3
- package/water/water.fragment.js.map +1 -1
- package/water/water.vertex.js +56 -3
- package/water/water.vertex.js.map +1 -1
- package/water/waterMaterial.js +283 -313
- package/water/waterMaterial.js.map +1 -1
@@ -12,10 +12,58 @@ import "@babylonjs/core/Shaders/ShadersInclude/depthPrePass.js";
|
|
12
12
|
import "@babylonjs/core/Shaders/ShadersInclude/lightFragment.js";
|
13
13
|
import "@babylonjs/core/Shaders/ShadersInclude/fogFragment.js";
|
14
14
|
import "@babylonjs/core/Shaders/ShadersInclude/imageProcessingCompatibility.js";
|
15
|
-
|
16
|
-
|
15
|
+
const name = "terrainPixelShader";
|
16
|
+
const shader = `precision highp float;
|
17
|
+
uniform vec4 vSpecularColor;
|
18
|
+
varying vec3 vPositionW;
|
19
|
+
varying vec3 vNormalW;
|
20
|
+
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)
|
21
|
+
varying vec4 vColor;
|
22
|
+
#include<helperFunctions>
|
23
|
+
#include<__decl__lightFragment>[0..maxSimultaneousLights]
|
24
|
+
#ifdef DIFFUSE
|
25
|
+
varying vec2 vTextureUV;
|
26
|
+
#ifdef BUMP
|
27
|
+
uniform sampler2D bump1Sampler;
|
28
|
+
#include<lightsFragmentFunctions>
|
29
|
+
#include<shadowsFragmentFunctions>
|
30
|
+
#include<clipPlaneFragmentDeclaration>
|
31
|
+
#include<fogFragmentDeclaration>
|
32
|
+
#ifdef BUMP
|
33
|
+
#extension GL_OES_standard_derivatives : enable
|
34
|
+
mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)
|
35
|
+
#define CUSTOM_FRAGMENT_DEFINITIONS
|
36
|
+
void main(void) {
|
37
|
+
#include<clipPlaneFragment>
|
38
|
+
vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
|
39
|
+
float glossiness=vSpecularColor.a;
|
40
|
+
float glossiness=0.;
|
41
|
+
float alpha=vDiffuseColor.a;
|
42
|
+
vec3 normalW=normalize(vNormalW);
|
43
|
+
vec3 normalW=vec3(1.0,1.0,1.0);
|
44
|
+
#ifdef DIFFUSE
|
45
|
+
baseColor=texture2D(textureSampler,vTextureUV);
|
46
|
+
normalW=perturbNormal(viewDirectionW,baseColor.rgb);
|
47
|
+
#ifdef ALPHATEST
|
48
|
+
if (baseColor.a<0.4)
|
49
|
+
#include<depthPrePass>
|
50
|
+
baseColor.rgb*=vTextureInfos.y;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"terrain.fragment.js","sourceRoot":"","sources":["../../../../../lts/materials/generated/terrain/terrain.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,mEAAqD;AACrD,4EAA8D;AAC9D,uEAAyD;AACzD,2EAA6D;AAC7D,4EAA8D;AAC9D,gFAAkE;AAClE,0EAA4D;AAC5D,qEAAuD;AACvD,gEAAkD;AAClD,iEAAmD;AACnD,+DAAiD;AACjD,gFAAkE;AAElE,
|
1
|
+
{"version":3,"file":"terrain.fragment.js","sourceRoot":"","sources":["../../../../../lts/materials/generated/terrain/terrain.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,mEAAqD;AACrD,4EAA8D;AAC9D,uEAAyD;AACzD,2EAA6D;AAC7D,4EAA8D;AAC9D,gFAAkE;AAClE,0EAA4D;AAC5D,qEAAuD;AACvD,gEAAkD;AAClD,iEAAmD;AACnD,+DAAiD;AACjD,gFAAkE;AAElE,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAClC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Hd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,cAAc;AACd,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"core/Shaders/ShadersInclude/helperFunctions\";\nimport \"core/Shaders/ShadersInclude/lightFragmentDeclaration\";\nimport \"core/Shaders/ShadersInclude/lightUboDeclaration\";\nimport \"core/Shaders/ShadersInclude/lightsFragmentFunctions\";\nimport \"core/Shaders/ShadersInclude/shadowsFragmentFunctions\";\nimport \"core/Shaders/ShadersInclude/clipPlaneFragmentDeclaration\";\nimport \"core/Shaders/ShadersInclude/fogFragmentDeclaration\";\nimport \"core/Shaders/ShadersInclude/clipPlaneFragment\";\nimport \"core/Shaders/ShadersInclude/depthPrePass\";\nimport \"core/Shaders/ShadersInclude/lightFragment\";\nimport \"core/Shaders/ShadersInclude/fogFragment\";\nimport \"core/Shaders/ShadersInclude/imageProcessingCompatibility\";\n\nconst name = \"terrainPixelShader\";\nconst shader = `precision highp float;\runiform vec4 vEyePosition;\runiform vec4 vDiffuseColor;\r#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\r#endif\nvarying vec3 vPositionW;\r#ifdef NORMAL\nvarying vec3 vNormalW;\r#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\r#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\runiform sampler2D textureSampler;\runiform vec2 vTextureInfos;\runiform sampler2D diffuse1Sampler;\runiform sampler2D diffuse2Sampler;\runiform sampler2D diffuse3Sampler;\runiform vec2 diffuse1Infos;\runiform vec2 diffuse2Infos;\runiform vec2 diffuse3Infos;\r#endif\n#ifdef BUMP\nuniform sampler2D bump1Sampler;\runiform sampler2D bump2Sampler;\runiform sampler2D bump3Sampler;\r#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#ifdef BUMP\n#extension GL_OES_standard_derivatives : enable\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\r{\rvec3 dp1=dFdx(p);\rvec3 dp2=dFdy(p);\rvec2 duv1=dFdx(uv);\rvec2 duv2=dFdy(uv);\rvec3 dp2perp=cross(dp2,normal);\rvec3 dp1perp=cross(normal,dp1);\rvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\rvec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;\rfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));\rreturn mat3(tangent*invmax,binormal*invmax,normal);\r}\rvec3 perturbNormal(vec3 viewDir,vec3 mixColor)\r{\rvec3 bump1Color=texture2D(bump1Sampler,vTextureUV*diffuse1Infos).xyz;\rvec3 bump2Color=texture2D(bump2Sampler,vTextureUV*diffuse2Infos).xyz;\rvec3 bump3Color=texture2D(bump3Sampler,vTextureUV*diffuse3Infos).xyz;\rbump1Color.rgb*=mixColor.r;\rbump2Color.rgb=mix(bump1Color.rgb,bump2Color.rgb,mixColor.g);\rvec3 map=mix(bump2Color.rgb,bump3Color.rgb,mixColor.b);\rmap=map*255./127.-128./127.;\rmat3 TBN=cotangent_frame(vNormalW*vTextureInfos.y,-viewDir,vTextureUV);\rreturn normalize(TBN*map);\r}\r#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\r#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\rvec4 baseColor=vec4(1.,1.,1.,1.);\rvec3 diffuseColor=vDiffuseColor.rgb;\r#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\rvec3 specularColor=vSpecularColor.rgb;\r#else\nfloat glossiness=0.;\r#endif\nfloat alpha=vDiffuseColor.a;\r#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\r#else\nvec3 normalW=vec3(1.0,1.0,1.0);\r#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(textureSampler,vTextureUV);\r#if defined(BUMP) && defined(DIFFUSE)\nnormalW=perturbNormal(viewDirectionW,baseColor.rgb);\r#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\rdiscard;\r#endif\n#include<depthPrePass>\nbaseColor.rgb*=vTextureInfos.y;\rvec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);\rvec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);\rvec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);\rdiffuse1Color.rgb*=baseColor.r;\rdiffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,baseColor.g);\rbaseColor.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,baseColor.b);\r#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nbaseColor.rgb*=vColor.rgb;\r#endif\nvec3 diffuseBase=vec3(0.,0.,0.);\rlightingInfo info;\rfloat shadow=1.;\r#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\r#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR)\nalpha*=vColor.a;\r#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\r#else\nvec3 finalSpecular=vec3(0.0);\r#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor*baseColor.rgb,0.0,1.0);\rvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\r#include<fogFragment>\ngl_FragColor=color;\r#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\r`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @hidden */\nexport const terrainPixelShader = { name, shader };\n"]}
|
@@ -14,10 +14,74 @@ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneVertex.js";
|
|
14
14
|
import "@babylonjs/core/Shaders/ShadersInclude/fogVertex.js";
|
15
15
|
import "@babylonjs/core/Shaders/ShadersInclude/shadowsVertex.js";
|
16
16
|
import "@babylonjs/core/Shaders/ShadersInclude/vertexColorMixing.js";
|
17
|
-
|
18
|
-
|
17
|
+
const name = "terrainVertexShader";
|
18
|
+
const shader = `precision highp float;attribute vec3 position;
|
19
|
+
#ifdef NORMAL
|
20
|
+
attribute vec3 normal;
|
21
|
+
#endif
|
22
|
+
#ifdef UV1
|
23
|
+
attribute vec2 uv;
|
24
|
+
#endif
|
25
|
+
#ifdef UV2
|
26
|
+
attribute vec2 uv2;
|
27
|
+
#endif
|
28
|
+
#ifdef VERTEXCOLOR
|
29
|
+
attribute vec4 color;
|
30
|
+
#endif
|
31
|
+
#include<bonesDeclaration>
|
32
|
+
#include<bakedVertexAnimationDeclaration>
|
33
|
+
#include<instancesDeclaration>
|
34
|
+
uniform mat4 view;uniform mat4 viewProjection;
|
35
|
+
#ifdef DIFFUSE
|
36
|
+
varying vec2 vTextureUV;uniform mat4 textureMatrix;uniform vec2 vTextureInfos;
|
37
|
+
#endif
|
38
|
+
#ifdef POINTSIZE
|
39
|
+
uniform float pointSize;
|
40
|
+
#endif
|
41
|
+
varying vec3 vPositionW;
|
42
|
+
#ifdef NORMAL
|
43
|
+
varying vec3 vNormalW;
|
44
|
+
#endif
|
45
|
+
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)
|
46
|
+
varying vec4 vColor;
|
47
|
+
#endif
|
48
|
+
#include<clipPlaneVertexDeclaration>
|
49
|
+
#include<fogVertexDeclaration>
|
50
|
+
#include<__decl__lightFragment>[0..maxSimultaneousLights]
|
51
|
+
#define CUSTOM_VERTEX_DEFINITIONS
|
52
|
+
void main(void) {
|
53
|
+
#define CUSTOM_VERTEX_MAIN_BEGIN
|
54
|
+
#include<instancesVertex>
|
55
|
+
#include<bonesVertex>
|
56
|
+
#include<bakedVertexAnimation>
|
57
|
+
vec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);
|
58
|
+
#ifdef NORMAL
|
59
|
+
vNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));
|
60
|
+
#endif
|
61
|
+
#ifndef UV1
|
62
|
+
vec2 uv=vec2(0.,0.);
|
63
|
+
#endif
|
64
|
+
#ifndef UV2
|
65
|
+
vec2 uv2=vec2(0.,0.);
|
66
|
+
#endif
|
67
|
+
#ifdef DIFFUSE
|
68
|
+
if (vTextureInfos.x==0.)
|
69
|
+
{vTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));}
|
70
|
+
else
|
71
|
+
{vTextureUV=vec2(textureMatrix*vec4(uv2,1.0,0.0));}
|
72
|
+
#endif
|
73
|
+
#include<clipPlaneVertex>
|
74
|
+
#include<fogVertex>
|
75
|
+
#include<shadowsVertex>[0..maxSimultaneousLights]
|
76
|
+
#include<vertexColorMixing>
|
77
|
+
#if defined(POINTSIZE) && !defined(WEBGPU)
|
78
|
+
gl_PointSize=pointSize;
|
79
|
+
#endif
|
80
|
+
#define CUSTOM_VERTEX_MAIN_END
|
81
|
+
}
|
82
|
+
`;
|
19
83
|
// Sideeffect
|
20
84
|
ShaderStore.ShadersStore[name] = shader;
|
21
85
|
/** @hidden */
|
22
|
-
export
|
86
|
+
export const terrainVertexShader = { name, shader };
|
23
87
|
//# sourceMappingURL=terrain.vertex.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"terrain.vertex.js","sourceRoot":"","sources":["../../../../../lts/materials/generated/terrain/terrain.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,oEAAsD;AACtD,mFAAqE;AACrE,wEAA0D;AAC1D,8EAAgE;AAChE,wEAA0D;AAC1D,4EAA8D;AAC9D,uEAAyD;AACzD,mEAAqD;AACrD,+DAAiD;AACjD,wEAA0D;AAC1D,mEAAqD;AACrD,6DAA+C;AAC/C,iEAAmD;AACnD,qEAAuD;AAEvD,
|
1
|
+
{"version":3,"file":"terrain.vertex.js","sourceRoot":"","sources":["../../../../../lts/materials/generated/terrain/terrain.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,oEAAsD;AACtD,mFAAqE;AACrE,wEAA0D;AAC1D,8EAAgE;AAChE,wEAA0D;AAC1D,4EAA8D;AAC9D,uEAAyD;AACzD,mEAAqD;AACrD,+DAAiD;AACjD,wEAA0D;AAC1D,mEAAqD;AACrD,6DAA+C;AAC/C,iEAAmD;AACnD,qEAAuD;AAEvD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgEd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,cAAc;AACd,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"core/Shaders/ShadersInclude/bonesDeclaration\";\nimport \"core/Shaders/ShadersInclude/bakedVertexAnimationDeclaration\";\nimport \"core/Shaders/ShadersInclude/instancesDeclaration\";\nimport \"core/Shaders/ShadersInclude/clipPlaneVertexDeclaration\";\nimport \"core/Shaders/ShadersInclude/fogVertexDeclaration\";\nimport \"core/Shaders/ShadersInclude/lightFragmentDeclaration\";\nimport \"core/Shaders/ShadersInclude/lightUboDeclaration\";\nimport \"core/Shaders/ShadersInclude/instancesVertex\";\nimport \"core/Shaders/ShadersInclude/bonesVertex\";\nimport \"core/Shaders/ShadersInclude/bakedVertexAnimation\";\nimport \"core/Shaders/ShadersInclude/clipPlaneVertex\";\nimport \"core/Shaders/ShadersInclude/fogVertex\";\nimport \"core/Shaders/ShadersInclude/shadowsVertex\";\nimport \"core/Shaders/ShadersInclude/vertexColorMixing\";\n\nconst name = \"terrainVertexShader\";\nconst shader = `precision highp float;attribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;uniform mat4 textureMatrix;uniform vec2 vTextureInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vTextureInfos.x==0.)\n{vTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));}\nelse\n{vTextureUV=vec2(textureMatrix*vec4(uv2,1.0,0.0));}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @hidden */\nexport const terrainVertexShader = { name, shader };\n"]}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { __decorate
|
1
|
+
import { __decorate } from "@babylonjs/core/tslib.es6.js";
|
2
2
|
import { serializeAsTexture, serialize, expandToProperty, serializeAsColor3, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
|
3
3
|
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
4
4
|
import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
|
@@ -11,61 +11,56 @@ import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
|
11
11
|
import "./terrain.fragment.js";
|
12
12
|
import "./terrain.vertex.js";
|
13
13
|
import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
_this.rebuild();
|
43
|
-
return _this;
|
14
|
+
class TerrainMaterialDefines extends MaterialDefines {
|
15
|
+
constructor() {
|
16
|
+
super();
|
17
|
+
this.DIFFUSE = false;
|
18
|
+
this.BUMP = false;
|
19
|
+
this.CLIPPLANE = false;
|
20
|
+
this.CLIPPLANE2 = false;
|
21
|
+
this.CLIPPLANE3 = false;
|
22
|
+
this.CLIPPLANE4 = false;
|
23
|
+
this.CLIPPLANE5 = false;
|
24
|
+
this.CLIPPLANE6 = false;
|
25
|
+
this.ALPHATEST = false;
|
26
|
+
this.DEPTHPREPASS = false;
|
27
|
+
this.POINTSIZE = false;
|
28
|
+
this.FOG = false;
|
29
|
+
this.SPECULARTERM = false;
|
30
|
+
this.NORMAL = false;
|
31
|
+
this.UV1 = false;
|
32
|
+
this.UV2 = false;
|
33
|
+
this.VERTEXCOLOR = false;
|
34
|
+
this.VERTEXALPHA = false;
|
35
|
+
this.NUM_BONE_INFLUENCERS = 0;
|
36
|
+
this.BonesPerMesh = 0;
|
37
|
+
this.INSTANCES = false;
|
38
|
+
this.INSTANCESCOLOR = false;
|
39
|
+
this.IMAGEPROCESSINGPOSTPROCESS = false;
|
40
|
+
this.SKIPFINALCOLORCLAMP = false;
|
41
|
+
this.rebuild();
|
44
42
|
}
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
_this._disableLighting = false;
|
55
|
-
_this._maxSimultaneousLights = 4;
|
56
|
-
return _this;
|
43
|
+
}
|
44
|
+
export class TerrainMaterial extends PushMaterial {
|
45
|
+
constructor(name, scene) {
|
46
|
+
super(name, scene);
|
47
|
+
this.diffuseColor = new Color3(1, 1, 1);
|
48
|
+
this.specularColor = new Color3(0, 0, 0);
|
49
|
+
this.specularPower = 64;
|
50
|
+
this._disableLighting = false;
|
51
|
+
this._maxSimultaneousLights = 4;
|
57
52
|
}
|
58
|
-
|
53
|
+
needAlphaBlending() {
|
59
54
|
return this.alpha < 1.0;
|
60
|
-
}
|
61
|
-
|
55
|
+
}
|
56
|
+
needAlphaTesting() {
|
62
57
|
return false;
|
63
|
-
}
|
64
|
-
|
58
|
+
}
|
59
|
+
getAlphaTestTexture() {
|
65
60
|
return null;
|
66
|
-
}
|
61
|
+
}
|
67
62
|
// Methods
|
68
|
-
|
63
|
+
isReadyForSubMesh(mesh, subMesh, useInstances) {
|
69
64
|
if (this.isFrozen) {
|
70
65
|
if (subMesh.effect && subMesh.effect._wasPreviouslyReady && subMesh.effect._wasPreviouslyUsingInstances === useInstances) {
|
71
66
|
return true;
|
@@ -74,12 +69,12 @@ var TerrainMaterial = /** @class */ (function (_super) {
|
|
74
69
|
if (!subMesh.materialDefines) {
|
75
70
|
subMesh.materialDefines = new TerrainMaterialDefines();
|
76
71
|
}
|
77
|
-
|
78
|
-
|
72
|
+
const defines = subMesh.materialDefines;
|
73
|
+
const scene = this.getScene();
|
79
74
|
if (this._isReadyForSubMesh(subMesh)) {
|
80
75
|
return true;
|
81
76
|
}
|
82
|
-
|
77
|
+
const engine = scene.getEngine();
|
83
78
|
// Textures
|
84
79
|
if (scene.texturesEnabled) {
|
85
80
|
if (!this.mixTexture || !this.mixTexture.isReady()) {
|
@@ -125,7 +120,7 @@ var TerrainMaterial = /** @class */ (function (_super) {
|
|
125
120
|
defines.markAsProcessed();
|
126
121
|
scene.resetCachedMaterial();
|
127
122
|
// Fallbacks
|
128
|
-
|
123
|
+
const fallbacks = new EffectFallbacks();
|
129
124
|
if (defines.FOG) {
|
130
125
|
fallbacks.addFallback(1, "FOG");
|
131
126
|
}
|
@@ -135,7 +130,7 @@ var TerrainMaterial = /** @class */ (function (_super) {
|
|
135
130
|
}
|
136
131
|
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
|
137
132
|
//Attributes
|
138
|
-
|
133
|
+
const attribs = [VertexBuffer.PositionKind];
|
139
134
|
if (defines.NORMAL) {
|
140
135
|
attribs.push(VertexBuffer.NormalKind);
|
141
136
|
}
|
@@ -151,9 +146,9 @@ var TerrainMaterial = /** @class */ (function (_super) {
|
|
151
146
|
MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
|
152
147
|
MaterialHelper.PrepareAttributesForInstances(attribs, defines);
|
153
148
|
// Legacy browser patch
|
154
|
-
|
155
|
-
|
156
|
-
|
149
|
+
const shaderName = "terrain";
|
150
|
+
const join = defines.toString();
|
151
|
+
const uniforms = [
|
157
152
|
"world",
|
158
153
|
"view",
|
159
154
|
"viewProjection",
|
@@ -177,8 +172,8 @@ var TerrainMaterial = /** @class */ (function (_super) {
|
|
177
172
|
"diffuse2Infos",
|
178
173
|
"diffuse3Infos",
|
179
174
|
];
|
180
|
-
|
181
|
-
|
175
|
+
const samplers = ["textureSampler", "diffuse1Sampler", "diffuse2Sampler", "diffuse3Sampler", "bump1Sampler", "bump2Sampler", "bump3Sampler"];
|
176
|
+
const uniformBuffers = new Array();
|
182
177
|
MaterialHelper.PrepareUniformsAndSamplersList({
|
183
178
|
uniformsNames: uniforms,
|
184
179
|
uniformBuffersNames: uniformBuffers,
|
@@ -205,14 +200,14 @@ var TerrainMaterial = /** @class */ (function (_super) {
|
|
205
200
|
subMesh.effect._wasPreviouslyReady = true;
|
206
201
|
subMesh.effect._wasPreviouslyUsingInstances = !!useInstances;
|
207
202
|
return true;
|
208
|
-
}
|
209
|
-
|
210
|
-
|
211
|
-
|
203
|
+
}
|
204
|
+
bindForSubMesh(world, mesh, subMesh) {
|
205
|
+
const scene = this.getScene();
|
206
|
+
const defines = subMesh.materialDefines;
|
212
207
|
if (!defines) {
|
213
208
|
return;
|
214
209
|
}
|
215
|
-
|
210
|
+
const effect = subMesh.effect;
|
216
211
|
if (!effect) {
|
217
212
|
return;
|
218
213
|
}
|
@@ -276,16 +271,16 @@ var TerrainMaterial = /** @class */ (function (_super) {
|
|
276
271
|
// Fog
|
277
272
|
MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
|
278
273
|
this._afterBind(mesh, this._activeEffect);
|
279
|
-
}
|
280
|
-
|
281
|
-
|
274
|
+
}
|
275
|
+
getAnimatables() {
|
276
|
+
const results = [];
|
282
277
|
if (this.mixTexture && this.mixTexture.animations && this.mixTexture.animations.length > 0) {
|
283
278
|
results.push(this.mixTexture);
|
284
279
|
}
|
285
280
|
return results;
|
286
|
-
}
|
287
|
-
|
288
|
-
|
281
|
+
}
|
282
|
+
getActiveTextures() {
|
283
|
+
const activeTextures = super.getActiveTextures();
|
289
284
|
if (this._mixTexture) {
|
290
285
|
activeTextures.push(this._mixTexture);
|
291
286
|
}
|
@@ -308,9 +303,9 @@ var TerrainMaterial = /** @class */ (function (_super) {
|
|
308
303
|
activeTextures.push(this._bumpTexture3);
|
309
304
|
}
|
310
305
|
return activeTextures;
|
311
|
-
}
|
312
|
-
|
313
|
-
if (
|
306
|
+
}
|
307
|
+
hasTexture(texture) {
|
308
|
+
if (super.hasTexture(texture)) {
|
314
309
|
return true;
|
315
310
|
}
|
316
311
|
if (this._mixTexture === texture) {
|
@@ -335,94 +330,91 @@ var TerrainMaterial = /** @class */ (function (_super) {
|
|
335
330
|
return true;
|
336
331
|
}
|
337
332
|
return false;
|
338
|
-
}
|
339
|
-
|
333
|
+
}
|
334
|
+
dispose(forceDisposeEffect) {
|
340
335
|
if (this.mixTexture) {
|
341
336
|
this.mixTexture.dispose();
|
342
337
|
}
|
343
|
-
|
344
|
-
}
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
var serializationObject = _super.prototype.serialize.call(this);
|
338
|
+
super.dispose(forceDisposeEffect);
|
339
|
+
}
|
340
|
+
clone(name) {
|
341
|
+
return SerializationHelper.Clone(() => new TerrainMaterial(name, this.getScene()), this);
|
342
|
+
}
|
343
|
+
serialize() {
|
344
|
+
const serializationObject = super.serialize();
|
351
345
|
serializationObject.customType = "BABYLON.TerrainMaterial";
|
352
346
|
return serializationObject;
|
353
|
-
}
|
354
|
-
|
347
|
+
}
|
348
|
+
getClassName() {
|
355
349
|
return "TerrainMaterial";
|
356
|
-
}
|
350
|
+
}
|
357
351
|
// Statics
|
358
|
-
|
359
|
-
return SerializationHelper.Parse(
|
360
|
-
}
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
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
|
-
}(PushMaterial));
|
426
|
-
export { TerrainMaterial };
|
352
|
+
static Parse(source, scene, rootUrl) {
|
353
|
+
return SerializationHelper.Parse(() => new TerrainMaterial(source.name, scene), source, scene, rootUrl);
|
354
|
+
}
|
355
|
+
}
|
356
|
+
__decorate([
|
357
|
+
serializeAsTexture("mixTexture")
|
358
|
+
], TerrainMaterial.prototype, "_mixTexture", void 0);
|
359
|
+
__decorate([
|
360
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
361
|
+
], TerrainMaterial.prototype, "mixTexture", void 0);
|
362
|
+
__decorate([
|
363
|
+
serializeAsTexture("diffuseTexture1")
|
364
|
+
], TerrainMaterial.prototype, "_diffuseTexture1", void 0);
|
365
|
+
__decorate([
|
366
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
367
|
+
], TerrainMaterial.prototype, "diffuseTexture1", void 0);
|
368
|
+
__decorate([
|
369
|
+
serializeAsTexture("diffuseTexture2")
|
370
|
+
], TerrainMaterial.prototype, "_diffuseTexture2", void 0);
|
371
|
+
__decorate([
|
372
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
373
|
+
], TerrainMaterial.prototype, "diffuseTexture2", void 0);
|
374
|
+
__decorate([
|
375
|
+
serializeAsTexture("diffuseTexture3")
|
376
|
+
], TerrainMaterial.prototype, "_diffuseTexture3", void 0);
|
377
|
+
__decorate([
|
378
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
379
|
+
], TerrainMaterial.prototype, "diffuseTexture3", void 0);
|
380
|
+
__decorate([
|
381
|
+
serializeAsTexture("bumpTexture1")
|
382
|
+
], TerrainMaterial.prototype, "_bumpTexture1", void 0);
|
383
|
+
__decorate([
|
384
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
385
|
+
], TerrainMaterial.prototype, "bumpTexture1", void 0);
|
386
|
+
__decorate([
|
387
|
+
serializeAsTexture("bumpTexture2")
|
388
|
+
], TerrainMaterial.prototype, "_bumpTexture2", void 0);
|
389
|
+
__decorate([
|
390
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
391
|
+
], TerrainMaterial.prototype, "bumpTexture2", void 0);
|
392
|
+
__decorate([
|
393
|
+
serializeAsTexture("bumpTexture3")
|
394
|
+
], TerrainMaterial.prototype, "_bumpTexture3", void 0);
|
395
|
+
__decorate([
|
396
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
397
|
+
], TerrainMaterial.prototype, "bumpTexture3", void 0);
|
398
|
+
__decorate([
|
399
|
+
serializeAsColor3()
|
400
|
+
], TerrainMaterial.prototype, "diffuseColor", void 0);
|
401
|
+
__decorate([
|
402
|
+
serializeAsColor3()
|
403
|
+
], TerrainMaterial.prototype, "specularColor", void 0);
|
404
|
+
__decorate([
|
405
|
+
serialize()
|
406
|
+
], TerrainMaterial.prototype, "specularPower", void 0);
|
407
|
+
__decorate([
|
408
|
+
serialize("disableLighting")
|
409
|
+
], TerrainMaterial.prototype, "_disableLighting", void 0);
|
410
|
+
__decorate([
|
411
|
+
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
412
|
+
], TerrainMaterial.prototype, "disableLighting", void 0);
|
413
|
+
__decorate([
|
414
|
+
serialize("maxSimultaneousLights")
|
415
|
+
], TerrainMaterial.prototype, "_maxSimultaneousLights", void 0);
|
416
|
+
__decorate([
|
417
|
+
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
418
|
+
], TerrainMaterial.prototype, "maxSimultaneousLights", void 0);
|
427
419
|
RegisterClass("BABYLON.TerrainMaterial", TerrainMaterial);
|
428
420
|
//# sourceMappingURL=terrainMaterial.js.map
|