@babylonjs/core 7.40.4 → 7.41.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/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Misc/screenshotTools.d.ts +18 -12
- package/Misc/screenshotTools.js +57 -47
- package/Misc/screenshotTools.js.map +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js +7 -6
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/helperFunctions.js +23 -21
- package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// Do not edit.
|
|
2
2
|
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
3
|
const name = "helperFunctions";
|
|
4
|
-
const shader = `const PI: f32=3.1415926535897932384626433832795;const RECIPROCAL_PI: f32=0.3183098861837907;const RECIPROCAL_PI2: f32=0.15915494309189535;const HALF_MIN: f32=5.96046448e-08;
|
|
5
|
-
const LinearEncodePowerApprox: f32=2.2;const GammaEncodePowerApprox: f32=1.0/LinearEncodePowerApprox;const LuminanceEncodeApprox:
|
|
4
|
+
const shader = `const PI: f32=3.1415926535897932384626433832795;const TWO_PI: f32=6.283185307179586;const HALF_PI: f32=1.5707963267948966;const RECIPROCAL_PI: f32=0.3183098861837907;const RECIPROCAL_PI2: f32=0.15915494309189535;const RECIPROCAL_PI4: f32=0.07957747154594767;const HALF_MIN: f32=5.96046448e-08;
|
|
5
|
+
const LinearEncodePowerApprox: f32=2.2;const GammaEncodePowerApprox: f32=1.0/LinearEncodePowerApprox;const LuminanceEncodeApprox: vec3f=vec3f(0.2126,0.7152,0.0722);const Epsilon:f32=0.0000001;fn square(x: f32)->f32 {return x*x;}
|
|
6
6
|
fn saturate(x: f32)->f32 {return clamp(x,0.0,1.0);}
|
|
7
|
-
fn saturateVec3(x: vec3f)->vec3f {return clamp(x,vec3f(
|
|
8
|
-
fn saturateEps(x: f32)->f32 {return clamp(x,Epsilon,1.0);}
|
|
7
|
+
fn saturateVec3(x: vec3f)->vec3f {return clamp(x,vec3f(),vec3f(1.0));}
|
|
8
|
+
fn saturateEps(x: f32)->f32 {return clamp(x,Epsilon,1.0);}
|
|
9
9
|
fn maxEps(x: f32)->f32 {return max(x,Epsilon);}
|
|
10
10
|
fn maxEpsVec3(x: vec3f)->vec3f {return max(x,vec3f(Epsilon));}
|
|
11
11
|
fn absEps(x: f32)->f32 {return abs(x)+Epsilon;}
|
|
12
|
-
fn transposeMat3(inMatrix: mat3x3f)->mat3x3f {let i0:
|
|
12
|
+
fn transposeMat3(inMatrix: mat3x3f)->mat3x3f {let i0: vec3f=inMatrix[0];let i1: vec3f=inMatrix[1];let i2: vec3f=inMatrix[2];let outMatrix:mat3x3f=mat3x3f(
|
|
13
13
|
vec3(i0.x,i1.x,i2.x),
|
|
14
14
|
vec3(i0.y,i1.y,i2.y),
|
|
15
15
|
vec3(i0.z,i1.z,i2.z)
|
|
@@ -18,10 +18,10 @@ fn inverseMat3(inMatrix: mat3x3f)->mat3x3f {let a00: f32=inMatrix[0][0];let a01:
|
|
|
18
18
|
b11/det,(a22*a00-a02*a20)/det,(-a12*a00+a02*a10)/det,
|
|
19
19
|
b21/det,(-a21*a00+a01*a20)/det,(a11*a00-a01*a10)/det);}
|
|
20
20
|
#if USE_EXACT_SRGB_CONVERSIONS
|
|
21
|
-
fn toLinearSpaceExact(color:
|
|
22
|
-
{let nearZeroSection:
|
|
23
|
-
fn toGammaSpaceExact(color:
|
|
24
|
-
{let nearZeroSection:
|
|
21
|
+
fn toLinearSpaceExact(color: vec3f)->vec3f
|
|
22
|
+
{let nearZeroSection: vec3f=0.0773993808*color;let remainingSection: vec3f=pow(0.947867299*(color+vec3f(0.055)),vec3f(2.4));return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3f(0.04045)));}
|
|
23
|
+
fn toGammaSpaceExact(color: vec3f)->vec3f
|
|
24
|
+
{let nearZeroSection: vec3f=12.92*color;let remainingSection: vec3f=1.055*pow(color,vec3f(0.41666))-vec3f(0.055);return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3f(0.0031308)));}
|
|
25
25
|
#endif
|
|
26
26
|
fn toLinearSpace(color: f32)->f32
|
|
27
27
|
{
|
|
@@ -31,12 +31,12 @@ var nearZeroSection=0.0773993808*color;var remainingSection=pow(0.947867299*(col
|
|
|
31
31
|
return pow(color,LinearEncodePowerApprox);
|
|
32
32
|
#endif
|
|
33
33
|
}
|
|
34
|
-
fn toLinearSpaceVec3(color:
|
|
34
|
+
fn toLinearSpaceVec3(color: vec3f)->vec3f
|
|
35
35
|
{
|
|
36
36
|
#if USE_EXACT_SRGB_CONVERSIONS
|
|
37
37
|
return toLinearSpaceExact(color);
|
|
38
38
|
#else
|
|
39
|
-
return pow(color,
|
|
39
|
+
return pow(color,vec3f(LinearEncodePowerApprox));
|
|
40
40
|
#endif
|
|
41
41
|
}
|
|
42
42
|
fn toLinearSpaceVec4(color: vec4<f32>)->vec4<f32>
|
|
@@ -52,28 +52,30 @@ fn toGammaSpace(color: vec4<f32>)->vec4<f32>
|
|
|
52
52
|
#if USE_EXACT_SRGB_CONVERSIONS
|
|
53
53
|
return vec4<f32>(toGammaSpaceExact(color.rgb),color.a);
|
|
54
54
|
#else
|
|
55
|
-
return vec4<f32>(pow(color.rgb,
|
|
55
|
+
return vec4<f32>(pow(color.rgb,vec3f(GammaEncodePowerApprox)),color.a);
|
|
56
56
|
#endif
|
|
57
57
|
}
|
|
58
|
-
fn toGammaSpaceVec3(color:
|
|
58
|
+
fn toGammaSpaceVec3(color: vec3f)->vec3f
|
|
59
59
|
{
|
|
60
60
|
#if USE_EXACT_SRGB_CONVERSIONS
|
|
61
61
|
return toGammaSpaceExact(color);
|
|
62
62
|
#else
|
|
63
|
-
return pow(color,
|
|
63
|
+
return pow(color,vec3f(GammaEncodePowerApprox));
|
|
64
64
|
#endif
|
|
65
65
|
}
|
|
66
|
-
fn squareVec3(value:
|
|
66
|
+
fn squareVec3(value: vec3f)->vec3f
|
|
67
67
|
{return value*value;}
|
|
68
68
|
fn pow5(value: f32)->f32 {let sq: f32=value*value;return sq*sq*value;}
|
|
69
|
-
fn getLuminance(color:
|
|
70
|
-
{return
|
|
69
|
+
fn getLuminance(color: vec3f)->f32
|
|
70
|
+
{return saturate(dot(color,LuminanceEncodeApprox));}
|
|
71
71
|
fn getRand(seed: vec2<f32>)->f32 {return fract(sin(dot(seed.xy ,vec2<f32>(12.9898,78.233)))*43758.5453);}
|
|
72
72
|
fn dither(seed: vec2<f32>,varianceAmount: f32)->f32 {let rand: f32=getRand(seed);let normVariance: f32=varianceAmount/255.0;let dither: f32=mix(-normVariance,normVariance,rand);return dither;}
|
|
73
|
-
const rgbdMaxRange: f32=255.0;fn toRGBD(color:
|
|
74
|
-
fn fromRGBD(rgbd: vec4<f32>)->
|
|
75
|
-
fn parallaxCorrectNormal(vertexPos:
|
|
76
|
-
fn equirectangularToCubemapDirection(uv : vec2f)->vec3f {var longitude : f32=uv.x*
|
|
73
|
+
const rgbdMaxRange: f32=255.0;fn toRGBD(color: vec3f)->vec4<f32> {let maxRGB: f32=max(max(color.r,max(color.g,color.b)),Epsilon);var D: f32 =max(rgbdMaxRange/maxRGB,1.);D =clamp(floor(D)/255.0,0.,1.);var rgb: vec3f =color.rgb*D;rgb=toGammaSpaceVec3(rgb);return vec4<f32>(saturateVec3(rgb),D);}
|
|
74
|
+
fn fromRGBD(rgbd: vec4<f32>)->vec3f {let rgb=toLinearSpaceVec3(rgbd.rgb);return rgb/rgbd.a;}
|
|
75
|
+
fn parallaxCorrectNormal(vertexPos: vec3f,origVec: vec3f,cubeSize: vec3f,cubePos: vec3f)->vec3f {let invOrigVec: vec3f=vec3f(1.)/origVec;let halfSize: vec3f=cubeSize*0.5;let intersecAtMaxPlane: vec3f=(cubePos+halfSize-vertexPos)*invOrigVec;let intersecAtMinPlane: vec3f=(cubePos-halfSize-vertexPos)*invOrigVec;let largestIntersec: vec3f=max(intersecAtMaxPlane,intersecAtMinPlane);let distance: f32=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);let intersectPositionWS: vec3f=vertexPos+origVec*distance;return intersectPositionWS-cubePos;}
|
|
76
|
+
fn equirectangularToCubemapDirection(uv : vec2f)->vec3f {var longitude : f32=uv.x*TWO_PI-PI;var latitude : f32=HALF_PI-uv.y*PI;var direction : vec3f;direction.x=cos(latitude)*sin(longitude);direction.y=sin(latitude);direction.z=cos(latitude)*cos(longitude);return direction;}
|
|
77
|
+
fn sqrtClamped(value: f32)->f32 {return sqrt(max(value,0.));}
|
|
78
|
+
fn avg(value: vec3f)->f32 {return dot(value,vec3f(0.333333333));}
|
|
77
79
|
`;
|
|
78
80
|
// Sideeffect
|
|
79
81
|
ShaderStore.IncludesShadersStoreWGSL[name] = shader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helperFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/helperFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAC/B,MAAM,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"helperFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/helperFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAC/B,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Ed,CAAC;AACF,aAAa;AACb,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"helperFunctions\";\nconst shader = `const PI: f32=3.1415926535897932384626433832795;const TWO_PI: f32=6.283185307179586;const HALF_PI: f32=1.5707963267948966;const RECIPROCAL_PI: f32=0.3183098861837907;const RECIPROCAL_PI2: f32=0.15915494309189535;const RECIPROCAL_PI4: f32=0.07957747154594767;const HALF_MIN: f32=5.96046448e-08; \nconst LinearEncodePowerApprox: f32=2.2;const GammaEncodePowerApprox: f32=1.0/LinearEncodePowerApprox;const LuminanceEncodeApprox: vec3f=vec3f(0.2126,0.7152,0.0722);const Epsilon:f32=0.0000001;fn square(x: f32)->f32 {return x*x;}\nfn saturate(x: f32)->f32 {return clamp(x,0.0,1.0);}\nfn saturateVec3(x: vec3f)->vec3f {return clamp(x,vec3f(),vec3f(1.0));}\nfn saturateEps(x: f32)->f32 {return clamp(x,Epsilon,1.0);}\nfn maxEps(x: f32)->f32 {return max(x,Epsilon);}\nfn maxEpsVec3(x: vec3f)->vec3f {return max(x,vec3f(Epsilon));}\nfn absEps(x: f32)->f32 {return abs(x)+Epsilon;}\nfn transposeMat3(inMatrix: mat3x3f)->mat3x3f {let i0: vec3f=inMatrix[0];let i1: vec3f=inMatrix[1];let i2: vec3f=inMatrix[2];let outMatrix:mat3x3f=mat3x3f(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);return outMatrix;}\nfn inverseMat3(inMatrix: mat3x3f)->mat3x3f {let a00: f32=inMatrix[0][0];let a01: f32=inMatrix[0][1];let a02: f32=inMatrix[0][2];let a10: f32=inMatrix[1][0];let a11: f32=inMatrix[1][1];let a12: f32=inMatrix[1][2];let a20: f32=inMatrix[2][0];let a21: f32=inMatrix[2][1];let a22: f32=inMatrix[2][2];let b01: f32=a22*a11-a12*a21;let b11: f32=-a22*a10+a12*a20;let b21: f32=a21*a10-a11*a20;let det: f32=a00*b01+a01*b11+a02*b21;return mat3x3f(b01/det,(-a22*a01+a02*a21)/det,(a12*a01-a02*a11)/det,\nb11/det,(a22*a00-a02*a20)/det,(-a12*a00+a02*a10)/det,\nb21/det,(-a21*a00+a01*a20)/det,(a11*a00-a01*a10)/det);}\n#if USE_EXACT_SRGB_CONVERSIONS\nfn toLinearSpaceExact(color: vec3f)->vec3f\n{let nearZeroSection: vec3f=0.0773993808*color;let remainingSection: vec3f=pow(0.947867299*(color+vec3f(0.055)),vec3f(2.4));return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3f(0.04045)));}\nfn toGammaSpaceExact(color: vec3f)->vec3f\n{let nearZeroSection: vec3f=12.92*color;let remainingSection: vec3f=1.055*pow(color,vec3f(0.41666))-vec3f(0.055);return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3f(0.0031308)));}\n#endif\nfn toLinearSpace(color: f32)->f32\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nvar nearZeroSection=0.0773993808*color;var remainingSection=pow(0.947867299*(color+0.055),2.4);return select(remainingSection,nearZeroSection,color<=0.04045);\n#else\nreturn pow(color,LinearEncodePowerApprox);\n#endif\n}\nfn toLinearSpaceVec3(color: vec3f)->vec3f\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn toLinearSpaceExact(color);\n#else\nreturn pow(color,vec3f(LinearEncodePowerApprox));\n#endif\n}\nfn toLinearSpaceVec4(color: vec4<f32>)->vec4<f32>\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4f(toLinearSpaceExact(color.rgb),color.a);\n#else\nreturn vec4f(pow(color.rgb,vec3f(LinearEncodePowerApprox)),color.a);\n#endif\n}\nfn toGammaSpace(color: vec4<f32>)->vec4<f32>\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4<f32>(toGammaSpaceExact(color.rgb),color.a);\n#else\nreturn vec4<f32>(pow(color.rgb,vec3f(GammaEncodePowerApprox)),color.a);\n#endif\n}\nfn toGammaSpaceVec3(color: vec3f)->vec3f\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn toGammaSpaceExact(color);\n#else\nreturn pow(color,vec3f(GammaEncodePowerApprox));\n#endif\n}\nfn squareVec3(value: vec3f)->vec3f\n{return value*value;}\nfn pow5(value: f32)->f32 {let sq: f32=value*value;return sq*sq*value;}\nfn getLuminance(color: vec3f)->f32\n{return saturate(dot(color,LuminanceEncodeApprox));}\nfn getRand(seed: vec2<f32>)->f32 {return fract(sin(dot(seed.xy ,vec2<f32>(12.9898,78.233)))*43758.5453);}\nfn dither(seed: vec2<f32>,varianceAmount: f32)->f32 {let rand: f32=getRand(seed);let normVariance: f32=varianceAmount/255.0;let dither: f32=mix(-normVariance,normVariance,rand);return dither;}\nconst rgbdMaxRange: f32=255.0;fn toRGBD(color: vec3f)->vec4<f32> {let maxRGB: f32=max(max(color.r,max(color.g,color.b)),Epsilon);var D: f32 =max(rgbdMaxRange/maxRGB,1.);D =clamp(floor(D)/255.0,0.,1.);var rgb: vec3f =color.rgb*D;rgb=toGammaSpaceVec3(rgb);return vec4<f32>(saturateVec3(rgb),D);}\nfn fromRGBD(rgbd: vec4<f32>)->vec3f {let rgb=toLinearSpaceVec3(rgbd.rgb);return rgb/rgbd.a;}\nfn parallaxCorrectNormal(vertexPos: vec3f,origVec: vec3f,cubeSize: vec3f,cubePos: vec3f)->vec3f {let invOrigVec: vec3f=vec3f(1.)/origVec;let halfSize: vec3f=cubeSize*0.5;let intersecAtMaxPlane: vec3f=(cubePos+halfSize-vertexPos)*invOrigVec;let intersecAtMinPlane: vec3f=(cubePos-halfSize-vertexPos)*invOrigVec;let largestIntersec: vec3f=max(intersecAtMaxPlane,intersecAtMinPlane);let distance: f32=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);let intersectPositionWS: vec3f=vertexPos+origVec*distance;return intersectPositionWS-cubePos;}\nfn equirectangularToCubemapDirection(uv : vec2f)->vec3f {var longitude : f32=uv.x*TWO_PI-PI;var latitude : f32=HALF_PI-uv.y*PI;var direction : vec3f;direction.x=cos(latitude)*sin(longitude);direction.y=sin(latitude);direction.z=cos(latitude)*cos(longitude);return direction;}\nfn sqrtClamped(value: f32)->f32 {return sqrt(max(value,0.));}\nfn avg(value: vec3f)->f32 {return dot(value,vec3f(0.333333333));}\n`;\n// Sideeffect\nShaderStore.IncludesShadersStoreWGSL[name] = shader;\n/** @internal */\nexport const helperFunctionsWGSL = { name, shader };\n"]}
|