@babylonjs/materials 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.
- package/cell/cell.fragment.js +8 -5
- package/cell/cell.fragment.js.map +1 -1
- package/cell/cell.vertex.js +41 -19
- package/cell/cell.vertex.js.map +1 -1
- package/gradient/gradient.fragment.js +33 -16
- package/gradient/gradient.fragment.js.map +1 -1
- package/gradient/gradient.vertex.js +34 -17
- package/gradient/gradient.vertex.js.map +1 -1
- package/grid/grid.fragment.js +2 -3
- package/grid/grid.fragment.js.map +1 -1
- package/grid/grid.vertex.js +27 -12
- package/grid/grid.vertex.js.map +1 -1
- package/mix/mix.fragment.js +34 -19
- package/mix/mix.fragment.js.map +1 -1
- package/normal/normal.fragment.js +33 -16
- package/normal/normal.fragment.js.map +1 -1
- package/normal/normal.vertex.js +39 -18
- package/normal/normal.vertex.js.map +1 -1
- package/package.json +2 -2
- package/shadowOnly/shadowOnly.fragment.js +18 -9
- package/shadowOnly/shadowOnly.fragment.js.map +1 -1
- package/shadowOnly/shadowOnly.vertex.js +24 -12
- package/shadowOnly/shadowOnly.vertex.js.map +1 -1
- package/simple/simple.fragment.js +35 -17
- package/simple/simple.fragment.js.map +1 -1
- package/simple/simple.vertex.js +41 -19
- package/simple/simple.vertex.js.map +1 -1
- package/sky/sky.fragment.js +50 -12
- package/sky/sky.fragment.js.map +1 -1
- package/sky/sky.vertex.js +22 -11
- package/sky/sky.vertex.js.map +1 -1
- package/terrain/terrain.fragment.js +40 -19
- package/terrain/terrain.fragment.js.map +1 -1
- package/triPlanar/triplanar.fragment.js +69 -34
- package/triPlanar/triplanar.fragment.js.map +1 -1
- package/triPlanar/triplanar.vertex.js +45 -22
- package/triPlanar/triplanar.vertex.js.map +1 -1
- package/water/water.fragment.js +106 -51
- package/water/water.fragment.js.map +1 -1
- package/water/water.vertex.js +71 -33
- package/water/water.vertex.js.map +1 -1
package/sky/sky.fragment.js
CHANGED
@@ -7,26 +7,64 @@ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragment.js";
|
|
7
7
|
import "@babylonjs/core/Shaders/ShadersInclude/fogFragment.js";
|
8
8
|
import "@babylonjs/core/Shaders/ShadersInclude/imageProcessingCompatibility.js";
|
9
9
|
const name = "skyPixelShader";
|
10
|
-
const shader = `precision highp float;
|
11
|
-
|
10
|
+
const shader = `precision highp float;varying vec3 vPositionW;
|
11
|
+
#ifdef VERTEXCOLOR
|
12
|
+
varying vec4 vColor;
|
13
|
+
#endif
|
12
14
|
#include<clipPlaneFragmentDeclaration>
|
13
|
-
uniform vec3 cameraPosition;
|
14
|
-
|
15
|
+
uniform vec3 cameraPosition;uniform vec3 cameraOffset;uniform vec3 up;uniform float luminance;uniform float turbidity;uniform float rayleigh;uniform float mieCoefficient;uniform float mieDirectionalG;uniform vec3 sunPosition;
|
16
|
+
#include<fogFragmentDeclaration>
|
17
|
+
const float e=2.71828182845904523536028747135266249775724709369995957;const float pi=3.141592653589793238462643383279502884197169;const float n=1.0003;const float N=2.545E25;const float pn=0.035;const vec3 lambda=vec3(680E-9,550E-9,450E-9);const vec3 K=vec3(0.686,0.678,0.666);const float v=4.0;const float rayleighZenithLength=8.4E3;const float mieZenithLength=1.25E3;const float EE=1000.0;const float sunAngularDiameterCos=0.999956676946448443553574619906976478926848692873900859324;const float cutoffAngle=pi/1.95;const float steepness=1.5;vec3 totalRayleigh(vec3 lambda)
|
18
|
+
{return (8.0*pow(pi,3.0)*pow(pow(n,2.0)-1.0,2.0)*(6.0+3.0*pn))/(3.0*N*pow(lambda,vec3(4.0))*(6.0-7.0*pn));}
|
19
|
+
vec3 simplifiedRayleigh()
|
20
|
+
{return 0.0005/vec3(94,40,18);}
|
21
|
+
float rayleighPhase(float cosTheta)
|
22
|
+
{
|
23
|
+
return (3.0/(16.0*pi))*(1.0+pow(cosTheta,2.0));}
|
24
|
+
vec3 totalMie(vec3 lambda,vec3 K,float T)
|
25
|
+
{float c=(0.2*T )*10E-18;return 0.434*c*pi*pow((2.0*pi)/lambda,vec3(v-2.0))*K;}
|
26
|
+
float hgPhase(float cosTheta,float g)
|
27
|
+
{return (1.0/(4.0*pi))*((1.0-pow(g,2.0))/pow(1.0-2.0*g*cosTheta+pow(g,2.0),1.5));}
|
28
|
+
float sunIntensity(float zenithAngleCos)
|
29
|
+
{return EE*max(0.0,1.0-exp((-(cutoffAngle-acos(zenithAngleCos))/steepness)));}
|
30
|
+
float A=0.15;float B=0.50;float C=0.10;float D=0.20;float EEE=0.02;float F=0.30;float W=1000.0;vec3 Uncharted2Tonemap(vec3 x)
|
31
|
+
{return ((x*(A*x+C*B)+D*EEE)/(x*(A*x+B)+D*F))-EEE/F;}
|
32
|
+
#if DITHER
|
15
33
|
#include<helperFunctions>
|
16
34
|
#endif
|
17
35
|
#define CUSTOM_FRAGMENT_DEFINITIONS
|
18
|
-
void main(void) {
|
36
|
+
void main(void) {
|
37
|
+
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
19
38
|
#include<clipPlaneFragment>
|
20
|
-
/**
|
21
|
-
|
39
|
+
/**
|
40
|
+
*--------------------------------------------------------------------------------------------------
|
41
|
+
* Sky Color
|
42
|
+
*--------------------------------------------------------------------------------------------------
|
43
|
+
*/
|
44
|
+
float sunfade=1.0-clamp(1.0-exp((sunPosition.y/450000.0)),0.0,1.0);float rayleighCoefficient=rayleigh-(1.0*(1.0-sunfade));vec3 sunDirection=normalize(sunPosition);float sunE=sunIntensity(dot(sunDirection,up));vec3 betaR=simplifiedRayleigh()*rayleighCoefficient;vec3 betaM=totalMie(lambda,K,turbidity)*mieCoefficient;float zenithAngle=acos(max(0.0,dot(up,normalize(vPositionW-cameraPosition+cameraOffset))));float sR=rayleighZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));float sM=mieZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));vec3 Fex=exp(-(betaR*sR+betaM*sM));float cosTheta=dot(normalize(vPositionW-cameraPosition),sunDirection);float rPhase=rayleighPhase(cosTheta*0.5+0.5);vec3 betaRTheta=betaR*rPhase;float mPhase=hgPhase(cosTheta,mieDirectionalG);vec3 betaMTheta=betaM*mPhase;vec3 Lin=pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*(1.0-Fex),vec3(1.5));Lin*=mix(vec3(1.0),pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*Fex,vec3(1.0/2.0)),clamp(pow(1.0-dot(up,sunDirection),5.0),0.0,1.0));vec3 direction=normalize(vPositionW-cameraPosition);float theta=acos(direction.y);float phi=atan(direction.z,direction.x);vec2 uv=vec2(phi,theta)/vec2(2.0*pi,pi)+vec2(0.5,0.0);vec3 L0=vec3(0.1)*Fex;float sundisk=smoothstep(sunAngularDiameterCos,sunAngularDiameterCos+0.00002,cosTheta);L0+=(sunE*19000.0*Fex)*sundisk;vec3 whiteScale=1.0/Uncharted2Tonemap(vec3(W));vec3 texColor=(Lin+L0);texColor*=0.04 ;texColor+=vec3(0.0,0.001,0.0025)*0.3;float g_fMaxLuminance=1.0;float fLumScaled=0.1/luminance;
|
45
|
+
float fLumCompressed=(fLumScaled*(1.0+(fLumScaled/(g_fMaxLuminance*g_fMaxLuminance))))/(1.0+fLumScaled);
|
46
|
+
float ExposureBias=fLumCompressed;vec3 curr=Uncharted2Tonemap((log2(2.0/pow(luminance,4.0)))*texColor);vec3 retColor=curr*whiteScale;/**
|
47
|
+
*--------------------------------------------------------------------------------------------------
|
48
|
+
* Sky Color
|
49
|
+
*--------------------------------------------------------------------------------------------------
|
50
|
+
*/
|
51
|
+
float alpha=1.0;
|
52
|
+
#ifdef VERTEXCOLOR
|
53
|
+
retColor.rgb*=vColor.rgb;
|
54
|
+
#endif
|
22
55
|
#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
23
|
-
alpha*=vColor.a;
|
56
|
+
alpha*=vColor.a;
|
57
|
+
#endif
|
24
58
|
#if DITHER
|
25
|
-
retColor.rgb+=dither(gl_FragCoord.xy,0.5);
|
26
|
-
|
27
|
-
|
59
|
+
retColor.rgb+=dither(gl_FragCoord.xy,0.5);
|
60
|
+
#endif
|
61
|
+
vec4 color=clamp(vec4(retColor.rgb,alpha),0.0,1.0);
|
62
|
+
#include<fogFragment>
|
63
|
+
gl_FragColor=color;
|
64
|
+
#include<imageProcessingCompatibility>
|
28
65
|
#define CUSTOM_FRAGMENT_MAIN_END
|
29
|
-
}
|
66
|
+
}
|
67
|
+
`;
|
30
68
|
// Sideeffect
|
31
69
|
ShaderStore.ShadersStore[name] = shader;
|
32
70
|
/** @internal */
|
package/sky/sky.fragment.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sky.fragment.js","sourceRoot":"","sources":["../../../../dev/materials/src/sky/sky.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,gFAAkE;AAClE,0EAA4D;AAC5D,mEAAqD;AACrD,qEAAuD;AACvD,+DAAiD;AACjD,gFAAkE;AAElE,MAAM,IAAI,GAAG,gBAAgB,CAAC;AAC9B,MAAM,MAAM,GAAG
|
1
|
+
{"version":3,"file":"sky.fragment.js","sourceRoot":"","sources":["../../../../dev/materials/src/sky/sky.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,gFAAkE;AAClE,0EAA4D;AAC5D,mEAAqD;AACrD,qEAAuD;AACvD,+DAAiD;AACjD,gFAAkE;AAElE,MAAM,IAAI,GAAG,gBAAgB,CAAC;AAC9B,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyDd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"core/Shaders/ShadersInclude/clipPlaneFragmentDeclaration\";\nimport \"core/Shaders/ShadersInclude/fogFragmentDeclaration\";\nimport \"core/Shaders/ShadersInclude/helperFunctions\";\nimport \"core/Shaders/ShadersInclude/clipPlaneFragment\";\nimport \"core/Shaders/ShadersInclude/fogFragment\";\nimport \"core/Shaders/ShadersInclude/imageProcessingCompatibility\";\n\nconst name = \"skyPixelShader\";\nconst shader = `precision highp float;varying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneFragmentDeclaration>\nuniform vec3 cameraPosition;uniform vec3 cameraOffset;uniform vec3 up;uniform float luminance;uniform float turbidity;uniform float rayleigh;uniform float mieCoefficient;uniform float mieDirectionalG;uniform vec3 sunPosition;\n#include<fogFragmentDeclaration>\nconst float e=2.71828182845904523536028747135266249775724709369995957;const float pi=3.141592653589793238462643383279502884197169;const float n=1.0003;const float N=2.545E25;const float pn=0.035;const vec3 lambda=vec3(680E-9,550E-9,450E-9);const vec3 K=vec3(0.686,0.678,0.666);const float v=4.0;const float rayleighZenithLength=8.4E3;const float mieZenithLength=1.25E3;const float EE=1000.0;const float sunAngularDiameterCos=0.999956676946448443553574619906976478926848692873900859324;const float cutoffAngle=pi/1.95;const float steepness=1.5;vec3 totalRayleigh(vec3 lambda)\n{return (8.0*pow(pi,3.0)*pow(pow(n,2.0)-1.0,2.0)*(6.0+3.0*pn))/(3.0*N*pow(lambda,vec3(4.0))*(6.0-7.0*pn));}\nvec3 simplifiedRayleigh()\n{return 0.0005/vec3(94,40,18);}\nfloat rayleighPhase(float cosTheta)\n{ \nreturn (3.0/(16.0*pi))*(1.0+pow(cosTheta,2.0));}\nvec3 totalMie(vec3 lambda,vec3 K,float T)\n{float c=(0.2*T )*10E-18;return 0.434*c*pi*pow((2.0*pi)/lambda,vec3(v-2.0))*K;}\nfloat hgPhase(float cosTheta,float g)\n{return (1.0/(4.0*pi))*((1.0-pow(g,2.0))/pow(1.0-2.0*g*cosTheta+pow(g,2.0),1.5));}\nfloat sunIntensity(float zenithAngleCos)\n{return EE*max(0.0,1.0-exp((-(cutoffAngle-acos(zenithAngleCos))/steepness)));}\nfloat A=0.15;float B=0.50;float C=0.10;float D=0.20;float EEE=0.02;float F=0.30;float W=1000.0;vec3 Uncharted2Tonemap(vec3 x)\n{return ((x*(A*x+C*B)+D*EEE)/(x*(A*x+B)+D*F))-EEE/F;}\n#if DITHER\n#include<helperFunctions>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\n/**\n*--------------------------------------------------------------------------------------------------\n* Sky Color\n*--------------------------------------------------------------------------------------------------\n*/\nfloat sunfade=1.0-clamp(1.0-exp((sunPosition.y/450000.0)),0.0,1.0);float rayleighCoefficient=rayleigh-(1.0*(1.0-sunfade));vec3 sunDirection=normalize(sunPosition);float sunE=sunIntensity(dot(sunDirection,up));vec3 betaR=simplifiedRayleigh()*rayleighCoefficient;vec3 betaM=totalMie(lambda,K,turbidity)*mieCoefficient;float zenithAngle=acos(max(0.0,dot(up,normalize(vPositionW-cameraPosition+cameraOffset))));float sR=rayleighZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));float sM=mieZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));vec3 Fex=exp(-(betaR*sR+betaM*sM));float cosTheta=dot(normalize(vPositionW-cameraPosition),sunDirection);float rPhase=rayleighPhase(cosTheta*0.5+0.5);vec3 betaRTheta=betaR*rPhase;float mPhase=hgPhase(cosTheta,mieDirectionalG);vec3 betaMTheta=betaM*mPhase;vec3 Lin=pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*(1.0-Fex),vec3(1.5));Lin*=mix(vec3(1.0),pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*Fex,vec3(1.0/2.0)),clamp(pow(1.0-dot(up,sunDirection),5.0),0.0,1.0));vec3 direction=normalize(vPositionW-cameraPosition);float theta=acos(direction.y);float phi=atan(direction.z,direction.x);vec2 uv=vec2(phi,theta)/vec2(2.0*pi,pi)+vec2(0.5,0.0);vec3 L0=vec3(0.1)*Fex;float sundisk=smoothstep(sunAngularDiameterCos,sunAngularDiameterCos+0.00002,cosTheta);L0+=(sunE*19000.0*Fex)*sundisk;vec3 whiteScale=1.0/Uncharted2Tonemap(vec3(W));vec3 texColor=(Lin+L0);texColor*=0.04 ;texColor+=vec3(0.0,0.001,0.0025)*0.3;float g_fMaxLuminance=1.0;float fLumScaled=0.1/luminance; \nfloat fLumCompressed=(fLumScaled*(1.0+(fLumScaled/(g_fMaxLuminance*g_fMaxLuminance))))/(1.0+fLumScaled); \nfloat ExposureBias=fLumCompressed;vec3 curr=Uncharted2Tonemap((log2(2.0/pow(luminance,4.0)))*texColor);vec3 retColor=curr*whiteScale;/**\n*--------------------------------------------------------------------------------------------------\n* Sky Color\n*--------------------------------------------------------------------------------------------------\n*/\nfloat alpha=1.0;\n#ifdef VERTEXCOLOR\nretColor.rgb*=vColor.rgb;\n#endif\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\n#if DITHER\nretColor.rgb+=dither(gl_FragCoord.xy,0.5);\n#endif\nvec4 color=clamp(vec4(retColor.rgb,alpha),0.0,1.0);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @internal */\nexport const skyPixelShader = { name, shader };\n"]}
|
package/sky/sky.vertex.js
CHANGED
@@ -5,24 +5,35 @@ import "@babylonjs/core/Shaders/ShadersInclude/fogVertexDeclaration.js";
|
|
5
5
|
import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneVertex.js";
|
6
6
|
import "@babylonjs/core/Shaders/ShadersInclude/fogVertex.js";
|
7
7
|
const name = "skyVertexShader";
|
8
|
-
const shader = `precision highp float;
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
const shader = `precision highp float;attribute vec3 position;
|
9
|
+
#ifdef VERTEXCOLOR
|
10
|
+
attribute vec4 color;
|
11
|
+
#endif
|
12
|
+
uniform mat4 world;uniform mat4 view;uniform mat4 viewProjection;
|
13
|
+
#ifdef POINTSIZE
|
14
|
+
uniform float pointSize;
|
15
|
+
#endif
|
16
|
+
varying vec3 vPositionW;
|
17
|
+
#ifdef VERTEXCOLOR
|
18
|
+
varying vec4 vColor;
|
19
|
+
#endif
|
14
20
|
#include<clipPlaneVertexDeclaration>
|
15
21
|
#include<fogVertexDeclaration>
|
16
22
|
#define CUSTOM_VERTEX_DEFINITIONS
|
17
|
-
void main(void) {
|
18
|
-
|
23
|
+
void main(void) {
|
24
|
+
#define CUSTOM_VERTEX_MAIN_BEGIN
|
25
|
+
gl_Position=viewProjection*world*vec4(position,1.0);vec4 worldPos=world*vec4(position,1.0);vPositionW=vec3(worldPos);
|
26
|
+
#include<clipPlaneVertex>
|
19
27
|
#include<fogVertex>
|
20
28
|
#ifdef VERTEXCOLOR
|
21
|
-
vColor=color;
|
29
|
+
vColor=color;
|
30
|
+
#endif
|
22
31
|
#if defined(POINTSIZE) && !defined(WEBGPU)
|
23
|
-
gl_PointSize=pointSize;
|
32
|
+
gl_PointSize=pointSize;
|
33
|
+
#endif
|
24
34
|
#define CUSTOM_VERTEX_MAIN_END
|
25
|
-
}
|
35
|
+
}
|
36
|
+
`;
|
26
37
|
// Sideeffect
|
27
38
|
ShaderStore.ShadersStore[name] = shader;
|
28
39
|
/** @internal */
|
package/sky/sky.vertex.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sky.vertex.js","sourceRoot":"","sources":["../../../../dev/materials/src/sky/sky.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,8EAAgE;AAChE,wEAA0D;AAC1D,mEAAqD;AACrD,6DAA+C;AAE/C,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAC/B,MAAM,MAAM,GAAG
|
1
|
+
{"version":3,"file":"sky.vertex.js","sourceRoot":"","sources":["../../../../dev/materials/src/sky/sky.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,8EAAgE;AAChE,wEAA0D;AAC1D,mEAAqD;AACrD,6DAA+C;AAE/C,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAC/B,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Bd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"core/Shaders/ShadersInclude/clipPlaneVertexDeclaration\";\nimport \"core/Shaders/ShadersInclude/fogVertexDeclaration\";\nimport \"core/Shaders/ShadersInclude/clipPlaneVertex\";\nimport \"core/Shaders/ShadersInclude/fogVertex\";\n\nconst name = \"skyVertexShader\";\nconst shader = `precision highp float;attribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\nuniform mat4 world;uniform mat4 view;uniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\ngl_Position=viewProjection*world*vec4(position,1.0);vec4 worldPos=world*vec4(position,1.0);vPositionW=vec3(worldPos);\n#include<clipPlaneVertex>\n#include<fogVertex>\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\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/** @internal */\nexport const skyVertexShader = { name, shader };\n"]}
|
@@ -13,55 +13,87 @@ 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
15
|
const name = "terrainPixelShader";
|
16
|
-
const shader = `precision highp float;
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
const shader = `precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;
|
17
|
+
#ifdef SPECULARTERM
|
18
|
+
uniform vec4 vSpecularColor;
|
19
|
+
#endif
|
20
|
+
varying vec3 vPositionW;
|
21
|
+
#ifdef NORMAL
|
22
|
+
varying vec3 vNormalW;
|
23
|
+
#endif
|
20
24
|
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
21
|
-
varying vec4 vColor;
|
25
|
+
varying vec4 vColor;
|
26
|
+
#endif
|
22
27
|
#include<helperFunctions>
|
23
28
|
#include<__decl__lightFragment>[0..maxSimultaneousLights]
|
24
29
|
#ifdef DIFFUSE
|
25
|
-
varying vec2 vTextureUV;
|
30
|
+
varying vec2 vTextureUV;uniform sampler2D textureSampler;uniform vec2 vTextureInfos;uniform sampler2D diffuse1Sampler;uniform sampler2D diffuse2Sampler;uniform sampler2D diffuse3Sampler;uniform vec2 diffuse1Infos;uniform vec2 diffuse2Infos;uniform vec2 diffuse3Infos;
|
31
|
+
#endif
|
26
32
|
#ifdef BUMP
|
27
|
-
uniform sampler2D bump1Sampler;
|
33
|
+
uniform sampler2D bump1Sampler;uniform sampler2D bump2Sampler;uniform sampler2D bump3Sampler;
|
34
|
+
#endif
|
28
35
|
#include<lightsFragmentFunctions>
|
29
36
|
#include<shadowsFragmentFunctions>
|
30
37
|
#include<clipPlaneFragmentDeclaration>
|
31
38
|
#include<fogFragmentDeclaration>
|
32
39
|
#ifdef BUMP
|
33
40
|
#extension GL_OES_standard_derivatives : enable
|
34
|
-
mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)
|
41
|
+
mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)
|
42
|
+
{vec3 dp1=dFdx(p);vec3 dp2=dFdy(p);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;float invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));return mat3(tangent*invmax,binormal*invmax,normal);}
|
43
|
+
vec3 perturbNormal(vec3 viewDir,vec3 mixColor)
|
44
|
+
{vec3 bump1Color=texture2D(bump1Sampler,vTextureUV*diffuse1Infos).xyz;vec3 bump2Color=texture2D(bump2Sampler,vTextureUV*diffuse2Infos).xyz;vec3 bump3Color=texture2D(bump3Sampler,vTextureUV*diffuse3Infos).xyz;bump1Color.rgb*=mixColor.r;bump2Color.rgb=mix(bump1Color.rgb,bump2Color.rgb,mixColor.g);vec3 map=mix(bump2Color.rgb,bump3Color.rgb,mixColor.b);map=map*255./127.-128./127.;mat3 TBN=cotangent_frame(vNormalW*vTextureInfos.y,-viewDir,vTextureUV);return normalize(TBN*map);}
|
45
|
+
#endif
|
35
46
|
#define CUSTOM_FRAGMENT_DEFINITIONS
|
36
|
-
void main(void) {
|
47
|
+
void main(void) {
|
48
|
+
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
37
49
|
#include<clipPlaneFragment>
|
38
|
-
vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
|
39
|
-
|
40
|
-
float glossiness=
|
41
|
-
|
42
|
-
|
43
|
-
|
50
|
+
vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;
|
51
|
+
#ifdef SPECULARTERM
|
52
|
+
float glossiness=vSpecularColor.a;vec3 specularColor=vSpecularColor.rgb;
|
53
|
+
#else
|
54
|
+
float glossiness=0.;
|
55
|
+
#endif
|
56
|
+
float alpha=vDiffuseColor.a;
|
57
|
+
#ifdef NORMAL
|
58
|
+
vec3 normalW=normalize(vNormalW);
|
59
|
+
#else
|
60
|
+
vec3 normalW=vec3(1.0,1.0,1.0);
|
61
|
+
#endif
|
44
62
|
#ifdef DIFFUSE
|
45
|
-
baseColor=texture2D(textureSampler,vTextureUV);
|
46
|
-
|
63
|
+
baseColor=texture2D(textureSampler,vTextureUV);
|
64
|
+
#if defined(BUMP) && defined(DIFFUSE)
|
65
|
+
normalW=perturbNormal(viewDirectionW,baseColor.rgb);
|
66
|
+
#endif
|
47
67
|
#ifdef ALPHATEST
|
48
|
-
if (baseColor.a<0.4)
|
68
|
+
if (baseColor.a<0.4)
|
69
|
+
discard;
|
70
|
+
#endif
|
49
71
|
#include<depthPrePass>
|
50
|
-
baseColor.rgb*=vTextureInfos.y;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"terrain.fragment.js","sourceRoot":"","sources":["../../../../dev/materials/src/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
|
1
|
+
{"version":3,"file":"terrain.fragment.js","sourceRoot":"","sources":["../../../../dev/materials/src/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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgFd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,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;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;uniform sampler2D textureSampler;uniform vec2 vTextureInfos;uniform sampler2D diffuse1Sampler;uniform sampler2D diffuse2Sampler;uniform sampler2D diffuse3Sampler;uniform vec2 diffuse1Infos;uniform vec2 diffuse2Infos;uniform vec2 diffuse3Infos;\n#endif\n#ifdef BUMP\nuniform sampler2D bump1Sampler;uniform sampler2D bump2Sampler;uniform sampler2D bump3Sampler;\n#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)\n{vec3 dp1=dFdx(p);vec3 dp2=dFdy(p);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;float invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));return mat3(tangent*invmax,binormal*invmax,normal);}\nvec3 perturbNormal(vec3 viewDir,vec3 mixColor)\n{vec3 bump1Color=texture2D(bump1Sampler,vTextureUV*diffuse1Infos).xyz;vec3 bump2Color=texture2D(bump2Sampler,vTextureUV*diffuse2Infos).xyz;vec3 bump3Color=texture2D(bump3Sampler,vTextureUV*diffuse3Infos).xyz;bump1Color.rgb*=mixColor.r;bump2Color.rgb=mix(bump1Color.rgb,bump2Color.rgb,mixColor.g);vec3 map=mix(bump2Color.rgb,bump3Color.rgb,mixColor.b);map=map*255./127.-128./127.;mat3 TBN=cotangent_frame(vNormalW*vTextureInfos.y,-viewDir,vTextureUV);return normalize(TBN*map);}\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;vec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\nfloat alpha=vDiffuseColor.a;\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(textureSampler,vTextureUV);\n#if defined(BUMP) && defined(DIFFUSE)\nnormalW=perturbNormal(viewDirectionW,baseColor.rgb);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vTextureInfos.y;vec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);vec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);vec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);diffuse1Color.rgb*=baseColor.r;diffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,baseColor.g);baseColor.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,baseColor.b);\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nbaseColor.rgb*=vColor.rgb;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor*baseColor.rgb,0.0,1.0);vec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @internal */\nexport const terrainPixelShader = { name, shader };\n"]}
|
@@ -13,68 +13,103 @@ 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
15
|
const name = "triplanarPixelShader";
|
16
|
-
const shader = `precision highp float;
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
const shader = `precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;
|
17
|
+
#ifdef SPECULARTERM
|
18
|
+
uniform vec4 vSpecularColor;
|
19
|
+
#endif
|
20
|
+
varying vec3 vPositionW;
|
21
|
+
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
22
|
+
varying vec4 vColor;
|
23
|
+
#endif
|
20
24
|
#include<helperFunctions>
|
21
25
|
#include<__decl__lightFragment>[0..maxSimultaneousLights]
|
22
26
|
#ifdef DIFFUSEX
|
23
|
-
varying vec2 vTextureUVX;
|
24
|
-
|
27
|
+
varying vec2 vTextureUVX;uniform sampler2D diffuseSamplerX;
|
28
|
+
#ifdef BUMPX
|
29
|
+
uniform sampler2D normalSamplerX;
|
30
|
+
#endif
|
25
31
|
#endif
|
26
32
|
#ifdef DIFFUSEY
|
27
|
-
varying vec2 vTextureUVY;
|
28
|
-
|
33
|
+
varying vec2 vTextureUVY;uniform sampler2D diffuseSamplerY;
|
34
|
+
#ifdef BUMPY
|
35
|
+
uniform sampler2D normalSamplerY;
|
36
|
+
#endif
|
29
37
|
#endif
|
30
38
|
#ifdef DIFFUSEZ
|
31
|
-
varying vec2 vTextureUVZ;
|
32
|
-
|
39
|
+
varying vec2 vTextureUVZ;uniform sampler2D diffuseSamplerZ;
|
40
|
+
#ifdef BUMPZ
|
41
|
+
uniform sampler2D normalSamplerZ;
|
42
|
+
#endif
|
33
43
|
#endif
|
34
44
|
#ifdef NORMAL
|
35
|
-
varying mat3 tangentSpace;
|
45
|
+
varying mat3 tangentSpace;
|
46
|
+
#endif
|
36
47
|
#include<lightsFragmentFunctions>
|
37
48
|
#include<shadowsFragmentFunctions>
|
38
49
|
#include<clipPlaneFragmentDeclaration>
|
39
50
|
#include<fogFragmentDeclaration>
|
40
51
|
#define CUSTOM_FRAGMENT_DEFINITIONS
|
41
|
-
void main(void) {
|
52
|
+
void main(void) {
|
53
|
+
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
42
54
|
#include<clipPlaneFragment>
|
43
|
-
vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
|
44
|
-
|
45
|
-
vec3 normalW=
|
46
|
-
|
47
|
-
|
48
|
-
|
55
|
+
vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(0.,0.,0.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a;
|
56
|
+
#ifdef NORMAL
|
57
|
+
vec3 normalW=tangentSpace[2];
|
58
|
+
#else
|
59
|
+
vec3 normalW=vec3(1.0,1.0,1.0);
|
60
|
+
#endif
|
61
|
+
vec4 baseNormal=vec4(0.0,0.0,0.0,1.0);normalW*=normalW;
|
62
|
+
#ifdef DIFFUSEX
|
63
|
+
baseColor+=texture2D(diffuseSamplerX,vTextureUVX)*normalW.x;
|
64
|
+
#ifdef BUMPX
|
65
|
+
baseNormal+=texture2D(normalSamplerX,vTextureUVX)*normalW.x;
|
66
|
+
#endif
|
49
67
|
#endif
|
50
68
|
#ifdef DIFFUSEY
|
51
|
-
baseColor+=texture2D(diffuseSamplerY,vTextureUVY)*normalW.y;
|
52
|
-
|
69
|
+
baseColor+=texture2D(diffuseSamplerY,vTextureUVY)*normalW.y;
|
70
|
+
#ifdef BUMPY
|
71
|
+
baseNormal+=texture2D(normalSamplerY,vTextureUVY)*normalW.y;
|
72
|
+
#endif
|
53
73
|
#endif
|
54
74
|
#ifdef DIFFUSEZ
|
55
|
-
baseColor+=texture2D(diffuseSamplerZ,vTextureUVZ)*normalW.z;
|
56
|
-
|
75
|
+
baseColor+=texture2D(diffuseSamplerZ,vTextureUVZ)*normalW.z;
|
76
|
+
#ifdef BUMPZ
|
77
|
+
baseNormal+=texture2D(normalSamplerZ,vTextureUVZ)*normalW.z;
|
78
|
+
#endif
|
57
79
|
#endif
|
58
80
|
#ifdef NORMAL
|
59
|
-
normalW=normalize((2.0*baseNormal.xyz-1.0)*tangentSpace);
|
81
|
+
normalW=normalize((2.0*baseNormal.xyz-1.0)*tangentSpace);
|
82
|
+
#endif
|
60
83
|
#ifdef ALPHATEST
|
61
|
-
if (baseColor.a<0.4)
|
84
|
+
if (baseColor.a<0.4)
|
85
|
+
discard;
|
86
|
+
#endif
|
62
87
|
#include<depthPrePass>
|
63
88
|
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
64
|
-
baseColor.rgb*=vColor.rgb;
|
65
|
-
|
66
|
-
|
67
|
-
|
89
|
+
baseColor.rgb*=vColor.rgb;
|
90
|
+
#endif
|
91
|
+
vec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;
|
92
|
+
#ifdef SPECULARTERM
|
93
|
+
float glossiness=vSpecularColor.a;vec3 specularBase=vec3(0.,0.,0.);vec3 specularColor=vSpecularColor.rgb;
|
94
|
+
#else
|
95
|
+
float glossiness=0.;
|
96
|
+
#endif
|
68
97
|
#include<lightFragment>[0..maxSimultaneousLights]
|
69
98
|
#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
70
|
-
alpha*=vColor.a;
|
99
|
+
alpha*=vColor.a;
|
100
|
+
#endif
|
71
101
|
#ifdef SPECULARTERM
|
72
|
-
vec3 finalSpecular=specularBase*specularColor;
|
73
|
-
|
74
|
-
vec3
|
75
|
-
|
102
|
+
vec3 finalSpecular=specularBase*specularColor;
|
103
|
+
#else
|
104
|
+
vec3 finalSpecular=vec3(0.0);
|
105
|
+
#endif
|
106
|
+
vec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;vec4 color=vec4(finalDiffuse+finalSpecular,alpha);
|
107
|
+
#include<fogFragment>
|
108
|
+
gl_FragColor=color;
|
109
|
+
#include<imageProcessingCompatibility>
|
76
110
|
#define CUSTOM_FRAGMENT_MAIN_END
|
77
|
-
}
|
111
|
+
}
|
112
|
+
`;
|
78
113
|
// Sideeffect
|
79
114
|
ShaderStore.ShadersStore[name] = shader;
|
80
115
|
/** @internal */
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"triplanar.fragment.js","sourceRoot":"","sources":["../../../../dev/materials/src/triPlanar/triplanar.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,sBAAsB,CAAC;AACpC,MAAM,MAAM,GAAG
|
1
|
+
{"version":3,"file":"triplanar.fragment.js","sourceRoot":"","sources":["../../../../dev/materials/src/triPlanar/triplanar.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,sBAAsB,CAAC;AACpC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgGd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,oBAAoB,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 = \"triplanarPixelShader\";\nconst shader = `precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nvarying vec3 vPositionW;\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef DIFFUSEX\nvarying vec2 vTextureUVX;uniform sampler2D diffuseSamplerX;\n#ifdef BUMPX\nuniform sampler2D normalSamplerX;\n#endif\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;uniform sampler2D diffuseSamplerY;\n#ifdef BUMPY\nuniform sampler2D normalSamplerY;\n#endif\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;uniform sampler2D diffuseSamplerZ;\n#ifdef BUMPZ\nuniform sampler2D normalSamplerZ;\n#endif\n#endif\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(0.,0.,0.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a;\n#ifdef NORMAL\nvec3 normalW=tangentSpace[2];\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nvec4 baseNormal=vec4(0.0,0.0,0.0,1.0);normalW*=normalW;\n#ifdef DIFFUSEX\nbaseColor+=texture2D(diffuseSamplerX,vTextureUVX)*normalW.x;\n#ifdef BUMPX\nbaseNormal+=texture2D(normalSamplerX,vTextureUVX)*normalW.x;\n#endif\n#endif\n#ifdef DIFFUSEY\nbaseColor+=texture2D(diffuseSamplerY,vTextureUVY)*normalW.y;\n#ifdef BUMPY\nbaseNormal+=texture2D(normalSamplerY,vTextureUVY)*normalW.y;\n#endif\n#endif\n#ifdef DIFFUSEZ\nbaseColor+=texture2D(diffuseSamplerZ,vTextureUVZ)*normalW.z;\n#ifdef BUMPZ\nbaseNormal+=texture2D(normalSamplerZ,vTextureUVZ)*normalW.z;\n#endif\n#endif\n#ifdef NORMAL\nnormalW=normalize((2.0*baseNormal.xyz-1.0)*tangentSpace);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nbaseColor.rgb*=vColor.rgb;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;vec3 specularBase=vec3(0.,0.,0.);vec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;vec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @internal */\nexport const triplanarPixelShader = { name, shader };\n"]}
|
@@ -16,52 +16,75 @@ import "@babylonjs/core/Shaders/ShadersInclude/fogVertex.js";
|
|
16
16
|
import "@babylonjs/core/Shaders/ShadersInclude/shadowsVertex.js";
|
17
17
|
import "@babylonjs/core/Shaders/ShadersInclude/vertexColorMixing.js";
|
18
18
|
const name = "triplanarVertexShader";
|
19
|
-
const shader = `precision highp float;
|
20
|
-
|
19
|
+
const shader = `precision highp float;attribute vec3 position;
|
20
|
+
#ifdef NORMAL
|
21
|
+
attribute vec3 normal;
|
22
|
+
#endif
|
21
23
|
#ifdef VERTEXCOLOR
|
22
|
-
attribute vec4 color;
|
24
|
+
attribute vec4 color;
|
25
|
+
#endif
|
23
26
|
#include<helperFunctions>
|
24
27
|
#include<bonesDeclaration>
|
25
28
|
#include<bakedVertexAnimationDeclaration>
|
26
29
|
#include<instancesDeclaration>
|
27
|
-
uniform mat4 view;
|
28
|
-
|
30
|
+
uniform mat4 view;uniform mat4 viewProjection;
|
31
|
+
#ifdef DIFFUSEX
|
32
|
+
varying vec2 vTextureUVX;
|
33
|
+
#endif
|
29
34
|
#ifdef DIFFUSEY
|
30
|
-
varying vec2 vTextureUVY;
|
35
|
+
varying vec2 vTextureUVY;
|
36
|
+
#endif
|
31
37
|
#ifdef DIFFUSEZ
|
32
|
-
varying vec2 vTextureUVZ;
|
33
|
-
|
34
|
-
uniform float
|
35
|
-
|
36
|
-
|
38
|
+
varying vec2 vTextureUVZ;
|
39
|
+
#endif
|
40
|
+
uniform float tileSize;
|
41
|
+
#ifdef POINTSIZE
|
42
|
+
uniform float pointSize;
|
43
|
+
#endif
|
44
|
+
varying vec3 vPositionW;
|
45
|
+
#ifdef NORMAL
|
46
|
+
varying mat3 tangentSpace;
|
47
|
+
#endif
|
37
48
|
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
38
|
-
varying vec4 vColor;
|
49
|
+
varying vec4 vColor;
|
50
|
+
#endif
|
39
51
|
#include<clipPlaneVertexDeclaration>
|
40
52
|
#include<fogVertexDeclaration>
|
41
53
|
#include<__decl__lightFragment>[0..maxSimultaneousLights]
|
42
54
|
#define CUSTOM_VERTEX_DEFINITIONS
|
43
|
-
void main(void)
|
55
|
+
void main(void)
|
56
|
+
{
|
57
|
+
#define CUSTOM_VERTEX_MAIN_BEGIN
|
44
58
|
#include<instancesVertex>
|
45
59
|
#include<bonesVertex>
|
46
60
|
#include<bakedVertexAnimation>
|
47
|
-
vec4 worldPos=finalWorld*vec4(position,1.0);
|
48
|
-
|
61
|
+
vec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);
|
62
|
+
#ifdef DIFFUSEX
|
63
|
+
vTextureUVX=worldPos.zy/tileSize;
|
64
|
+
#endif
|
49
65
|
#ifdef DIFFUSEY
|
50
|
-
vTextureUVY=worldPos.xz/tileSize;
|
66
|
+
vTextureUVY=worldPos.xz/tileSize;
|
67
|
+
#endif
|
51
68
|
#ifdef DIFFUSEZ
|
52
|
-
vTextureUVZ=worldPos.xy/tileSize;
|
69
|
+
vTextureUVZ=worldPos.xy/tileSize;
|
70
|
+
#endif
|
53
71
|
#ifdef NORMAL
|
54
|
-
vec3 xtan=vec3(0,0,1);
|
55
|
-
|
56
|
-
|
72
|
+
vec3 xtan=vec3(0,0,1);vec3 xbin=vec3(0,1,0);vec3 ytan=vec3(1,0,0);vec3 ybin=vec3(0,0,1);vec3 ztan=vec3(1,0,0);vec3 zbin=vec3(0,1,0);vec3 normalizedNormal=normalize(normal);normalizedNormal*=normalizedNormal;vec3 worldBinormal=normalize(xbin*normalizedNormal.x+ybin*normalizedNormal.y+zbin*normalizedNormal.z);vec3 worldTangent=normalize(xtan*normalizedNormal.x+ytan*normalizedNormal.y+ztan*normalizedNormal.z);mat3 normalWorld=mat3(world);
|
73
|
+
#ifdef NONUNIFORMSCALING
|
74
|
+
normalWorld=transposeMat3(inverseMat3(normalWorld));
|
75
|
+
#endif
|
76
|
+
worldTangent=normalize((normalWorld*worldTangent).xyz);worldBinormal=normalize((normalWorld*worldBinormal).xyz);vec3 worldNormal=normalize((normalWorld*normalize(normal)).xyz);tangentSpace[0]=worldTangent;tangentSpace[1]=worldBinormal;tangentSpace[2]=worldNormal;
|
77
|
+
#endif
|
57
78
|
#include<clipPlaneVertex>
|
58
79
|
#include<fogVertex>
|
59
80
|
#include<shadowsVertex>[0..maxSimultaneousLights]
|
60
81
|
#include<vertexColorMixing>
|
61
82
|
#if defined(POINTSIZE) && !defined(WEBGPU)
|
62
|
-
gl_PointSize=pointSize;
|
83
|
+
gl_PointSize=pointSize;
|
84
|
+
#endif
|
63
85
|
#define CUSTOM_VERTEX_MAIN_END
|
64
|
-
}
|
86
|
+
}
|
87
|
+
`;
|
65
88
|
// Sideeffect
|
66
89
|
ShaderStore.ShadersStore[name] = shader;
|
67
90
|
/** @internal */
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"triplanar.vertex.js","sourceRoot":"","sources":["../../../../dev/materials/src/triPlanar/triplanar.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,mEAAqD;AACrD,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,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG
|
1
|
+
{"version":3,"file":"triplanar.vertex.js","sourceRoot":"","sources":["../../../../dev/materials/src/triPlanar/triplanar.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,mEAAqD;AACrD,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,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoEd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,qBAAqB,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/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 = \"triplanarVertexShader\";\nconst shader = `precision highp float;attribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSEX\nvarying vec2 vTextureUVX;\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;\n#endif\nuniform float tileSize;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\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{\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 DIFFUSEX\nvTextureUVX=worldPos.zy/tileSize;\n#endif\n#ifdef DIFFUSEY\nvTextureUVY=worldPos.xz/tileSize;\n#endif\n#ifdef DIFFUSEZ\nvTextureUVZ=worldPos.xy/tileSize;\n#endif\n#ifdef NORMAL\nvec3 xtan=vec3(0,0,1);vec3 xbin=vec3(0,1,0);vec3 ytan=vec3(1,0,0);vec3 ybin=vec3(0,0,1);vec3 ztan=vec3(1,0,0);vec3 zbin=vec3(0,1,0);vec3 normalizedNormal=normalize(normal);normalizedNormal*=normalizedNormal;vec3 worldBinormal=normalize(xbin*normalizedNormal.x+ybin*normalizedNormal.y+zbin*normalizedNormal.z);vec3 worldTangent=normalize(xtan*normalizedNormal.x+ytan*normalizedNormal.y+ztan*normalizedNormal.z);mat3 normalWorld=mat3(world);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nworldTangent=normalize((normalWorld*worldTangent).xyz);worldBinormal=normalize((normalWorld*worldBinormal).xyz);vec3 worldNormal=normalize((normalWorld*normalize(normal)).xyz);tangentSpace[0]=worldTangent;tangentSpace[1]=worldBinormal;tangentSpace[2]=worldNormal;\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/** @internal */\nexport const triplanarVertexShader = { name, shader };\n"]}
|