@babylonjs/core 8.28.0 → 8.28.2
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/FrameGraph/Tasks/Rendering/objectRendererTask.js +6 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/frameGraphContext.d.ts +2 -1
- package/FrameGraph/frameGraphContext.js +4 -1
- package/FrameGraph/frameGraphContext.js.map +1 -1
- package/Materials/Background/backgroundMaterial.d.ts +19 -91
- package/Materials/Background/backgroundMaterial.js +17 -245
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +57 -69
- package/Materials/Node/nodeMaterial.js +9 -86
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/index.d.ts +5 -0
- package/Materials/PBR/index.js +5 -0
- package/Materials/PBR/index.js.map +1 -1
- package/Materials/PBR/openPbrMaterial.d.ts +998 -0
- package/Materials/PBR/openPbrMaterial.js +2069 -0
- package/Materials/PBR/openPbrMaterial.js.map +1 -0
- package/Materials/PBR/pbrBaseMaterial.d.ts +57 -43
- package/Materials/PBR/pbrBaseMaterial.js +21 -304
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrMaterial.d.ts +0 -78
- package/Materials/PBR/pbrMaterial.js +0 -110
- package/Materials/PBR/pbrMaterial.js.map +1 -1
- package/Materials/imageProcessing.d.ts +65 -0
- package/Materials/imageProcessing.js +162 -0
- package/Materials/imageProcessing.js.map +1 -0
- package/Materials/imageProcessingConfiguration.defines.d.ts +25 -0
- package/Materials/imageProcessingConfiguration.defines.js +27 -0
- package/Materials/imageProcessingConfiguration.defines.js.map +1 -1
- package/Materials/index.d.ts +2 -0
- package/Materials/index.js +2 -0
- package/Materials/index.js.map +1 -1
- package/Materials/material.d.ts +14 -0
- package/Materials/material.js +14 -0
- package/Materials/material.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +53 -0
- package/Materials/materialHelper.functions.js +297 -0
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/standardMaterial.d.ts +57 -121
- package/Materials/standardMaterial.js +21 -250
- package/Materials/standardMaterial.js.map +1 -1
- package/Materials/uv.defines.d.ts +22 -0
- package/Materials/uv.defines.js +24 -0
- package/Materials/uv.defines.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Misc/decorators.d.ts +7 -0
- package/Misc/decorators.js +34 -0
- package/Misc/decorators.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +10 -1
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
- package/Particles/Node/Blocks/index.d.ts +2 -0
- package/Particles/Node/Blocks/index.js +2 -0
- package/Particles/Node/Blocks/index.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +4 -1
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleLocalVariableBlock.d.ts +38 -0
- package/Particles/Node/Blocks/particleLocalVariableBlock.js +108 -0
- package/Particles/Node/Blocks/particleLocalVariableBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleVectorLengthBlock.d.ts +26 -0
- package/Particles/Node/Blocks/particleVectorLengthBlock.js +50 -0
- package/Particles/Node/Blocks/particleVectorLengthBlock.js.map +1 -0
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.d.ts +2 -1
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.js +45 -0
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +2 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +6 -4
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/iblCdfGenerator.js +28 -20
- package/Rendering/iblCdfGenerator.js.map +1 -1
- package/Rendering/reflectiveShadowMap.d.ts +3 -3
- package/Shaders/ShadersInclude/backgroundUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/backgroundUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/defaultUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/defaultUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +34 -0
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/importanceSampling.js +4 -0
- package/Shaders/ShadersInclude/importanceSampling.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrBaseLayerData.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrBaseLayerData.js +127 -0
- package/Shaders/ShadersInclude/openpbrBaseLayerData.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrBlockAmbientOcclusion.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrBlockAmbientOcclusion.js +35 -0
- package/Shaders/ShadersInclude/openpbrBlockAmbientOcclusion.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrBlockNormalFinal.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrBlockNormalFinal.js +25 -0
- package/Shaders/ShadersInclude/openpbrBlockNormalFinal.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrCoatLayerData.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrCoatLayerData.js +59 -0
- package/Shaders/ShadersInclude/openpbrCoatLayerData.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrConductorReflectance.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrConductorReflectance.js +19 -0
- package/Shaders/ShadersInclude/openpbrConductorReflectance.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrDielectricReflectance.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrDielectricReflectance.js +30 -0
- package/Shaders/ShadersInclude/openpbrDielectricReflectance.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrDirectLighting.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrDirectLighting.js +69 -0
- package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrDirectLightingInit.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrDirectLightingInit.js +80 -0
- package/Shaders/ShadersInclude/openpbrDirectLightingInit.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrDirectLightingShadow.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrDirectLightingShadow.js +129 -0
- package/Shaders/ShadersInclude/openpbrDirectLightingShadow.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +106 -0
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrFragmentDeclaration.d.ts +6 -0
- package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js +115 -0
- package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.d.ts +6 -0
- package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.js +72 -0
- package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrGeometryInfo.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrGeometryInfo.js +46 -0
- package/Shaders/ShadersInclude/openpbrGeometryInfo.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrIblFunctions.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrIblFunctions.js +221 -0
- package/Shaders/ShadersInclude/openpbrIblFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragment.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragment.js +64 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragment.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragmentFunctions.d.ts +6 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragmentFunctions.js +45 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragmentFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragmentMainFunctions.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragmentMainFunctions.js +72 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragmentMainFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrNormalMapVertex.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrNormalMapVertex.js +16 -0
- package/Shaders/ShadersInclude/openpbrNormalMapVertex.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrNormalMapVertexDeclaration.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrNormalMapVertexDeclaration.js +16 -0
- package/Shaders/ShadersInclude/openpbrNormalMapVertexDeclaration.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrUboDeclaration.d.ts +7 -0
- package/Shaders/ShadersInclude/openpbrUboDeclaration.js +18 -0
- package/Shaders/ShadersInclude/openpbrUboDeclaration.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.d.ts +6 -0
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.js +103 -0
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.js.map +1 -0
- package/Shaders/ShadersInclude/pbrBRDFFunctions.js +1 -1
- package/Shaders/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js +3 -1
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrHelperFunctions.js +2 -0
- package/Shaders/ShadersInclude/pbrHelperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/Shaders/openpbr.fragment.d.ts +54 -0
- package/Shaders/openpbr.fragment.js +206 -0
- package/Shaders/openpbr.fragment.js.map +1 -0
- package/Shaders/openpbr.vertex.d.ts +39 -0
- package/Shaders/openpbr.vertex.js +238 -0
- package/Shaders/openpbr.vertex.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/backgroundUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/backgroundUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/defaultUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/defaultUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +28 -0
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/importanceSampling.js +4 -0
- package/ShadersWGSL/ShadersInclude/importanceSampling.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js +126 -0
- package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockAmbientOcclusion.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockAmbientOcclusion.js +36 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockAmbientOcclusion.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockNormalFinal.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockNormalFinal.js +25 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockNormalFinal.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrCoatLayerData.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrCoatLayerData.js +59 -0
- package/ShadersWGSL/ShadersInclude/openpbrCoatLayerData.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrConductorReflectance.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrConductorReflectance.js +19 -0
- package/ShadersWGSL/ShadersInclude/openpbrConductorReflectance.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrDielectricReflectance.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrDielectricReflectance.js +33 -0
- package/ShadersWGSL/ShadersInclude/openpbrDielectricReflectance.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +69 -0
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js +80 -0
- package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +112 -0
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.d.ts +6 -0
- package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.js +68 -0
- package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrGeometryInfo.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrGeometryInfo.js +54 -0
- package/ShadersWGSL/ShadersInclude/openpbrGeometryInfo.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js +218 -0
- package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragment.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragment.js +64 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragment.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentFunctions.d.ts +6 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentFunctions.js +45 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentMainFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentMainFunctions.js +51 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentMainFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapVertex.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapVertex.js +16 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapVertex.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapVertexDeclaration.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapVertexDeclaration.js +16 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapVertexDeclaration.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.d.ts +7 -0
- package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js +17 -0
- package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +3 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrHelperFunctions.js +2 -0
- package/ShadersWGSL/ShadersInclude/pbrHelperFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/ShadersWGSL/openpbr.fragment.d.ts +52 -0
- package/ShadersWGSL/openpbr.fragment.js +193 -0
- package/ShadersWGSL/openpbr.fragment.js.map +1 -0
- package/ShadersWGSL/openpbr.vertex.d.ts +37 -0
- package/ShadersWGSL/openpbr.vertex.js +227 -0
- package/ShadersWGSL/openpbr.vertex.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
const name = "openpbrDirectLightingInit";
|
|
4
|
+
const shader = `#ifdef LIGHT{X}
|
|
5
|
+
var preInfo{X}: preLightingInfo;var preInfoCoat{X}: preLightingInfo;let lightColor{X}: vec4f=light{X}.vLightDiffuse;var shadow{X}: f32=1.0f;
|
|
6
|
+
#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
|
|
7
|
+
#else
|
|
8
|
+
#define CUSTOM_LIGHT{X}_COLOR
|
|
9
|
+
#ifdef SPOTLIGHT{X}
|
|
10
|
+
preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);
|
|
11
|
+
#elif defined(POINTLIGHT{X})
|
|
12
|
+
preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);
|
|
13
|
+
#elif defined(HEMILIGHT{X})
|
|
14
|
+
preInfo{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);
|
|
15
|
+
#elif defined(DIRLIGHT{X})
|
|
16
|
+
preInfo{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);
|
|
17
|
+
#elif defined(AREALIGHT{X}) && defined(AREALIGHTSUPPORTED)
|
|
18
|
+
preInfo{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,specular_roughness);preInfoCoat{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,coatNormalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,coat_roughness);
|
|
19
|
+
#endif
|
|
20
|
+
preInfo{X}.NdotV=baseGeoInfo.NdotV;preInfoCoat{X}.NdotV=coatGeoInfo.NdotV;
|
|
21
|
+
#ifdef SPOTLIGHT{X}
|
|
22
|
+
#ifdef LIGHT_FALLOFF_GLTF{X}
|
|
23
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);
|
|
24
|
+
#ifdef IESLIGHTTEXTURE{X}
|
|
25
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
|
|
26
|
+
#else
|
|
27
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
|
|
28
|
+
#endif
|
|
29
|
+
#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
|
|
30
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);
|
|
31
|
+
#ifdef IESLIGHTTEXTURE{X}
|
|
32
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
|
|
33
|
+
#else
|
|
34
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w);
|
|
35
|
+
#endif
|
|
36
|
+
#elif defined(LIGHT_FALLOFF_STANDARD{X})
|
|
37
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);
|
|
38
|
+
#ifdef IESLIGHTTEXTURE{X}
|
|
39
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
|
|
40
|
+
#else
|
|
41
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
|
|
42
|
+
#endif
|
|
43
|
+
#else
|
|
44
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
|
|
45
|
+
#ifdef IESLIGHTTEXTURE{X}
|
|
46
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
|
|
47
|
+
#else
|
|
48
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
|
|
49
|
+
#endif
|
|
50
|
+
#endif
|
|
51
|
+
#elif defined(POINTLIGHT{X})
|
|
52
|
+
#ifdef LIGHT_FALLOFF_GLTF{X}
|
|
53
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);
|
|
54
|
+
#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
|
|
55
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);
|
|
56
|
+
#elif defined(LIGHT_FALLOFF_STANDARD{X})
|
|
57
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);
|
|
58
|
+
#else
|
|
59
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
|
|
60
|
+
#endif
|
|
61
|
+
#else
|
|
62
|
+
preInfo{X}.attenuation=1.0f;
|
|
63
|
+
#endif
|
|
64
|
+
preInfoCoat{X}.attenuation=preInfo{X}.attenuation;
|
|
65
|
+
#if defined(HEMILIGHT{X}) || defined(AREALIGHT{X})
|
|
66
|
+
preInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness;
|
|
67
|
+
#else
|
|
68
|
+
preInfo{X}.roughness=adjustRoughnessFromLightProperties(specular_roughness,light{X}.vLightSpecular.a,preInfo{X}.lightDistance);preInfoCoat{X}.roughness=adjustRoughnessFromLightProperties(coat_roughness,light{X}.vLightSpecular.a,preInfoCoat{X}.lightDistance);
|
|
69
|
+
#endif
|
|
70
|
+
preInfo{X}.diffuseRoughness=base_diffuse_roughness;preInfo{X}.surfaceAlbedo=base_color.rgb;
|
|
71
|
+
#endif
|
|
72
|
+
#endif
|
|
73
|
+
`;
|
|
74
|
+
// Sideeffect
|
|
75
|
+
if (!ShaderStore.IncludesShadersStoreWGSL[name]) {
|
|
76
|
+
ShaderStore.IncludesShadersStoreWGSL[name] = shader;
|
|
77
|
+
}
|
|
78
|
+
/** @internal */
|
|
79
|
+
export const openpbrDirectLightingInitWGSL = { name, shader };
|
|
80
|
+
//# sourceMappingURL=openpbrDirectLightingInit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrDirectLightingInit.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,2BAA2B,CAAC;AACzC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqEd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"openpbrDirectLightingInit\";\nconst shader = `#ifdef LIGHT{X}\nvar preInfo{X}: preLightingInfo;var preInfoCoat{X}: preLightingInfo;let lightColor{X}: vec4f=light{X}.vLightDiffuse;var shadow{X}: f32=1.0f;\n#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n#else\n#define CUSTOM_LIGHT{X}_COLOR \n#ifdef SPOTLIGHT{X}\npreInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);\n#elif defined(POINTLIGHT{X})\npreInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);\n#elif defined(HEMILIGHT{X})\npreInfo{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);\n#elif defined(DIRLIGHT{X})\npreInfo{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);\n#elif defined(AREALIGHT{X}) && defined(AREALIGHTSUPPORTED)\npreInfo{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,specular_roughness);preInfoCoat{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,coatNormalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,coat_roughness);\n#endif\npreInfo{X}.NdotV=baseGeoInfo.NdotV;preInfoCoat{X}.NdotV=coatGeoInfo.NdotV;\n#ifdef SPOTLIGHT{X}\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);\n#ifdef IESLIGHTTEXTURE{X}\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});\n#else\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);\n#ifdef IESLIGHTTEXTURE{X}\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});\n#else\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w);\n#endif\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);\n#ifdef IESLIGHTTEXTURE{X}\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});\n#else\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#endif\n#else\npreInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#ifdef IESLIGHTTEXTURE{X}\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});\n#else\npreInfo{X}.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#endif\n#elif defined(POINTLIGHT{X})\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);\n#else\npreInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\n#else\npreInfo{X}.attenuation=1.0f;\n#endif\npreInfoCoat{X}.attenuation=preInfo{X}.attenuation;\n#if defined(HEMILIGHT{X}) || defined(AREALIGHT{X})\npreInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness;\n#else\npreInfo{X}.roughness=adjustRoughnessFromLightProperties(specular_roughness,light{X}.vLightSpecular.a,preInfo{X}.lightDistance);preInfoCoat{X}.roughness=adjustRoughnessFromLightProperties(coat_roughness,light{X}.vLightSpecular.a,preInfoCoat{X}.lightDistance);\n#endif\npreInfo{X}.diffuseRoughness=base_diffuse_roughness;preInfo{X}.surfaceAlbedo=base_color.rgb;\n#endif\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrDirectLightingInitWGSL = { name, shader };\n"]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
const name = "openpbrEnvironmentLighting";
|
|
4
|
+
const shader = `#ifdef REFLECTION
|
|
5
|
+
var baseDiffuseEnvironmentLight: vec3f=sampleIrradiance(
|
|
6
|
+
normalW
|
|
7
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
8
|
+
,vEnvironmentIrradiance
|
|
9
|
+
#endif
|
|
10
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
11
|
+
,uniforms.reflectionMatrix
|
|
12
|
+
#endif
|
|
13
|
+
#ifdef USEIRRADIANCEMAP
|
|
14
|
+
,irradianceSampler
|
|
15
|
+
,irradianceSamplerSampler
|
|
16
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
17
|
+
,uniforms.vReflectionDominantDirection
|
|
18
|
+
#endif
|
|
19
|
+
#endif
|
|
20
|
+
#ifdef REALTIME_FILTERING
|
|
21
|
+
,uniforms.vReflectionFilteringInfo
|
|
22
|
+
#ifdef IBL_CDF_FILTERING
|
|
23
|
+
,icdfSampler
|
|
24
|
+
,icdfSamplerSampler
|
|
25
|
+
#endif
|
|
26
|
+
#endif
|
|
27
|
+
,uniforms.vReflectionInfos
|
|
28
|
+
,viewDirectionW
|
|
29
|
+
,base_diffuse_roughness
|
|
30
|
+
,base_color
|
|
31
|
+
);
|
|
32
|
+
#ifdef REFLECTIONMAP_3D
|
|
33
|
+
var reflectionCoords: vec3f=vec3f(0.f,0.f,0.f);
|
|
34
|
+
#else
|
|
35
|
+
var reflectionCoords: vec2f=vec2f(0.f,0.f);
|
|
36
|
+
#endif
|
|
37
|
+
let specularAlphaG: f32=specular_roughness*specular_roughness;
|
|
38
|
+
#ifdef ANISOTROPIC_BASE
|
|
39
|
+
var baseSpecularEnvironmentLight: vec3f=sampleRadianceAnisotropic(specularAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
|
|
40
|
+
,baseGeoInfo
|
|
41
|
+
,normalW
|
|
42
|
+
,viewDirectionW
|
|
43
|
+
,fragmentInputs.vPositionW
|
|
44
|
+
,noise
|
|
45
|
+
,reflectionSampler
|
|
46
|
+
,reflectionSamplerSampler
|
|
47
|
+
#ifdef REALTIME_FILTERING
|
|
48
|
+
,uniforms.vReflectionFilteringInfo
|
|
49
|
+
#endif
|
|
50
|
+
);
|
|
51
|
+
#else
|
|
52
|
+
reflectionCoords=createReflectionCoords(fragmentInputs.vPositionW,normalW);var baseSpecularEnvironmentLight: vec3f=sampleRadiance(specularAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
|
|
53
|
+
,baseGeoInfo
|
|
54
|
+
,reflectionSampler
|
|
55
|
+
,reflectionSamplerSampler
|
|
56
|
+
,reflectionCoords
|
|
57
|
+
#ifdef REALTIME_FILTERING
|
|
58
|
+
,uniforms.vReflectionFilteringInfo
|
|
59
|
+
#endif
|
|
60
|
+
);
|
|
61
|
+
#endif
|
|
62
|
+
#ifdef ANISOTROPIC_BASE
|
|
63
|
+
baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG*specularAlphaG *max(1.0f-baseGeoInfo.anisotropy,0.3f));
|
|
64
|
+
#else
|
|
65
|
+
baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG);
|
|
66
|
+
#endif
|
|
67
|
+
var coatEnvironmentLight: vec3f=vec3f(0.f,0.f,0.f);if (coat_weight>0.0) {
|
|
68
|
+
#ifdef REFLECTIONMAP_3D
|
|
69
|
+
var reflectionCoords: vec3f=vec3f(0.f,0.f,0.f);
|
|
70
|
+
#else
|
|
71
|
+
var reflectionCoords: vec2f=vec2f(0.f,0.f);
|
|
72
|
+
#endif
|
|
73
|
+
reflectionCoords=createReflectionCoords(fragmentInputs.vPositionW,coatNormalW);var coatAlphaG: f32=coat_roughness*coat_roughness;
|
|
74
|
+
#ifdef ANISOTROPIC_COAT
|
|
75
|
+
coatEnvironmentLight=sampleRadianceAnisotropic(coatAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
|
|
76
|
+
,coatGeoInfo
|
|
77
|
+
,coatNormalW
|
|
78
|
+
,viewDirectionW
|
|
79
|
+
,fragmentInputs.vPositionW
|
|
80
|
+
,noise
|
|
81
|
+
,reflectionSampler
|
|
82
|
+
,reflectionSamplerSampler
|
|
83
|
+
#ifdef REALTIME_FILTERING
|
|
84
|
+
,uniforms.vReflectionFilteringInfo
|
|
85
|
+
#endif
|
|
86
|
+
);
|
|
87
|
+
#else
|
|
88
|
+
coatEnvironmentLight=sampleRadiance(coatAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
|
|
89
|
+
,coatGeoInfo
|
|
90
|
+
,reflectionSampler
|
|
91
|
+
,reflectionSamplerSampler
|
|
92
|
+
,reflectionCoords
|
|
93
|
+
#ifdef REALTIME_FILTERING
|
|
94
|
+
,uniforms.vReflectionFilteringInfo
|
|
95
|
+
#endif
|
|
96
|
+
);
|
|
97
|
+
#endif
|
|
98
|
+
}
|
|
99
|
+
let dielectricIblFresnel: f32=getReflectanceFromBRDFWithEnvLookup(vec3f(baseDielectricReflectance.F0),vec3f(baseDielectricReflectance.F90),baseGeoInfo.environmentBrdf).r;let dielectricIblColoredFresnel: vec3f=getReflectanceFromBRDFWithEnvLookup(baseDielectricReflectance.coloredF0,baseDielectricReflectance.coloredF90,baseGeoInfo.environmentBrdf);let conductorIblFresnel: vec3f=conductorIblFresnel(baseConductorReflectance,baseGeoInfo.NdotV,specular_roughness,baseGeoInfo.environmentBrdf);var coatIblFresnel: f32=0.0;if (coat_weight>0.0) {coatIblFresnel=getReflectanceFromBRDFWithEnvLookup(vec3f(coatReflectance.F0),vec3f(coatReflectance.F90),coatGeoInfo.environmentBrdf).r;}
|
|
100
|
+
var slab_diffuse_ibl: vec3f=vec3f(0.,0.,0.);var slab_glossy_ibl: vec3f=vec3f(0.,0.,0.);var slab_metal_ibl: vec3f=vec3f(0.,0.,0.);var slab_coat_ibl: vec3f=vec3f(0.,0.,0.);slab_diffuse_ibl=baseDiffuseEnvironmentLight*uniforms.vLightingIntensity.z;slab_diffuse_ibl*=aoOut.ambientOcclusionColor;slab_glossy_ibl=baseSpecularEnvironmentLight*uniforms.vLightingIntensity.z;slab_metal_ibl=baseSpecularEnvironmentLight*conductorIblFresnel*uniforms.vLightingIntensity.z;var coatAbsorption=vec3f(1.0);if (coat_weight>0.0) {slab_coat_ibl=coatEnvironmentLight*uniforms.vLightingIntensity.z;let hemisphere_avg_fresnel: f32=coatReflectance.F0+0.5f*(1.0f-coatReflectance.F0);var averageReflectance: f32=(coatIblFresnel+hemisphere_avg_fresnel)*0.5f;let roughnessFactor=1.0f-coat_roughness*0.5f;averageReflectance*=roughnessFactor;var darkened_transmission: f32=(1.0f-averageReflectance)*(1.0f-averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);var sin2: f32=1.0f-coatGeoInfo.NdotV*coatGeoInfo.NdotV;sin2=sin2/(coat_ior*coat_ior);let cos_t: f32=sqrt(1.0f-sin2);let coatPathLength=1.0f/cos_t;let colored_transmission: vec3f=pow(coat_color,vec3f(coatPathLength));coatAbsorption=mix(vec3f(1.0f),colored_transmission*vec3f(darkened_transmission),coat_weight);}
|
|
101
|
+
var slab_subsurface_ibl: vec3f=vec3f(0.,0.,0.);var slab_translucent_base_ibl: vec3f=vec3f(0.,0.,0.);var slab_fuzz_ibl: vec3f=vec3f(0.,0.,0.);slab_diffuse_ibl*=base_color.rgb;
|
|
102
|
+
#define CUSTOM_FRAGMENT_BEFORE_IBLLAYERCOMPOSITION
|
|
103
|
+
let material_opaque_base_ibl: vec3f=mix(slab_diffuse_ibl,slab_subsurface_ibl,subsurface_weight);let material_dielectric_base_ibl: vec3f=mix(material_opaque_base_ibl,slab_translucent_base_ibl,transmission_weight);let material_dielectric_gloss_ibl: vec3f=layer(material_dielectric_base_ibl,slab_glossy_ibl,dielectricIblFresnel,vec3f(1.0f),specular_color);let material_base_substrate_ibl: vec3f=mix(material_dielectric_gloss_ibl,slab_metal_ibl,base_metalness);let material_coated_base_ibl: vec3f=layer(material_base_substrate_ibl,slab_coat_ibl,coatIblFresnel,coatAbsorption,vec3f(1.0f));material_surface_ibl=mix(material_coated_base_ibl,slab_fuzz_ibl,fuzz_weight);
|
|
104
|
+
#endif
|
|
105
|
+
`;
|
|
106
|
+
// Sideeffect
|
|
107
|
+
if (!ShaderStore.IncludesShadersStoreWGSL[name]) {
|
|
108
|
+
ShaderStore.IncludesShadersStoreWGSL[name] = shader;
|
|
109
|
+
}
|
|
110
|
+
/** @internal */
|
|
111
|
+
export const openpbrEnvironmentLightingWGSL = { name, shader };
|
|
112
|
+
//# sourceMappingURL=openpbrEnvironmentLighting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrEnvironmentLighting.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,4BAA4B,CAAC;AAC1C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqGd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,8BAA8B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"openpbrEnvironmentLighting\";\nconst shader = `#ifdef REFLECTION\nvar baseDiffuseEnvironmentLight: vec3f=sampleIrradiance(\nnormalW\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\n,vEnvironmentIrradiance \n#endif\n#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))\n,uniforms.reflectionMatrix\n#endif\n#ifdef USEIRRADIANCEMAP\n,irradianceSampler\n,irradianceSamplerSampler\n#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION\n,uniforms.vReflectionDominantDirection\n#endif\n#endif\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#ifdef IBL_CDF_FILTERING\n,icdfSampler\n,icdfSamplerSampler\n#endif\n#endif\n,uniforms.vReflectionInfos\n,viewDirectionW\n,base_diffuse_roughness\n,base_color\n);\n#ifdef REFLECTIONMAP_3D\nvar reflectionCoords: vec3f=vec3f(0.f,0.f,0.f);\n#else\nvar reflectionCoords: vec2f=vec2f(0.f,0.f);\n#endif\nlet specularAlphaG: f32=specular_roughness*specular_roughness;\n#ifdef ANISOTROPIC_BASE\nvar baseSpecularEnvironmentLight: vec3f=sampleRadianceAnisotropic(specularAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,baseGeoInfo\n,normalW\n,viewDirectionW\n,fragmentInputs.vPositionW\n,noise\n,reflectionSampler\n,reflectionSamplerSampler\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n);\n#else\nreflectionCoords=createReflectionCoords(fragmentInputs.vPositionW,normalW);var baseSpecularEnvironmentLight: vec3f=sampleRadiance(specularAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,baseGeoInfo\n,reflectionSampler\n,reflectionSamplerSampler\n,reflectionCoords\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n);\n#endif\n#ifdef ANISOTROPIC_BASE\nbaseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG*specularAlphaG *max(1.0f-baseGeoInfo.anisotropy,0.3f));\n#else\nbaseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG);\n#endif\nvar coatEnvironmentLight: vec3f=vec3f(0.f,0.f,0.f);if (coat_weight>0.0) {\n#ifdef REFLECTIONMAP_3D\nvar reflectionCoords: vec3f=vec3f(0.f,0.f,0.f);\n#else\nvar reflectionCoords: vec2f=vec2f(0.f,0.f);\n#endif\nreflectionCoords=createReflectionCoords(fragmentInputs.vPositionW,coatNormalW);var coatAlphaG: f32=coat_roughness*coat_roughness;\n#ifdef ANISOTROPIC_COAT\ncoatEnvironmentLight=sampleRadianceAnisotropic(coatAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,coatGeoInfo\n,coatNormalW\n,viewDirectionW\n,fragmentInputs.vPositionW\n,noise\n,reflectionSampler\n,reflectionSamplerSampler\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n);\n#else\ncoatEnvironmentLight=sampleRadiance(coatAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,coatGeoInfo\n,reflectionSampler\n,reflectionSamplerSampler\n,reflectionCoords\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n);\n#endif\n}\nlet dielectricIblFresnel: f32=getReflectanceFromBRDFWithEnvLookup(vec3f(baseDielectricReflectance.F0),vec3f(baseDielectricReflectance.F90),baseGeoInfo.environmentBrdf).r;let dielectricIblColoredFresnel: vec3f=getReflectanceFromBRDFWithEnvLookup(baseDielectricReflectance.coloredF0,baseDielectricReflectance.coloredF90,baseGeoInfo.environmentBrdf);let conductorIblFresnel: vec3f=conductorIblFresnel(baseConductorReflectance,baseGeoInfo.NdotV,specular_roughness,baseGeoInfo.environmentBrdf);var coatIblFresnel: f32=0.0;if (coat_weight>0.0) {coatIblFresnel=getReflectanceFromBRDFWithEnvLookup(vec3f(coatReflectance.F0),vec3f(coatReflectance.F90),coatGeoInfo.environmentBrdf).r;}\nvar slab_diffuse_ibl: vec3f=vec3f(0.,0.,0.);var slab_glossy_ibl: vec3f=vec3f(0.,0.,0.);var slab_metal_ibl: vec3f=vec3f(0.,0.,0.);var slab_coat_ibl: vec3f=vec3f(0.,0.,0.);slab_diffuse_ibl=baseDiffuseEnvironmentLight*uniforms.vLightingIntensity.z;slab_diffuse_ibl*=aoOut.ambientOcclusionColor;slab_glossy_ibl=baseSpecularEnvironmentLight*uniforms.vLightingIntensity.z;slab_metal_ibl=baseSpecularEnvironmentLight*conductorIblFresnel*uniforms.vLightingIntensity.z;var coatAbsorption=vec3f(1.0);if (coat_weight>0.0) {slab_coat_ibl=coatEnvironmentLight*uniforms.vLightingIntensity.z;let hemisphere_avg_fresnel: f32=coatReflectance.F0+0.5f*(1.0f-coatReflectance.F0);var averageReflectance: f32=(coatIblFresnel+hemisphere_avg_fresnel)*0.5f;let roughnessFactor=1.0f-coat_roughness*0.5f;averageReflectance*=roughnessFactor;var darkened_transmission: f32=(1.0f-averageReflectance)*(1.0f-averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);var sin2: f32=1.0f-coatGeoInfo.NdotV*coatGeoInfo.NdotV;sin2=sin2/(coat_ior*coat_ior);let cos_t: f32=sqrt(1.0f-sin2);let coatPathLength=1.0f/cos_t;let colored_transmission: vec3f=pow(coat_color,vec3f(coatPathLength));coatAbsorption=mix(vec3f(1.0f),colored_transmission*vec3f(darkened_transmission),coat_weight);}\nvar slab_subsurface_ibl: vec3f=vec3f(0.,0.,0.);var slab_translucent_base_ibl: vec3f=vec3f(0.,0.,0.);var slab_fuzz_ibl: vec3f=vec3f(0.,0.,0.);slab_diffuse_ibl*=base_color.rgb;\n#define CUSTOM_FRAGMENT_BEFORE_IBLLAYERCOMPOSITION\nlet material_opaque_base_ibl: vec3f=mix(slab_diffuse_ibl,slab_subsurface_ibl,subsurface_weight);let material_dielectric_base_ibl: vec3f=mix(material_opaque_base_ibl,slab_translucent_base_ibl,transmission_weight);let material_dielectric_gloss_ibl: vec3f=layer(material_dielectric_base_ibl,slab_glossy_ibl,dielectricIblFresnel,vec3f(1.0f),specular_color);let material_base_substrate_ibl: vec3f=mix(material_dielectric_gloss_ibl,slab_metal_ibl,base_metalness);let material_coated_base_ibl: vec3f=layer(material_base_substrate_ibl,slab_coat_ibl,coatIblFresnel,coatAbsorption,vec3f(1.0f));material_surface_ibl=mix(material_coated_base_ibl,slab_fuzz_ibl,fuzz_weight);\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrEnvironmentLightingWGSL = { name, shader };\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
import "./samplerFragmentDeclaration.js";
|
|
4
|
+
const name = "openpbrFragmentSamplersDeclaration";
|
|
5
|
+
const shader = `#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor,_SAMPLERNAME_,baseColor)
|
|
6
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight)
|
|
7
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness)
|
|
8
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_METALNESS,_VARYINGNAME_,BaseMetalness,_SAMPLERNAME_,baseMetalness)
|
|
9
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_WEIGHT,_VARYINGNAME_,SpecularWeight,_SAMPLERNAME_,specularWeight)
|
|
10
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_COLOR,_VARYINGNAME_,SpecularColor,_SAMPLERNAME_,specularColor)
|
|
11
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS,_VARYINGNAME_,SpecularRoughness,_SAMPLERNAME_,specularRoughness)
|
|
12
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,SpecularRoughnessAnisotropy,_SAMPLERNAME_,specularRoughnessAnisotropy)
|
|
13
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_WEIGHT,_VARYINGNAME_,CoatWeight,_SAMPLERNAME_,coatWeight)
|
|
14
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_COLOR,_VARYINGNAME_,CoatColor,_SAMPLERNAME_,coatColor)
|
|
15
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS,_VARYINGNAME_,CoatRoughness,_SAMPLERNAME_,coatRoughness)
|
|
16
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,CoatRoughnessAnisotropy,_SAMPLERNAME_,coatRoughnessAnisotropy)
|
|
17
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_DARKENING,_VARYINGNAME_,CoatDarkening,_SAMPLERNAME_,coatDarkening)
|
|
18
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_OPACITY,_VARYINGNAME_,GeometryOpacity,_SAMPLERNAME_,geometryOpacity)
|
|
19
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_TANGENT,_VARYINGNAME_,GeometryTangent,_SAMPLERNAME_,geometryTangent)
|
|
20
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_COAT_TANGENT,_VARYINGNAME_,GeometryCoatTangent,_SAMPLERNAME_,geometryCoatTangent)
|
|
21
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSION_COLOR,_VARYINGNAME_,EmissionColor,_SAMPLERNAME_,emissionColor)
|
|
22
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_SAMPLERNAME_,ambientOcclusion)
|
|
23
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
|
|
24
|
+
#ifdef REFLECTION
|
|
25
|
+
#ifdef REFLECTIONMAP_3D
|
|
26
|
+
var reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube<f32>;
|
|
27
|
+
#ifdef LODBASEDMICROSFURACE
|
|
28
|
+
#else
|
|
29
|
+
var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_cube<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_cube<f32>;
|
|
30
|
+
#endif
|
|
31
|
+
#ifdef USEIRRADIANCEMAP
|
|
32
|
+
var irradianceSamplerSampler: sampler;var irradianceSampler: texture_cube<f32>;
|
|
33
|
+
#endif
|
|
34
|
+
#else
|
|
35
|
+
var reflectionSamplerSampler: sampler;var reflectionSampler: texture_2d<f32>;
|
|
36
|
+
#ifdef LODBASEDMICROSFURACE
|
|
37
|
+
#else
|
|
38
|
+
var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_2d<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_2d<f32>;
|
|
39
|
+
#endif
|
|
40
|
+
#ifdef USEIRRADIANCEMAP
|
|
41
|
+
var irradianceSamplerSampler: sampler;var irradianceSampler: texture_2d<f32>;
|
|
42
|
+
#endif
|
|
43
|
+
#endif
|
|
44
|
+
#ifdef REFLECTIONMAP_SKYBOX
|
|
45
|
+
varying vPositionUVW: vec3f;
|
|
46
|
+
#else
|
|
47
|
+
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
|
48
|
+
varying vDirectionW: vec3f;
|
|
49
|
+
#endif
|
|
50
|
+
#endif
|
|
51
|
+
#endif
|
|
52
|
+
#ifdef ENVIRONMENTBRDF
|
|
53
|
+
var environmentBrdfSamplerSampler: sampler;var environmentBrdfSampler: texture_2d<f32>;
|
|
54
|
+
#endif
|
|
55
|
+
#ifdef ANISOTROPIC
|
|
56
|
+
var blueNoiseSamplerSampler: sampler;var blueNoiseSampler: texture_2d<f32>;
|
|
57
|
+
#endif
|
|
58
|
+
#ifdef IBL_CDF_FILTERING
|
|
59
|
+
var icdfSamplerSampler: sampler;var icdfSampler: texture_2d<f32>;
|
|
60
|
+
#endif
|
|
61
|
+
`;
|
|
62
|
+
// Sideeffect
|
|
63
|
+
if (!ShaderStore.IncludesShadersStoreWGSL[name]) {
|
|
64
|
+
ShaderStore.IncludesShadersStoreWGSL[name] = shader;
|
|
65
|
+
}
|
|
66
|
+
/** @internal */
|
|
67
|
+
export const openpbrFragmentSamplersDeclarationWGSL = { name, shader };
|
|
68
|
+
//# sourceMappingURL=openpbrFragmentSamplersDeclaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrFragmentSamplersDeclaration.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,8BAA8B,CAAC;AAEtC,MAAM,IAAI,GAAG,oCAAoC,CAAC;AAClD,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,sCAAsC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\nimport \"./samplerFragmentDeclaration\";\n\nconst name = \"openpbrFragmentSamplersDeclaration\";\nconst shader = `#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor,_SAMPLERNAME_,baseColor)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_METALNESS,_VARYINGNAME_,BaseMetalness,_SAMPLERNAME_,baseMetalness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_WEIGHT,_VARYINGNAME_,SpecularWeight,_SAMPLERNAME_,specularWeight)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_COLOR,_VARYINGNAME_,SpecularColor,_SAMPLERNAME_,specularColor)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS,_VARYINGNAME_,SpecularRoughness,_SAMPLERNAME_,specularRoughness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,SpecularRoughnessAnisotropy,_SAMPLERNAME_,specularRoughnessAnisotropy)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_WEIGHT,_VARYINGNAME_,CoatWeight,_SAMPLERNAME_,coatWeight)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_COLOR,_VARYINGNAME_,CoatColor,_SAMPLERNAME_,coatColor)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS,_VARYINGNAME_,CoatRoughness,_SAMPLERNAME_,coatRoughness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,CoatRoughnessAnisotropy,_SAMPLERNAME_,coatRoughnessAnisotropy)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_DARKENING,_VARYINGNAME_,CoatDarkening,_SAMPLERNAME_,coatDarkening)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_OPACITY,_VARYINGNAME_,GeometryOpacity,_SAMPLERNAME_,geometryOpacity)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_TANGENT,_VARYINGNAME_,GeometryTangent,_SAMPLERNAME_,geometryTangent)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_COAT_TANGENT,_VARYINGNAME_,GeometryCoatTangent,_SAMPLERNAME_,geometryCoatTangent)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSION_COLOR,_VARYINGNAME_,EmissionColor,_SAMPLERNAME_,emissionColor)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_SAMPLERNAME_,ambientOcclusion)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nvar reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube<f32>;\n#ifdef LODBASEDMICROSFURACE\n#else\nvar reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_cube<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_cube<f32>;\n#endif\n#ifdef USEIRRADIANCEMAP\nvar irradianceSamplerSampler: sampler;var irradianceSampler: texture_cube<f32>;\n#endif\n#else\nvar reflectionSamplerSampler: sampler;var reflectionSampler: texture_2d<f32>;\n#ifdef LODBASEDMICROSFURACE\n#else\nvar reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_2d<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_2d<f32>;\n#endif\n#ifdef USEIRRADIANCEMAP\nvar irradianceSamplerSampler: sampler;var irradianceSampler: texture_2d<f32>;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vPositionUVW: vec3f;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vDirectionW: vec3f;\n#endif\n#endif\n#endif\n#ifdef ENVIRONMENTBRDF\nvar environmentBrdfSamplerSampler: sampler;var environmentBrdfSampler: texture_2d<f32>;\n#endif\n#ifdef ANISOTROPIC\nvar blueNoiseSamplerSampler: sampler;var blueNoiseSampler: texture_2d<f32>;\n#endif\n#ifdef IBL_CDF_FILTERING\nvar icdfSamplerSampler: sampler;var icdfSampler: texture_2d<f32>;\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrFragmentSamplersDeclarationWGSL = { name, shader };\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
const name = "openpbrGeometryInfo";
|
|
4
|
+
const shader = `struct geometryInfoOutParams
|
|
5
|
+
{NdotV: f32,
|
|
6
|
+
NdotVUnclamped: f32,
|
|
7
|
+
environmentBrdf: vec3f,
|
|
8
|
+
horizonOcclusion: f32};
|
|
9
|
+
#ifdef ANISOTROPIC
|
|
10
|
+
struct geometryInfoAnisoOutParams
|
|
11
|
+
{NdotV: f32,
|
|
12
|
+
NdotVUnclamped: f32,
|
|
13
|
+
environmentBrdf: vec3f,
|
|
14
|
+
horizonOcclusion: f32,
|
|
15
|
+
anisotropy: f32,
|
|
16
|
+
anisotropicTangent: vec3f,
|
|
17
|
+
anisotropicBitangent: vec3f,
|
|
18
|
+
TBN: mat3x3<f32>};
|
|
19
|
+
#endif
|
|
20
|
+
fn geometryInfo(
|
|
21
|
+
normalW: vec3f,viewDirectionW: vec3f,roughness: f32,geometricNormalW: vec3f
|
|
22
|
+
)->geometryInfoOutParams
|
|
23
|
+
{var outParams: geometryInfoOutParams;outParams.NdotVUnclamped=dot(normalW,viewDirectionW);outParams.NdotV=absEps(outParams.NdotVUnclamped);
|
|
24
|
+
#if defined(ENVIRONMENTBRDF)
|
|
25
|
+
outParams.environmentBrdf=getBRDFLookup(outParams.NdotV,roughness);
|
|
26
|
+
#else
|
|
27
|
+
outParams.environmentBrdf=vec3f(0.0);
|
|
28
|
+
#endif
|
|
29
|
+
outParams.horizonOcclusion=1.0f;
|
|
30
|
+
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
|
31
|
+
#ifdef HORIZONOCCLUSION
|
|
32
|
+
#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL)
|
|
33
|
+
#ifdef REFLECTIONMAP_3D
|
|
34
|
+
outParams.horizonOcclusion=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
|
|
35
|
+
#endif
|
|
36
|
+
#endif
|
|
37
|
+
#endif
|
|
38
|
+
#endif
|
|
39
|
+
return outParams;}
|
|
40
|
+
#ifdef ANISOTROPIC
|
|
41
|
+
fn geometryInfoAniso(
|
|
42
|
+
normalW: vec3f,viewDirectionW: vec3f,roughness: f32,geometricNormalW: vec3f
|
|
43
|
+
,vAnisotropy: vec3f,TBN: mat3x3<f32>
|
|
44
|
+
)->geometryInfoAnisoOutParams
|
|
45
|
+
{let geoInfo: geometryInfoOutParams=geometryInfo(normalW,viewDirectionW,roughness,geometricNormalW);var outParams: geometryInfoAnisoOutParams;outParams.NdotV=geoInfo.NdotV;outParams.NdotVUnclamped=geoInfo.NdotVUnclamped;outParams.environmentBrdf=geoInfo.environmentBrdf;outParams.horizonOcclusion=geoInfo.horizonOcclusion;outParams.anisotropy=vAnisotropy.b;let anisotropyDirection: vec3f=vec3f(vAnisotropy.xy,0.);let anisoTBN: mat3x3<f32>=mat3x3<f32>(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));outParams.anisotropicTangent=normalize(anisoTBN*anisotropyDirection);outParams.anisotropicBitangent=normalize(cross(anisoTBN[2],outParams.anisotropicTangent));outParams.TBN=TBN;return outParams;}
|
|
46
|
+
#endif
|
|
47
|
+
`;
|
|
48
|
+
// Sideeffect
|
|
49
|
+
if (!ShaderStore.IncludesShadersStoreWGSL[name]) {
|
|
50
|
+
ShaderStore.IncludesShadersStoreWGSL[name] = shader;
|
|
51
|
+
}
|
|
52
|
+
/** @internal */
|
|
53
|
+
export const openpbrGeometryInfoWGSL = { name, shader };
|
|
54
|
+
//# sourceMappingURL=openpbrGeometryInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrGeometryInfo.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/openpbrGeometryInfo.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Cd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"openpbrGeometryInfo\";\nconst shader = `struct geometryInfoOutParams\n{NdotV: f32,\nNdotVUnclamped: f32,\nenvironmentBrdf: vec3f,\nhorizonOcclusion: f32};\n#ifdef ANISOTROPIC\nstruct geometryInfoAnisoOutParams\n{NdotV: f32,\nNdotVUnclamped: f32,\nenvironmentBrdf: vec3f,\nhorizonOcclusion: f32,\nanisotropy: f32,\nanisotropicTangent: vec3f,\nanisotropicBitangent: vec3f,\nTBN: mat3x3<f32>};\n#endif\nfn geometryInfo(\nnormalW: vec3f,viewDirectionW: vec3f,roughness: f32,geometricNormalW: vec3f\n)->geometryInfoOutParams\n{var outParams: geometryInfoOutParams;outParams.NdotVUnclamped=dot(normalW,viewDirectionW);outParams.NdotV=absEps(outParams.NdotVUnclamped);\n#if defined(ENVIRONMENTBRDF)\noutParams.environmentBrdf=getBRDFLookup(outParams.NdotV,roughness);\n#else\noutParams.environmentBrdf=vec3f(0.0);\n#endif\noutParams.horizonOcclusion=1.0f;\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n#ifdef HORIZONOCCLUSION\n#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL)\n#ifdef REFLECTIONMAP_3D\noutParams.horizonOcclusion=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);\n#endif\n#endif\n#endif\n#endif\nreturn outParams;}\n#ifdef ANISOTROPIC\nfn geometryInfoAniso(\nnormalW: vec3f,viewDirectionW: vec3f,roughness: f32,geometricNormalW: vec3f\n,vAnisotropy: vec3f,TBN: mat3x3<f32>\n)->geometryInfoAnisoOutParams\n{let geoInfo: geometryInfoOutParams=geometryInfo(normalW,viewDirectionW,roughness,geometricNormalW);var outParams: geometryInfoAnisoOutParams;outParams.NdotV=geoInfo.NdotV;outParams.NdotVUnclamped=geoInfo.NdotVUnclamped;outParams.environmentBrdf=geoInfo.environmentBrdf;outParams.horizonOcclusion=geoInfo.horizonOcclusion;outParams.anisotropy=vAnisotropy.b;let anisotropyDirection: vec3f=vec3f(vAnisotropy.xy,0.);let anisoTBN: mat3x3<f32>=mat3x3<f32>(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));outParams.anisotropicTangent=normalize(anisoTBN*anisotropyDirection);outParams.anisotropicBitangent=normalize(cross(anisoTBN[2],outParams.anisotropicTangent));outParams.TBN=TBN;return outParams;}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrGeometryInfoWGSL = { name, shader };\n"]}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
const name = "openpbrIblFunctions";
|
|
4
|
+
const shader = `#ifdef REFLECTION
|
|
5
|
+
fn sampleIrradiance(
|
|
6
|
+
surfaceNormal: vec3f
|
|
7
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
8
|
+
,vEnvironmentIrradianceSH: vec3f
|
|
9
|
+
#endif
|
|
10
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
11
|
+
,iblMatrix: mat4x4f
|
|
12
|
+
#endif
|
|
13
|
+
#ifdef USEIRRADIANCEMAP
|
|
14
|
+
#ifdef REFLECTIONMAP_3D
|
|
15
|
+
,irradianceSampler: texture_cube<f32>
|
|
16
|
+
,irradianceSamplerSampler: sampler
|
|
17
|
+
#else
|
|
18
|
+
,irradianceSampler: texture_2d<f32>
|
|
19
|
+
,irradianceSamplerSampler: sampler
|
|
20
|
+
#endif
|
|
21
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
22
|
+
,reflectionDominantDirection: vec3f
|
|
23
|
+
#endif
|
|
24
|
+
#endif
|
|
25
|
+
#ifdef REALTIME_FILTERING
|
|
26
|
+
,reflectionFilteringInfo: vec2f
|
|
27
|
+
#ifdef IBL_CDF_FILTERING
|
|
28
|
+
,icdfSampler: texture_2d<f32>
|
|
29
|
+
,icdfSamplerSampler: sampler
|
|
30
|
+
#endif
|
|
31
|
+
#endif
|
|
32
|
+
,reflectionInfos: vec2f
|
|
33
|
+
,viewDirectionW: vec3f
|
|
34
|
+
,diffuseRoughness: f32
|
|
35
|
+
,surfaceAlbedo: vec3f
|
|
36
|
+
)->vec3f {var environmentIrradiance=vec3f(0.,0.,0.);
|
|
37
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
38
|
+
var irradianceVector=(iblMatrix*vec4f(surfaceNormal,0.0f)).xyz;let irradianceView=(iblMatrix*vec4f(viewDirectionW,0.0f)).xyz;
|
|
39
|
+
#if !defined(USE_IRRADIANCE_DOMINANT_DIRECTION) && !defined(REALTIME_FILTERING)
|
|
40
|
+
#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY
|
|
41
|
+
{let NdotV=max(dot(surfaceNormal,viewDirectionW),0.0f);irradianceVector=mix(irradianceVector,irradianceView,(0.5f*(1.0f-NdotV))*diffuseRoughness);}
|
|
42
|
+
#endif
|
|
43
|
+
#endif
|
|
44
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
45
|
+
irradianceVector.z*=-1.0f;
|
|
46
|
+
#endif
|
|
47
|
+
#ifdef INVERTCUBICMAP
|
|
48
|
+
irradianceVector.y*=-1.0f;
|
|
49
|
+
#endif
|
|
50
|
+
#endif
|
|
51
|
+
#ifdef USESPHERICALFROMREFLECTIONMAP
|
|
52
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
53
|
+
environmentIrradiance=vEnvironmentIrradianceSH;
|
|
54
|
+
#else
|
|
55
|
+
#if defined(REALTIME_FILTERING)
|
|
56
|
+
environmentIrradiance=irradiance(reflectionSampler,reflectionSamplerSampler,irradianceVector,reflectionFilteringInfo,diffuseRoughness,surfaceAlbedo,irradianceView
|
|
57
|
+
#ifdef IBL_CDF_FILTERING
|
|
58
|
+
,icdfSampler
|
|
59
|
+
,icdfSamplerSampler
|
|
60
|
+
#endif
|
|
61
|
+
);
|
|
62
|
+
#else
|
|
63
|
+
environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
|
|
64
|
+
#endif
|
|
65
|
+
#endif
|
|
66
|
+
#elif defined(USEIRRADIANCEMAP)
|
|
67
|
+
#ifdef REFLECTIONMAP_3D
|
|
68
|
+
let environmentIrradianceFromTexture: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,irradianceVector);
|
|
69
|
+
#else
|
|
70
|
+
let environmentIrradianceFromTexture: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,reflectionCoords);
|
|
71
|
+
#endif
|
|
72
|
+
environmentIrradiance=environmentIrradianceFromTexture.rgb;
|
|
73
|
+
#ifdef RGBDREFLECTION
|
|
74
|
+
environmentIrradiance.rgb=fromRGBD(environmentIrradianceFromTexture);
|
|
75
|
+
#endif
|
|
76
|
+
#ifdef GAMMAREFLECTION
|
|
77
|
+
environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);
|
|
78
|
+
#endif
|
|
79
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
80
|
+
let Ls: vec3f=normalize(reflectionDominantDirection);let NoL: f32=dot(irradianceVector,Ls);let NoV: f32=dot(irradianceVector,irradianceView);var diffuseRoughnessTerm=vec3f(1.0f);
|
|
81
|
+
#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
|
|
82
|
+
let LoV: f32=dot (Ls,irradianceView);let mag: f32=length(reflectionDominantDirection)*2.0f;let clampedAlbedo: vec3f=clamp(surfaceAlbedo,vec3f(0.1f),vec3f(1.0f));diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;diffuseRoughnessTerm=diffuseRoughnessTerm/clampedAlbedo;diffuseRoughnessTerm=mix(vec3f(1.0f),diffuseRoughnessTerm,sqrt(clamp(mag*NoV,0.0f,1.0f)));
|
|
83
|
+
#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
|
|
84
|
+
let H: vec3f=(irradianceView+Ls)*0.5f;let VoH: f32=dot(irradianceView,H);diffuseRoughnessTerm=vec3f(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);
|
|
85
|
+
#endif
|
|
86
|
+
environmentIrradiance=environmentIrradiance.rgb*diffuseRoughnessTerm;
|
|
87
|
+
#endif
|
|
88
|
+
#endif
|
|
89
|
+
environmentIrradiance*=reflectionInfos.x;return environmentIrradiance;}
|
|
90
|
+
#ifdef REFLECTIONMAP_3D
|
|
91
|
+
fn createReflectionCoords(vPositionW: vec3f,normalW: vec3f)->vec3f
|
|
92
|
+
#else
|
|
93
|
+
fn createReflectionCoords(vPositionW: vec3f,normalW: vec3f)->vec2f
|
|
94
|
+
#endif
|
|
95
|
+
{var reflectionVector: vec3f=computeReflectionCoords(vec4f(vPositionW,1.0f),normalW);
|
|
96
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
97
|
+
reflectionVector.z*=-1.0;
|
|
98
|
+
#endif
|
|
99
|
+
#ifdef REFLECTIONMAP_3D
|
|
100
|
+
var reflectionCoords: vec3f=reflectionVector;
|
|
101
|
+
#else
|
|
102
|
+
var reflectionCoords: vec2f=reflectionVector.xy;
|
|
103
|
+
#ifdef REFLECTIONMAP_PROJECTION
|
|
104
|
+
reflectionCoords/=reflectionVector.z;
|
|
105
|
+
#endif
|
|
106
|
+
reflectionCoords.y=1.0f-reflectionCoords.y;
|
|
107
|
+
#endif
|
|
108
|
+
return reflectionCoords;}
|
|
109
|
+
fn sampleRadiance(
|
|
110
|
+
alphaG: f32
|
|
111
|
+
,reflectionMicrosurfaceInfos: vec3f
|
|
112
|
+
,reflectionInfos: vec2f
|
|
113
|
+
,geoInfo: geometryInfoOutParams
|
|
114
|
+
#ifdef REFLECTIONMAP_3D
|
|
115
|
+
,reflectionSampler: texture_cube<f32>
|
|
116
|
+
,reflectionSamplerSampler: sampler
|
|
117
|
+
,reflectionCoords: vec3f
|
|
118
|
+
#else
|
|
119
|
+
,reflectionSampler: texture_2d<f32>
|
|
120
|
+
,reflectionSamplerSampler: sampler
|
|
121
|
+
,reflectionCoords: vec2f
|
|
122
|
+
#endif
|
|
123
|
+
#ifdef REALTIME_FILTERING
|
|
124
|
+
,reflectionFilteringInfo: vec2f
|
|
125
|
+
#endif
|
|
126
|
+
)->vec3f {var environmentRadiance: vec4f=vec4f(0.f,0.f,0.f,0.f);
|
|
127
|
+
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
|
128
|
+
var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,alphaG,geoInfo.NdotVUnclamped);
|
|
129
|
+
#elif defined(LINEARSPECULARREFLECTION)
|
|
130
|
+
var reflectionLOD: f32=getLinearLodFromRoughness(reflectionMicrosurfaceInfos.x,roughness);
|
|
131
|
+
#else
|
|
132
|
+
var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,alphaG);
|
|
133
|
+
#endif
|
|
134
|
+
reflectionLOD=reflectionLOD*reflectionMicrosurfaceInfos.y+reflectionMicrosurfaceInfos.z;
|
|
135
|
+
#ifdef REALTIME_FILTERING
|
|
136
|
+
environmentRadiance=vec4f(radiance(alphaG,reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionFilteringInfo),1.0f);
|
|
137
|
+
#else
|
|
138
|
+
environmentRadiance=textureSampleLevel(reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionLOD);
|
|
139
|
+
#endif
|
|
140
|
+
#ifdef RGBDREFLECTION
|
|
141
|
+
environmentRadiance.rgb=fromRGBD(environmentRadiance);
|
|
142
|
+
#endif
|
|
143
|
+
#ifdef GAMMAREFLECTION
|
|
144
|
+
environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);
|
|
145
|
+
#endif
|
|
146
|
+
return environmentRadiance.rgb;}
|
|
147
|
+
#if defined(ANISOTROPIC)
|
|
148
|
+
fn sampleRadianceAnisotropic(
|
|
149
|
+
alphaG: f32
|
|
150
|
+
,reflectionMicrosurfaceInfos: vec3f
|
|
151
|
+
,reflectionInfos: vec2f
|
|
152
|
+
,geoInfo: geometryInfoAnisoOutParams
|
|
153
|
+
,normalW: vec3f
|
|
154
|
+
,viewDirectionW: vec3f
|
|
155
|
+
,positionW: vec3f
|
|
156
|
+
,noise: vec3f
|
|
157
|
+
#ifdef REFLECTIONMAP_3D
|
|
158
|
+
,reflectionSampler: texture_cube<f32>
|
|
159
|
+
,reflectionSamplerSampler: sampler
|
|
160
|
+
#else
|
|
161
|
+
,reflectionSampler: texture_2d<f32>
|
|
162
|
+
,reflectionSamplerSampler: sampler
|
|
163
|
+
#endif
|
|
164
|
+
#ifdef REALTIME_FILTERING
|
|
165
|
+
,reflectionFilteringInfo: vec2f
|
|
166
|
+
#endif
|
|
167
|
+
)->vec3f {var environmentRadiance: vec4f=vec4f(0.f,0.f,0.f,0.f);let alphaT=alphaG*sqrt(2.0f/(1.0f+(1.0f-geoInfo.anisotropy)*(1.0f-geoInfo.anisotropy)));let alphaB=(1.0f-geoInfo.anisotropy)*alphaT;let modifiedAlphaG=alphaB;
|
|
168
|
+
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
|
169
|
+
var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,modifiedAlphaG,geoInfo.NdotVUnclamped);
|
|
170
|
+
#elif defined(LINEARSPECULARREFLECTION)
|
|
171
|
+
var reflectionLOD: f32=getLinearLodFromRoughness(reflectionMicrosurfaceInfos.x,roughness);
|
|
172
|
+
#else
|
|
173
|
+
var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,modifiedAlphaG);
|
|
174
|
+
#endif
|
|
175
|
+
reflectionLOD=reflectionLOD*reflectionMicrosurfaceInfos.y+reflectionMicrosurfaceInfos.z;
|
|
176
|
+
#ifdef REALTIME_FILTERING
|
|
177
|
+
var view=(uniforms.reflectionMatrix*vec4f(viewDirectionW,0.0f)).xyz;var tangent=(uniforms.reflectionMatrix*vec4f(geoInfo.anisotropicTangent,0.0f)).xyz;var bitangent=(uniforms.reflectionMatrix*vec4f(geoInfo.anisotropicBitangent,0.0f)).xyz;var normal=(uniforms.reflectionMatrix*vec4f(normalW,0.0f)).xyz;
|
|
178
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
179
|
+
view.z*=-1.0f;tangent.z*=-1.0f;bitangent.z*=-1.0f;normal.z*=-1.0f;
|
|
180
|
+
#endif
|
|
181
|
+
environmentRadiance =
|
|
182
|
+
vec4f(radianceAnisotropic(alphaT,alphaB,reflectionSampler,reflectionSamplerSampler,
|
|
183
|
+
view,tangent,
|
|
184
|
+
bitangent,normal,
|
|
185
|
+
reflectionFilteringInfo,noise.xy),
|
|
186
|
+
1.0f);
|
|
187
|
+
#else
|
|
188
|
+
const samples: i32=16;var radianceSample=vec4f(0.0);var accumulatedRadiance=vec3f(0.0);var reflectionCoords=vec3f(0.0);var sample_weight=0.0f;var total_weight=0.0f;let step=1.0f/f32(max(samples-1,1));for (var i: i32=0; i<samples; i++) {var t: f32=mix(-1.0,1.0,f32(i)*step);t+=step*2.0*noise.x;sample_weight=max(1.0-abs(t),0.001);sample_weight*=sample_weight;t*=min(4.0*alphaT*geoInfo.anisotropy,1.0);var bentNormal: vec3f;if (t<0.0) {let blend: f32=t+1.0;bentNormal=normalize(mix(-geoInfo.anisotropicTangent,normalW,blend));} else if (t>0.0) {let blend: f32=t;bentNormal=normalize(mix(normalW,geoInfo.anisotropicTangent,blend));} else {bentNormal=normalW;}
|
|
189
|
+
reflectionCoords=createReflectionCoords(positionW,bentNormal);radianceSample=textureSampleLevel(reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionLOD);
|
|
190
|
+
#ifdef RGBDREFLECTION
|
|
191
|
+
accumulatedRadiance+=vec3f(sample_weight)*fromRGBD(radianceSample);
|
|
192
|
+
#elif defined(GAMMAREFLECTION)
|
|
193
|
+
accumulatedRadiance+=vec3f(sample_weight)*toLinearSpace(radianceSample.rgb);
|
|
194
|
+
#else
|
|
195
|
+
accumulatedRadiance+=vec3f(sample_weight)*radianceSample.rgb;
|
|
196
|
+
#endif
|
|
197
|
+
total_weight+=sample_weight;}
|
|
198
|
+
environmentRadiance=vec4f(accumulatedRadiance/vec3f(total_weight),1.0f);
|
|
199
|
+
#endif
|
|
200
|
+
environmentRadiance=vec4f(environmentRadiance.rgb*reflectionInfos.xxx,environmentRadiance.a);return environmentRadiance.rgb;}
|
|
201
|
+
#endif
|
|
202
|
+
fn conductorIblFresnel(reflectance: ReflectanceParams,NdotV: f32,roughness: f32,environmentBrdf: vec3f)->vec3f
|
|
203
|
+
{
|
|
204
|
+
#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
|
|
205
|
+
let albedoF0: vec3f=mix(reflectance.coloredF0,pow(reflectance.coloredF0,vec3f(1.4f)),roughness);return getF82Specular(NdotV,albedoF0,reflectance.coloredF90,roughness);
|
|
206
|
+
#else
|
|
207
|
+
return getReflectanceFromBRDFLookup(reflectance.coloredF0,reflectance.coloredF90,environmentBrdf);
|
|
208
|
+
#endif
|
|
209
|
+
}
|
|
210
|
+
#endif
|
|
211
|
+
`;
|
|
212
|
+
// Sideeffect
|
|
213
|
+
if (!ShaderStore.IncludesShadersStoreWGSL[name]) {
|
|
214
|
+
ShaderStore.IncludesShadersStoreWGSL[name] = shader;
|
|
215
|
+
}
|
|
216
|
+
/** @internal */
|
|
217
|
+
export const openpbrIblFunctionsWGSL = { name, shader };
|
|
218
|
+
//# sourceMappingURL=openpbrIblFunctions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrIblFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/openpbrIblFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Md,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"openpbrIblFunctions\";\nconst shader = `#ifdef REFLECTION\nfn sampleIrradiance(\nsurfaceNormal: vec3f\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\n,vEnvironmentIrradianceSH: vec3f\n#endif\n#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))\n,iblMatrix: mat4x4f\n#endif\n#ifdef USEIRRADIANCEMAP\n#ifdef REFLECTIONMAP_3D\n,irradianceSampler: texture_cube<f32>\n,irradianceSamplerSampler: sampler\n#else\n,irradianceSampler: texture_2d<f32>\n,irradianceSamplerSampler: sampler\n#endif\n#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION\n,reflectionDominantDirection: vec3f\n#endif\n#endif\n#ifdef REALTIME_FILTERING\n,reflectionFilteringInfo: vec2f\n#ifdef IBL_CDF_FILTERING\n,icdfSampler: texture_2d<f32>\n,icdfSamplerSampler: sampler\n#endif\n#endif\n,reflectionInfos: vec2f\n,viewDirectionW: vec3f\n,diffuseRoughness: f32\n,surfaceAlbedo: vec3f\n)->vec3f {var environmentIrradiance=vec3f(0.,0.,0.);\n#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))\nvar irradianceVector=(iblMatrix*vec4f(surfaceNormal,0.0f)).xyz;let irradianceView=(iblMatrix*vec4f(viewDirectionW,0.0f)).xyz;\n#if !defined(USE_IRRADIANCE_DOMINANT_DIRECTION) && !defined(REALTIME_FILTERING)\n#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY\n{let NdotV=max(dot(surfaceNormal,viewDirectionW),0.0f);irradianceVector=mix(irradianceVector,irradianceView,(0.5f*(1.0f-NdotV))*diffuseRoughness);}\n#endif\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0f;\n#endif\n#ifdef INVERTCUBICMAP\nirradianceVector.y*=-1.0f;\n#endif\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradianceSH;\n#else\n#if defined(REALTIME_FILTERING)\nenvironmentIrradiance=irradiance(reflectionSampler,reflectionSamplerSampler,irradianceVector,reflectionFilteringInfo,diffuseRoughness,surfaceAlbedo,irradianceView\n#ifdef IBL_CDF_FILTERING\n,icdfSampler\n,icdfSamplerSampler\n#endif\n);\n#else\nenvironmentIrradiance=computeEnvironmentIrradiance(irradianceVector);\n#endif\n#endif\n#elif defined(USEIRRADIANCEMAP)\n#ifdef REFLECTIONMAP_3D\nlet environmentIrradianceFromTexture: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,irradianceVector);\n#else\nlet environmentIrradianceFromTexture: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,reflectionCoords);\n#endif\nenvironmentIrradiance=environmentIrradianceFromTexture.rgb;\n#ifdef RGBDREFLECTION\nenvironmentIrradiance.rgb=fromRGBD(environmentIrradianceFromTexture);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);\n#endif\n#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION\nlet Ls: vec3f=normalize(reflectionDominantDirection);let NoL: f32=dot(irradianceVector,Ls);let NoV: f32=dot(irradianceVector,irradianceView);var diffuseRoughnessTerm=vec3f(1.0f);\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\nlet LoV: f32=dot (Ls,irradianceView);let mag: f32=length(reflectionDominantDirection)*2.0f;let clampedAlbedo: vec3f=clamp(surfaceAlbedo,vec3f(0.1f),vec3f(1.0f));diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;diffuseRoughnessTerm=diffuseRoughnessTerm/clampedAlbedo;diffuseRoughnessTerm=mix(vec3f(1.0f),diffuseRoughnessTerm,sqrt(clamp(mag*NoV,0.0f,1.0f)));\n#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY\nlet H: vec3f=(irradianceView+Ls)*0.5f;let VoH: f32=dot(irradianceView,H);diffuseRoughnessTerm=vec3f(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);\n#endif\nenvironmentIrradiance=environmentIrradiance.rgb*diffuseRoughnessTerm;\n#endif\n#endif\nenvironmentIrradiance*=reflectionInfos.x;return environmentIrradiance;}\n#ifdef REFLECTIONMAP_3D\nfn createReflectionCoords(vPositionW: vec3f,normalW: vec3f)->vec3f\n#else\nfn createReflectionCoords(vPositionW: vec3f,normalW: vec3f)->vec2f\n#endif\n{var reflectionVector: vec3f=computeReflectionCoords(vec4f(vPositionW,1.0f),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n#ifdef REFLECTIONMAP_3D\nvar reflectionCoords: vec3f=reflectionVector;\n#else\nvar reflectionCoords: vec2f=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0f-reflectionCoords.y;\n#endif\nreturn reflectionCoords;}\nfn sampleRadiance(\nalphaG: f32\n,reflectionMicrosurfaceInfos: vec3f\n,reflectionInfos: vec2f\n,geoInfo: geometryInfoOutParams\n#ifdef REFLECTIONMAP_3D\n,reflectionSampler: texture_cube<f32>\n,reflectionSamplerSampler: sampler\n,reflectionCoords: vec3f\n#else\n,reflectionSampler: texture_2d<f32>\n,reflectionSamplerSampler: sampler\n,reflectionCoords: vec2f\n#endif\n#ifdef REALTIME_FILTERING\n,reflectionFilteringInfo: vec2f\n#endif\n)->vec3f {var environmentRadiance: vec4f=vec4f(0.f,0.f,0.f,0.f);\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nvar reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,alphaG,geoInfo.NdotVUnclamped);\n#elif defined(LINEARSPECULARREFLECTION)\nvar reflectionLOD: f32=getLinearLodFromRoughness(reflectionMicrosurfaceInfos.x,roughness);\n#else\nvar reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,alphaG);\n#endif\nreflectionLOD=reflectionLOD*reflectionMicrosurfaceInfos.y+reflectionMicrosurfaceInfos.z;\n#ifdef REALTIME_FILTERING\nenvironmentRadiance=vec4f(radiance(alphaG,reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionFilteringInfo),1.0f);\n#else\nenvironmentRadiance=textureSampleLevel(reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionLOD);\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\nreturn environmentRadiance.rgb;}\n#if defined(ANISOTROPIC)\nfn sampleRadianceAnisotropic(\nalphaG: f32\n,reflectionMicrosurfaceInfos: vec3f\n,reflectionInfos: vec2f\n,geoInfo: geometryInfoAnisoOutParams\n,normalW: vec3f\n,viewDirectionW: vec3f\n,positionW: vec3f\n,noise: vec3f\n#ifdef REFLECTIONMAP_3D\n,reflectionSampler: texture_cube<f32>\n,reflectionSamplerSampler: sampler\n#else\n,reflectionSampler: texture_2d<f32>\n,reflectionSamplerSampler: sampler\n#endif\n#ifdef REALTIME_FILTERING\n,reflectionFilteringInfo: vec2f\n#endif\n)->vec3f {var environmentRadiance: vec4f=vec4f(0.f,0.f,0.f,0.f);let alphaT=alphaG*sqrt(2.0f/(1.0f+(1.0f-geoInfo.anisotropy)*(1.0f-geoInfo.anisotropy)));let alphaB=(1.0f-geoInfo.anisotropy)*alphaT;let modifiedAlphaG=alphaB;\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nvar reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,modifiedAlphaG,geoInfo.NdotVUnclamped);\n#elif defined(LINEARSPECULARREFLECTION)\nvar reflectionLOD: f32=getLinearLodFromRoughness(reflectionMicrosurfaceInfos.x,roughness);\n#else\nvar reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,modifiedAlphaG);\n#endif\nreflectionLOD=reflectionLOD*reflectionMicrosurfaceInfos.y+reflectionMicrosurfaceInfos.z;\n#ifdef REALTIME_FILTERING\nvar view=(uniforms.reflectionMatrix*vec4f(viewDirectionW,0.0f)).xyz;var tangent=(uniforms.reflectionMatrix*vec4f(geoInfo.anisotropicTangent,0.0f)).xyz;var bitangent=(uniforms.reflectionMatrix*vec4f(geoInfo.anisotropicBitangent,0.0f)).xyz;var normal=(uniforms.reflectionMatrix*vec4f(normalW,0.0f)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nview.z*=-1.0f;tangent.z*=-1.0f;bitangent.z*=-1.0f;normal.z*=-1.0f;\n#endif\nenvironmentRadiance =\nvec4f(radianceAnisotropic(alphaT,alphaB,reflectionSampler,reflectionSamplerSampler,\nview,tangent,\nbitangent,normal,\nreflectionFilteringInfo,noise.xy),\n1.0f);\n#else\nconst samples: i32=16;var radianceSample=vec4f(0.0);var accumulatedRadiance=vec3f(0.0);var reflectionCoords=vec3f(0.0);var sample_weight=0.0f;var total_weight=0.0f;let step=1.0f/f32(max(samples-1,1));for (var i: i32=0; i<samples; i++) {var t: f32=mix(-1.0,1.0,f32(i)*step);t+=step*2.0*noise.x;sample_weight=max(1.0-abs(t),0.001);sample_weight*=sample_weight;t*=min(4.0*alphaT*geoInfo.anisotropy,1.0);var bentNormal: vec3f;if (t<0.0) {let blend: f32=t+1.0;bentNormal=normalize(mix(-geoInfo.anisotropicTangent,normalW,blend));} else if (t>0.0) {let blend: f32=t;bentNormal=normalize(mix(normalW,geoInfo.anisotropicTangent,blend));} else {bentNormal=normalW;}\nreflectionCoords=createReflectionCoords(positionW,bentNormal);radianceSample=textureSampleLevel(reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionLOD);\n#ifdef RGBDREFLECTION\naccumulatedRadiance+=vec3f(sample_weight)*fromRGBD(radianceSample);\n#elif defined(GAMMAREFLECTION)\naccumulatedRadiance+=vec3f(sample_weight)*toLinearSpace(radianceSample.rgb);\n#else\naccumulatedRadiance+=vec3f(sample_weight)*radianceSample.rgb;\n#endif\ntotal_weight+=sample_weight;}\nenvironmentRadiance=vec4f(accumulatedRadiance/vec3f(total_weight),1.0f);\n#endif\nenvironmentRadiance=vec4f(environmentRadiance.rgb*reflectionInfos.xxx,environmentRadiance.a);return environmentRadiance.rgb;}\n#endif\nfn conductorIblFresnel(reflectance: ReflectanceParams,NdotV: f32,roughness: f32,environmentBrdf: vec3f)->vec3f\n{\n#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)\nlet albedoF0: vec3f=mix(reflectance.coloredF0,pow(reflectance.coloredF0,vec3f(1.4f)),roughness);return getF82Specular(NdotV,albedoF0,reflectance.coloredF90,roughness);\n#else\nreturn getReflectanceFromBRDFLookup(reflectance.coloredF0,reflectance.coloredF90,environmentBrdf);\n#endif\n}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrIblFunctionsWGSL = { name, shader };\n"]}
|