@babylonjs/core 8.28.1 → 8.28.3
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/frameGraphContext.d.ts +2 -1
- package/FrameGraph/frameGraphContext.js +4 -1
- package/FrameGraph/frameGraphContext.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/Background/backgroundMaterial.d.ts +19 -91
- package/Materials/Background/backgroundMaterial.js +17 -245
- package/Materials/Background/backgroundMaterial.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/nodeMaterial.d.ts +57 -69
- package/Materials/Node/nodeMaterial.js +9 -86
- package/Materials/Node/nodeMaterial.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/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/floatingOriginMatrixOverrides.d.ts +3 -0
- package/Materials/floatingOriginMatrixOverrides.js +91 -0
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -0
- 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/reflectiveShadowMap.d.ts +3 -3
- package/Shaders/ShadersInclude/backgroundUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/backgroundUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/clusteredLightingFunctions.js +3 -1
- package/Shaders/ShadersInclude/clusteredLightingFunctions.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/helperFunctions.js +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/importanceSampling.js +4 -0
- package/Shaders/ShadersInclude/importanceSampling.js.map +1 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js +1 -0
- package/Shaders/ShadersInclude/lightsFragmentFunctions.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/pbrClusteredLightingFunctions.js +1 -0
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.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
- package/scene.d.ts +21 -0
- package/scene.js +29 -3
- package/scene.js.map +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
const name = "openpbrDirectLighting";
|
|
4
|
+
const shader = `#ifdef LIGHT{X}
|
|
5
|
+
{vec3 slab_diffuse=vec3(0.,0.,0.);vec3 slab_subsurface=vec3(0.,0.,0.);vec3 slab_translucent=vec3(0.,0.,0.);vec3 slab_glossy=vec3(0.,0.,0.);float specularFresnel=0.0;vec3 slab_metal=vec3(0.,0.,0.);vec3 slab_coat=vec3(0.,0.,0.);float coatFresnel=0.0;vec3 slab_fuzz=vec3(0.,0.,0.);
|
|
6
|
+
#ifdef HEMILIGHT{X}
|
|
7
|
+
slab_diffuse=computeHemisphericDiffuseLighting(preInfo{X},lightColor{X}.rgb,light{X}.vLightGround);
|
|
8
|
+
#elif defined(AREALIGHT{X})
|
|
9
|
+
slab_diffuse=computeAreaDiffuseLighting(preInfo{X},lightColor{X}.rgb);
|
|
10
|
+
#else
|
|
11
|
+
slab_diffuse=computeDiffuseLighting(preInfo{X},lightColor{X}.rgb);
|
|
12
|
+
#endif
|
|
13
|
+
#ifdef PROJECTEDLIGHTTEXTURE{X}
|
|
14
|
+
slab_diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},vPositionW);
|
|
15
|
+
#endif
|
|
16
|
+
numLights+=1.0;
|
|
17
|
+
#if AREALIGHT{X}
|
|
18
|
+
slab_glossy=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);
|
|
19
|
+
#else
|
|
20
|
+
{
|
|
21
|
+
#ifdef ANISOTROPIC_BASE
|
|
22
|
+
slab_glossy=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,
|
|
23
|
+
baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,
|
|
24
|
+
0.0,lightColor{X}.rgb);
|
|
25
|
+
#else
|
|
26
|
+
slab_glossy=computeSpecularLighting(preInfo{X},normalW,baseDielectricReflectance.coloredF0,baseDielectricReflectance.coloredF90,specular_roughness,lightColor{X}.rgb);
|
|
27
|
+
#endif
|
|
28
|
+
float NdotH=dot(normalW,preInfo{X}.H);specularFresnel=fresnelSchlickGGX(NdotH,baseDielectricReflectance.F0,baseDielectricReflectance.F90);}
|
|
29
|
+
#endif
|
|
30
|
+
#if AREALIGHT{X}
|
|
31
|
+
slab_metal=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);
|
|
32
|
+
#else
|
|
33
|
+
{
|
|
34
|
+
#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
|
|
35
|
+
vec3 coloredFresnel=specular_weight*getF82Specular(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90,specular_roughness);
|
|
36
|
+
#else
|
|
37
|
+
vec3 coloredFresnel=fresnelSchlickGGX(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90);
|
|
38
|
+
#endif
|
|
39
|
+
#ifdef ANISOTROPIC_BASE
|
|
40
|
+
slab_metal=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,0.0,lightColor{X}.rgb);
|
|
41
|
+
#else
|
|
42
|
+
slab_metal=computeSpecularLighting(preInfo{X},normalW,baseConductorReflectance.coloredF0,coloredFresnel,specular_roughness,lightColor{X}.rgb);
|
|
43
|
+
#endif
|
|
44
|
+
}
|
|
45
|
+
#endif
|
|
46
|
+
#if AREALIGHT{X}
|
|
47
|
+
slab_coat=computeAreaSpecularLighting(preInfoCoat{X},light{X}.vLightSpecular.rgb,coatReflectance.F0,coatReflectance.F90);
|
|
48
|
+
#else
|
|
49
|
+
{
|
|
50
|
+
#ifdef ANISOTROPIC_COAT
|
|
51
|
+
slab_coat=computeAnisotropicSpecularLighting(preInfoCoat{X},viewDirectionW,coatNormalW,
|
|
52
|
+
coatGeoInfo.anisotropicTangent,coatGeoInfo.anisotropicBitangent,coatGeoInfo.anisotropy,
|
|
53
|
+
0.0,lightColor{X}.rgb);
|
|
54
|
+
#else
|
|
55
|
+
slab_coat=computeSpecularLighting(preInfoCoat{X},coatNormalW,vec3(coatReflectance.F0),vec3(1.0),coat_roughness,lightColor{X}.rgb);
|
|
56
|
+
#endif
|
|
57
|
+
float NdotH=dot(coatNormalW,preInfoCoat{X}.H);coatFresnel=fresnelSchlickGGX(NdotH,coatReflectance.F0,coatReflectance.F90);}
|
|
58
|
+
#endif
|
|
59
|
+
vec3 coatAbsorption=vec3(1.0);if (coat_weight>0.0) {float cosTheta_view=max(preInfoCoat{X}.NdotV,0.001);float cosTheta_light=max(preInfoCoat{X}.NdotL,0.001);float fresnel_view=coatReflectance.F0+(1.0-coatReflectance.F0)*pow(1.0-cosTheta_view,5.0);float fresnel_light=coatReflectance.F0+(1.0-coatReflectance.F0)*pow(1.0-cosTheta_light,5.0);float averageReflectance=(fresnel_view+fresnel_light)*0.5;float darkened_transmission=(1.0-averageReflectance)/(1.0+averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);float sin2=1.0-cosTheta_view*cosTheta_view;sin2=sin2/(coat_ior*coat_ior);float cos_t=sqrt(1.0-sin2);float coatPathLength=1.0/cos_t;vec3 colored_transmission=pow(coat_color,vec3(coatPathLength));coatAbsorption=mix(vec3(1.0),colored_transmission*darkened_transmission,coat_weight);}
|
|
60
|
+
slab_diffuse*=base_color.rgb;vec3 material_opaque_base=mix(slab_diffuse,slab_subsurface,subsurface_weight);vec3 material_dielectric_base=mix(material_opaque_base,slab_translucent,transmission_weight);vec3 material_dielectric_gloss=layer(material_dielectric_base,slab_glossy,specularFresnel,vec3(1.0),specular_color);vec3 material_base_substrate=mix(material_dielectric_gloss,slab_metal,base_metalness);vec3 material_coated_base=layer(material_base_substrate,slab_coat,coatFresnel,coatAbsorption,vec3(1.0));material_surface_direct+=mix(material_coated_base,slab_fuzz,fuzz_weight);}
|
|
61
|
+
#endif
|
|
62
|
+
`;
|
|
63
|
+
// Sideeffect
|
|
64
|
+
if (!ShaderStore.IncludesShadersStore[name]) {
|
|
65
|
+
ShaderStore.IncludesShadersStore[name] = shader;
|
|
66
|
+
}
|
|
67
|
+
/** @internal */
|
|
68
|
+
export const openpbrDirectLighting = { name, shader };
|
|
69
|
+
//# sourceMappingURL=openpbrDirectLighting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrDirectLighting.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/openpbrDirectLighting.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Dd,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,qBAAqB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"openpbrDirectLighting\";\nconst shader = `#ifdef LIGHT{X}\n{vec3 slab_diffuse=vec3(0.,0.,0.);vec3 slab_subsurface=vec3(0.,0.,0.);vec3 slab_translucent=vec3(0.,0.,0.);vec3 slab_glossy=vec3(0.,0.,0.);float specularFresnel=0.0;vec3 slab_metal=vec3(0.,0.,0.);vec3 slab_coat=vec3(0.,0.,0.);float coatFresnel=0.0;vec3 slab_fuzz=vec3(0.,0.,0.);\n#ifdef HEMILIGHT{X}\nslab_diffuse=computeHemisphericDiffuseLighting(preInfo{X},lightColor{X}.rgb,light{X}.vLightGround);\n#elif defined(AREALIGHT{X})\nslab_diffuse=computeAreaDiffuseLighting(preInfo{X},lightColor{X}.rgb);\n#else\nslab_diffuse=computeDiffuseLighting(preInfo{X},lightColor{X}.rgb);\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nslab_diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},vPositionW);\n#endif\nnumLights+=1.0;\n#if AREALIGHT{X}\nslab_glossy=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);\n#else\n{\n#ifdef ANISOTROPIC_BASE\nslab_glossy=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,\nbaseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,\n0.0,lightColor{X}.rgb);\n#else\nslab_glossy=computeSpecularLighting(preInfo{X},normalW,baseDielectricReflectance.coloredF0,baseDielectricReflectance.coloredF90,specular_roughness,lightColor{X}.rgb);\n#endif\nfloat NdotH=dot(normalW,preInfo{X}.H);specularFresnel=fresnelSchlickGGX(NdotH,baseDielectricReflectance.F0,baseDielectricReflectance.F90);}\n#endif\n#if AREALIGHT{X}\nslab_metal=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);\n#else\n{\n#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)\nvec3 coloredFresnel=specular_weight*getF82Specular(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90,specular_roughness);\n#else\nvec3 coloredFresnel=fresnelSchlickGGX(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90);\n#endif\n#ifdef ANISOTROPIC_BASE\nslab_metal=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,0.0,lightColor{X}.rgb);\n#else\nslab_metal=computeSpecularLighting(preInfo{X},normalW,baseConductorReflectance.coloredF0,coloredFresnel,specular_roughness,lightColor{X}.rgb);\n#endif\n}\n#endif\n#if AREALIGHT{X}\nslab_coat=computeAreaSpecularLighting(preInfoCoat{X},light{X}.vLightSpecular.rgb,coatReflectance.F0,coatReflectance.F90);\n#else\n{\n#ifdef ANISOTROPIC_COAT\nslab_coat=computeAnisotropicSpecularLighting(preInfoCoat{X},viewDirectionW,coatNormalW,\ncoatGeoInfo.anisotropicTangent,coatGeoInfo.anisotropicBitangent,coatGeoInfo.anisotropy,\n0.0,lightColor{X}.rgb);\n#else\nslab_coat=computeSpecularLighting(preInfoCoat{X},coatNormalW,vec3(coatReflectance.F0),vec3(1.0),coat_roughness,lightColor{X}.rgb);\n#endif\nfloat NdotH=dot(coatNormalW,preInfoCoat{X}.H);coatFresnel=fresnelSchlickGGX(NdotH,coatReflectance.F0,coatReflectance.F90);}\n#endif\nvec3 coatAbsorption=vec3(1.0);if (coat_weight>0.0) {float cosTheta_view=max(preInfoCoat{X}.NdotV,0.001);float cosTheta_light=max(preInfoCoat{X}.NdotL,0.001);float fresnel_view=coatReflectance.F0+(1.0-coatReflectance.F0)*pow(1.0-cosTheta_view,5.0);float fresnel_light=coatReflectance.F0+(1.0-coatReflectance.F0)*pow(1.0-cosTheta_light,5.0);float averageReflectance=(fresnel_view+fresnel_light)*0.5;float darkened_transmission=(1.0-averageReflectance)/(1.0+averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);float sin2=1.0-cosTheta_view*cosTheta_view;sin2=sin2/(coat_ior*coat_ior);float cos_t=sqrt(1.0-sin2);float coatPathLength=1.0/cos_t;vec3 colored_transmission=pow(coat_color,vec3(coatPathLength));coatAbsorption=mix(vec3(1.0),colored_transmission*darkened_transmission,coat_weight);}\nslab_diffuse*=base_color.rgb;vec3 material_opaque_base=mix(slab_diffuse,slab_subsurface,subsurface_weight);vec3 material_dielectric_base=mix(material_opaque_base,slab_translucent,transmission_weight);vec3 material_dielectric_gloss=layer(material_dielectric_base,slab_glossy,specularFresnel,vec3(1.0),specular_color);vec3 material_base_substrate=mix(material_dielectric_gloss,slab_metal,base_metalness);vec3 material_coated_base=layer(material_base_substrate,slab_coat,coatFresnel,coatAbsorption,vec3(1.0));material_surface_direct+=mix(material_coated_base,slab_fuzz,fuzz_weight);}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const openpbrDirectLighting = { name, shader };\n"]}
|
|
@@ -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
|
+
preLightingInfo preInfo{X};preLightingInfo preInfoCoat{X};vec4 lightColor{X}=light{X}.vLightDiffuse;float shadow{X}=1.;
|
|
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.0;
|
|
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.IncludesShadersStore[name]) {
|
|
76
|
+
ShaderStore.IncludesShadersStore[name] = shader;
|
|
77
|
+
}
|
|
78
|
+
/** @internal */
|
|
79
|
+
export const openpbrDirectLightingInit = { name, shader };
|
|
80
|
+
//# sourceMappingURL=openpbrDirectLightingInit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrDirectLightingInit.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/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,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1C,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,yBAAyB,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}\npreLightingInfo preInfo{X};preLightingInfo preInfoCoat{X};vec4 lightColor{X}=light{X}.vLightDiffuse;float shadow{X}=1.;\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.0;\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.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const openpbrDirectLightingInit = { name, shader };\n"]}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
const name = "openpbrDirectLightingShadow";
|
|
4
|
+
const shader = `#ifdef LIGHT{X}
|
|
5
|
+
#ifdef SHADOW{X}
|
|
6
|
+
#ifdef SHADOWCSM{X}
|
|
7
|
+
for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++)
|
|
8
|
+
{
|
|
9
|
+
#ifdef SHADOWCSM_RIGHTHANDED{X}
|
|
10
|
+
diff{X}=viewFrustumZ{X}[i]+vPositionFromCamera{X}.z;
|
|
11
|
+
#else
|
|
12
|
+
diff{X}=viewFrustumZ{X}[i]-vPositionFromCamera{X}.z;
|
|
13
|
+
#endif
|
|
14
|
+
if (diff{X}>=0.) {index{X}=i;break;}}
|
|
15
|
+
#ifdef SHADOWCSMUSESHADOWMAXZ{X}
|
|
16
|
+
if (index{X}>=0)
|
|
17
|
+
#endif
|
|
18
|
+
{
|
|
19
|
+
#if defined(SHADOWPCF{X})
|
|
20
|
+
#if defined(SHADOWLOWQUALITY{X})
|
|
21
|
+
shadow{X}=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
22
|
+
#elif defined(SHADOWMEDIUMQUALITY{X})
|
|
23
|
+
shadow{X}=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
24
|
+
#else
|
|
25
|
+
shadow{X}=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
26
|
+
#endif
|
|
27
|
+
#elif defined(SHADOWPCSS{X})
|
|
28
|
+
#if defined(SHADOWLOWQUALITY{X})
|
|
29
|
+
shadow{X}=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
|
|
30
|
+
#elif defined(SHADOWMEDIUMQUALITY{X})
|
|
31
|
+
shadow{X}=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
|
|
32
|
+
#else
|
|
33
|
+
shadow{X}=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
|
|
34
|
+
#endif
|
|
35
|
+
#else
|
|
36
|
+
shadow{X}=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
37
|
+
#endif
|
|
38
|
+
#ifdef SHADOWCSMDEBUG{X}
|
|
39
|
+
shadowDebug{X}=vec3(shadow{X})*vCascadeColorsMultiplier{X}[index{X}];
|
|
40
|
+
#endif
|
|
41
|
+
#ifndef SHADOWCSMNOBLEND{X}
|
|
42
|
+
float frustumLength=frustumLengths{X}[index{X}];float diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)
|
|
43
|
+
{index{X}+=1;float nextShadow=0.;
|
|
44
|
+
#if defined(SHADOWPCF{X})
|
|
45
|
+
#if defined(SHADOWLOWQUALITY{X})
|
|
46
|
+
nextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
47
|
+
#elif defined(SHADOWMEDIUMQUALITY{X})
|
|
48
|
+
nextShadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
49
|
+
#else
|
|
50
|
+
nextShadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
51
|
+
#endif
|
|
52
|
+
#elif defined(SHADOWPCSS{X})
|
|
53
|
+
#if defined(SHADOWLOWQUALITY{X})
|
|
54
|
+
nextShadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
|
|
55
|
+
#elif defined(SHADOWMEDIUMQUALITY{X})
|
|
56
|
+
nextShadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
|
|
57
|
+
#else
|
|
58
|
+
nextShadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
|
|
59
|
+
#endif
|
|
60
|
+
#else
|
|
61
|
+
nextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
62
|
+
#endif
|
|
63
|
+
shadow{X}=mix(nextShadow,shadow{X},diffRatio);
|
|
64
|
+
#ifdef SHADOWCSMDEBUG{X}
|
|
65
|
+
shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);
|
|
66
|
+
#endif
|
|
67
|
+
}
|
|
68
|
+
#endif
|
|
69
|
+
}
|
|
70
|
+
#elif defined(SHADOWCLOSEESM{X})
|
|
71
|
+
#if defined(SHADOWCUBE{X})
|
|
72
|
+
shadow{X}=computeShadowWithCloseESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
|
|
73
|
+
#else
|
|
74
|
+
shadow{X}=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
|
|
75
|
+
#endif
|
|
76
|
+
#elif defined(SHADOWESM{X})
|
|
77
|
+
#if defined(SHADOWCUBE{X})
|
|
78
|
+
shadow{X}=computeShadowWithESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
|
|
79
|
+
#else
|
|
80
|
+
shadow{X}=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
|
|
81
|
+
#endif
|
|
82
|
+
#elif defined(SHADOWPOISSON{X})
|
|
83
|
+
#if defined(SHADOWCUBE{X})
|
|
84
|
+
shadow{X}=computeShadowWithPoissonSamplingCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);
|
|
85
|
+
#else
|
|
86
|
+
shadow{X}=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
87
|
+
#endif
|
|
88
|
+
#elif defined(SHADOWPCF{X})
|
|
89
|
+
#if defined(SHADOWLOWQUALITY{X})
|
|
90
|
+
shadow{X}=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
91
|
+
#elif defined(SHADOWMEDIUMQUALITY{X})
|
|
92
|
+
shadow{X}=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
93
|
+
#else
|
|
94
|
+
shadow{X}=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
95
|
+
#endif
|
|
96
|
+
#elif defined(SHADOWPCSS{X})
|
|
97
|
+
#if defined(SHADOWLOWQUALITY{X})
|
|
98
|
+
shadow{X}=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
99
|
+
#elif defined(SHADOWMEDIUMQUALITY{X})
|
|
100
|
+
shadow{X}=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
101
|
+
#else
|
|
102
|
+
shadow{X}=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
103
|
+
#endif
|
|
104
|
+
#else
|
|
105
|
+
#if defined(SHADOWCUBE{X})
|
|
106
|
+
shadow{X}=computeShadowCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.depthValues);
|
|
107
|
+
#else
|
|
108
|
+
shadow{X}=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
|
109
|
+
#endif
|
|
110
|
+
#endif
|
|
111
|
+
#ifdef SHADOWONLY
|
|
112
|
+
#ifndef SHADOWINUSE
|
|
113
|
+
#define SHADOWINUSE
|
|
114
|
+
#endif
|
|
115
|
+
globalShadow+=shadow{X};shadowLightCount+=1.0;
|
|
116
|
+
#endif
|
|
117
|
+
#else
|
|
118
|
+
shadow{X}=1.;
|
|
119
|
+
#endif
|
|
120
|
+
aggShadow+=shadow{X};
|
|
121
|
+
#endif
|
|
122
|
+
`;
|
|
123
|
+
// Sideeffect
|
|
124
|
+
if (!ShaderStore.IncludesShadersStore[name]) {
|
|
125
|
+
ShaderStore.IncludesShadersStore[name] = shader;
|
|
126
|
+
}
|
|
127
|
+
/** @internal */
|
|
128
|
+
export const openpbrDirectLightingShadow = { name, shader };
|
|
129
|
+
//# sourceMappingURL=openpbrDirectLightingShadow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrDirectLightingShadow.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/openpbrDirectLightingShadow.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,6BAA6B,CAAC;AAC3C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsHd,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,2BAA2B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"openpbrDirectLightingShadow\";\nconst shader = `#ifdef LIGHT{X}\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nfor (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++)\n{\n#ifdef SHADOWCSM_RIGHTHANDED{X}\ndiff{X}=viewFrustumZ{X}[i]+vPositionFromCamera{X}.z;\n#else\ndiff{X}=viewFrustumZ{X}[i]-vPositionFromCamera{X}.z;\n#endif\nif (diff{X}>=0.) {index{X}=i;break;}}\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nif (index{X}>=0)\n#endif\n{\n#if defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow{X}=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow{X}=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow{X}=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow{X}=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow{X}=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#else\nshadow{X}=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#endif\n#else\nshadow{X}=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nshadowDebug{X}=vec3(shadow{X})*vCascadeColorsMultiplier{X}[index{X}];\n#endif\n#ifndef SHADOWCSMNOBLEND{X}\nfloat frustumLength=frustumLengths{X}[index{X}];float diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)\n{index{X}+=1;float nextShadow=0.;\n#if defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nnextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nnextShadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nnextShadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nnextShadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#elif defined(SHADOWMEDIUMQUALITY{X})\nnextShadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#else\nnextShadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#endif\n#else\nnextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\nshadow{X}=mix(nextShadow,shadow{X},diffRatio);\n#ifdef SHADOWCSMDEBUG{X}\nshadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);\n#endif\n}\n#endif\n}\n#elif defined(SHADOWCLOSEESM{X})\n#if defined(SHADOWCUBE{X})\nshadow{X}=computeShadowWithCloseESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow{X}=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow{X}=computeShadowWithESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow{X}=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow{X}=computeShadowWithPoissonSamplingCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow{X}=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow{X}=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow{X}=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow{X}=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow{X}=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow{X}=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow{X}=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow{X}=computeShadowCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow{X}=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow{X};shadowLightCount+=1.0;\n#endif\n#else\nshadow{X}=1.;\n#endif\naggShadow+=shadow{X};\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const openpbrDirectLightingShadow = { name, shader };\n"]}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
const name = "openpbrEnvironmentLighting";
|
|
4
|
+
const shader = `#ifdef REFLECTION
|
|
5
|
+
vec3 baseDiffuseEnvironmentLight=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
|
+
,reflectionMatrix
|
|
12
|
+
#endif
|
|
13
|
+
#ifdef USEIRRADIANCEMAP
|
|
14
|
+
,irradianceSampler
|
|
15
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
16
|
+
,vReflectionDominantDirection
|
|
17
|
+
#endif
|
|
18
|
+
#endif
|
|
19
|
+
#ifdef REALTIME_FILTERING
|
|
20
|
+
,vReflectionFilteringInfo
|
|
21
|
+
#ifdef IBL_CDF_FILTERING
|
|
22
|
+
,icdfSampler
|
|
23
|
+
#endif
|
|
24
|
+
#endif
|
|
25
|
+
,vReflectionInfos
|
|
26
|
+
,viewDirectionW
|
|
27
|
+
,base_diffuse_roughness
|
|
28
|
+
,base_color
|
|
29
|
+
);
|
|
30
|
+
#ifdef REFLECTIONMAP_3D
|
|
31
|
+
vec3 reflectionCoords=vec3(0.,0.,0.);
|
|
32
|
+
#else
|
|
33
|
+
vec2 reflectionCoords=vec2(0.,0.);
|
|
34
|
+
#endif
|
|
35
|
+
float specularAlphaG=specular_roughness*specular_roughness;
|
|
36
|
+
#ifdef ANISOTROPIC_BASE
|
|
37
|
+
vec3 baseSpecularEnvironmentLight=sampleRadianceAnisotropic(specularAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
|
|
38
|
+
,baseGeoInfo
|
|
39
|
+
,normalW
|
|
40
|
+
,viewDirectionW
|
|
41
|
+
,vPositionW
|
|
42
|
+
,noise
|
|
43
|
+
,reflectionSampler
|
|
44
|
+
#ifdef REALTIME_FILTERING
|
|
45
|
+
,vReflectionFilteringInfo
|
|
46
|
+
#endif
|
|
47
|
+
);
|
|
48
|
+
#else
|
|
49
|
+
reflectionCoords=createReflectionCoords(vPositionW,normalW);vec3 baseSpecularEnvironmentLight=sampleRadiance(specularAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
|
|
50
|
+
,baseGeoInfo
|
|
51
|
+
,reflectionSampler
|
|
52
|
+
,reflectionCoords
|
|
53
|
+
#ifdef REALTIME_FILTERING
|
|
54
|
+
,vReflectionFilteringInfo
|
|
55
|
+
#endif
|
|
56
|
+
);
|
|
57
|
+
#endif
|
|
58
|
+
#ifdef ANISOTROPIC_BASE
|
|
59
|
+
baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG*specularAlphaG*max(1.0-baseGeoInfo.anisotropy,0.3));
|
|
60
|
+
#else
|
|
61
|
+
baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG);
|
|
62
|
+
#endif
|
|
63
|
+
vec3 coatEnvironmentLight=vec3(0.,0.,0.);if (coat_weight>0.0) {
|
|
64
|
+
#ifdef REFLECTIONMAP_3D
|
|
65
|
+
vec3 reflectionCoords=vec3(0.,0.,0.);
|
|
66
|
+
#else
|
|
67
|
+
vec2 reflectionCoords=vec2(0.,0.);
|
|
68
|
+
#endif
|
|
69
|
+
reflectionCoords=createReflectionCoords(vPositionW,coatNormalW);float coatAlphaG=coat_roughness*coat_roughness;
|
|
70
|
+
#ifdef ANISOTROPIC_COAT
|
|
71
|
+
coatEnvironmentLight=sampleRadianceAnisotropic(coatAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
|
|
72
|
+
,coatGeoInfo
|
|
73
|
+
,coatNormalW
|
|
74
|
+
,viewDirectionW
|
|
75
|
+
,vPositionW
|
|
76
|
+
,noise
|
|
77
|
+
,reflectionSampler
|
|
78
|
+
#ifdef REALTIME_FILTERING
|
|
79
|
+
,vReflectionFilteringInfo
|
|
80
|
+
#endif
|
|
81
|
+
);
|
|
82
|
+
#else
|
|
83
|
+
coatEnvironmentLight=sampleRadiance(coatAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
|
|
84
|
+
,coatGeoInfo
|
|
85
|
+
,reflectionSampler
|
|
86
|
+
,reflectionCoords
|
|
87
|
+
#ifdef REALTIME_FILTERING
|
|
88
|
+
,vReflectionFilteringInfo
|
|
89
|
+
#endif
|
|
90
|
+
);
|
|
91
|
+
#endif
|
|
92
|
+
}
|
|
93
|
+
float dielectricIblFresnel=getReflectanceFromBRDFLookup(vec3(baseDielectricReflectance.F0),vec3(baseDielectricReflectance.F90),baseGeoInfo.environmentBrdf).r;vec3 dielectricIblColoredFresnel=getReflectanceFromBRDFLookup(baseDielectricReflectance.coloredF0,baseDielectricReflectance.coloredF90,baseGeoInfo.environmentBrdf);vec3 conductorIblFresnel=conductorIblFresnel(baseConductorReflectance,baseGeoInfo.NdotV,specular_roughness,baseGeoInfo.environmentBrdf);float coatIblFresnel=0.0;if (coat_weight>0.0) {coatIblFresnel=getReflectanceFromBRDFLookup(vec3(coatReflectance.F0),vec3(coatReflectance.F90),coatGeoInfo.environmentBrdf).r;}
|
|
94
|
+
vec3 slab_diffuse_ibl=vec3(0.,0.,0.);vec3 slab_glossy_ibl=vec3(0.,0.,0.);vec3 slab_metal_ibl=vec3(0.,0.,0.);vec3 slab_coat_ibl=vec3(0.,0.,0.);slab_diffuse_ibl=baseDiffuseEnvironmentLight*vLightingIntensity.z;slab_diffuse_ibl*=aoOut.ambientOcclusionColor;slab_glossy_ibl=baseSpecularEnvironmentLight*vLightingIntensity.z;slab_metal_ibl=baseSpecularEnvironmentLight*conductorIblFresnel*vLightingIntensity.z;vec3 coatAbsorption=vec3(1.0);if (coat_weight>0.0) {slab_coat_ibl=coatEnvironmentLight*vLightingIntensity.z;float hemisphere_avg_fresnel=coatReflectance.F0+0.5*(1.0-coatReflectance.F0);float averageReflectance=(coatIblFresnel+hemisphere_avg_fresnel)*0.5;float roughnessFactor=1.0-coat_roughness*0.5;averageReflectance*=roughnessFactor;float darkened_transmission=(1.0-averageReflectance)*(1.0-averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);float sin2=1.0-coatGeoInfo.NdotV*coatGeoInfo.NdotV;sin2=sin2/(coat_ior*coat_ior);float cos_t=sqrt(1.0-sin2);float coatPathLength=1.0/cos_t;vec3 colored_transmission=pow(coat_color,vec3(coatPathLength));coatAbsorption=mix(vec3(1.0),colored_transmission*darkened_transmission,coat_weight);}
|
|
95
|
+
vec3 slab_subsurface_ibl=vec3(0.,0.,0.);vec3 slab_translucent_base_ibl=vec3(0.,0.,0.);vec3 slab_fuzz_ibl=vec3(0.,0.,0.);slab_diffuse_ibl*=base_color.rgb;
|
|
96
|
+
#define CUSTOM_FRAGMENT_BEFORE_IBLLAYERCOMPOSITION
|
|
97
|
+
vec3 material_opaque_base_ibl=mix(slab_diffuse_ibl,slab_subsurface_ibl,subsurface_weight);vec3 material_dielectric_base_ibl=mix(material_opaque_base_ibl,slab_translucent_base_ibl,transmission_weight);vec3 material_dielectric_gloss_ibl=layer(material_dielectric_base_ibl,slab_glossy_ibl,dielectricIblFresnel,vec3(1.0),specular_color);vec3 material_base_substrate_ibl=mix(material_dielectric_gloss_ibl,slab_metal_ibl,base_metalness);vec3 material_coated_base_ibl=layer(material_base_substrate_ibl,slab_coat_ibl,coatIblFresnel,coatAbsorption,vec3(1.0));material_surface_ibl=mix(material_coated_base_ibl,slab_fuzz_ibl,fuzz_weight);
|
|
98
|
+
#endif
|
|
99
|
+
`;
|
|
100
|
+
// Sideeffect
|
|
101
|
+
if (!ShaderStore.IncludesShadersStore[name]) {
|
|
102
|
+
ShaderStore.IncludesShadersStore[name] = shader;
|
|
103
|
+
}
|
|
104
|
+
/** @internal */
|
|
105
|
+
export const openpbrEnvironmentLighting = { name, shader };
|
|
106
|
+
//# sourceMappingURL=openpbrEnvironmentLighting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrEnvironmentLighting.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Fd,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,0BAA0B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"openpbrEnvironmentLighting\";\nconst shader = `#ifdef REFLECTION\nvec3 baseDiffuseEnvironmentLight=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,reflectionMatrix\n#endif\n#ifdef USEIRRADIANCEMAP\n,irradianceSampler\n#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION\n,vReflectionDominantDirection\n#endif\n#endif\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#ifdef IBL_CDF_FILTERING\n,icdfSampler\n#endif\n#endif\n,vReflectionInfos\n,viewDirectionW\n,base_diffuse_roughness\n,base_color\n);\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=vec3(0.,0.,0.);\n#else\nvec2 reflectionCoords=vec2(0.,0.);\n#endif\nfloat specularAlphaG=specular_roughness*specular_roughness;\n#ifdef ANISOTROPIC_BASE\nvec3 baseSpecularEnvironmentLight=sampleRadianceAnisotropic(specularAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos\n,baseGeoInfo\n,normalW\n,viewDirectionW\n,vPositionW\n,noise\n,reflectionSampler\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#endif\n);\n#else\nreflectionCoords=createReflectionCoords(vPositionW,normalW);vec3 baseSpecularEnvironmentLight=sampleRadiance(specularAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos\n,baseGeoInfo\n,reflectionSampler\n,reflectionCoords\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#endif\n);\n#endif\n#ifdef ANISOTROPIC_BASE\nbaseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG*specularAlphaG*max(1.0-baseGeoInfo.anisotropy,0.3));\n#else\nbaseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG);\n#endif\nvec3 coatEnvironmentLight=vec3(0.,0.,0.);if (coat_weight>0.0) {\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=vec3(0.,0.,0.);\n#else\nvec2 reflectionCoords=vec2(0.,0.);\n#endif\nreflectionCoords=createReflectionCoords(vPositionW,coatNormalW);float coatAlphaG=coat_roughness*coat_roughness;\n#ifdef ANISOTROPIC_COAT\ncoatEnvironmentLight=sampleRadianceAnisotropic(coatAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos\n,coatGeoInfo\n,coatNormalW\n,viewDirectionW\n,vPositionW\n,noise\n,reflectionSampler\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#endif\n);\n#else\ncoatEnvironmentLight=sampleRadiance(coatAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos\n,coatGeoInfo\n,reflectionSampler\n,reflectionCoords\n#ifdef REALTIME_FILTERING\n,vReflectionFilteringInfo\n#endif\n);\n#endif\n}\nfloat dielectricIblFresnel=getReflectanceFromBRDFLookup(vec3(baseDielectricReflectance.F0),vec3(baseDielectricReflectance.F90),baseGeoInfo.environmentBrdf).r;vec3 dielectricIblColoredFresnel=getReflectanceFromBRDFLookup(baseDielectricReflectance.coloredF0,baseDielectricReflectance.coloredF90,baseGeoInfo.environmentBrdf);vec3 conductorIblFresnel=conductorIblFresnel(baseConductorReflectance,baseGeoInfo.NdotV,specular_roughness,baseGeoInfo.environmentBrdf);float coatIblFresnel=0.0;if (coat_weight>0.0) {coatIblFresnel=getReflectanceFromBRDFLookup(vec3(coatReflectance.F0),vec3(coatReflectance.F90),coatGeoInfo.environmentBrdf).r;}\nvec3 slab_diffuse_ibl=vec3(0.,0.,0.);vec3 slab_glossy_ibl=vec3(0.,0.,0.);vec3 slab_metal_ibl=vec3(0.,0.,0.);vec3 slab_coat_ibl=vec3(0.,0.,0.);slab_diffuse_ibl=baseDiffuseEnvironmentLight*vLightingIntensity.z;slab_diffuse_ibl*=aoOut.ambientOcclusionColor;slab_glossy_ibl=baseSpecularEnvironmentLight*vLightingIntensity.z;slab_metal_ibl=baseSpecularEnvironmentLight*conductorIblFresnel*vLightingIntensity.z;vec3 coatAbsorption=vec3(1.0);if (coat_weight>0.0) {slab_coat_ibl=coatEnvironmentLight*vLightingIntensity.z;float hemisphere_avg_fresnel=coatReflectance.F0+0.5*(1.0-coatReflectance.F0);float averageReflectance=(coatIblFresnel+hemisphere_avg_fresnel)*0.5;float roughnessFactor=1.0-coat_roughness*0.5;averageReflectance*=roughnessFactor;float darkened_transmission=(1.0-averageReflectance)*(1.0-averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);float sin2=1.0-coatGeoInfo.NdotV*coatGeoInfo.NdotV;sin2=sin2/(coat_ior*coat_ior);float cos_t=sqrt(1.0-sin2);float coatPathLength=1.0/cos_t;vec3 colored_transmission=pow(coat_color,vec3(coatPathLength));coatAbsorption=mix(vec3(1.0),colored_transmission*darkened_transmission,coat_weight);}\nvec3 slab_subsurface_ibl=vec3(0.,0.,0.);vec3 slab_translucent_base_ibl=vec3(0.,0.,0.);vec3 slab_fuzz_ibl=vec3(0.,0.,0.);slab_diffuse_ibl*=base_color.rgb;\n#define CUSTOM_FRAGMENT_BEFORE_IBLLAYERCOMPOSITION\nvec3 material_opaque_base_ibl=mix(slab_diffuse_ibl,slab_subsurface_ibl,subsurface_weight);vec3 material_dielectric_base_ibl=mix(material_opaque_base_ibl,slab_translucent_base_ibl,transmission_weight);vec3 material_dielectric_gloss_ibl=layer(material_dielectric_base_ibl,slab_glossy_ibl,dielectricIblFresnel,vec3(1.0),specular_color);vec3 material_base_substrate_ibl=mix(material_dielectric_gloss_ibl,slab_metal_ibl,base_metalness);vec3 material_coated_base_ibl=layer(material_base_substrate_ibl,slab_coat_ibl,coatIblFresnel,coatAbsorption,vec3(1.0));material_surface_ibl=mix(material_coated_base_ibl,slab_fuzz_ibl,fuzz_weight);\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const openpbrEnvironmentLighting = { name, shader };\n"]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
import "./decalFragmentDeclaration.js";
|
|
4
|
+
const name = "openpbrFragmentDeclaration";
|
|
5
|
+
const shader = `uniform vec4 vEyePosition;uniform float vBaseWeight;uniform vec4 vBaseColor;uniform float vBaseDiffuseRoughness;uniform vec4 vReflectanceInfo;uniform vec4 vSpecularColor;uniform vec3 vSpecularAnisotropy;uniform float vCoatWeight;uniform vec3 vCoatColor;uniform float vCoatRoughness;uniform float vCoatRoughnessAnisotropy;uniform float vCoatIor;uniform float vCoatDarkening;uniform vec2 vGeometryCoatTangent;uniform vec3 vEmissionColor;uniform vec4 vLightingIntensity;uniform float visibility;
|
|
6
|
+
#ifdef BASE_COLOR
|
|
7
|
+
uniform vec2 vBaseColorInfos;
|
|
8
|
+
#endif
|
|
9
|
+
#ifdef BASE_WEIGHT
|
|
10
|
+
uniform vec2 vBaseWeightInfos;
|
|
11
|
+
#endif
|
|
12
|
+
#ifdef BASE_METALNESS
|
|
13
|
+
uniform vec2 vBaseMetalnessInfos;
|
|
14
|
+
#endif
|
|
15
|
+
#ifdef BASE_DIFFUSE_ROUGHNESS
|
|
16
|
+
uniform vec2 vBaseDiffuseRoughnessInfos;
|
|
17
|
+
#endif
|
|
18
|
+
#ifdef SPECULAR_WEIGHT
|
|
19
|
+
uniform vec2 vSpecularWeightInfos;
|
|
20
|
+
#endif
|
|
21
|
+
#ifdef SPECULAR_COLOR
|
|
22
|
+
uniform vec2 vSpecularColorInfos;
|
|
23
|
+
#endif
|
|
24
|
+
#ifdef SPECULAR_ROUGHNESS
|
|
25
|
+
uniform vec2 vSpecularRoughnessInfos;
|
|
26
|
+
#endif
|
|
27
|
+
#ifdef SPECULAR_ROUGHNESS_ANISOTROPY
|
|
28
|
+
uniform vec2 vSpecularRoughnessAnisotropyInfos;
|
|
29
|
+
#endif
|
|
30
|
+
#ifdef SPECULAR_IOR
|
|
31
|
+
uniform vec2 vSpecularIorInfos;
|
|
32
|
+
#endif
|
|
33
|
+
#ifdef AMBIENT_OCCLUSION
|
|
34
|
+
uniform vec2 vAmbientOcclusionInfos;
|
|
35
|
+
#endif
|
|
36
|
+
#ifdef GEOMETRY_NORMAL
|
|
37
|
+
uniform vec2 vGeometryNormalInfos;uniform vec2 vTangentSpaceParams;
|
|
38
|
+
#endif
|
|
39
|
+
#ifdef GEOMETRY_TANGENT
|
|
40
|
+
uniform vec2 vGeometryTangentInfos;
|
|
41
|
+
#endif
|
|
42
|
+
#ifdef GEOMETRY_COAT_NORMAL
|
|
43
|
+
uniform vec2 vGeometryCoatNormalInfos;
|
|
44
|
+
#endif
|
|
45
|
+
#ifdef GEOMETRY_OPACITY
|
|
46
|
+
uniform vec2 vGeometryOpacityInfos;
|
|
47
|
+
#endif
|
|
48
|
+
#ifdef EMISSION_COLOR
|
|
49
|
+
uniform vec2 vEmissionColorInfos;
|
|
50
|
+
#endif
|
|
51
|
+
#ifdef COAT_WEIGHT
|
|
52
|
+
uniform vec2 vCoatWeightInfos;
|
|
53
|
+
#endif
|
|
54
|
+
#ifdef COAT_COLOR
|
|
55
|
+
uniform vec2 vCoatColorInfos;
|
|
56
|
+
#endif
|
|
57
|
+
#ifdef COAT_ROUGHNESS
|
|
58
|
+
uniform vec2 vCoatRoughnessInfos;
|
|
59
|
+
#endif
|
|
60
|
+
#ifdef COAT_ROUGHNESS_ANISOTROPY
|
|
61
|
+
uniform vec2 vCoatRoughnessAnisotropyInfos;
|
|
62
|
+
#endif
|
|
63
|
+
#ifdef COAT_IOR
|
|
64
|
+
uniform vec2 vCoatIorInfos;
|
|
65
|
+
#endif
|
|
66
|
+
#ifdef COAT_DARKENING
|
|
67
|
+
uniform vec2 vCoatDarkeningInfos;
|
|
68
|
+
#endif
|
|
69
|
+
#ifdef GEOMETRY_COAT_TANGENT
|
|
70
|
+
uniform vec2 vGeometryCoatTangentInfos;
|
|
71
|
+
#endif
|
|
72
|
+
#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION) || defined(PREPASS)
|
|
73
|
+
uniform mat4 view;
|
|
74
|
+
#endif
|
|
75
|
+
#ifdef REFLECTION
|
|
76
|
+
uniform vec2 vReflectionInfos;
|
|
77
|
+
#ifdef REALTIME_FILTERING
|
|
78
|
+
uniform vec2 vReflectionFilteringInfo;
|
|
79
|
+
#endif
|
|
80
|
+
uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;
|
|
81
|
+
#if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION)
|
|
82
|
+
uniform vec3 vReflectionDominantDirection;
|
|
83
|
+
#endif
|
|
84
|
+
#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
|
|
85
|
+
uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize;
|
|
86
|
+
#endif
|
|
87
|
+
#endif
|
|
88
|
+
#ifdef PREPASS
|
|
89
|
+
#ifdef SS_SCATTERING
|
|
90
|
+
uniform float scatteringDiffusionProfile;
|
|
91
|
+
#endif
|
|
92
|
+
#endif
|
|
93
|
+
#if DEBUGMODE>0
|
|
94
|
+
uniform vec2 vDebugMode;
|
|
95
|
+
#endif
|
|
96
|
+
#ifdef DETAIL
|
|
97
|
+
uniform vec4 vDetailInfos;
|
|
98
|
+
#endif
|
|
99
|
+
#include<decalFragmentDeclaration>
|
|
100
|
+
#ifdef USESPHERICALFROMREFLECTIONMAP
|
|
101
|
+
#ifdef SPHERICAL_HARMONICS
|
|
102
|
+
uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22;
|
|
103
|
+
#else
|
|
104
|
+
uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX;
|
|
105
|
+
#endif
|
|
106
|
+
#endif
|
|
107
|
+
#define ADDITIONAL_FRAGMENT_DECLARATION
|
|
108
|
+
`;
|
|
109
|
+
// Sideeffect
|
|
110
|
+
if (!ShaderStore.IncludesShadersStore[name]) {
|
|
111
|
+
ShaderStore.IncludesShadersStore[name] = shader;
|
|
112
|
+
}
|
|
113
|
+
/** @internal */
|
|
114
|
+
export const openpbrFragmentDeclaration = { name, shader };
|
|
115
|
+
//# sourceMappingURL=openpbrFragmentDeclaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrFragmentDeclaration.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/openpbrFragmentDeclaration.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,4BAA4B,CAAC;AAEpC,MAAM,IAAI,GAAG,4BAA4B,CAAC;AAC1C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuGd,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,0BAA0B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\nimport \"./decalFragmentDeclaration\";\n\nconst name = \"openpbrFragmentDeclaration\";\nconst shader = `uniform vec4 vEyePosition;uniform float vBaseWeight;uniform vec4 vBaseColor;uniform float vBaseDiffuseRoughness;uniform vec4 vReflectanceInfo;uniform vec4 vSpecularColor;uniform vec3 vSpecularAnisotropy;uniform float vCoatWeight;uniform vec3 vCoatColor;uniform float vCoatRoughness;uniform float vCoatRoughnessAnisotropy;uniform float vCoatIor;uniform float vCoatDarkening;uniform vec2 vGeometryCoatTangent;uniform vec3 vEmissionColor;uniform vec4 vLightingIntensity;uniform float visibility;\n#ifdef BASE_COLOR\nuniform vec2 vBaseColorInfos;\n#endif\n#ifdef BASE_WEIGHT\nuniform vec2 vBaseWeightInfos;\n#endif\n#ifdef BASE_METALNESS\nuniform vec2 vBaseMetalnessInfos;\n#endif\n#ifdef BASE_DIFFUSE_ROUGHNESS\nuniform vec2 vBaseDiffuseRoughnessInfos;\n#endif\n#ifdef SPECULAR_WEIGHT\nuniform vec2 vSpecularWeightInfos;\n#endif\n#ifdef SPECULAR_COLOR\nuniform vec2 vSpecularColorInfos;\n#endif\n#ifdef SPECULAR_ROUGHNESS\nuniform vec2 vSpecularRoughnessInfos;\n#endif\n#ifdef SPECULAR_ROUGHNESS_ANISOTROPY\nuniform vec2 vSpecularRoughnessAnisotropyInfos;\n#endif\n#ifdef SPECULAR_IOR\nuniform vec2 vSpecularIorInfos;\n#endif\n#ifdef AMBIENT_OCCLUSION\nuniform vec2 vAmbientOcclusionInfos;\n#endif\n#ifdef GEOMETRY_NORMAL\nuniform vec2 vGeometryNormalInfos;uniform vec2 vTangentSpaceParams;\n#endif\n#ifdef GEOMETRY_TANGENT\nuniform vec2 vGeometryTangentInfos;\n#endif\n#ifdef GEOMETRY_COAT_NORMAL\nuniform vec2 vGeometryCoatNormalInfos;\n#endif\n#ifdef GEOMETRY_OPACITY\nuniform vec2 vGeometryOpacityInfos;\n#endif\n#ifdef EMISSION_COLOR\nuniform vec2 vEmissionColorInfos;\n#endif\n#ifdef COAT_WEIGHT\nuniform vec2 vCoatWeightInfos;\n#endif\n#ifdef COAT_COLOR\nuniform vec2 vCoatColorInfos;\n#endif\n#ifdef COAT_ROUGHNESS\nuniform vec2 vCoatRoughnessInfos;\n#endif\n#ifdef COAT_ROUGHNESS_ANISOTROPY\nuniform vec2 vCoatRoughnessAnisotropyInfos;\n#endif\n#ifdef COAT_IOR\nuniform vec2 vCoatIorInfos;\n#endif\n#ifdef COAT_DARKENING\nuniform vec2 vCoatDarkeningInfos;\n#endif\n#ifdef GEOMETRY_COAT_TANGENT\nuniform vec2 vGeometryCoatTangentInfos;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION) || defined(PREPASS)\nuniform mat4 view;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REALTIME_FILTERING\nuniform vec2 vReflectionFilteringInfo;\n#endif\nuniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION)\nuniform vec3 vReflectionDominantDirection;\n#endif\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;uniform vec3 vReflectionSize;\n#endif\n#endif\n#ifdef PREPASS\n#ifdef SS_SCATTERING\nuniform float scatteringDiffusionProfile;\n#endif\n#endif\n#if DEBUGMODE>0\nuniform vec2 vDebugMode;\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\n#endif\n#include<decalFragmentDeclaration>\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nuniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22;\n#else\nuniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX;\n#endif\n#endif\n#define ADDITIONAL_FRAGMENT_DECLARATION\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const openpbrFragmentDeclaration = { name, shader };\n"]}
|