@babylonjs/core 8.28.2 → 8.29.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/Lights/Clustered/clusteredLightContainer.d.ts +1 -1
- package/Lights/Clustered/clusteredLightContainer.js +4 -5
- package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
- package/Lights/pointLight.js +4 -4
- package/Lights/pointLight.js.map +1 -1
- package/Lights/rectAreaLight.js +4 -4
- package/Lights/rectAreaLight.js.map +1 -1
- package/Lights/spotLight.js +2 -2
- package/Lights/spotLight.js.map +1 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.d.ts +3 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js +15 -6
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js +1 -1
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js +15 -4
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.d.ts +20 -0
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js +41 -3
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/smartFilterFragmentOutputBlock.js +0 -1
- package/Materials/Node/Blocks/Fragment/smartFilterFragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +28 -5
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.d.ts +3 -1
- package/Materials/Node/nodeMaterialBuildState.js +35 -15
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.d.ts +3 -0
- package/Materials/floatingOriginMatrixOverrides.js +91 -0
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -0
- package/Shaders/ShadersInclude/clusteredLightingFunctions.js +3 -1
- package/Shaders/ShadersInclude/clusteredLightingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js +1 -0
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js +1 -0
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +21 -0
- package/scene.js +29 -3
- package/scene.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lightsFragmentFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/lightsFragmentFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,sBAAsB,CAAC;AAC9B,OAAO,8BAA8B,CAAC;AAEtC,MAAM,IAAI,GAAG,yBAAyB,CAAC;AACvC,MAAM,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"lightsFragmentFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/lightsFragmentFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,sBAAsB,CAAC;AAC9B,OAAO,8BAA8B,CAAC;AAEtC,MAAM,IAAI,GAAG,yBAAyB,CAAC;AACvC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkGd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1C,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\nimport \"./ltcHelperFunctions\";\nimport \"./clusteredLightingFunctions\";\n\nconst name = \"lightsFragmentFunctions\";\nconst shader = `struct lightingInfo\n{vec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};lightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {lightingInfo result;vec3 lightVectorW;float attenuation=1.0;if (lightData.w==0.)\n{vec3 direction=lightData.xyz-vPositionW;attenuation=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);}\nelse\n{lightVectorW=normalize(-lightData.xyz);}\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;}\nfloat getAttenuation(float cosAngle,float exponent) {return max(0.,pow(cosAngle,exponent));}\nfloat getIESAttenuation(float cosAngle,sampler2D iesLightSampler) {float angle=acos(cosAngle)/PI;return texture2D(iesLightSampler,vec2(angle,0.)).r;}\nlightingInfo basicSpotLighting(vec3 viewDirectionW,vec3 lightVectorW,vec3 vNormal,float attenuation,vec3 diffuseColor,vec3 specularColor,float glossiness) {lightingInfo result; \nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;}\nlightingInfo computeIESSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness,sampler2D iesLightSampler) { \nvec3 direction=lightData.xyz-vPositionW;vec3 lightVectorW=normalize(direction);float attenuation=max(0.,1.0-length(direction)/range);float dotProduct=dot(lightDirection.xyz,-lightVectorW);float cosAngle=max(0.,dotProduct);if (cosAngle>=lightDirection.w)\n{ \nattenuation*=getIESAttenuation(dotProduct,iesLightSampler);return basicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);}\nlightingInfo result;result.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {vec3 direction=lightData.xyz-vPositionW;vec3 lightVectorW=normalize(direction);float attenuation=max(0.,1.0-length(direction)/range);float cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));if (cosAngle>=lightDirection.w)\n{ \nattenuation*=getAttenuation(cosAngle,lightData.w);return basicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);}\nlightingInfo result;result.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {lightingInfo result;float ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor;\n#endif\nreturn result;}\n#define inline\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix,vec3 posW){vec4 strq=textureProjectionMatrix*vec4(posW,1.0);strq/=strq.w;vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;return textureColor;}\n#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\n#include<ltcHelperFunctions>\nuniform sampler2D areaLightsLTC1Sampler;uniform sampler2D areaLightsLTC2Sampler;\n#define inline\nlightingInfo computeAreaLighting(sampler2D ltc1,sampler2D ltc2,vec3 viewDirectionW,vec3 vNormal,vec3 vPosition,vec3 lightPosition,vec3 halfWidth,vec3 halfHeight,vec3 diffuseColor,vec3 specularColor,float roughness) \n{lightingInfo result;areaLightData data=computeAreaLightSpecularDiffuseFresnel(ltc1,ltc2,viewDirectionW,vNormal,vPosition,lightPosition,halfWidth,halfHeight,roughness);\n#ifdef SPECULARTERM\nvec3 fresnel=( specularColor*data.Fresnel.x+( vec3( 1.0 )-specularColor )*data.Fresnel.y );result.specular+=specularColor*fresnel*data.Specular;\n#endif\nresult.diffuse+=diffuseColor*data.Diffuse;return result;}\n#endif\n#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0\n#include<clusteredLightingFunctions>\n#define inline\nlightingInfo computeClusteredLighting(\nsampler2D lightDataTexture,\nsampler2D tileMaskTexture,\nvec3 viewDirectionW,\nvec3 vNormal,\nvec4 lightData,\nivec2 sliceRange,\nfloat glossiness\n) {lightingInfo result;ivec2 tilePosition=ivec2(gl_FragCoord.xy*lightData.xy);int maskHeight=int(lightData.z);tilePosition.y=min(tilePosition.y,maskHeight-1);ivec2 batchRange=sliceRange/CLUSTLIGHT_BATCH;int batchOffset=batchRange.x*CLUSTLIGHT_BATCH;tilePosition.y+=maskHeight*batchRange.x;for (int i=batchRange.x; i<=batchRange.y; i+=1) {uint mask=uint(texelFetch(tileMaskTexture,tilePosition,0).r);tilePosition.y+=maskHeight;int maskOffset=max(sliceRange.x-batchOffset,0);int maskWidth=min(sliceRange.y-batchOffset+1,CLUSTLIGHT_BATCH);mask=extractBits(mask,maskOffset,maskWidth);while (mask != 0u) {uint bit=mask & -mask;mask ^= bit;int position=onlyBitPosition(bit);ClusteredLight light=getClusteredLight(lightDataTexture,batchOffset+maskOffset+position);lightingInfo info;if (light.vLightDirection.w<0.0) {info=computeLighting(viewDirectionW,vNormal,light.vLightData,light.vLightDiffuse.rgb,light.vLightSpecular.rgb,light.vLightDiffuse.a,glossiness);} else {info=computeSpotLighting(viewDirectionW,vNormal,light.vLightData,light.vLightDirection,light.vLightDiffuse.rgb,light.vLightSpecular.rgb,light.vLightDiffuse.a,glossiness);}\nresult.diffuse+=info.diffuse;\n#ifdef SPECULARTERM\nresult.specular+=info.specular;\n#endif\n}\nbatchOffset+=CLUSTLIGHT_BATCH;}\nreturn result;}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const lightsFragmentFunctions = { name, shader };\n"]}
|
|
@@ -5,6 +5,7 @@ import "./pbrBlockReflectance0.js";
|
|
|
5
5
|
const name = "pbrClusteredLightingFunctions";
|
|
6
6
|
const shader = `#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
|
|
7
7
|
#include<clusteredLightingFunctions>
|
|
8
|
+
#define inline
|
|
8
9
|
lightingInfo computeClusteredLighting(
|
|
9
10
|
sampler2D lightDataTexture,
|
|
10
11
|
sampler2D tileMaskTexture,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pbrClusteredLightingFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/pbrClusteredLightingFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,8BAA8B,CAAC;AACtC,OAAO,wBAAwB,CAAC;AAEhC,MAAM,IAAI,GAAG,+BAA+B,CAAC;AAC7C,MAAM,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"pbrClusteredLightingFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/pbrClusteredLightingFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,8BAA8B,CAAC;AACtC,OAAO,wBAAwB,CAAC;AAEhC,MAAM,IAAI,GAAG,+BAA+B,CAAC;AAC7C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiHd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1C,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\nimport \"./clusteredLightingFunctions\";\nimport \"./pbrBlockReflectance0\";\n\nconst name = \"pbrClusteredLightingFunctions\";\nconst shader = `#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0\n#include<clusteredLightingFunctions>\n#define inline\nlightingInfo computeClusteredLighting(\nsampler2D lightDataTexture,\nsampler2D tileMaskTexture,\nvec4 lightData,\nivec2 sliceRange,\nvec3 V,\nvec3 N,\nvec3 posW,\nvec3 surfaceAlbedo,\nreflectivityOutParams reflectivityOut\n#ifdef IRIDESCENCE\n,float iridescenceIntensity\n#endif\n#ifdef SS_TRANSLUCENCY\n,subSurfaceOutParams subSurfaceOut\n#endif\n#ifdef SPECULARTERM\n,float AARoughnessFactor\n#endif\n#ifdef ANISOTROPIC\n,anisotropicOutParams anisotropicOut\n#endif\n#ifdef SHEEN\n,sheenOutParams sheenOut\n#endif\n#ifdef CLEARCOAT\n,clearcoatOutParams clearcoatOut\n#endif\n) {float NdotV=absEps(dot(N,V));\n#include<pbrBlockReflectance0>\n#ifdef CLEARCOAT\nspecularEnvironmentR0=clearcoatOut.specularEnvironmentR0;\n#endif\nlightingInfo result;ivec2 tilePosition=ivec2(gl_FragCoord.xy*lightData.xy);int maskHeight=int(lightData.z);tilePosition.y=min(tilePosition.y,maskHeight-1);ivec2 batchRange=sliceRange/CLUSTLIGHT_BATCH;int batchOffset=batchRange.x*CLUSTLIGHT_BATCH;tilePosition.y+=maskHeight*batchRange.x;for (int i=batchRange.x; i<=batchRange.y; i+=1) {uint mask=uint(texelFetch(tileMaskTexture,tilePosition,0).r);tilePosition.y+=maskHeight;int maskOffset=max(sliceRange.x-batchOffset,0);int maskWidth=min(sliceRange.y-batchOffset+1,CLUSTLIGHT_BATCH);mask=extractBits(mask,maskOffset,maskWidth);while (mask != 0u) {uint bit=mask & -mask;mask ^= bit;int position=onlyBitPosition(bit);ClusteredLight light=getClusteredLight(lightDataTexture,batchOffset+maskOffset+position);preLightingInfo preInfo=computePointAndSpotPreLightingInfo(light.vLightData,V,N,posW);preInfo.NdotV=NdotV;preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light.vLightFalloff.x,light.vLightFalloff.y);if (light.vLightDirection.w>=0.0) {preInfo.attenuation*=computeDirectionalLightFalloff(light.vLightDirection.xyz,preInfo.L,light.vLightDirection.w,light.vLightData.w,light.vLightFalloff.z,light.vLightFalloff.w);}\npreInfo.roughness=adjustRoughnessFromLightProperties(reflectivityOut.roughness,light.vLightSpecular.a,preInfo.lightDistance);preInfo.diffuseRoughness=reflectivityOut.diffuseRoughness;preInfo.surfaceAlbedo=surfaceAlbedo;\n#ifdef IRIDESCENCE\npreInfo.iridescenceIntensity=iridescenceIntensity;\n#endif\nlightingInfo info;\n#ifdef SS_TRANSLUCENCY\n#ifdef SS_TRANSLUCENCY_LEGACY\ninfo.diffuse=computeDiffuseTransmittedLighting(preInfo,light.vLightDiffuse.rgb,subSurfaceOut.transmittance);info.diffuseTransmission=vec3(0);\n#else\ninfo.diffuse=computeDiffuseLighting(preInfo,light.vLightDiffuse.rgb)*(1.0-subSurfaceOut.translucencyIntensity);info.diffuseTransmission=computeDiffuseTransmittedLighting(preInfo,light.vLightDiffuse.rgb,subSurfaceOut.transmittance);\n#endif\n#else\ninfo.diffuse=computeDiffuseLighting(preInfo,light.vLightDiffuse.rgb);\n#endif\n#ifdef SPECULARTERM\n#if CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR\nvec3 metalFresnel=reflectivityOut.specularWeight*getF82Specular(preInfo.VdotH,specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);vec3 dielectricFresnel=fresnelSchlickGGX(preInfo.VdotH,reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90);vec3 coloredFresnel=mix(dielectricFresnel,metalFresnel,reflectivityOut.metallic);\n#else\nvec3 coloredFresnel=fresnelSchlickGGX(preInfo.VdotH,specularEnvironmentR0,reflectivityOut.colorReflectanceF90);\n#endif\n#ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION\nfloat NdotH=dot(N,preInfo.H);vec3 fresnel=fresnelSchlickGGX(NdotH,vec3(reflectanceF0),specularEnvironmentR90);info.diffuse*=(vec3(1.0)-fresnel);\n#endif\n#ifdef ANISOTROPIC\ninfo.specular=computeAnisotropicSpecularLighting(preInfo,V,N,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactor,light.vLightDiffuse.rgb);\n#else\ninfo.specular=computeSpecularLighting(preInfo,N,specularEnvironmentR0,coloredFresnel,AARoughnessFactor,light.vLightDiffuse.rgb);\n#endif\n#endif\n#ifdef SHEEN\n#ifdef SHEEN_LINKWITHALBEDO\npreInfo.roughness=sheenOut.sheenIntensity;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light.vLightSpecular.a,preInfo.lightDistance);\n#endif\ninfo.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactor,light.vLightDiffuse.rgb);\n#endif\n#ifdef CLEARCOAT\npreInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light.vLightSpecular.a,preInfo.lightDistance);info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light.vLightDiffuse.rgb);\n#ifdef CLEARCOAT_TINT\nfloat absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption;\n#ifdef SS_TRANSLUCENCY\ninfo.diffuseTransmission*=absorption;\n#endif\n#ifdef SPECULARTERM\ninfo.specular*=absorption;\n#endif\n#endif\ninfo.diffuse*=info.clearCoat.w;\n#ifdef SS_TRANSLUCENCY\ninfo.diffuseTransmission*=info.clearCoat.w;\n#endif\n#ifdef SPECULARTERM\ninfo.specular*=info.clearCoat.w;\n#endif\n#ifdef SHEEN\ninfo.sheen*=info.clearCoat.w;\n#endif\n#endif\nresult.diffuse+=info.diffuse;\n#ifdef SS_TRANSLUCENCY\nresult.diffuseTransmission+=info.diffuseTransmission;\n#endif\n#ifdef SPECULARTERM\nresult.specular+=info.specular;\n#endif\n#ifdef CLEARCOAT\nresult.clearCoat+=info.clearCoat;\n#endif\n#ifdef SHEEN\nresult.sheen+=info.sheen;\n#endif\n}\nbatchOffset+=CLUSTLIGHT_BATCH;}\nreturn result;}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const pbrClusteredLightingFunctions = { name, shader };\n"]}
|
package/package.json
CHANGED
package/scene.d.ts
CHANGED
|
@@ -90,6 +90,13 @@ export interface SceneOptions {
|
|
|
90
90
|
useClonedMeshMap?: boolean;
|
|
91
91
|
/** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
|
|
92
92
|
virtual?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* @experimental
|
|
95
|
+
* FloatingOriginMode helps avoid floating point imprecision of rendering large worlds by
|
|
96
|
+
* 1. Forcing the engine to use doublePrecision mode
|
|
97
|
+
* 2. Offsetting uniform values before passing to shader so that camera is centered at origin and world is offset by camera position
|
|
98
|
+
*/
|
|
99
|
+
floatingOriginMode?: boolean;
|
|
93
100
|
}
|
|
94
101
|
/**
|
|
95
102
|
* Define how the scene should favor performance over ease of use
|
|
@@ -1581,6 +1588,20 @@ export declare class Scene implements IAnimatable, IClipPlanesHolder, IAssetCont
|
|
|
1581
1588
|
* @param ubo the ubo to set for the scene
|
|
1582
1589
|
*/
|
|
1583
1590
|
setSceneUniformBuffer(ubo: UniformBuffer): void;
|
|
1591
|
+
private _floatingOriginMode;
|
|
1592
|
+
/**
|
|
1593
|
+
* @experimental
|
|
1594
|
+
* When true, enables floatingOriginMode which helps avoid floating point imprecision when using huge coordinate system by
|
|
1595
|
+
* 1. Forcing the engine to use doublePrecision mode
|
|
1596
|
+
* 2. Offsetting uniform values before passing to shader so that camera is centered at origin and world is offset by camera position
|
|
1597
|
+
*/
|
|
1598
|
+
get floatingOriginMode(): boolean;
|
|
1599
|
+
private _floatingOriginOffsetDefault;
|
|
1600
|
+
/**
|
|
1601
|
+
* @experimental
|
|
1602
|
+
* When floatingOriginMode is enabled, offset is equal to the active camera position. If no active camera or floatingOriginMode is disabled, offset is 0.
|
|
1603
|
+
*/
|
|
1604
|
+
get floatingOriginOffset(): Vector3;
|
|
1584
1605
|
/**
|
|
1585
1606
|
* Gets an unique (relatively to the current scene) Id
|
|
1586
1607
|
* @returns an unique number for the scene
|
package/scene.js
CHANGED
|
@@ -10,6 +10,7 @@ import { UniformBuffer } from "./Materials/uniformBuffer.js";
|
|
|
10
10
|
import { PickingInfo } from "./Collisions/pickingInfo.js";
|
|
11
11
|
import { ActionEvent } from "./Actions/actionEvent.js";
|
|
12
12
|
import { PostProcessManager } from "./PostProcesses/postProcessManager.js";
|
|
13
|
+
import { OverrideMatrixFunctions, ResetMatrixFunctions } from "./Materials/floatingOriginMatrixOverrides.js";
|
|
13
14
|
import { RenderingManager } from "./Rendering/renderingManager.js";
|
|
14
15
|
import { Stage } from "./sceneComponent.js";
|
|
15
16
|
|
|
@@ -376,12 +377,13 @@ export class Scene {
|
|
|
376
377
|
: (this.activeCamera?.globalPosition ?? Vector3.ZeroReadOnly);
|
|
377
378
|
const invertNormal = this.useRightHandedSystem === (this._mirroredCameraPosition != null);
|
|
378
379
|
TmpVectors.Vector4[0].set(eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
|
|
380
|
+
TmpVectors.Vector4[1].copyFromFloats(TmpVectors.Vector4[0].x - this.floatingOriginOffset.x, TmpVectors.Vector4[0].y - this.floatingOriginOffset.y, TmpVectors.Vector4[0].z - this.floatingOriginOffset.z, TmpVectors.Vector4[0].w);
|
|
379
381
|
if (effect) {
|
|
380
382
|
if (isVector3) {
|
|
381
|
-
effect.setFloat3(variableName, TmpVectors.Vector4[
|
|
383
|
+
effect.setFloat3(variableName, TmpVectors.Vector4[1].x, TmpVectors.Vector4[1].y, TmpVectors.Vector4[1].z);
|
|
382
384
|
}
|
|
383
385
|
else {
|
|
384
|
-
effect.setVector4(variableName, TmpVectors.Vector4[
|
|
386
|
+
effect.setVector4(variableName, TmpVectors.Vector4[1]);
|
|
385
387
|
}
|
|
386
388
|
}
|
|
387
389
|
return TmpVectors.Vector4[0];
|
|
@@ -393,7 +395,7 @@ export class Scene {
|
|
|
393
395
|
finalizeSceneUbo() {
|
|
394
396
|
const ubo = this.getSceneUniformBuffer();
|
|
395
397
|
const eyePosition = this.bindEyePosition(null);
|
|
396
|
-
ubo.updateFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, eyePosition.w);
|
|
398
|
+
ubo.updateFloat4("vEyePosition", eyePosition.x - this.floatingOriginOffset.x, eyePosition.y - this.floatingOriginOffset.y, eyePosition.z - this.floatingOriginOffset.z, eyePosition.w);
|
|
397
399
|
ubo.update();
|
|
398
400
|
return ubo;
|
|
399
401
|
}
|
|
@@ -1450,6 +1452,8 @@ export class Scene {
|
|
|
1450
1452
|
data: [],
|
|
1451
1453
|
length: 0,
|
|
1452
1454
|
};
|
|
1455
|
+
this._floatingOriginMode = false;
|
|
1456
|
+
this._floatingOriginOffsetDefault = Vector3.Zero();
|
|
1453
1457
|
this._preventFreeActiveMeshesAndRenderingGroups = false;
|
|
1454
1458
|
/** @internal */
|
|
1455
1459
|
this._activeMeshesFrozen = false;
|
|
@@ -1493,6 +1497,11 @@ export class Scene {
|
|
|
1493
1497
|
EngineStore._LastCreatedScene = this;
|
|
1494
1498
|
engine.scenes.push(this);
|
|
1495
1499
|
}
|
|
1500
|
+
if (options?.floatingOriginMode) {
|
|
1501
|
+
engine.getCreationOptions().useHighPrecisionMatrix = true;
|
|
1502
|
+
OverrideMatrixFunctions(this);
|
|
1503
|
+
this._floatingOriginMode = true;
|
|
1504
|
+
}
|
|
1496
1505
|
this._uid = null;
|
|
1497
1506
|
this._renderingManager = new RenderingManager(this);
|
|
1498
1507
|
if (PostProcessManager) {
|
|
@@ -2136,6 +2145,22 @@ export class Scene {
|
|
|
2136
2145
|
this._viewUpdateFlag = -1;
|
|
2137
2146
|
this._projectionUpdateFlag = -1;
|
|
2138
2147
|
}
|
|
2148
|
+
/**
|
|
2149
|
+
* @experimental
|
|
2150
|
+
* When true, enables floatingOriginMode which helps avoid floating point imprecision when using huge coordinate system by
|
|
2151
|
+
* 1. Forcing the engine to use doublePrecision mode
|
|
2152
|
+
* 2. Offsetting uniform values before passing to shader so that camera is centered at origin and world is offset by camera position
|
|
2153
|
+
*/
|
|
2154
|
+
get floatingOriginMode() {
|
|
2155
|
+
return this._floatingOriginMode;
|
|
2156
|
+
}
|
|
2157
|
+
/**
|
|
2158
|
+
* @experimental
|
|
2159
|
+
* When floatingOriginMode is enabled, offset is equal to the active camera position. If no active camera or floatingOriginMode is disabled, offset is 0.
|
|
2160
|
+
*/
|
|
2161
|
+
get floatingOriginOffset() {
|
|
2162
|
+
return this.floatingOriginMode && this.activeCamera ? this.activeCamera.position : this._floatingOriginOffsetDefault;
|
|
2163
|
+
}
|
|
2139
2164
|
/**
|
|
2140
2165
|
* Gets an unique (relatively to the current scene) Id
|
|
2141
2166
|
* @returns an unique number for the scene
|
|
@@ -4641,6 +4666,7 @@ export class Scene {
|
|
|
4641
4666
|
this.onClearColorChangedObservable.clear();
|
|
4642
4667
|
this.onEnvironmentTextureChangedObservable.clear();
|
|
4643
4668
|
this.onMeshUnderPointerUpdatedObservable.clear();
|
|
4669
|
+
ResetMatrixFunctions();
|
|
4644
4670
|
this._isDisposed = true;
|
|
4645
4671
|
}
|
|
4646
4672
|
_disposeList(items, callback) {
|