@babylonjs/core 9.4.1 → 9.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cameras/Inputs/freeCameraTouchInput.js +5 -3
- package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraVirtualJoystickInput.js +11 -7
- package/Cameras/Inputs/freeCameraVirtualJoystickInput.js.map +1 -1
- package/Cameras/arcRotateCamera.js +2 -1
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/camera.js +1 -0
- package/Cameras/camera.js.map +1 -1
- package/Cameras/followCamera.js +1 -1
- package/Cameras/followCamera.js.map +1 -1
- package/Collisions/gpuPicker.d.ts +12 -0
- package/Collisions/gpuPicker.js +51 -0
- package/Collisions/gpuPicker.js.map +1 -1
- package/Culling/ray.core.js +46 -2
- package/Culling/ray.core.js.map +1 -1
- package/Engines/Native/nativeHelpers.js +26 -0
- package/Engines/Native/nativeHelpers.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +26 -0
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/constants.d.ts +52 -0
- package/Engines/constants.js +52 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/engine.d.ts +13 -0
- package/Engines/thinEngine.js +52 -0
- package/Engines/thinEngine.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +10 -3
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.d.ts +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js +36 -3
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js.map +1 -1
- package/FlowGraph/flowGraphEventBlock.d.ts +13 -0
- package/FlowGraph/flowGraphEventBlock.js +21 -2
- package/FlowGraph/flowGraphEventBlock.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.js +26 -0
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/Layers/layer.js +5 -1
- package/Layers/layer.js.map +1 -1
- package/LensFlares/lensFlareSystem.js +1 -0
- package/LensFlares/lensFlareSystem.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.js +11 -1
- package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +14 -0
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.d.ts +1 -0
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js +6 -3
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +2 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +10 -3
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.d.ts +2 -1
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js +10 -4
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.d.ts +11 -0
- package/Materials/PBR/openpbrMaterial.js +59 -12
- package/Materials/PBR/openpbrMaterial.js.map +1 -1
- package/Materials/Textures/Loaders/ktxTextureLoader.js +26 -0
- package/Materials/Textures/Loaders/ktxTextureLoader.js.map +1 -1
- package/Materials/Textures/envCubeTexture.js +33 -15
- package/Materials/Textures/envCubeTexture.js.map +1 -1
- package/Materials/material.d.ts +16 -1
- package/Materials/material.js +16 -1
- package/Materials/material.js.map +1 -1
- package/Materials/standardMaterial.js +4 -2
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +16 -18
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.d.ts +24 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js +93 -18
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js.map +1 -1
- package/Meshes/abstractMesh.js +1 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/mesh.js +3 -0
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/transformNode.d.ts +6 -0
- package/Meshes/transformNode.js +6 -0
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/brdfTextureTools.d.ts +12 -0
- package/Misc/brdfTextureTools.js +22 -0
- package/Misc/brdfTextureTools.js.map +1 -1
- package/Misc/depthReducer.js +1 -1
- package/Misc/depthReducer.js.map +1 -1
- package/Misc/snapshotRenderingHelper.d.ts +7 -1
- package/Misc/snapshotRenderingHelper.js +7 -1
- package/Misc/snapshotRenderingHelper.js.map +1 -1
- package/Misc/textureTools.js +26 -0
- package/Misc/textureTools.js.map +1 -1
- package/Misc/tools.js +1 -1
- package/Misc/tools.js.map +1 -1
- package/Particles/Node/Blocks/Update/updateFlowMapBlock.js +17 -10
- package/Particles/Node/Blocks/Update/updateFlowMapBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/updateNoiseBlock.js +14 -0
- package/Particles/Node/Blocks/Update/updateNoiseBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleSourceTextureBlock.js +114 -12
- package/Particles/Node/Blocks/particleSourceTextureBlock.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +11 -0
- package/Particles/Node/nodeParticleBuildState.js +15 -0
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.js +23 -22
- package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
- package/Particles/gpuParticleSystem.js +1 -0
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.js +1 -0
- package/Particles/thinParticleSystem.js.map +1 -1
- package/PostProcesses/postProcessManager.d.ts +2 -0
- package/PostProcesses/postProcessManager.js +14 -8
- package/PostProcesses/postProcessManager.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +12 -9
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Rendering/depthRendererSceneComponent.js +6 -6
- package/Rendering/depthRendererSceneComponent.js.map +1 -1
- package/Rendering/iblCdfGeneratorSceneComponent.d.ts +6 -0
- package/Rendering/iblCdfGeneratorSceneComponent.js +16 -0
- package/Rendering/iblCdfGeneratorSceneComponent.js.map +1 -1
- package/Rendering/prePassRenderer.d.ts +4 -1
- package/Rendering/prePassRenderer.js +31 -9
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js +1 -1
- package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrDirectLighting.js +18 -10
- package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +36 -14
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrIblFunctions.js +8 -5
- package/Shaders/ShadersInclude/openpbrIblFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBRDFFunctions.js +10 -6
- package/Shaders/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
- package/Shaders/openpbr.fragment.js +14 -15
- package/Shaders/openpbr.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +19 -11
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js +3 -3
- package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +36 -14
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js +5 -3
- package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js +5 -6
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
- package/ShadersWGSL/openpbr.fragment.js +16 -17
- package/ShadersWGSL/openpbr.fragment.js.map +1 -1
- package/Sprites/spriteManager.js +1 -0
- package/Sprites/spriteManager.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +16 -0
- package/scene.js +13 -0
- package/scene.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openpbr.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/openpbr.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,iCAAiC,CAAC;AACzC,OAAO,6CAA6C,CAAC;AACrD,OAAO,wCAAwC,CAAC;AAChD,OAAO,8CAA8C,CAAC;AACtD,OAAO,2CAA2C,CAAC;AACnD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,qDAAqD,CAAC;AAC7D,OAAO,6CAA6C,CAAC;AACrD,OAAO,+CAA+C,CAAC;AACvD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,yCAAyC,CAAC;AACjD,OAAO,kCAAkC,CAAC;AAC1C,OAAO,gDAAgD,CAAC;AACxD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,2CAA2C,CAAC;AACnD,OAAO,2CAA2C,CAAC;AACnD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,kDAAkD,CAAC;AAC1D,OAAO,oDAAoD,CAAC;AAC5D,OAAO,mCAAmC,CAAC;AAC3C,OAAO,wCAAwC,CAAC;AAChD,OAAO,6CAA6C,CAAC;AACrD,OAAO,kCAAkC,CAAC;AAC1C,OAAO,wDAAwD,CAAC;AAChE,OAAO,oDAAoD,CAAC;AAC5D,OAAO,qCAAqC,CAAC;AAC7C,OAAO,+CAA+C,CAAC;AACvD,OAAO,8CAA8C,CAAC;AACtD,OAAO,mDAAmD,CAAC;AAC3D,OAAO,sCAAsC,CAAC;AAC9C,OAAO,sCAAsC,CAAC;AAC9C,OAAO,yCAAyC,CAAC;AACjD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,0CAA0C,CAAC;AAClD,OAAO,2CAA2C,CAAC;AACnD,OAAO,0CAA0C,CAAC;AAClD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,+CAA+C,CAAC;AACvD,OAAO,6CAA6C,CAAC;AACrD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,2CAA2C,CAAC;AACnD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,8CAA8C,CAAC;AACtD,OAAO,+BAA+B,CAAC;AACvC,OAAO,gDAAgD,CAAC;AACxD,OAAO,6CAA6C,CAAC;AACrD,OAAO,4CAA4C,CAAC;AACpD,OAAO,wCAAwC,CAAC;AAChD,OAAO,mCAAmC,CAAC;AAC3C,OAAO,8BAA8B,CAAC;AACtC,OAAO,0CAA0C,CAAC;AAClD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,8BAA8B,CAAC;AACtC,OAAO,2BAA2B,CAAC;AAEnC,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAClC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Od,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/prePassDeclaration\";\nimport \"./ShadersInclude/oitDeclaration\";\nimport \"./ShadersInclude/openpbrFragmentDeclaration\";\nimport \"./ShadersInclude/openpbrUboDeclaration\";\nimport \"./ShadersInclude/pbrFragmentExtraDeclaration\";\nimport \"./ShadersInclude/lightFragmentDeclaration\";\nimport \"./ShadersInclude/lightUboDeclaration\";\nimport \"./ShadersInclude/openpbrFragmentSamplersDeclaration\";\nimport \"./ShadersInclude/imageProcessingDeclaration\";\nimport \"./ShadersInclude/clipPlaneFragmentDeclaration\";\nimport \"./ShadersInclude/logDepthDeclaration\";\nimport \"./ShadersInclude/fogFragmentDeclaration\";\nimport \"./ShadersInclude/helperFunctions\";\nimport \"./ShadersInclude/subSurfaceScatteringFunctions\";\nimport \"./ShadersInclude/importanceSampling\";\nimport \"./ShadersInclude/pbrHelperFunctions\";\nimport \"./ShadersInclude/imageProcessingFunctions\";\nimport \"./ShadersInclude/shadowsFragmentFunctions\";\nimport \"./ShadersInclude/harmonicsFunctions\";\nimport \"./ShadersInclude/pbrDirectLightingSetupFunctions\";\nimport \"./ShadersInclude/pbrDirectLightingFalloffFunctions\";\nimport \"./ShadersInclude/pbrBRDFFunctions\";\nimport \"./ShadersInclude/hdrFilteringFunctions\";\nimport \"./ShadersInclude/pbrDirectLightingFunctions\";\nimport \"./ShadersInclude/pbrIBLFunctions\";\nimport \"./ShadersInclude/openpbrNormalMapFragmentMainFunctions\";\nimport \"./ShadersInclude/openpbrNormalMapFragmentFunctions\";\nimport \"./ShadersInclude/reflectionFunction\";\nimport \"./ShadersInclude/openpbrDielectricReflectance\";\nimport \"./ShadersInclude/openpbrConductorReflectance\";\nimport \"./ShadersInclude/openpbrAmbientOcclusionFunctions\";\nimport \"./ShadersInclude/openpbrGeometryInfo\";\nimport \"./ShadersInclude/openpbrIblFunctions\";\nimport \"./ShadersInclude/openpbrVolumeFunctions\";\nimport \"./ShadersInclude/clipPlaneFragment\";\nimport \"./ShadersInclude/pbrBlockNormalGeometric\";\nimport \"./ShadersInclude/openpbrNormalMapFragment\";\nimport \"./ShadersInclude/openpbrBlockNormalFinal\";\nimport \"./ShadersInclude/openpbrBaseLayerData\";\nimport \"./ShadersInclude/openpbrTransmissionLayerData\";\nimport \"./ShadersInclude/openpbrSubsurfaceLayerData\";\nimport \"./ShadersInclude/openpbrCoatLayerData\";\nimport \"./ShadersInclude/openpbrThinFilmLayerData\";\nimport \"./ShadersInclude/openpbrFuzzLayerData\";\nimport \"./ShadersInclude/openpbrAmbientOcclusionData\";\nimport \"./ShadersInclude/depthPrePass\";\nimport \"./ShadersInclude/openpbrBackgroundTransmission\";\nimport \"./ShadersInclude/openpbrEnvironmentLighting\";\nimport \"./ShadersInclude/openpbrDirectLightingInit\";\nimport \"./ShadersInclude/openpbrDirectLighting\";\nimport \"./ShadersInclude/logDepthFragment\";\nimport \"./ShadersInclude/fogFragment\";\nimport \"./ShadersInclude/pbrBlockImageProcessing\";\nimport \"./ShadersInclude/openpbrBlockPrePass\";\nimport \"./ShadersInclude/oitFragment\";\nimport \"./ShadersInclude/pbrDebug\";\n\nconst name = \"openpbrPixelShader\";\nconst shader = `#define OPENPBR_FRAGMENT_SHADER\n#define CUSTOM_FRAGMENT_EXTENSION\n#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<prePassDeclaration>[SCENE_MRT_COUNT]\nprecision highp float;\n#include<oitDeclaration>\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE\n#endif\n#include<__decl__openpbrFragment>\n#include<pbrFragmentExtraDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<openpbrFragmentSamplersDeclaration>\n#include<imageProcessingDeclaration>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#include<helperFunctions>\n#include<subSurfaceScatteringFunctions>\n#include<importanceSampling>\n#include<pbrHelperFunctions>\n#include<imageProcessingFunctions>\n#include<shadowsFragmentFunctions>\n#include<harmonicsFunctions>\n#include<pbrDirectLightingSetupFunctions>\n#include<pbrDirectLightingFalloffFunctions>\n#include<pbrBRDFFunctions>\n#include<hdrFilteringFunctions>\n#include<pbrDirectLightingFunctions>\n#include<pbrIBLFunctions>\n#include<openpbrNormalMapFragmentMainFunctions>\n#include<openpbrNormalMapFragmentFunctions>\n#ifdef REFLECTION\n#include<reflectionFunction>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\n#include<openpbrDielectricReflectance>\n#include<openpbrConductorReflectance>\n#include<openpbrAmbientOcclusionFunctions>\n#include<openpbrGeometryInfo>\n#include<openpbrIblFunctions>\n#include<openpbrVolumeFunctions>\nvec3 layer(vec3 slab_bottom,vec3 slab_top,float lerp_factor,vec3 bottom_multiplier,vec3 top_multiplier) {return mix(slab_bottom*bottom_multiplier,slab_top*top_multiplier,lerp_factor);}\nvoid main(void) {\n#ifdef PREPASS_IRRADIANCE\nvec3 total_direct_diffuse=vec3(0.0);\n#endif\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\n#include<pbrBlockNormalGeometric>\nvec3 coatNormalW=normalW;\n#include<openpbrNormalMapFragment>\n#include<openpbrBlockNormalFinal>\n#include<openpbrBaseLayerData>\n#include<openpbrTransmissionLayerData>\n#include<openpbrSubsurfaceLayerData>\n#include<openpbrCoatLayerData>\n#include<openpbrThinFilmLayerData>\n#include<openpbrFuzzLayerData>\n#include<openpbrAmbientOcclusionData>\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\n#include<depthPrePass>\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n#ifdef ANISOTROPIC_COAT\ngeometryInfoAnisoOutParams coatGeoInfo=geometryInfoAniso(\ncoatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW\n,vec3(geometry_coat_tangent.x,geometry_coat_tangent.y,coat_roughness_anisotropy),TBN\n);\n#else\ngeometryInfoOutParams coatGeoInfo=geometryInfo(\ncoatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW\n);\n#endif\nspecular_roughness=mix(specular_roughness,pow(min(1.0,pow(specular_roughness,4.0)+2.0*pow(coat_roughness,4.0)),0.25),coat_weight);\n#ifdef ANISOTROPIC_BASE\ngeometryInfoAnisoOutParams baseGeoInfo=geometryInfoAniso(\nnormalW,viewDirectionW.xyz,specular_roughness,geometricNormalW\n,vec3(geometry_tangent.x,geometry_tangent.y,specular_roughness_anisotropy),TBN\n);\n#else\ngeometryInfoOutParams baseGeoInfo=geometryInfo(\nnormalW,viewDirectionW.xyz,specular_roughness,geometricNormalW\n);\n#endif\n#ifdef FUZZ\nvec3 fuzzNormalW=normalize(mix(normalW,coatNormalW,coat_weight));vec3 fuzzTangent=normalize(TBN[0]);fuzzTangent=normalize(fuzzTangent-dot(fuzzTangent,fuzzNormalW)*fuzzNormalW);vec3 fuzzBitangent=cross(fuzzNormalW,fuzzTangent);geometryInfoOutParams fuzzGeoInfo=geometryInfo(\nfuzzNormalW,viewDirectionW.xyz,fuzz_roughness,geometricNormalW\n);\n#endif\nReflectanceParams coatReflectance;coatReflectance=dielectricReflectance(\ncoat_ior \n,1.0 \n,vec3(1.0)\n,coat_weight\n);\n#ifdef THIN_FILM\nfloat thin_film_outside_ior=mix(1.0,coat_ior,coat_weight);\n#endif\nReflectanceParams baseDielectricReflectance;{float effectiveCoatIor=mix(1.0,coat_ior,coat_weight);baseDielectricReflectance=dielectricReflectance(\nspecular_ior \n,effectiveCoatIor \n,specular_color\n,specular_weight\n);}\nReflectanceParams baseConductorReflectance;baseConductorReflectance=conductorReflectance(base_color,specular_color,specular_weight);vec3 volume_absorption=vec3(1.0);vec3 transmission_tint=vec3(1.0);float surface_translucency_weight=0.0;\n#if defined(REFRACTED_BACKGROUND) || defined(REFRACTED_ENVIRONMENT) || defined(REFRACTED_LIGHTS)\n#if defined(GEOMETRY_THIN_WALLED)\nvec3 refractedViewVector=-viewDirectionW;\n#else\n#ifdef DISPERSION\nvec3 refractedViewVectors[3];float iorDispersionSpread=transmission_dispersion_scale/transmission_dispersion_abbe_number*(specular_ior-1.0);vec3 dispersion_iors=vec3(specular_ior-iorDispersionSpread,specular_ior,specular_ior+iorDispersionSpread);for (int i=0; i<3; i++) {refractedViewVectors[i]=double_refract(-viewDirectionW,normalW,dispersion_iors[i]); }\n#else\nvec3 refractedViewVector=double_refract(-viewDirectionW,normalW,specular_ior);\n#endif\n#endif\n#ifdef GEOMETRY_THIN_WALLED\nfloat transmission_roughness=specular_roughness;\n#else\nfloat transmission_roughness=specular_roughness*clamp(4.0*(specular_ior-1.0),0.001,1.0);\n#endif\n#if (defined(TRANSMISSION_SLAB) || defined(SUBSURFACE_SLAB))\nOpenPBRHomogeneousVolume volumeParams;{\n#if defined(TRANSMISSION_SLAB)\nOpenPBRHomogeneousVolume transmissionVolumeParams=computeOpenPBRTransmissionVolume(\ntransmission_color.rgb,\ntransmission_depth,\ntransmission_scatter.rgb,\ntransmission_scatter_anisotropy\n);\n#endif\n#if defined(SUBSURFACE_SLAB)\nOpenPBRHomogeneousVolume subsurfaceVolumeParams=computeOpenPBRSubsurfaceVolume(\nsubsurface_color.rgb,\nsubsurface_radius,\nsubsurface_radius_scale.rgb,\nsubsurface_scatter_anisotropy\n);\n#endif\n#if !defined(TRANSMISSION_SLAB)\nvolumeParams=subsurfaceVolumeParams;surface_translucency_weight=subsurface_weight;\n#elif !defined(SUBSURFACE_SLAB)\nvolumeParams=transmissionVolumeParams;\n#ifdef TRANSMISSION_SLAB_VOLUME\nvolumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo);\n#endif\nsurface_translucency_weight=transmission_weight;\n#else\nfloat subsurface_fraction_of_dielectric=(1.0f-transmission_weight)*subsurface_weight;float subsurface_and_transmission_fraction_of_dielectric=subsurface_fraction_of_dielectric+transmission_weight;float reciprocal_of_subsurface_and_transmission_fraction_of_dielectric =\n1.0f/maxEps(subsurface_and_transmission_fraction_of_dielectric);float trans_weight=transmission_weight*reciprocal_of_subsurface_and_transmission_fraction_of_dielectric;float subsurf_weight=subsurface_fraction_of_dielectric*reciprocal_of_subsurface_and_transmission_fraction_of_dielectric;volumeParams.scatter_coeff=transmissionVolumeParams.scatter_coeff*trans_weight+subsurfaceVolumeParams.scatter_coeff*subsurf_weight;volumeParams.absorption_coeff=transmissionVolumeParams.absorption_coeff*trans_weight+subsurfaceVolumeParams.absorption_coeff*subsurf_weight;volumeParams.anisotropy=(transmissionVolumeParams.anisotropy*trans_weight+subsurfaceVolumeParams.anisotropy*subsurf_weight)/maxEps(trans_weight+subsurf_weight);volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=volumeParams.scatter_coeff/maxEps(volumeParams.extinction_coeff);volumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo);surface_translucency_weight=subsurface_and_transmission_fraction_of_dielectric;\n#endif\n}\nvolume_absorption=exp(-volumeParams.absorption_coeff*geometry_thickness);vec3 backscatter_color=vec3(1.0);{vec3 reduced_scatter=volumeParams.scatter_coeff*vec3(1.0-volumeParams.anisotropy);vec3 reduced_albedo=reduced_scatter/(volumeParams.absorption_coeff+reduced_scatter);vec3 sqrt_term=max(sqrt(1.0-reduced_albedo),0.0001);backscatter_color=(1.0-sqrt_term)/(1.0+sqrt_term);}\n#elif defined(TRANSMISSION_SLAB)\nsurface_translucency_weight=transmission_weight;\n#endif\nfloat refractionAlphaG=transmission_roughness*transmission_roughness;\n#ifdef SCATTERING\n#ifdef GEOMETRY_THIN_WALLED\nvec3 iso_scatter_density=vec3(1.0);float roughness_alpha_modified_for_scatter=1.0;\n#else\n#ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING\nvec3 mfp=vec3(100.0)/volumeParams.extinction_coeff;vec3 scattered_light_from_irradiance_texture=sss_convolve(sceneIrradianceSampler,sceneDepthSampler,renderTargetSize,mfp,projection,inverseProjection,16,noise.xy);\n#else\nvec3 scattered_light_from_irradiance_texture=vec3(0.0);\n#endif\nfloat back_to_iso_scattering_blend=min(1.0+volumeParams.anisotropy,1.0);float iso_to_forward_scattering_blend=max(volumeParams.anisotropy,0.0);vec3 iso_scatter_transmittance=pow(exp(-volumeParams.scatter_coeff*geometry_thickness),vec3(0.2));vec3 iso_scatter_density=clamp(vec3(1.0)-iso_scatter_transmittance,0.0,1.0);float roughness_alpha_modified_for_scatter=min(refractionAlphaG+(1.0-abs(volumeParams.anisotropy))*max3(iso_scatter_density*iso_scatter_density),1.0);roughness_alpha_modified_for_scatter=pow(roughness_alpha_modified_for_scatter,6.0);roughness_alpha_modified_for_scatter=clamp(roughness_alpha_modified_for_scatter,refractionAlphaG,1.0);\n#endif\nvolumeParams.multi_scatter_color=mix(volumeParams.ss_albedo,volumeParams.multi_scatter_color,max3(iso_scatter_density));\n#else\nfloat roughness_alpha_modified_for_scatter=refractionAlphaG;\n#endif\n#if defined(TRANSMISSION_SLAB) && (!defined(TRANSMISSION_SLAB_VOLUME) || defined(GEOMETRY_THIN_WALLED))\ntransmission_tint*=transmission_color.rgb*transmission_color.rgb;\n#ifdef SUBSURFACE_SLAB\nfloat unweighted_translucency=mix(subsurface_weight,1.0f,transmission_weight);transmission_tint=mix(vec3(1.0),transmission_tint,transmission_weight/unweighted_translucency);roughness_alpha_modified_for_scatter=mix(1.0,refractionAlphaG,transmission_weight/unweighted_translucency);\n#endif\n#ifdef GEOMETRY_THIN_WALLED\nfloat sin2=1.0-baseGeoInfo.NdotV*baseGeoInfo.NdotV;sin2=sin2/(specular_ior*specular_ior);float cos_t=sqrt(1.0-sin2);float pathLength=1.0/cos_t;transmission_tint=pow(transmission_tint,vec3(pathLength));\n#endif\n#endif\n#endif\n#include<openpbrBackgroundTransmission>\nvec3 material_surface_ibl=vec3(0.,0.,0.);\n#include<openpbrEnvironmentLighting>\nvec3 material_surface_direct=vec3(0.,0.,0.);\n#ifdef REFLECTION\nslab_translucent_background=vec4(0.,0.,0.,1.);\n#else\nslab_translucent_background/=float(LIGHTCOUNT); \n#endif\n#if defined(LIGHT0)\nfloat aggShadow=0.;\n#include<openpbrDirectLightingInit>[0..maxSimultaneousLights]\n#include<openpbrDirectLighting>[0..maxSimultaneousLights]\n#endif\nvec3 material_surface_emission=vEmissionColor;\n#ifdef EMISSION_COLOR\nvec3 emissionColorTex=texture2D(emissionColorSampler,vEmissionColorUV+uvOffset).rgb;\n#ifdef EMISSION_COLOR_GAMMA\nmaterial_surface_emission*=toLinearSpace(emissionColorTex.rgb);\n#else\nmaterial_surface_emission*=emissionColorTex.rgb;\n#endif\nmaterial_surface_emission*= vEmissionColorInfos.y;\n#endif\nmaterial_surface_emission*=vLightingIntensity.y;\n#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION\nvec4 finalColor=vec4(material_surface_ibl+material_surface_direct+material_surface_emission,alpha);\n#define CUSTOM_FRAGMENT_BEFORE_FOG\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#include<pbrBlockImageProcessing>\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\n#ifdef PREPASS\n#include<openpbrBlockPrePass>\n#endif\n#if !defined(PREPASS) || defined(WEBGL2)\ngl_FragColor=finalColor;\n#endif\n#include<oitFragment>\n#if ORDER_INDEPENDENT_TRANSPARENCY\nif (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);} else {backColor+=finalColor;}\n#endif\n#include<pbrDebug>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const openpbrPixelShader = { name, shader };\n"]}
|
|
1
|
+
{"version":3,"file":"openpbr.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/openpbr.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,iCAAiC,CAAC;AACzC,OAAO,6CAA6C,CAAC;AACrD,OAAO,wCAAwC,CAAC;AAChD,OAAO,8CAA8C,CAAC;AACtD,OAAO,2CAA2C,CAAC;AACnD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,qDAAqD,CAAC;AAC7D,OAAO,6CAA6C,CAAC;AACrD,OAAO,+CAA+C,CAAC;AACvD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,yCAAyC,CAAC;AACjD,OAAO,kCAAkC,CAAC;AAC1C,OAAO,gDAAgD,CAAC;AACxD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,2CAA2C,CAAC;AACnD,OAAO,2CAA2C,CAAC;AACnD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,kDAAkD,CAAC;AAC1D,OAAO,oDAAoD,CAAC;AAC5D,OAAO,mCAAmC,CAAC;AAC3C,OAAO,wCAAwC,CAAC;AAChD,OAAO,6CAA6C,CAAC;AACrD,OAAO,kCAAkC,CAAC;AAC1C,OAAO,wDAAwD,CAAC;AAChE,OAAO,oDAAoD,CAAC;AAC5D,OAAO,qCAAqC,CAAC;AAC7C,OAAO,+CAA+C,CAAC;AACvD,OAAO,8CAA8C,CAAC;AACtD,OAAO,mDAAmD,CAAC;AAC3D,OAAO,sCAAsC,CAAC;AAC9C,OAAO,sCAAsC,CAAC;AAC9C,OAAO,yCAAyC,CAAC;AACjD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,0CAA0C,CAAC;AAClD,OAAO,2CAA2C,CAAC;AACnD,OAAO,0CAA0C,CAAC;AAClD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,+CAA+C,CAAC;AACvD,OAAO,6CAA6C,CAAC;AACrD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,2CAA2C,CAAC;AACnD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,8CAA8C,CAAC;AACtD,OAAO,+BAA+B,CAAC;AACvC,OAAO,gDAAgD,CAAC;AACxD,OAAO,6CAA6C,CAAC;AACrD,OAAO,4CAA4C,CAAC;AACpD,OAAO,wCAAwC,CAAC;AAChD,OAAO,mCAAmC,CAAC;AAC3C,OAAO,8BAA8B,CAAC;AACtC,OAAO,0CAA0C,CAAC;AAClD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,8BAA8B,CAAC;AACtC,OAAO,2BAA2B,CAAC;AAEnC,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAClC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Od,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/prePassDeclaration\";\nimport \"./ShadersInclude/oitDeclaration\";\nimport \"./ShadersInclude/openpbrFragmentDeclaration\";\nimport \"./ShadersInclude/openpbrUboDeclaration\";\nimport \"./ShadersInclude/pbrFragmentExtraDeclaration\";\nimport \"./ShadersInclude/lightFragmentDeclaration\";\nimport \"./ShadersInclude/lightUboDeclaration\";\nimport \"./ShadersInclude/openpbrFragmentSamplersDeclaration\";\nimport \"./ShadersInclude/imageProcessingDeclaration\";\nimport \"./ShadersInclude/clipPlaneFragmentDeclaration\";\nimport \"./ShadersInclude/logDepthDeclaration\";\nimport \"./ShadersInclude/fogFragmentDeclaration\";\nimport \"./ShadersInclude/helperFunctions\";\nimport \"./ShadersInclude/subSurfaceScatteringFunctions\";\nimport \"./ShadersInclude/importanceSampling\";\nimport \"./ShadersInclude/pbrHelperFunctions\";\nimport \"./ShadersInclude/imageProcessingFunctions\";\nimport \"./ShadersInclude/shadowsFragmentFunctions\";\nimport \"./ShadersInclude/harmonicsFunctions\";\nimport \"./ShadersInclude/pbrDirectLightingSetupFunctions\";\nimport \"./ShadersInclude/pbrDirectLightingFalloffFunctions\";\nimport \"./ShadersInclude/pbrBRDFFunctions\";\nimport \"./ShadersInclude/hdrFilteringFunctions\";\nimport \"./ShadersInclude/pbrDirectLightingFunctions\";\nimport \"./ShadersInclude/pbrIBLFunctions\";\nimport \"./ShadersInclude/openpbrNormalMapFragmentMainFunctions\";\nimport \"./ShadersInclude/openpbrNormalMapFragmentFunctions\";\nimport \"./ShadersInclude/reflectionFunction\";\nimport \"./ShadersInclude/openpbrDielectricReflectance\";\nimport \"./ShadersInclude/openpbrConductorReflectance\";\nimport \"./ShadersInclude/openpbrAmbientOcclusionFunctions\";\nimport \"./ShadersInclude/openpbrGeometryInfo\";\nimport \"./ShadersInclude/openpbrIblFunctions\";\nimport \"./ShadersInclude/openpbrVolumeFunctions\";\nimport \"./ShadersInclude/clipPlaneFragment\";\nimport \"./ShadersInclude/pbrBlockNormalGeometric\";\nimport \"./ShadersInclude/openpbrNormalMapFragment\";\nimport \"./ShadersInclude/openpbrBlockNormalFinal\";\nimport \"./ShadersInclude/openpbrBaseLayerData\";\nimport \"./ShadersInclude/openpbrTransmissionLayerData\";\nimport \"./ShadersInclude/openpbrSubsurfaceLayerData\";\nimport \"./ShadersInclude/openpbrCoatLayerData\";\nimport \"./ShadersInclude/openpbrThinFilmLayerData\";\nimport \"./ShadersInclude/openpbrFuzzLayerData\";\nimport \"./ShadersInclude/openpbrAmbientOcclusionData\";\nimport \"./ShadersInclude/depthPrePass\";\nimport \"./ShadersInclude/openpbrBackgroundTransmission\";\nimport \"./ShadersInclude/openpbrEnvironmentLighting\";\nimport \"./ShadersInclude/openpbrDirectLightingInit\";\nimport \"./ShadersInclude/openpbrDirectLighting\";\nimport \"./ShadersInclude/logDepthFragment\";\nimport \"./ShadersInclude/fogFragment\";\nimport \"./ShadersInclude/pbrBlockImageProcessing\";\nimport \"./ShadersInclude/openpbrBlockPrePass\";\nimport \"./ShadersInclude/oitFragment\";\nimport \"./ShadersInclude/pbrDebug\";\n\nconst name = \"openpbrPixelShader\";\nconst shader = `#define OPENPBR_FRAGMENT_SHADER\n#define CUSTOM_FRAGMENT_EXTENSION\n#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<prePassDeclaration>[SCENE_MRT_COUNT]\nprecision highp float;\n#include<oitDeclaration>\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE\n#endif\n#include<__decl__openpbrFragment>\n#include<pbrFragmentExtraDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<openpbrFragmentSamplersDeclaration>\n#include<imageProcessingDeclaration>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#include<helperFunctions>\n#include<subSurfaceScatteringFunctions>\n#include<importanceSampling>\n#include<pbrHelperFunctions>\n#include<imageProcessingFunctions>\n#include<shadowsFragmentFunctions>\n#include<harmonicsFunctions>\n#include<pbrDirectLightingSetupFunctions>\n#include<pbrDirectLightingFalloffFunctions>\n#include<pbrBRDFFunctions>\n#include<hdrFilteringFunctions>\n#include<pbrDirectLightingFunctions>\n#include<pbrIBLFunctions>\n#include<openpbrNormalMapFragmentMainFunctions>\n#include<openpbrNormalMapFragmentFunctions>\n#ifdef REFLECTION\n#include<reflectionFunction>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\n#include<openpbrDielectricReflectance>\n#include<openpbrConductorReflectance>\n#include<openpbrAmbientOcclusionFunctions>\n#include<openpbrGeometryInfo>\n#include<openpbrIblFunctions>\n#include<openpbrVolumeFunctions>\nvec3 layer(vec3 slab_bottom,vec3 slab_top,float lerp_factor,vec3 bottom_multiplier,vec3 top_multiplier) {return mix(slab_bottom*bottom_multiplier,slab_top*top_multiplier,lerp_factor);}\nvoid main(void) {\n#ifdef PREPASS_IRRADIANCE\nvec3 total_direct_diffuse=vec3(0.0);\n#endif\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\n#include<pbrBlockNormalGeometric>\nvec3 coatNormalW=normalW;\n#include<openpbrNormalMapFragment>\n#include<openpbrBlockNormalFinal>\n#include<openpbrBaseLayerData>\n#include<openpbrTransmissionLayerData>\n#include<openpbrSubsurfaceLayerData>\n#include<openpbrCoatLayerData>\n#include<openpbrThinFilmLayerData>\n#include<openpbrFuzzLayerData>\n#include<openpbrAmbientOcclusionData>\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\n#include<depthPrePass>\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n#ifdef ANISOTROPIC_COAT\ngeometryInfoAnisoOutParams coatGeoInfo=geometryInfoAniso(\ncoatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW\n,vec3(geometry_coat_tangent.x,geometry_coat_tangent.y,coat_roughness_anisotropy),TBN\n);\n#else\ngeometryInfoOutParams coatGeoInfo=geometryInfo(\ncoatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW\n);\n#endif\nspecular_roughness=mix(specular_roughness,pow(min(1.0,pow(specular_roughness,4.0)+2.0*pow(coat_roughness,4.0)),0.25),coat_weight);\n#ifdef ANISOTROPIC_BASE\ngeometryInfoAnisoOutParams baseGeoInfo=geometryInfoAniso(\nnormalW,viewDirectionW.xyz,specular_roughness,geometricNormalW\n,vec3(geometry_tangent.x,geometry_tangent.y,specular_roughness_anisotropy),TBN\n);\n#else\ngeometryInfoOutParams baseGeoInfo=geometryInfo(\nnormalW,viewDirectionW.xyz,specular_roughness,geometricNormalW\n);\n#endif\n#ifdef FUZZ\nvec3 fuzzNormalW=normalize(mix(normalW,coatNormalW,coat_weight));vec3 fuzzTangent=normalize(TBN[0]);fuzzTangent=normalize(fuzzTangent-dot(fuzzTangent,fuzzNormalW)*fuzzNormalW);vec3 fuzzBitangent=cross(fuzzNormalW,fuzzTangent);geometryInfoOutParams fuzzGeoInfo=geometryInfo(\nfuzzNormalW,viewDirectionW.xyz,fuzz_roughness,geometricNormalW\n);\n#endif\nReflectanceParams coatReflectance;coatReflectance=dielectricReflectance(\ncoat_ior \n,1.0 \n,vec3(1.0)\n,coat_weight\n);\n#ifdef THIN_FILM\nfloat thin_film_outside_ior=mix(1.0,coat_ior,coat_weight);\n#endif\nReflectanceParams baseDielectricReflectance;{float effectiveCoatIor=mix(1.0,coat_ior,coat_weight);baseDielectricReflectance=dielectricReflectance(\nspecular_ior \n,effectiveCoatIor \n,specular_color\n,specular_weight\n);}\nReflectanceParams baseConductorReflectance;baseConductorReflectance=conductorReflectance(base_color,specular_color,specular_weight);vec3 volume_absorption=vec3(1.0);vec3 transmission_tint=vec3(1.0);float surface_translucency_weight=0.0;\n#if defined(REFRACTED_BACKGROUND) || defined(REFRACTED_ENVIRONMENT) || defined(REFRACTED_LIGHTS)\n#if defined(GEOMETRY_THIN_WALLED)\nvec3 refractedViewVector=-viewDirectionW;\n#else\n#ifdef DISPERSION\nvec3 refractedViewVectors[3];float iorDispersionSpread=transmission_dispersion_scale/transmission_dispersion_abbe_number*(specular_ior-1.0);vec3 dispersion_iors=vec3(specular_ior-iorDispersionSpread,specular_ior,specular_ior+iorDispersionSpread);for (int i=0; i<3; i++) {refractedViewVectors[i]=double_refract(-viewDirectionW,normalW,dispersion_iors[i]); }\n#else\nvec3 refractedViewVector=double_refract(-viewDirectionW,normalW,specular_ior);\n#endif\n#endif\n#ifdef GEOMETRY_THIN_WALLED\nfloat transmission_roughness=specular_roughness;\n#else\nfloat transmission_roughness=specular_roughness*clamp(4.0*(specular_ior-1.0),0.001,1.0);\n#endif\n#if (defined(TRANSMISSION_SLAB) || defined(SUBSURFACE_SLAB))\nOpenPBRHomogeneousVolume volumeParams;{\n#if defined(TRANSMISSION_SLAB)\nOpenPBRHomogeneousVolume transmissionVolumeParams=computeOpenPBRTransmissionVolume(\ntransmission_color.rgb,\ntransmission_depth,\ntransmission_scatter.rgb,\ntransmission_scatter_anisotropy\n);\n#endif\n#if defined(SUBSURFACE_SLAB)\nOpenPBRHomogeneousVolume subsurfaceVolumeParams=computeOpenPBRSubsurfaceVolume(\nsubsurface_color.rgb,\nsubsurface_radius,\nsubsurface_radius_scale.rgb,\nsubsurface_scatter_anisotropy\n);\n#endif\n#if !defined(TRANSMISSION_SLAB)\nvolumeParams=subsurfaceVolumeParams;surface_translucency_weight=subsurface_weight;\n#elif !defined(SUBSURFACE_SLAB)\nvolumeParams=transmissionVolumeParams;\n#ifdef TRANSMISSION_SLAB_VOLUME\nvolumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo);\n#endif\nsurface_translucency_weight=transmission_weight;\n#else\nfloat subsurface_fraction_of_dielectric=(1.0f-transmission_weight)*subsurface_weight;float subsurface_and_transmission_fraction_of_dielectric=subsurface_fraction_of_dielectric+transmission_weight;float reciprocal_of_subsurface_and_transmission_fraction_of_dielectric =\n1.0f/maxEps(subsurface_and_transmission_fraction_of_dielectric);float trans_weight=transmission_weight*reciprocal_of_subsurface_and_transmission_fraction_of_dielectric;float subsurf_weight=subsurface_fraction_of_dielectric*reciprocal_of_subsurface_and_transmission_fraction_of_dielectric;volumeParams.scatter_coeff=transmissionVolumeParams.scatter_coeff*trans_weight+subsurfaceVolumeParams.scatter_coeff*subsurf_weight;volumeParams.absorption_coeff=transmissionVolumeParams.absorption_coeff*trans_weight+subsurfaceVolumeParams.absorption_coeff*subsurf_weight;volumeParams.anisotropy=(transmissionVolumeParams.anisotropy*trans_weight+subsurfaceVolumeParams.anisotropy*subsurf_weight)/maxEps(trans_weight+subsurf_weight);volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=volumeParams.scatter_coeff/maxEps(volumeParams.extinction_coeff);volumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo);surface_translucency_weight=subsurface_and_transmission_fraction_of_dielectric;\n#endif\n}\nvolume_absorption=exp(-volumeParams.absorption_coeff*geometry_thickness);vec3 backscatter_color=vec3(1.0);{vec3 reduced_scatter=volumeParams.scatter_coeff*vec3(1.0-volumeParams.anisotropy);vec3 reduced_albedo=reduced_scatter/(volumeParams.absorption_coeff+reduced_scatter);vec3 sqrt_term=max(sqrt(1.0-reduced_albedo),0.0001);backscatter_color=(1.0-sqrt_term)/(1.0+sqrt_term);}\n#elif defined(TRANSMISSION_SLAB)\nsurface_translucency_weight=transmission_weight;\n#endif\n#ifdef SCATTERING\n#ifdef GEOMETRY_THIN_WALLED\nvec3 iso_scatter_density=vec3(1.0);\n#else\n#ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING\nvec3 mfp=vec3(100.0)/volumeParams.extinction_coeff;vec3 scattered_light_from_irradiance_texture=sss_convolve(sceneIrradianceSampler,sceneDepthSampler,renderTargetSize,mfp,projection,inverseProjection,16,noise.xy);float numLights=float(LIGHTCOUNT);\n#ifdef REFLECTION\nnumLights+=1.0;\n#endif\nscattered_light_from_irradiance_texture/=numLights;\n#else\nvec3 scattered_light_from_irradiance_texture=vec3(0.0);\n#endif\nfloat back_to_iso_scattering_blend=min(1.0+volumeParams.anisotropy,1.0);float iso_to_forward_scattering_blend=max(volumeParams.anisotropy,0.0);vec3 iso_scatter_transmittance=pow(exp(-volumeParams.scatter_coeff*geometry_thickness),vec3(0.2));vec3 iso_scatter_density=clamp(vec3(1.0)-iso_scatter_transmittance,0.0,1.0);transmission_roughness=min(transmission_roughness+pow((1.0-abs(volumeParams.anisotropy))*max3(iso_scatter_density*iso_scatter_density),3.0),1.0);\n#endif\nvolumeParams.multi_scatter_color=mix(volumeParams.ss_albedo,volumeParams.multi_scatter_color,max3(iso_scatter_density));\n#endif\n#if defined(TRANSMISSION_SLAB) && (!defined(TRANSMISSION_SLAB_VOLUME) || defined(GEOMETRY_THIN_WALLED))\ntransmission_tint*=transmission_color.rgb;\n#ifdef GEOMETRY_THIN_WALLED\nfloat sin2=1.0-baseGeoInfo.NdotV*baseGeoInfo.NdotV;sin2=sin2/(specular_ior*specular_ior);float cos_t=sqrt(1.0-sin2);float pathLength=1.0/cos_t;transmission_tint=pow(transmission_tint,vec3(pathLength));\n#else\ntransmission_tint*=transmission_color.rgb;\n#endif\n#endif\n#if defined(SUBSURFACE_SLAB) && defined(GEOMETRY_THIN_WALLED)\nfloat unweighted_translucency=mix(subsurface_weight,1.0f,transmission_weight);transmission_tint=mix(vec3(1.0),transmission_tint,transmission_weight/unweighted_translucency);transmission_roughness=mix(1.0,transmission_roughness,transmission_weight/unweighted_translucency);\n#endif\nfloat transmission_roughness_alpha=transmission_roughness*transmission_roughness;\n#endif\n#include<openpbrBackgroundTransmission>\nvec3 material_surface_ibl=vec3(0.,0.,0.);\n#include<openpbrEnvironmentLighting>\nvec3 material_surface_direct=vec3(0.,0.,0.);\n#if defined(LIGHT0)\nfloat aggShadow=0.;\n#include<openpbrDirectLightingInit>[0..maxSimultaneousLights]\n#include<openpbrDirectLighting>[0..maxSimultaneousLights]\n#endif\nvec3 material_surface_emission=vEmissionColor;\n#ifdef EMISSION_COLOR\nvec3 emissionColorTex=texture2D(emissionColorSampler,vEmissionColorUV+uvOffset).rgb;\n#ifdef EMISSION_COLOR_GAMMA\nmaterial_surface_emission*=toLinearSpace(emissionColorTex.rgb);\n#else\nmaterial_surface_emission*=emissionColorTex.rgb;\n#endif\nmaterial_surface_emission*= vEmissionColorInfos.y;\n#endif\nmaterial_surface_emission*=vLightingIntensity.y;\n#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION\nvec4 finalColor=vec4(material_surface_ibl+material_surface_direct+material_surface_emission,alpha);\n#define CUSTOM_FRAGMENT_BEFORE_FOG\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#include<pbrBlockImageProcessing>\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\n#ifdef PREPASS\n#include<openpbrBlockPrePass>\n#endif\n#if !defined(PREPASS) || defined(WEBGL2)\ngl_FragColor=finalColor;\n#endif\n#include<oitFragment>\n#if ORDER_INDEPENDENT_TRANSPARENCY\nif (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);} else {backColor+=finalColor;}\n#endif\n#include<pbrDebug>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const openpbrPixelShader = { name, shader };\n"]}
|
|
@@ -78,7 +78,7 @@ result=result/clampedAlbedo;
|
|
|
78
78
|
#endif
|
|
79
79
|
return result;}
|
|
80
80
|
fn radiance(alphaG: f32,inputTexture: texture_cube<f32>,inputSampler: sampler,inputN: vec3f,filteringInfo: vec2f)->vec3f
|
|
81
|
-
{var n: vec3f=normalize(inputN);var c: vec3f=
|
|
81
|
+
{var n: vec3f=normalize(inputN);var c: vec3f=textureSampleLevel(inputTexture,inputSampler,n,0.0).rgb;
|
|
82
82
|
if (alphaG==0.) {
|
|
83
83
|
#ifdef GAMMA_INPUT
|
|
84
84
|
c=toLinearSpaceVec3(c);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hdrFilteringFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqHd,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,yBAAyB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"hdrFilteringFunctions\";\nconst shader = `#ifdef NUM_SAMPLES\n#if NUM_SAMPLES>0\nfn radicalInverse_VdC(value: u32)->f32 \n{var bits=(value<<16u) | (value>>16u);bits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);bits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);bits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);bits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);return f32(bits)*2.3283064365386963e-10; }\nfn hammersley(i: u32,N: u32)->vec2f\n{return vec2f( f32(i)/ f32(N),radicalInverse_VdC(i));}\nfn log4(x: f32)->f32 {return log2(x)/2.;}\nfn uv_to_normal(uv: vec2f)->vec3f {var N: vec3f;var uvRange: vec2f=uv;var theta: f32=uvRange.x*2.0*PI;var phi: f32=uvRange.y*PI;N.x=cos(theta)*sin(phi);N.z=sin(theta)*sin(phi);N.y=cos(phi);return N;}\nconst NUM_SAMPLES_FLOAT: f32= f32(NUM_SAMPLES);const NUM_SAMPLES_FLOAT_INVERSED: f32=1./NUM_SAMPLES_FLOAT;const K: f32=4.;fn irradiance(\n#ifdef CUSTOM_IRRADIANCE_FILTERING_INPUT\nCUSTOM_IRRADIANCE_FILTERING_INPUT\n#else\ninputTexture: texture_cube<f32>,inputSampler: sampler,\n#endif\ninputN: vec3f,\nfilteringInfo: vec2f,\ndiffuseRoughness: f32,\nsurfaceAlbedo: vec3f,\ninputV: vec3f\n#ifdef IBL_CDF_FILTERING\n,icdfSampler: texture_2d<f32>,icdfSamplerSampler: sampler\n#endif\n)->vec3f\n{var n: vec3f=normalize(inputN);var result: vec3f= vec3f(0.0);\n#ifndef IBL_CDF_FILTERING\nvar tangent: vec3f=select(vec3f(1.,0.,0.),vec3f(0.,0.,1.),abs(n.z)<0.999);tangent=normalize(cross(tangent,n));var bitangent: vec3f=cross(n,tangent);var tbn: mat3x3f= mat3x3f(tangent,bitangent,n);var tbnInverse: mat3x3f=transpose(tbn);\n#endif\nvar maxLevel: f32=filteringInfo.y;var dim0: f32=filteringInfo.x;var omegaP: f32=(4.*PI)/(6.*dim0*dim0);var clampedAlbedo: vec3f=clamp(surfaceAlbedo,vec3f(0.1),vec3f(1.0));for(var i: u32=0u; i<NUM_SAMPLES; i++)\n{var Xi: vec2f=hammersley(i,NUM_SAMPLES);\n#ifdef IBL_CDF_FILTERING\nvar T: vec2f;T.x=textureSampleLevel(icdfSampler,icdfSamplerSampler,vec2(Xi.x,0.0),0.0).x;T.y=textureSampleLevel(icdfSampler,icdfSamplerSampler,vec2(T.x,Xi.y),0.0).y;var Ls: vec3f=uv_to_normal(vec2f(1.0-fract(T.x+0.25),T.y));var NoL: f32=dot(n,Ls);var NoV: f32=dot(n,inputV);\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\nvar LoV: f32=dot(Ls,inputV);\n#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY\nvar H: vec3f=(inputV+Ls)*0.5;var VoH: f32=dot(inputV,H);\n#endif \n#else\nvar Ls: vec3f=hemisphereCosSample(Xi);Ls=normalize(Ls);var Ns: vec3f= vec3f(0.,0.,1.);var NoL: f32=dot(Ns,Ls);var V: vec3f=tbnInverse*inputV;var NoV: f32=dot(Ns,V);\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\nvar LoV: f32=dot(Ls,V);\n#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY\nvar H: vec3f=(V+Ls)*0.5;var VoH: f32=dot(V,H);\n#endif\n#endif\nif (NoL>0.) {\n#ifdef IBL_CDF_FILTERING\nvar pdf: f32=textureSampleLevel(icdfSampler,icdfSamplerSampler,T,0.0).z;var c: vec3f=textureSampleLevel(inputTexture,inputSampler,Ls,0.0).rgb;\n#else\nvar pdf_inversed: f32=PI/NoL;var omegaS: f32=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;var l: f32=log4(omegaS)-log4(omegaP)+log4(K);var mipLevel: f32=clamp(l,0.0,maxLevel);\n#ifdef CUSTOM_IRRADIANCE_FILTERING_FUNCTION\nCUSTOM_IRRADIANCE_FILTERING_FUNCTION\n#else\nvar c: vec3f=textureSampleLevel(inputTexture,inputSampler,tbn*Ls,mipLevel).rgb;\n#endif\n#endif\n#ifdef GAMMA_INPUT\nc=toLinearSpaceVec3(c);\n#endif\nvar diffuseRoughnessTerm: vec3f=vec3f(1.0);\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\ndiffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;\n#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY\ndiffuseRoughnessTerm=vec3f(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);\n#endif\n#ifdef IBL_CDF_FILTERING\nvar light: vec3f=vec3f(0.0);if (pdf>1e-6) {light=vec3f(1.0)/vec3f(pdf)*c;}\nresult+=NoL*diffuseRoughnessTerm*light;\n#else\nresult+=c*diffuseRoughnessTerm;\n#endif\n}}\nresult=result*NUM_SAMPLES_FLOAT_INVERSED;\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\nresult=result/clampedAlbedo;\n#endif\nreturn result;}\nfn radiance(alphaG: f32,inputTexture: texture_cube<f32>,inputSampler: sampler,inputN: vec3f,filteringInfo: vec2f)->vec3f\n{var n: vec3f=normalize(inputN);var c: vec3f=
|
|
1
|
+
{"version":3,"file":"hdrFilteringFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqHd,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,yBAAyB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"hdrFilteringFunctions\";\nconst shader = `#ifdef NUM_SAMPLES\n#if NUM_SAMPLES>0\nfn radicalInverse_VdC(value: u32)->f32 \n{var bits=(value<<16u) | (value>>16u);bits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);bits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);bits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);bits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);return f32(bits)*2.3283064365386963e-10; }\nfn hammersley(i: u32,N: u32)->vec2f\n{return vec2f( f32(i)/ f32(N),radicalInverse_VdC(i));}\nfn log4(x: f32)->f32 {return log2(x)/2.;}\nfn uv_to_normal(uv: vec2f)->vec3f {var N: vec3f;var uvRange: vec2f=uv;var theta: f32=uvRange.x*2.0*PI;var phi: f32=uvRange.y*PI;N.x=cos(theta)*sin(phi);N.z=sin(theta)*sin(phi);N.y=cos(phi);return N;}\nconst NUM_SAMPLES_FLOAT: f32= f32(NUM_SAMPLES);const NUM_SAMPLES_FLOAT_INVERSED: f32=1./NUM_SAMPLES_FLOAT;const K: f32=4.;fn irradiance(\n#ifdef CUSTOM_IRRADIANCE_FILTERING_INPUT\nCUSTOM_IRRADIANCE_FILTERING_INPUT\n#else\ninputTexture: texture_cube<f32>,inputSampler: sampler,\n#endif\ninputN: vec3f,\nfilteringInfo: vec2f,\ndiffuseRoughness: f32,\nsurfaceAlbedo: vec3f,\ninputV: vec3f\n#ifdef IBL_CDF_FILTERING\n,icdfSampler: texture_2d<f32>,icdfSamplerSampler: sampler\n#endif\n)->vec3f\n{var n: vec3f=normalize(inputN);var result: vec3f= vec3f(0.0);\n#ifndef IBL_CDF_FILTERING\nvar tangent: vec3f=select(vec3f(1.,0.,0.),vec3f(0.,0.,1.),abs(n.z)<0.999);tangent=normalize(cross(tangent,n));var bitangent: vec3f=cross(n,tangent);var tbn: mat3x3f= mat3x3f(tangent,bitangent,n);var tbnInverse: mat3x3f=transpose(tbn);\n#endif\nvar maxLevel: f32=filteringInfo.y;var dim0: f32=filteringInfo.x;var omegaP: f32=(4.*PI)/(6.*dim0*dim0);var clampedAlbedo: vec3f=clamp(surfaceAlbedo,vec3f(0.1),vec3f(1.0));for(var i: u32=0u; i<NUM_SAMPLES; i++)\n{var Xi: vec2f=hammersley(i,NUM_SAMPLES);\n#ifdef IBL_CDF_FILTERING\nvar T: vec2f;T.x=textureSampleLevel(icdfSampler,icdfSamplerSampler,vec2(Xi.x,0.0),0.0).x;T.y=textureSampleLevel(icdfSampler,icdfSamplerSampler,vec2(T.x,Xi.y),0.0).y;var Ls: vec3f=uv_to_normal(vec2f(1.0-fract(T.x+0.25),T.y));var NoL: f32=dot(n,Ls);var NoV: f32=dot(n,inputV);\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\nvar LoV: f32=dot(Ls,inputV);\n#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY\nvar H: vec3f=(inputV+Ls)*0.5;var VoH: f32=dot(inputV,H);\n#endif \n#else\nvar Ls: vec3f=hemisphereCosSample(Xi);Ls=normalize(Ls);var Ns: vec3f= vec3f(0.,0.,1.);var NoL: f32=dot(Ns,Ls);var V: vec3f=tbnInverse*inputV;var NoV: f32=dot(Ns,V);\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\nvar LoV: f32=dot(Ls,V);\n#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY\nvar H: vec3f=(V+Ls)*0.5;var VoH: f32=dot(V,H);\n#endif\n#endif\nif (NoL>0.) {\n#ifdef IBL_CDF_FILTERING\nvar pdf: f32=textureSampleLevel(icdfSampler,icdfSamplerSampler,T,0.0).z;var c: vec3f=textureSampleLevel(inputTexture,inputSampler,Ls,0.0).rgb;\n#else\nvar pdf_inversed: f32=PI/NoL;var omegaS: f32=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;var l: f32=log4(omegaS)-log4(omegaP)+log4(K);var mipLevel: f32=clamp(l,0.0,maxLevel);\n#ifdef CUSTOM_IRRADIANCE_FILTERING_FUNCTION\nCUSTOM_IRRADIANCE_FILTERING_FUNCTION\n#else\nvar c: vec3f=textureSampleLevel(inputTexture,inputSampler,tbn*Ls,mipLevel).rgb;\n#endif\n#endif\n#ifdef GAMMA_INPUT\nc=toLinearSpaceVec3(c);\n#endif\nvar diffuseRoughnessTerm: vec3f=vec3f(1.0);\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\ndiffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;\n#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY\ndiffuseRoughnessTerm=vec3f(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);\n#endif\n#ifdef IBL_CDF_FILTERING\nvar light: vec3f=vec3f(0.0);if (pdf>1e-6) {light=vec3f(1.0)/vec3f(pdf)*c;}\nresult+=NoL*diffuseRoughnessTerm*light;\n#else\nresult+=c*diffuseRoughnessTerm;\n#endif\n}}\nresult=result*NUM_SAMPLES_FLOAT_INVERSED;\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\nresult=result/clampedAlbedo;\n#endif\nreturn result;}\nfn radiance(alphaG: f32,inputTexture: texture_cube<f32>,inputSampler: sampler,inputN: vec3f,filteringInfo: vec2f)->vec3f\n{var n: vec3f=normalize(inputN);var c: vec3f=textureSampleLevel(inputTexture,inputSampler,n,0.0).rgb; \nif (alphaG==0.) {\n#ifdef GAMMA_INPUT\nc=toLinearSpaceVec3(c);\n#endif\nreturn c;} else {var result: vec3f= vec3f(0.);var tangent: vec3f=select(vec3f(1.,0.,0.),vec3f(0.,0.,1.),abs(n.z)<0.999);tangent=normalize(cross(tangent,n));var bitangent: vec3f=cross(n,tangent);var tbn: mat3x3f= mat3x3f(tangent,bitangent,n);var maxLevel: f32=filteringInfo.y;var dim0: f32=filteringInfo.x;var omegaP: f32=(4.*PI)/(6.*dim0*dim0);var weight: f32=0.;for(var i: u32=0u; i<NUM_SAMPLES; i++)\n{var Xi: vec2f=hammersley(i,NUM_SAMPLES);var H: vec3f=hemisphereImportanceSampleDggx(Xi,alphaG);var NoV: f32=1.;var NoH: f32=H.z;var NoH2: f32=H.z*H.z;var NoL: f32=2.*NoH2-1.;var L: vec3f= vec3f(2.*NoH*H.x,2.*NoH*H.y,NoL);L=normalize(L);if (NoL>0.) {var pdf_inversed: f32=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);var omegaS: f32=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;var l: f32=log4(omegaS)-log4(omegaP)+log4(K);var mipLevel: f32=clamp( f32(l),0.0,maxLevel);weight+=NoL;var c: vec3f=textureSampleLevel(inputTexture,inputSampler,tbn*L,mipLevel).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpaceVec3(c);\n#endif\nresult+=c*NoL;}}\nresult=result/weight;return result;}}\n#ifdef ANISOTROPIC\nfn radianceAnisotropic(\nalphaTangent: f32, \nalphaBitangent: f32, \ninputTexture: texture_cube<f32>,\ninputSampler: sampler,\ninputView: vec3f, \ninputTangent: vec3f, \ninputBitangent: vec3f, \ninputNormal: vec3f, \nfilteringInfo: vec2f,\nnoiseInput: vec2f, \nisRefraction: bool,\nior: f32 \n)->vec3f {var V: vec3f=inputView;var N: vec3f=inputNormal;var T: vec3f=inputTangent;var B: vec3f=inputBitangent;var result: vec3f=vec3f(0.f);var maxLevel: f32=filteringInfo.y;var dim0: f32=filteringInfo.x;let clampedAlphaT: f32=max(alphaTangent,MINIMUMVARIANCE);let clampedAlphaB: f32=max(alphaBitangent,MINIMUMVARIANCE);var effectiveDim: f32=dim0*sqrt(clampedAlphaT*clampedAlphaB);var omegaP: f32=(4.f*PI)/(6.f*effectiveDim*effectiveDim);let noiseScale: f32=clamp(log2(f32(NUM_SAMPLES))/12.0f,0.0f,1.0f);var weight: f32=0.f;for(var i: u32=0u; i<NUM_SAMPLES; i++)\n{var Xi: vec2f=hammersley(i,NUM_SAMPLES);Xi=fract(Xi+noiseInput*mix(0.5f,0.015f,noiseScale)); \nvar H_tangent: vec3f=hemisphereImportanceSampleDggxAnisotropic(Xi,clampedAlphaT,clampedAlphaB);var H: vec3f=normalize(H_tangent.x*T+H_tangent.y*B+H_tangent.z*N);var L: vec3f;if (isRefraction) {L=refract(-V,H,1.0/ior);} else {L=reflect(-V,H);}\nvar NoH: f32=max(dot(N,H),0.001f);var VoH: f32=max(dot(V,H),0.001f);var NoL: f32=max(dot(N,L),0.001f);if (NoL>0.f) {var pdf_inversed: f32=4./normalDistributionFunction_BurleyGGX_Anisotropic(\nH_tangent.z,H_tangent.x,H_tangent.y,vec2f(clampedAlphaT,clampedAlphaB)\n);var omegaS: f32=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;var l: f32=log4(omegaS)-log4(omegaP)+log4(K);var mipLevel: f32=clamp(l,0.0f,maxLevel);weight+=NoL;var c: vec3f=textureSampleLevel(inputTexture,inputSampler,L,mipLevel).rgb;\n#if GAMMA_INPUT\nc=toLinearSpaceVec3(c);\n#endif\nresult+=c*NoL;}}\nresult=result/weight;return result;}\n#endif\n#endif\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const hdrFilteringFunctionsWGSL = { name, shader };\n"]}
|
|
@@ -3,7 +3,7 @@ import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
|
3
3
|
const name = "openpbrBackgroundTransmission";
|
|
4
4
|
const shader = `var slab_translucent_background: vec4f=vec4f(0.,0.,0.,1.);
|
|
5
5
|
#ifdef REFRACTED_BACKGROUND
|
|
6
|
-
{let refractionLOD: f32=transmission_roughness*uniforms.vBackgroundRefractionInfos.x;var refractionNoiseOffset: vec2f=vec2f(0.0f);
|
|
6
|
+
{let refractionLOD: f32=min(transmission_roughness,0.7)*uniforms.vBackgroundRefractionInfos.x;var refractionNoiseOffset: vec2f=vec2f(0.0f);
|
|
7
7
|
#ifdef DISPERSION
|
|
8
8
|
for (var i: i32=0; i<3; i++) {let refractedViewVector: vec3f=refractedViewVectors[i];
|
|
9
9
|
#endif
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openpbrBackgroundTransmission.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,+BAA+B,CAAC;AAC7C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;CAed,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,iCAAiC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"openpbrBackgroundTransmission\";\nconst shader = `var slab_translucent_background: vec4f=vec4f(0.,0.,0.,1.);\n#ifdef REFRACTED_BACKGROUND\n{let refractionLOD: f32=transmission_roughness*uniforms.vBackgroundRefractionInfos.x;var refractionNoiseOffset: vec2f=vec2f(0.0f);\n#ifdef DISPERSION\nfor (var i: i32=0; i<3; i++) {let refractedViewVector: vec3f=refractedViewVectors[i];\n#endif\nlet refractionUVW: vec3f=vec3f((uniforms.backgroundRefractionMatrix*(scene.view*vec4f(fragmentInputs.vPositionW+refractedViewVector*geometry_thickness,1.0f))).xyz);var refractionCoords: vec2f=refractionUVW.xy/refractionUVW.z;refractionCoords.y=1.0f-refractionCoords.y;if (refractionLOD>0.0f) {refractionNoiseOffset=(noise.xy+refractedViewVector.xy)/vec2f(pow(2.0f,uniforms.vBackgroundRefractionInfos.x-refractionLOD));}\nrefractionCoords+=refractionNoiseOffset;\n#ifdef DISPERSION\nslab_translucent_background[i]=textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords,refractionLOD)[i];}\n#else\nslab_translucent_background=textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords,refractionLOD);\n#endif\n}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrBackgroundTransmissionWGSL = { name, shader };\n"]}
|
|
1
|
+
{"version":3,"file":"openpbrBackgroundTransmission.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,+BAA+B,CAAC;AAC7C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;CAed,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,iCAAiC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"openpbrBackgroundTransmission\";\nconst shader = `var slab_translucent_background: vec4f=vec4f(0.,0.,0.,1.);\n#ifdef REFRACTED_BACKGROUND\n{let refractionLOD: f32=min(transmission_roughness,0.7)*uniforms.vBackgroundRefractionInfos.x;var refractionNoiseOffset: vec2f=vec2f(0.0f);\n#ifdef DISPERSION\nfor (var i: i32=0; i<3; i++) {let refractedViewVector: vec3f=refractedViewVectors[i];\n#endif\nlet refractionUVW: vec3f=vec3f((uniforms.backgroundRefractionMatrix*(scene.view*vec4f(fragmentInputs.vPositionW+refractedViewVector*geometry_thickness,1.0f))).xyz);var refractionCoords: vec2f=refractionUVW.xy/refractionUVW.z;refractionCoords.y=1.0f-refractionCoords.y;if (refractionLOD>0.0f) {refractionNoiseOffset=(noise.xy+refractedViewVector.xy)/vec2f(pow(2.0f,uniforms.vBackgroundRefractionInfos.x-refractionLOD));}\nrefractionCoords+=refractionNoiseOffset;\n#ifdef DISPERSION\nslab_translucent_background[i]=textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords,refractionLOD)[i];}\n#else\nslab_translucent_background=textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords,refractionLOD);\n#endif\n}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrBackgroundTransmissionWGSL = { name, shader };\n"]}
|
|
@@ -11,7 +11,7 @@ slab_diffuse=computeAreaDiffuseLighting(preInfo{X},lightColor{X}.rgb);
|
|
|
11
11
|
slab_diffuse=computeDiffuseLighting(preInfo{X},lightColor{X}.rgb);
|
|
12
12
|
#endif
|
|
13
13
|
#ifdef PROJECTEDLIGHTTEXTURE{X}
|
|
14
|
-
slab_diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},vPositionW);
|
|
14
|
+
slab_diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},fragmentInputs.vPositionW);
|
|
15
15
|
#endif
|
|
16
16
|
#ifdef FUZZ
|
|
17
17
|
let fuzzNdotH: f32=max(dot(fuzzNormalW,preInfo{X}.H),0.0f);let fuzzBrdf: vec3f=getFuzzBRDFLookup(fuzzNdotH,sqrt(fuzz_roughness));
|
|
@@ -42,7 +42,7 @@ var forwardScatteredLight: vec3f=vec3f(0.0f);
|
|
|
42
42
|
#else
|
|
43
43
|
{var preInfoTrans=preInfo{X};
|
|
44
44
|
#ifdef SCATTERING
|
|
45
|
-
preInfoTrans.roughness=sqrt(sqrt(max(
|
|
45
|
+
preInfoTrans.roughness=sqrt(sqrt(max(transmission_roughness_alpha,0.05f)));
|
|
46
46
|
#else
|
|
47
47
|
preInfoTrans.roughness=transmission_roughness;
|
|
48
48
|
#endif
|
|
@@ -73,9 +73,9 @@ forwardScatteredLight+=
|
|
|
73
73
|
#if defined(ANISOTROPIC_BASE)
|
|
74
74
|
computeAnisotropicSpecularLighting(preInfoTrans,viewDirectionW,refractNormalW,
|
|
75
75
|
baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,
|
|
76
|
-
|
|
76
|
+
transmission_roughness_alpha,lightColor{X}.rgb
|
|
77
77
|
#else
|
|
78
|
-
computeSpecularLighting(preInfoTrans,-refractNormalW,vec3f(1.0f),vec3f(1.0f),
|
|
78
|
+
computeSpecularLighting(preInfoTrans,-refractNormalW,vec3f(1.0f),vec3f(1.0f),transmission_roughness_alpha,lightColor{X}.rgb
|
|
79
79
|
#endif
|
|
80
80
|
#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)
|
|
81
81
|
)[i];}
|
|
@@ -83,21 +83,29 @@ computeSpecularLighting(preInfoTrans,-refractNormalW,vec3f(1.0f),vec3f(1.0f),rou
|
|
|
83
83
|
);
|
|
84
84
|
#endif
|
|
85
85
|
#if !defined(GEOMETRY_THIN_WALLED)
|
|
86
|
-
forwardScatteredLight=mix(forwardScatteredLight,0.25f*preInfoTrans.attenuation*lightColor{X}.rgb,clamp(1.0f-pow(baseGeoInfo.NdotV,
|
|
86
|
+
forwardScatteredLight=mix(forwardScatteredLight,0.25f*preInfoTrans.attenuation*lightColor{X}.rgb,clamp(1.0f-pow(baseGeoInfo.NdotV,transmission_roughness_alpha),0.0f,1.0f));
|
|
87
87
|
#endif
|
|
88
88
|
#ifdef REFRACTED_BACKGROUND
|
|
89
|
-
|
|
89
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
90
|
+
forwardScatteredLight=mix(vec3f(0.0f),forwardScatteredLight.rgb,0.2*transmission_roughness_alpha);
|
|
91
|
+
#else
|
|
92
|
+
forwardScatteredLight=max(vec3f(0.0f),mix(vec3f(0.0f),forwardScatteredLight,transmission_roughness_alpha));
|
|
93
|
+
#endif
|
|
90
94
|
#endif
|
|
91
95
|
#ifdef SCATTERING
|
|
92
|
-
#
|
|
93
|
-
let diffused_forward_scattered_light: vec3f=scattered_light_from_irradiance_texture;
|
|
94
|
-
#else
|
|
96
|
+
#if !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER)
|
|
95
97
|
preInfoTrans.roughness=1.0f;let diffused_forward_scattered_light: vec3f=computeSpecularLighting(preInfoTrans,normalW,vec3f(1.0f),vec3f(1.0f),1.0f,lightColor{X}.rgb)*volume_absorption;
|
|
96
98
|
#endif
|
|
97
99
|
#ifdef GEOMETRY_THIN_WALLED
|
|
98
|
-
let forward_scattered_light: vec3f=forwardScatteredLight*transmission_tint*volumeParams.multi_scatter_color
|
|
100
|
+
let forward_scattered_light: vec3f=forwardScatteredLight*transmission_tint*volumeParams.multi_scatter_color;let back_scattered_light: vec3f=slab_diffuse*volumeParams.multi_scatter_color;slab_translucent=mix(back_scattered_light,forward_scattered_light,0.5f+0.5f*volumeParams.anisotropy);
|
|
101
|
+
#else
|
|
102
|
+
let back_scattered_normal: vec3f=normalize(normalW+viewDirectionW);preInfoTrans.NdotL=max(dot(back_scattered_normal,preInfoTrans.L),0.0f);preInfoTrans.NdotV=dot(back_scattered_normal,viewDirectionW);preInfoTrans.H=normalize(viewDirectionW+preInfoTrans.L);preInfoTrans.VdotH=clamp(dot(viewDirectionW,preInfoTrans.H),0.0f,1.0f);preInfoTrans.roughness=0.2f;let back_scattered_light: vec3f=computeSpecularLighting(preInfoTrans,viewDirectionW,vec3f(1.0f),vec3f(0.08f),0.0f,lightColor{X}.rgb);let forward_scattered_light: vec3f=(forwardScatteredLight*volume_absorption);let iso_scattered_light: vec3f=slab_diffuse;let back_scattering: vec3f=mix(forward_scattered_light,forward_scattered_light+back_scattered_light*backscatter_color,iso_scatter_density);
|
|
103
|
+
#if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER)
|
|
104
|
+
let iso_scattering: vec3f=mix(forward_scattered_light,scattered_light_from_irradiance_texture*volumeParams.multi_scatter_color,iso_scatter_density);
|
|
99
105
|
#else
|
|
100
|
-
let
|
|
106
|
+
let iso_scattering: vec3f=mix(forward_scattered_light,(diffused_forward_scattered_light+iso_scattered_light)*volumeParams.multi_scatter_color,iso_scatter_density);
|
|
107
|
+
#endif
|
|
108
|
+
slab_translucent=mix(back_scattering,iso_scattering,back_to_iso_scattering_blend);slab_translucent=mix(slab_translucent,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;
|
|
101
109
|
#endif
|
|
102
110
|
#else
|
|
103
111
|
slab_translucent=forwardScatteredLight*transmission_tint*volume_absorption;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openpbrDirectLighting.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmJd,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,yBAAyB,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{var slab_diffuse: vec3f=vec3f(0.f,0.f,0.f);var slab_translucent: vec3f=vec3f(0.f,0.f,0.f);var slab_glossy: vec3f=vec3f(0.f,0.f,0.f);var specularFresnel: f32=0.0f;var specularColoredFresnel: vec3f=vec3f(0.f,0.f,0.f);var slab_metal: vec3f=vec3f(0.f,0.f,0.f);var slab_coat: vec3f=vec3f(0.f,0.f,0.f);var coatFresnel: f32=0.0f;var slab_fuzz: vec3f=vec3f(0.f,0.f,0.f);var fuzzFresnel: f32=0.0f;\n#ifdef HEMILIGHT{X}\nslab_diffuse=computeHemisphericDiffuseLighting(preInfo{X},lightColor{X}.rgb,light{X}.vLightGround);\n#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\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\n#ifdef FUZZ\nlet fuzzNdotH: f32=max(dot(fuzzNormalW,preInfo{X}.H),0.0f);let fuzzBrdf: vec3f=getFuzzBRDFLookup(fuzzNdotH,sqrt(fuzz_roughness));\n#endif\n#ifdef THIN_FILM\nlet thin_film_desaturation_scale: f32=(thin_film_ior-1.0f)*sqrt(thin_film_thickness*0.001f);\n#endif\n#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\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.0f,lightColor{X}.rgb);\n#else\nslab_glossy=computeSpecularLighting(preInfo{X},normalW,vec3(1.0),vec3(1.0),specular_roughness,lightColor{X}.rgb);\n#endif\nspecularFresnel=fresnelSchlickGGX(preInfo{X}.VdotH,baseDielectricReflectance.F0,baseDielectricReflectance.F90);specularColoredFresnel=specularFresnel*specular_color;\n#ifdef THIN_FILM\nvar thinFilmDielectricFresnel: vec3f=evalIridescence(thin_film_outside_ior,thin_film_ior,preInfo{X}.VdotH,thin_film_thickness,baseDielectricReflectance.coloredF0);thinFilmDielectricFresnel=mix(thinFilmDielectricFresnel,vec3f(dot(thinFilmDielectricFresnel,vec3f(0.3333f))),thin_film_desaturation_scale);specularColoredFresnel=mix(specularColoredFresnel,thinFilmDielectricFresnel*specular_color,thin_film_weight*thin_film_ior_scale);\n#endif\n}\n#endif\n#ifdef REFRACTED_LIGHTS\nvar forwardScatteredLight: vec3f=vec3f(0.0f);\n#if AREALIGHT{X}\n#else\n{var preInfoTrans=preInfo{X};\n#ifdef SCATTERING\npreInfoTrans.roughness=sqrt(sqrt(max(refractionAlphaG,0.05f)));\n#else\npreInfoTrans.roughness=transmission_roughness;\n#endif\nif (preInfoTrans.NdotLUnclamped<=0.0) {specularFresnel=0.0;specularColoredFresnel=specularFresnel*specular_color;}\n#ifdef GEOMETRY_THIN_WALLED\nlet refractNormalW: vec3f=viewDirectionW;\n#else\nlet refractNormalW: vec3f=normalW;\n#endif\npreInfoTrans.NdotL=0.5f*max(dot(-refractNormalW,preInfoTrans.L),0.0f)+0.5f;\n#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)\nvar dispersion_iors_local: vec3f=dispersion_iors;let diff: f32=min(dispersion_iors_local[2]-dispersion_iors_local[0],max(dispersion_iors_local[0]-1.0f,1.0f));dispersion_iors_local[2]+=diff;dispersion_iors_local[0]-=diff;for (var i: i32=0; i<3; i++) {let eta: f32=1.0f/dispersion_iors_local[i];\n#elif defined(GEOMETRY_THIN_WALLED)\nlet eta: f32=1.0f;\n#else\nlet eta: f32=1.0f/specular_ior;\n#endif\npreInfoTrans.H=preInfoTrans.L+min(eta,0.95f)*viewDirectionW;let len2: f32=dot(preInfoTrans.H,preInfoTrans.H);if (len2<1e-6f) {preInfoTrans.H=preInfoTrans.L;} else {preInfoTrans.H=preInfoTrans.H*inverseSqrt(len2);}\n#ifdef ANISOTROPIC_BASE\npreInfoTrans.H=-preInfoTrans.H;\n#endif\npreInfoTrans.VdotH=dot(viewDirectionW,preInfoTrans.H);\n#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)\nforwardScatteredLight[i]+=\n#else\nforwardScatteredLight+=\n#endif\n#if defined(ANISOTROPIC_BASE)\ncomputeAnisotropicSpecularLighting(preInfoTrans,viewDirectionW,refractNormalW,\nbaseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,\nroughness_alpha_modified_for_scatter,lightColor{X}.rgb\n#else\ncomputeSpecularLighting(preInfoTrans,-refractNormalW,vec3f(1.0f),vec3f(1.0f),roughness_alpha_modified_for_scatter,lightColor{X}.rgb\n#endif\n#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)\n)[i];}\n#else\n);\n#endif\n#if !defined(GEOMETRY_THIN_WALLED)\nforwardScatteredLight=mix(forwardScatteredLight,0.25f*preInfoTrans.attenuation*lightColor{X}.rgb,clamp(1.0f-pow(baseGeoInfo.NdotV,roughness_alpha_modified_for_scatter),0.0f,1.0f));\n#endif\n#ifdef REFRACTED_BACKGROUND\nforwardScatteredLight=max(slab_translucent_background.rgb,mix(slab_translucent_background.rgb,forwardScatteredLight,roughness_alpha_modified_for_scatter));\n#endif\n#ifdef SCATTERING\n#ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING\nlet diffused_forward_scattered_light: vec3f=scattered_light_from_irradiance_texture;\n#else\npreInfoTrans.roughness=1.0f;let diffused_forward_scattered_light: vec3f=computeSpecularLighting(preInfoTrans,normalW,vec3f(1.0f),vec3f(1.0f),1.0f,lightColor{X}.rgb)*volume_absorption;\n#endif\n#ifdef GEOMETRY_THIN_WALLED\nlet forward_scattered_light: vec3f=forwardScatteredLight*transmission_tint*volumeParams.multi_scatter_color*volumeParams.multi_scatter_color;let back_scattered_light: vec3f=slab_diffuse*volumeParams.multi_scatter_color;slab_translucent=mix(back_scattered_light,forward_scattered_light,0.5f+0.5f*volumeParams.anisotropy);\n#else\nlet back_scattered_normal: vec3f=normalize(normalW+viewDirectionW);preInfoTrans.NdotL=max(dot(back_scattered_normal,preInfoTrans.L),0.0f);preInfoTrans.NdotV=dot(back_scattered_normal,viewDirectionW);preInfoTrans.H=normalize(viewDirectionW+preInfoTrans.L);preInfoTrans.VdotH=clamp(dot(viewDirectionW,preInfoTrans.H),0.0f,1.0f);preInfoTrans.roughness=0.2f;let back_scattered_light: vec3f=computeSpecularLighting(preInfoTrans,viewDirectionW,vec3f(1.0f),vec3f(0.08f),0.0f,lightColor{X}.rgb);let forward_scattered_light: vec3f=(forwardScatteredLight*volume_absorption);let iso_scattered_light: vec3f=slab_diffuse;let back_scattering: vec3f=mix(forward_scattered_light,forward_scattered_light+back_scattered_light*backscatter_color,iso_scatter_density);let iso_scattering: vec3f=mix(forward_scattered_light,(diffused_forward_scattered_light+iso_scattered_light)*volumeParams.multi_scatter_color,iso_scatter_density);slab_translucent=mix(back_scattering,iso_scattering,back_to_iso_scattering_blend);slab_translucent=mix(slab_translucent,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;\n#endif\n#else\nslab_translucent=forwardScatteredLight*transmission_tint*volume_absorption;\n#endif\n}\n#endif\n#endif\n#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\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)\nvar coloredFresnel: vec3f=getF82Specular(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90,specular_roughness);\n#else\nvar coloredFresnel: vec3f=fresnelSchlickGGX(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90);\n#endif\n#ifdef THIN_FILM\nvar thinFilmConductorFresnel=evalIridescence(thin_film_outside_ior,thin_film_ior,preInfo{X}.VdotH,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorFresnel=mix(thinFilmConductorFresnel,vec3f(dot(thinFilmConductorFresnel,vec3f(0.3333f))),thin_film_desaturation_scale);coloredFresnel=mix(coloredFresnel,specular_weight*thin_film_ior_scale*thinFilmConductorFresnel,thin_film_weight);\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,vec3f(baseConductorReflectance.coloredF0),coloredFresnel,specular_roughness,lightColor{X}.rgb);\n#endif\n}\n#endif\n#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\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,0.0,\nlightColor{X}.rgb);\n#else\nslab_coat=computeSpecularLighting(preInfoCoat{X},coatNormalW,vec3f(coatReflectance.F0),vec3f(1.0f),coat_roughness,lightColor{X}.rgb);\n#endif\nlet NdotH: f32=saturateEps(dot(coatNormalW,preInfoCoat{X}.H));coatFresnel=fresnelSchlickGGX(NdotH,coatReflectance.F0,coatReflectance.F90);}\n#endif\nvar coatAbsorption=vec3f(1.0f);if (coat_weight>0.0) {let cosTheta_view: f32=max(preInfoCoat{X}.NdotV,0.001f);let cosTheta_light: f32=max(preInfoCoat{X}.NdotL,0.001f);let fresnel_view: f32=coatReflectance.F0+(1.0f-coatReflectance.F0)*pow(1.0f-cosTheta_view,5.0);let fresnel_light: f32=coatReflectance.F0+(1.0f-coatReflectance.F0)*pow(1.0f-cosTheta_light,5.0);let averageReflectance: f32=(fresnel_view+fresnel_light)*0.5;var darkened_transmission: f32=(1.0f-averageReflectance)/(1.0f+averageReflectance);darkened_transmission=mix(1.0f,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);}\n#ifdef FUZZ\nfuzzFresnel=fuzzBrdf.z;let fuzzNormalW=mix(normalW,coatNormalW,coat_weight);let fuzzNdotV: f32=max(dot(fuzzNormalW,viewDirectionW.xyz),0.0f);let fuzzNdotL: f32=max(dot(fuzzNormalW,preInfo{X}.L),0.0);slab_fuzz=lightColor{X}.rgb*preInfo{X}.attenuation*evalFuzz(preInfo{X}.L,fuzzNdotL,fuzzNdotV,fuzzTangent,fuzzBitangent,fuzzBrdf);\n#else\nlet fuzz_color=vec3f(0.0);\n#endif\n#ifdef PREPASS_IRRADIANCE\ntotal_direct_diffuse+=slab_diffuse;\n#endif\nlet material_dielectric_base: vec3f=mix(slab_diffuse*base_color.rgb,slab_translucent,surface_translucency_weight);let material_dielectric_gloss: vec3f=material_dielectric_base*(1.0f-specularFresnel)+slab_glossy*specularColoredFresnel;let material_base_substrate: vec3f=mix(material_dielectric_gloss,slab_metal,base_metalness);let material_coated_base: vec3f=layer(material_base_substrate,slab_coat,coatFresnel,coatAbsorption,vec3f(1.0f));material_surface_direct+=layer(material_coated_base,slab_fuzz,fuzzFresnel*fuzz_weight,vec3f(1.0f),fuzz_color);}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrDirectLightingWGSL = { name, shader };\n"]}
|
|
1
|
+
{"version":3,"file":"openpbrDirectLighting.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Jd,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,yBAAyB,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{var slab_diffuse: vec3f=vec3f(0.f,0.f,0.f);var slab_translucent: vec3f=vec3f(0.f,0.f,0.f);var slab_glossy: vec3f=vec3f(0.f,0.f,0.f);var specularFresnel: f32=0.0f;var specularColoredFresnel: vec3f=vec3f(0.f,0.f,0.f);var slab_metal: vec3f=vec3f(0.f,0.f,0.f);var slab_coat: vec3f=vec3f(0.f,0.f,0.f);var coatFresnel: f32=0.0f;var slab_fuzz: vec3f=vec3f(0.f,0.f,0.f);var fuzzFresnel: f32=0.0f;\n#ifdef HEMILIGHT{X}\nslab_diffuse=computeHemisphericDiffuseLighting(preInfo{X},lightColor{X}.rgb,light{X}.vLightGround);\n#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\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},fragmentInputs.vPositionW);\n#endif\n#ifdef FUZZ\nlet fuzzNdotH: f32=max(dot(fuzzNormalW,preInfo{X}.H),0.0f);let fuzzBrdf: vec3f=getFuzzBRDFLookup(fuzzNdotH,sqrt(fuzz_roughness));\n#endif\n#ifdef THIN_FILM\nlet thin_film_desaturation_scale: f32=(thin_film_ior-1.0f)*sqrt(thin_film_thickness*0.001f);\n#endif\n#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\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.0f,lightColor{X}.rgb);\n#else\nslab_glossy=computeSpecularLighting(preInfo{X},normalW,vec3(1.0),vec3(1.0),specular_roughness,lightColor{X}.rgb);\n#endif\nspecularFresnel=fresnelSchlickGGX(preInfo{X}.VdotH,baseDielectricReflectance.F0,baseDielectricReflectance.F90);specularColoredFresnel=specularFresnel*specular_color;\n#ifdef THIN_FILM\nvar thinFilmDielectricFresnel: vec3f=evalIridescence(thin_film_outside_ior,thin_film_ior,preInfo{X}.VdotH,thin_film_thickness,baseDielectricReflectance.coloredF0);thinFilmDielectricFresnel=mix(thinFilmDielectricFresnel,vec3f(dot(thinFilmDielectricFresnel,vec3f(0.3333f))),thin_film_desaturation_scale);specularColoredFresnel=mix(specularColoredFresnel,thinFilmDielectricFresnel*specular_color,thin_film_weight*thin_film_ior_scale);\n#endif\n}\n#endif\n#ifdef REFRACTED_LIGHTS\nvar forwardScatteredLight: vec3f=vec3f(0.0f);\n#if AREALIGHT{X}\n#else\n{var preInfoTrans=preInfo{X};\n#ifdef SCATTERING\npreInfoTrans.roughness=sqrt(sqrt(max(transmission_roughness_alpha,0.05f)));\n#else\npreInfoTrans.roughness=transmission_roughness;\n#endif\nif (preInfoTrans.NdotLUnclamped<=0.0) {specularFresnel=0.0;specularColoredFresnel=specularFresnel*specular_color;}\n#ifdef GEOMETRY_THIN_WALLED\nlet refractNormalW: vec3f=viewDirectionW;\n#else\nlet refractNormalW: vec3f=normalW;\n#endif\npreInfoTrans.NdotL=0.5f*max(dot(-refractNormalW,preInfoTrans.L),0.0f)+0.5f;\n#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)\nvar dispersion_iors_local: vec3f=dispersion_iors;let diff: f32=min(dispersion_iors_local[2]-dispersion_iors_local[0],max(dispersion_iors_local[0]-1.0f,1.0f));dispersion_iors_local[2]+=diff;dispersion_iors_local[0]-=diff;for (var i: i32=0; i<3; i++) {let eta: f32=1.0f/dispersion_iors_local[i];\n#elif defined(GEOMETRY_THIN_WALLED)\nlet eta: f32=1.0f;\n#else\nlet eta: f32=1.0f/specular_ior;\n#endif\npreInfoTrans.H=preInfoTrans.L+min(eta,0.95f)*viewDirectionW;let len2: f32=dot(preInfoTrans.H,preInfoTrans.H);if (len2<1e-6f) {preInfoTrans.H=preInfoTrans.L;} else {preInfoTrans.H=preInfoTrans.H*inverseSqrt(len2);}\n#ifdef ANISOTROPIC_BASE\npreInfoTrans.H=-preInfoTrans.H;\n#endif\npreInfoTrans.VdotH=dot(viewDirectionW,preInfoTrans.H);\n#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)\nforwardScatteredLight[i]+=\n#else\nforwardScatteredLight+=\n#endif\n#if defined(ANISOTROPIC_BASE)\ncomputeAnisotropicSpecularLighting(preInfoTrans,viewDirectionW,refractNormalW,\nbaseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,\ntransmission_roughness_alpha,lightColor{X}.rgb\n#else\ncomputeSpecularLighting(preInfoTrans,-refractNormalW,vec3f(1.0f),vec3f(1.0f),transmission_roughness_alpha,lightColor{X}.rgb\n#endif\n#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)\n)[i];}\n#else\n);\n#endif\n#if !defined(GEOMETRY_THIN_WALLED)\nforwardScatteredLight=mix(forwardScatteredLight,0.25f*preInfoTrans.attenuation*lightColor{X}.rgb,clamp(1.0f-pow(baseGeoInfo.NdotV,transmission_roughness_alpha),0.0f,1.0f));\n#endif\n#ifdef REFRACTED_BACKGROUND\n#ifdef GEOMETRY_THIN_WALLED\nforwardScatteredLight=mix(vec3f(0.0f),forwardScatteredLight.rgb,0.2*transmission_roughness_alpha);\n#else\nforwardScatteredLight=max(vec3f(0.0f),mix(vec3f(0.0f),forwardScatteredLight,transmission_roughness_alpha));\n#endif\n#endif\n#ifdef SCATTERING\n#if !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER)\npreInfoTrans.roughness=1.0f;let diffused_forward_scattered_light: vec3f=computeSpecularLighting(preInfoTrans,normalW,vec3f(1.0f),vec3f(1.0f),1.0f,lightColor{X}.rgb)*volume_absorption;\n#endif\n#ifdef GEOMETRY_THIN_WALLED\nlet forward_scattered_light: vec3f=forwardScatteredLight*transmission_tint*volumeParams.multi_scatter_color;let back_scattered_light: vec3f=slab_diffuse*volumeParams.multi_scatter_color;slab_translucent=mix(back_scattered_light,forward_scattered_light,0.5f+0.5f*volumeParams.anisotropy);\n#else\nlet back_scattered_normal: vec3f=normalize(normalW+viewDirectionW);preInfoTrans.NdotL=max(dot(back_scattered_normal,preInfoTrans.L),0.0f);preInfoTrans.NdotV=dot(back_scattered_normal,viewDirectionW);preInfoTrans.H=normalize(viewDirectionW+preInfoTrans.L);preInfoTrans.VdotH=clamp(dot(viewDirectionW,preInfoTrans.H),0.0f,1.0f);preInfoTrans.roughness=0.2f;let back_scattered_light: vec3f=computeSpecularLighting(preInfoTrans,viewDirectionW,vec3f(1.0f),vec3f(0.08f),0.0f,lightColor{X}.rgb);let forward_scattered_light: vec3f=(forwardScatteredLight*volume_absorption);let iso_scattered_light: vec3f=slab_diffuse;let back_scattering: vec3f=mix(forward_scattered_light,forward_scattered_light+back_scattered_light*backscatter_color,iso_scatter_density);\n#if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER)\nlet iso_scattering: vec3f=mix(forward_scattered_light,scattered_light_from_irradiance_texture*volumeParams.multi_scatter_color,iso_scatter_density);\n#else\nlet iso_scattering: vec3f=mix(forward_scattered_light,(diffused_forward_scattered_light+iso_scattered_light)*volumeParams.multi_scatter_color,iso_scatter_density);\n#endif\nslab_translucent=mix(back_scattering,iso_scattering,back_to_iso_scattering_blend);slab_translucent=mix(slab_translucent,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;\n#endif\n#else\nslab_translucent=forwardScatteredLight*transmission_tint*volume_absorption;\n#endif\n}\n#endif\n#endif\n#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\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)\nvar coloredFresnel: vec3f=getF82Specular(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90,specular_roughness);\n#else\nvar coloredFresnel: vec3f=fresnelSchlickGGX(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90);\n#endif\n#ifdef THIN_FILM\nvar thinFilmConductorFresnel=evalIridescence(thin_film_outside_ior,thin_film_ior,preInfo{X}.VdotH,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorFresnel=mix(thinFilmConductorFresnel,vec3f(dot(thinFilmConductorFresnel,vec3f(0.3333f))),thin_film_desaturation_scale);coloredFresnel=mix(coloredFresnel,specular_weight*thin_film_ior_scale*thinFilmConductorFresnel,thin_film_weight);\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,vec3f(baseConductorReflectance.coloredF0),coloredFresnel,specular_roughness,lightColor{X}.rgb);\n#endif\n}\n#endif\n#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\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,0.0,\nlightColor{X}.rgb);\n#else\nslab_coat=computeSpecularLighting(preInfoCoat{X},coatNormalW,vec3f(coatReflectance.F0),vec3f(1.0f),coat_roughness,lightColor{X}.rgb);\n#endif\nlet NdotH: f32=saturateEps(dot(coatNormalW,preInfoCoat{X}.H));coatFresnel=fresnelSchlickGGX(NdotH,coatReflectance.F0,coatReflectance.F90);}\n#endif\nvar coatAbsorption=vec3f(1.0f);if (coat_weight>0.0) {let cosTheta_view: f32=max(preInfoCoat{X}.NdotV,0.001f);let cosTheta_light: f32=max(preInfoCoat{X}.NdotL,0.001f);let fresnel_view: f32=coatReflectance.F0+(1.0f-coatReflectance.F0)*pow(1.0f-cosTheta_view,5.0);let fresnel_light: f32=coatReflectance.F0+(1.0f-coatReflectance.F0)*pow(1.0f-cosTheta_light,5.0);let averageReflectance: f32=(fresnel_view+fresnel_light)*0.5;var darkened_transmission: f32=(1.0f-averageReflectance)/(1.0f+averageReflectance);darkened_transmission=mix(1.0f,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);}\n#ifdef FUZZ\nfuzzFresnel=fuzzBrdf.z;let fuzzNormalW=mix(normalW,coatNormalW,coat_weight);let fuzzNdotV: f32=max(dot(fuzzNormalW,viewDirectionW.xyz),0.0f);let fuzzNdotL: f32=max(dot(fuzzNormalW,preInfo{X}.L),0.0);slab_fuzz=lightColor{X}.rgb*preInfo{X}.attenuation*evalFuzz(preInfo{X}.L,fuzzNdotL,fuzzNdotV,fuzzTangent,fuzzBitangent,fuzzBrdf);\n#else\nlet fuzz_color=vec3f(0.0);\n#endif\n#ifdef PREPASS_IRRADIANCE\ntotal_direct_diffuse+=slab_diffuse;\n#endif\nlet material_dielectric_base: vec3f=mix(slab_diffuse*base_color.rgb,slab_translucent,surface_translucency_weight);let material_dielectric_gloss: vec3f=material_dielectric_base*(1.0f-specularFresnel)+slab_glossy*specularColoredFresnel;let material_base_substrate: vec3f=mix(material_dielectric_gloss,slab_metal,base_metalness);let material_coated_base: vec3f=layer(material_base_substrate,slab_coat,coatFresnel,coatAbsorption,vec3f(1.0f));material_surface_direct+=layer(material_coated_base,slab_fuzz,fuzzFresnel*fuzz_weight,vec3f(1.0f),fuzz_color);}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrDirectLightingWGSL = { name, shader };\n"]}
|
|
@@ -7,15 +7,15 @@ var preInfo{X}: preLightingInfo;var preInfoCoat{X}: preLightingInfo;let lightCol
|
|
|
7
7
|
#else
|
|
8
8
|
#define CUSTOM_LIGHT{X}_COLOR
|
|
9
9
|
#ifdef SPOTLIGHT{X}
|
|
10
|
-
preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);
|
|
10
|
+
preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,fragmentInputs.vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,fragmentInputs.vPositionW);
|
|
11
11
|
#elif defined(POINTLIGHT{X})
|
|
12
|
-
preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);
|
|
12
|
+
preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,fragmentInputs.vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,fragmentInputs.vPositionW);
|
|
13
13
|
#elif defined(HEMILIGHT{X})
|
|
14
14
|
preInfo{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);
|
|
15
15
|
#elif defined(DIRLIGHT{X})
|
|
16
16
|
preInfo{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);
|
|
17
17
|
#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && 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);
|
|
18
|
+
preInfo{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,fragmentInputs.vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,specular_roughness);preInfoCoat{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,coatNormalW,fragmentInputs.vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,coat_roughness);
|
|
19
19
|
#endif
|
|
20
20
|
preInfo{X}.NdotV=baseGeoInfo.NdotV;preInfoCoat{X}.NdotV=coatGeoInfo.NdotV;
|
|
21
21
|
#ifdef SPOTLIGHT{X}
|
|
@@ -1 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuEd,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(AREALIGHTUSED) && 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})\npreInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness;\n#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\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"]}
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuEd,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,fragmentInputs.vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,fragmentInputs.vPositionW);\n#elif defined(POINTLIGHT{X})\npreInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,fragmentInputs.vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,fragmentInputs.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(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\npreInfo{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,fragmentInputs.vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,specular_roughness);preInfoCoat{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,coatNormalW,fragmentInputs.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})\npreInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness;\n#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)\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"]}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
// Do not edit.
|
|
2
2
|
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
3
|
const name = "openpbrEnvironmentLighting";
|
|
4
|
-
const shader = `#
|
|
4
|
+
const shader = `#if defined(REFLECTION) || defined(REFRACTED_BACKGROUND)
|
|
5
|
+
var coatAbsorption=vec3f(1.0f);var coatIblFresnel: f32=0.0;if (coat_weight>0.0) {coatIblFresnel=computeDielectricIblFresnel(coatReflectance,coatGeoInfo.environmentBrdf);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*darkened_transmission,coat_weight);}
|
|
6
|
+
#endif
|
|
7
|
+
#ifdef REFLECTION
|
|
5
8
|
#ifdef FUZZ
|
|
6
9
|
let environmentFuzzBrdf: vec3f=getFuzzBRDFLookup(fuzzGeoInfo.NdotV,sqrt(fuzz_roughness));
|
|
7
10
|
#endif
|
|
@@ -115,31 +118,30 @@ let modifiedFuzzRoughness: f32=clamp(fuzz_roughness*(1.0f-0.5f*environmentFuzzBr
|
|
|
115
118
|
);fuzzEnvironmentLight+=sampleWeight*mix(radianceSample,baseDiffuseEnvironmentLight,fiberBend);totalWeight+=sampleWeight;}
|
|
116
119
|
fuzzEnvironmentLight/=totalWeight;
|
|
117
120
|
#endif
|
|
118
|
-
let dielectricIblFresnel: f32=
|
|
121
|
+
let dielectricIblFresnel: f32=computeDielectricIblFresnel(baseDielectricReflectance,baseGeoInfo.environmentBrdf);var dielectricIblColoredFresnel: vec3f=dielectricIblFresnel*specular_color;
|
|
119
122
|
#ifdef THIN_FILM
|
|
120
123
|
var thin_film_dielectric: vec3f=evalIridescence(thin_film_outside_ior,thin_film_ior,baseGeoInfo.NdotV,thin_film_thickness,baseDielectricReflectance.coloredF0);let thin_film_desaturation_scale=(thin_film_ior-1.0)*sqrt(thin_film_thickness*0.001f*baseGeoInfo.NdotV);thin_film_dielectric=mix(thin_film_dielectric,vec3(dot(thin_film_dielectric,vec3f(0.3333f))),thin_film_desaturation_scale);dielectricIblColoredFresnel=mix(dielectricIblColoredFresnel,thin_film_dielectric*specular_color,thin_film_weight*thin_film_ior_scale);
|
|
121
124
|
#endif
|
|
122
|
-
var conductorIblFresnel: vec3f=
|
|
125
|
+
var conductorIblFresnel: vec3f=computeConductorIblFresnel(baseConductorReflectance,baseGeoInfo.environmentBrdf);
|
|
123
126
|
#ifdef THIN_FILM
|
|
124
127
|
var thinFilmConductorFresnel: vec3f=specular_weight*evalIridescence(thin_film_outside_ior,thin_film_ior,baseGeoInfo.NdotV,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorFresnel=mix(thinFilmConductorFresnel,vec3(dot(thinFilmConductorFresnel,vec3f(0.3333f))),thin_film_desaturation_scale);conductorIblFresnel=mix(conductorIblFresnel,thinFilmConductorFresnel,thin_film_weight*thin_film_ior_scale);
|
|
125
128
|
#endif
|
|
126
|
-
var coatIblFresnel: f32=0.0;if (coat_weight>0.0) {coatIblFresnel=getReflectanceFromBRDFWithEnvLookup(vec3f(coatReflectance.F0),vec3f(coatReflectance.F90),coatGeoInfo.environmentBrdf).r;}
|
|
127
129
|
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;
|
|
128
130
|
#ifdef AMBIENT_OCCLUSION
|
|
129
131
|
specular_ambient_occlusion=compute_specular_occlusion(baseGeoInfo.NdotV,base_metalness,ambient_occlusion.x,specular_roughness);
|
|
130
132
|
#endif
|
|
131
|
-
slab_glossy_ibl=baseSpecularEnvironmentLight*uniforms.vLightingIntensity.z;slab_metal_ibl=baseSpecularEnvironmentLight*conductorIblFresnel*uniforms.vLightingIntensity.z;
|
|
133
|
+
slab_glossy_ibl=baseSpecularEnvironmentLight*uniforms.vLightingIntensity.z;slab_metal_ibl=baseSpecularEnvironmentLight*conductorIblFresnel*uniforms.vLightingIntensity.z;if (coat_weight>0.0) {slab_coat_ibl=coatEnvironmentLight*uniforms.vLightingIntensity.z;
|
|
132
134
|
#ifdef AMBIENT_OCCLUSION
|
|
133
135
|
coat_specular_ambient_occlusion=compute_specular_occlusion(coatGeoInfo.NdotV,0.0,ambient_occlusion.x,coat_roughness);
|
|
134
136
|
#endif
|
|
135
|
-
|
|
137
|
+
}
|
|
136
138
|
#ifdef FUZZ
|
|
137
139
|
var slab_fuzz_ibl=fuzzEnvironmentLight*uniforms.vLightingIntensity.z;
|
|
138
140
|
#endif
|
|
139
141
|
var slab_translucent_base_ibl: vec3f=vec3f(0.0f,0.0f,0.0f);
|
|
140
142
|
#ifdef REFRACTED_ENVIRONMENT
|
|
141
143
|
#ifdef ANISOTROPIC_BASE
|
|
142
|
-
var forwardScatteredEnvironmentLight: vec3f=sampleRadianceAnisotropic(
|
|
144
|
+
var forwardScatteredEnvironmentLight: vec3f=sampleRadianceAnisotropic(transmission_roughness_alpha,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
|
|
143
145
|
,baseGeoInfo
|
|
144
146
|
#ifdef GEOMETRY_THIN_WALLED
|
|
145
147
|
,viewDirectionW
|
|
@@ -176,7 +178,7 @@ iblRefractionCoords=parallaxCorrectNormal(fragmentInputs.vPositionW,refractedVie
|
|
|
176
178
|
#endif
|
|
177
179
|
iblRefractionCoords=(uniforms.reflectionMatrix*vec4f(iblRefractionCoords,0.0f)).xyz;
|
|
178
180
|
#ifdef DISPERSION
|
|
179
|
-
forwardScatteredEnvironmentLight[i]=sampleRadiance(
|
|
181
|
+
forwardScatteredEnvironmentLight[i]=sampleRadiance(transmission_roughness_alpha,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
|
|
180
182
|
,baseGeoInfo
|
|
181
183
|
,reflectionSampler
|
|
182
184
|
,reflectionSamplerSampler
|
|
@@ -186,7 +188,7 @@ forwardScatteredEnvironmentLight[i]=sampleRadiance(roughness_alpha_modified_for_
|
|
|
186
188
|
#endif
|
|
187
189
|
)[i];
|
|
188
190
|
#else
|
|
189
|
-
forwardScatteredEnvironmentLight=sampleRadiance(
|
|
191
|
+
forwardScatteredEnvironmentLight=sampleRadiance(transmission_roughness_alpha,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
|
|
190
192
|
,baseGeoInfo
|
|
191
193
|
,reflectionSampler
|
|
192
194
|
,reflectionSamplerSampler
|
|
@@ -201,12 +203,13 @@ forwardScatteredEnvironmentLight=sampleRadiance(roughness_alpha_modified_for_sca
|
|
|
201
203
|
#endif
|
|
202
204
|
#endif
|
|
203
205
|
#ifdef REFRACTED_BACKGROUND
|
|
204
|
-
|
|
206
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
207
|
+
forwardScatteredEnvironmentLight=mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight.rgb,0.2*transmission_roughness_alpha);
|
|
208
|
+
#else
|
|
209
|
+
forwardScatteredEnvironmentLight=max(slab_translucent_background.rgb,mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight,transmission_roughness_alpha));
|
|
210
|
+
#endif
|
|
205
211
|
#endif
|
|
206
212
|
#ifdef SCATTERING
|
|
207
|
-
#ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING
|
|
208
|
-
var scatteredEnvironmentLight: vec3f=scattered_light_from_irradiance_texture;
|
|
209
|
-
#else
|
|
210
213
|
#ifdef GEOMETRY_THIN_WALLED
|
|
211
214
|
var scatterVector: vec3f=normalW;
|
|
212
215
|
#else
|
|
@@ -217,6 +220,9 @@ var scatterVector: vec3f=normalW;
|
|
|
217
220
|
#endif
|
|
218
221
|
scatterVector=mix(viewDirectionW,scatterVector,back_to_iso_scattering_blend);
|
|
219
222
|
#endif
|
|
223
|
+
#if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(GEOMETRY_THIN_WALLED)
|
|
224
|
+
var scatteredEnvironmentLight: vec3f=scattered_light_from_irradiance_texture;
|
|
225
|
+
#else
|
|
220
226
|
var scatteredEnvironmentLight: vec3f=sampleIrradiance(
|
|
221
227
|
scatterVector
|
|
222
228
|
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
@@ -251,7 +257,7 @@ scatterVector
|
|
|
251
257
|
);
|
|
252
258
|
#endif
|
|
253
259
|
#ifdef GEOMETRY_THIN_WALLED
|
|
254
|
-
let forward_scattered_light: vec3f=forwardScatteredEnvironmentLight*transmission_tint*volumeParams.multi_scatter_color
|
|
260
|
+
let forward_scattered_light: vec3f=forwardScatteredEnvironmentLight*transmission_tint*volumeParams.multi_scatter_color;let back_scattered_light: vec3f=scatteredEnvironmentLight*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(back_scattered_light,forward_scattered_light,0.5f+0.5f*volumeParams.anisotropy);
|
|
255
261
|
#else
|
|
256
262
|
let forward_scattered_light: vec3f=forwardScatteredEnvironmentLight*volume_absorption;let back_scattered_light: vec3f=mix(forward_scattered_light,scatteredEnvironmentLight*backscatter_color,iso_scatter_density);let iso_scattered_light: vec3f=mix(forward_scattered_light,scatteredEnvironmentLight*volumeParams.multi_scatter_color,iso_scatter_density);slab_translucent_base_ibl=mix(back_scattered_light,iso_scattered_light,back_to_iso_scattering_blend);slab_translucent_base_ibl=mix(slab_translucent_base_ibl,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;
|
|
257
263
|
#endif
|
|
@@ -266,6 +272,22 @@ slab_fuzz_ibl*=min(vec3(specular_ambient_occlusion),ambient_occlusion);material_
|
|
|
266
272
|
#else
|
|
267
273
|
material_surface_ibl=material_coated_base_ibl;
|
|
268
274
|
#endif
|
|
275
|
+
#elif defined(REFRACTED_BACKGROUND)
|
|
276
|
+
let black=vec3f(0.0f);var slab_translucent_base_ibl: vec3f=vec3f(0.0f);
|
|
277
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
278
|
+
#ifdef SCATTERING
|
|
279
|
+
let forward_scattered_light: vec3f=slab_translucent_background.rgb*transmission_tint*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(black,forward_scattered_light,0.5f+0.5f*volumeParams.anisotropy);
|
|
280
|
+
#else
|
|
281
|
+
slab_translucent_base_ibl=slab_translucent_background.rgb*transmission_tint;
|
|
282
|
+
#endif
|
|
283
|
+
#else
|
|
284
|
+
#ifdef SCATTERING
|
|
285
|
+
let forward_scattered_light: vec3f=slab_translucent_background.rgb*volume_absorption;let iso_scattered_light: vec3f=(1.0f-iso_scatter_density)*forward_scattered_light;slab_translucent_base_ibl=mix(black,iso_scattered_light,back_to_iso_scattering_blend);slab_translucent_base_ibl=mix(slab_translucent_base_ibl,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;
|
|
286
|
+
#else
|
|
287
|
+
slab_translucent_base_ibl=slab_translucent_background.rgb*volume_absorption*transmission_tint;
|
|
288
|
+
#endif
|
|
289
|
+
#endif
|
|
290
|
+
let material_dielectric_base_ibl: vec3f=mix(black,slab_translucent_base_ibl.rgb,surface_translucency_weight);let material_dielectric_gloss_ibl: vec3f=material_dielectric_base_ibl*(baseGeoInfo.NdotV);let material_base_substrate_ibl: vec3f=mix(material_dielectric_gloss_ibl,black,base_metalness);let material_coated_base_ibl: vec3f=layer(material_base_substrate_ibl,black,coatIblFresnel,coatAbsorption,vec3f(1.0f));material_surface_ibl=material_coated_base_ibl;
|
|
269
291
|
#endif
|
|
270
292
|
`;
|
|
271
293
|
// Sideeffect
|
|
@@ -1 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Qd,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\n#ifdef FUZZ\nlet environmentFuzzBrdf: vec3f=getFuzzBRDFLookup(fuzzGeoInfo.NdotV,sqrt(fuzz_roughness));\n#endif\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,false \n,1.0 \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,false \n,1.0 \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}\n#ifdef FUZZ\nlet modifiedFuzzRoughness: f32=clamp(fuzz_roughness*(1.0f-0.5f*environmentFuzzBrdf.y),0.0f,1.0f);var fuzzEnvironmentLight=vec3f(0.0f,0.0f,0.0f);var totalWeight=0.0f;let fuzzIblFresnel: f32=sqrt(environmentFuzzBrdf.z);for (var i: i32=0; i<i32(FUZZ_IBL_SAMPLES); i++) {var angle: f32=(f32(i)+noise.x)*(3.141592f*2.0f/f32(FUZZ_IBL_SAMPLES));var fiberCylinderNormal: vec3f=normalize(cos(angle)*fuzzTangent+sin(angle)*fuzzBitangent);let fiberBend=min(environmentFuzzBrdf.x*environmentFuzzBrdf.x*modifiedFuzzRoughness,1.0f);fiberCylinderNormal=normalize(mix(fiberCylinderNormal,fuzzNormalW,fiberBend));let sampleWeight=max(dot(viewDirectionW,fiberCylinderNormal),0.0f);var fuzzReflectionCoords=createReflectionCoords(fragmentInputs.vPositionW,fiberCylinderNormal);let radianceSample: vec3f=sampleRadiance(modifiedFuzzRoughness,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,fuzzGeoInfo\n,reflectionSampler\n,reflectionSamplerSampler\n,fuzzReflectionCoords\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n);fuzzEnvironmentLight+=sampleWeight*mix(radianceSample,baseDiffuseEnvironmentLight,fiberBend);totalWeight+=sampleWeight;}\nfuzzEnvironmentLight/=totalWeight;\n#endif\nlet dielectricIblFresnel: f32=getReflectanceFromBRDFWithEnvLookup(vec3f(baseDielectricReflectance.F0),vec3f(baseDielectricReflectance.F90),baseGeoInfo.environmentBrdf).r;var dielectricIblColoredFresnel: vec3f=dielectricIblFresnel*specular_color;\n#ifdef THIN_FILM\nvar thin_film_dielectric: vec3f=evalIridescence(thin_film_outside_ior,thin_film_ior,baseGeoInfo.NdotV,thin_film_thickness,baseDielectricReflectance.coloredF0);let thin_film_desaturation_scale=(thin_film_ior-1.0)*sqrt(thin_film_thickness*0.001f*baseGeoInfo.NdotV);thin_film_dielectric=mix(thin_film_dielectric,vec3(dot(thin_film_dielectric,vec3f(0.3333f))),thin_film_desaturation_scale);dielectricIblColoredFresnel=mix(dielectricIblColoredFresnel,thin_film_dielectric*specular_color,thin_film_weight*thin_film_ior_scale);\n#endif\nvar conductorIblFresnel: vec3f=conductorIblFresnel(baseConductorReflectance,baseGeoInfo.NdotV,specular_roughness,baseGeoInfo.environmentBrdf);\n#ifdef THIN_FILM\nvar thinFilmConductorFresnel: vec3f=specular_weight*evalIridescence(thin_film_outside_ior,thin_film_ior,baseGeoInfo.NdotV,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorFresnel=mix(thinFilmConductorFresnel,vec3(dot(thinFilmConductorFresnel,vec3f(0.3333f))),thin_film_desaturation_scale);conductorIblFresnel=mix(conductorIblFresnel,thinFilmConductorFresnel,thin_film_weight*thin_film_ior_scale);\n#endif\nvar 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;\n#ifdef AMBIENT_OCCLUSION\nspecular_ambient_occlusion=compute_specular_occlusion(baseGeoInfo.NdotV,base_metalness,ambient_occlusion.x,specular_roughness);\n#endif\nslab_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;\n#ifdef AMBIENT_OCCLUSION\ncoat_specular_ambient_occlusion=compute_specular_occlusion(coatGeoInfo.NdotV,0.0,ambient_occlusion.x,coat_roughness);\n#endif\nlet 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);}\n#ifdef FUZZ\nvar slab_fuzz_ibl=fuzzEnvironmentLight*uniforms.vLightingIntensity.z;\n#endif\nvar slab_translucent_base_ibl: vec3f=vec3f(0.0f,0.0f,0.0f);\n#ifdef REFRACTED_ENVIRONMENT\n#ifdef ANISOTROPIC_BASE\nvar forwardScatteredEnvironmentLight: vec3f=sampleRadianceAnisotropic(roughness_alpha_modified_for_scatter,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,baseGeoInfo\n#ifdef GEOMETRY_THIN_WALLED\n,viewDirectionW\n#else\n,normalW\n#endif\n,viewDirectionW\n,fragmentInputs.vPositionW\n,noise\n,true \n#ifdef GEOMETRY_THIN_WALLED\n,1.05f \n#else\n,specular_ior \n#endif\n,reflectionSampler\n,reflectionSamplerSampler\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n);\n#else\nvar forwardScatteredEnvironmentLight: vec3f=vec3f(0.,0.,0.);\n#ifdef DISPERSION\nfor (var i: i32=0; i<3; i++) {var iblRefractionCoords: vec3f=refractedViewVectors[i];\n#else\nvar iblRefractionCoords: vec3f=refractedViewVector;\n#endif\n#ifdef REFRACTED_ENVIRONMENT_OPPOSITEZ\niblRefractionCoords.z*=-1.0f;\n#endif\n#ifdef REFRACTED_ENVIRONMENT_LOCAL_CUBE\niblRefractionCoords=parallaxCorrectNormal(fragmentInputs.vPositionW,refractedViewVector,uniforms.refractionSize,uniforms.refractionPosition);\n#endif\niblRefractionCoords=(uniforms.reflectionMatrix*vec4f(iblRefractionCoords,0.0f)).xyz;\n#ifdef DISPERSION\nforwardScatteredEnvironmentLight[i]=sampleRadiance(roughness_alpha_modified_for_scatter,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,baseGeoInfo\n,reflectionSampler\n,reflectionSamplerSampler\n,iblRefractionCoords\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n)[i];\n#else\nforwardScatteredEnvironmentLight=sampleRadiance(roughness_alpha_modified_for_scatter,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,baseGeoInfo\n,reflectionSampler\n,reflectionSamplerSampler\n,iblRefractionCoords\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n);\n#endif\n#ifdef DISPERSION\n}\n#endif\n#endif\n#ifdef REFRACTED_BACKGROUND\nforwardScatteredEnvironmentLight=max(slab_translucent_background.rgb,mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight,roughness_alpha_modified_for_scatter));\n#endif\n#ifdef SCATTERING\n#ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING\nvar scatteredEnvironmentLight: vec3f=scattered_light_from_irradiance_texture;\n#else\n#ifdef GEOMETRY_THIN_WALLED\nvar scatterVector: vec3f=normalW;\n#else\n#if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION)\nvar scatterVector: vec3f=mix(uniforms.vReflectionDominantDirection,normalW,max3(iso_scatter_density));\n#else\nvar scatterVector: vec3f=normalW;\n#endif\nscatterVector=mix(viewDirectionW,scatterVector,back_to_iso_scattering_blend);\n#endif\nvar scatteredEnvironmentLight: vec3f=sampleIrradiance(\nscatterVector\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#if defined(GEOMETRY_THIN_WALLED)\n,base_diffuse_roughness\n,subsurface_color.rgb\n#else\n,1.0f\n,volumeParams.multi_scatter_color\n#endif\n);\n#endif\n#ifdef GEOMETRY_THIN_WALLED\nlet forward_scattered_light: vec3f=forwardScatteredEnvironmentLight*transmission_tint*volumeParams.multi_scatter_color*volumeParams.multi_scatter_color;let back_scattered_light: vec3f=scatteredEnvironmentLight*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(back_scattered_light,forward_scattered_light,0.5f+0.5f*volumeParams.anisotropy);\n#else\nlet forward_scattered_light: vec3f=forwardScatteredEnvironmentLight*volume_absorption;let back_scattered_light: vec3f=mix(forward_scattered_light,scatteredEnvironmentLight*backscatter_color,iso_scatter_density);let iso_scattered_light: vec3f=mix(forward_scattered_light,scatteredEnvironmentLight*volumeParams.multi_scatter_color,iso_scatter_density);slab_translucent_base_ibl=mix(back_scattered_light,iso_scattered_light,back_to_iso_scattering_blend);slab_translucent_base_ibl=mix(slab_translucent_base_ibl,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;\n#endif\n#else\nslab_translucent_base_ibl+=forwardScatteredEnvironmentLight*transmission_tint*volume_absorption;\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_IBLLAYERCOMPOSITION\nslab_diffuse_ibl*=ambient_occlusion;slab_metal_ibl*=specular_ambient_occlusion;slab_glossy_ibl*=specular_ambient_occlusion;slab_coat_ibl*=coat_specular_ambient_occlusion;let material_dielectric_base_ibl: vec3f=mix(slab_diffuse_ibl*base_color.rgb,slab_translucent_base_ibl,surface_translucency_weight);let material_dielectric_gloss_ibl: vec3f=material_dielectric_base_ibl*(1.0-dielectricIblFresnel)+slab_glossy_ibl*dielectricIblColoredFresnel;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));\n#ifdef FUZZ\nslab_fuzz_ibl*=min(vec3(specular_ambient_occlusion),ambient_occlusion);material_surface_ibl=layer(material_coated_base_ibl,slab_fuzz_ibl,fuzzIblFresnel*fuzz_weight,vec3f(1.0f),fuzz_color);\n#else\nmaterial_surface_ibl=material_coated_base_ibl;\n#endif\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrEnvironmentLightingWGSL = { name, shader };\n"]}
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgSd,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 = `#if defined(REFLECTION) || defined(REFRACTED_BACKGROUND)\nvar coatAbsorption=vec3f(1.0f);var coatIblFresnel: f32=0.0;if (coat_weight>0.0) {coatIblFresnel=computeDielectricIblFresnel(coatReflectance,coatGeoInfo.environmentBrdf);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*darkened_transmission,coat_weight);}\n#endif\n#ifdef REFLECTION\n#ifdef FUZZ\nlet environmentFuzzBrdf: vec3f=getFuzzBRDFLookup(fuzzGeoInfo.NdotV,sqrt(fuzz_roughness));\n#endif\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,false \n,1.0 \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,false \n,1.0 \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}\n#ifdef FUZZ\nlet modifiedFuzzRoughness: f32=clamp(fuzz_roughness*(1.0f-0.5f*environmentFuzzBrdf.y),0.0f,1.0f);var fuzzEnvironmentLight=vec3f(0.0f,0.0f,0.0f);var totalWeight=0.0f;let fuzzIblFresnel: f32=sqrt(environmentFuzzBrdf.z);for (var i: i32=0; i<i32(FUZZ_IBL_SAMPLES); i++) {var angle: f32=(f32(i)+noise.x)*(3.141592f*2.0f/f32(FUZZ_IBL_SAMPLES));var fiberCylinderNormal: vec3f=normalize(cos(angle)*fuzzTangent+sin(angle)*fuzzBitangent);let fiberBend=min(environmentFuzzBrdf.x*environmentFuzzBrdf.x*modifiedFuzzRoughness,1.0f);fiberCylinderNormal=normalize(mix(fiberCylinderNormal,fuzzNormalW,fiberBend));let sampleWeight=max(dot(viewDirectionW,fiberCylinderNormal),0.0f);var fuzzReflectionCoords=createReflectionCoords(fragmentInputs.vPositionW,fiberCylinderNormal);let radianceSample: vec3f=sampleRadiance(modifiedFuzzRoughness,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,fuzzGeoInfo\n,reflectionSampler\n,reflectionSamplerSampler\n,fuzzReflectionCoords\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n);fuzzEnvironmentLight+=sampleWeight*mix(radianceSample,baseDiffuseEnvironmentLight,fiberBend);totalWeight+=sampleWeight;}\nfuzzEnvironmentLight/=totalWeight;\n#endif\nlet dielectricIblFresnel: f32=computeDielectricIblFresnel(baseDielectricReflectance,baseGeoInfo.environmentBrdf);var dielectricIblColoredFresnel: vec3f=dielectricIblFresnel*specular_color;\n#ifdef THIN_FILM\nvar thin_film_dielectric: vec3f=evalIridescence(thin_film_outside_ior,thin_film_ior,baseGeoInfo.NdotV,thin_film_thickness,baseDielectricReflectance.coloredF0);let thin_film_desaturation_scale=(thin_film_ior-1.0)*sqrt(thin_film_thickness*0.001f*baseGeoInfo.NdotV);thin_film_dielectric=mix(thin_film_dielectric,vec3(dot(thin_film_dielectric,vec3f(0.3333f))),thin_film_desaturation_scale);dielectricIblColoredFresnel=mix(dielectricIblColoredFresnel,thin_film_dielectric*specular_color,thin_film_weight*thin_film_ior_scale);\n#endif\nvar conductorIblFresnel: vec3f=computeConductorIblFresnel(baseConductorReflectance,baseGeoInfo.environmentBrdf);\n#ifdef THIN_FILM\nvar thinFilmConductorFresnel: vec3f=specular_weight*evalIridescence(thin_film_outside_ior,thin_film_ior,baseGeoInfo.NdotV,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorFresnel=mix(thinFilmConductorFresnel,vec3(dot(thinFilmConductorFresnel,vec3f(0.3333f))),thin_film_desaturation_scale);conductorIblFresnel=mix(conductorIblFresnel,thinFilmConductorFresnel,thin_film_weight*thin_film_ior_scale);\n#endif\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;\n#ifdef AMBIENT_OCCLUSION\nspecular_ambient_occlusion=compute_specular_occlusion(baseGeoInfo.NdotV,base_metalness,ambient_occlusion.x,specular_roughness);\n#endif\nslab_glossy_ibl=baseSpecularEnvironmentLight*uniforms.vLightingIntensity.z;slab_metal_ibl=baseSpecularEnvironmentLight*conductorIblFresnel*uniforms.vLightingIntensity.z;if (coat_weight>0.0) {slab_coat_ibl=coatEnvironmentLight*uniforms.vLightingIntensity.z;\n#ifdef AMBIENT_OCCLUSION\ncoat_specular_ambient_occlusion=compute_specular_occlusion(coatGeoInfo.NdotV,0.0,ambient_occlusion.x,coat_roughness);\n#endif\n}\n#ifdef FUZZ\nvar slab_fuzz_ibl=fuzzEnvironmentLight*uniforms.vLightingIntensity.z;\n#endif\nvar slab_translucent_base_ibl: vec3f=vec3f(0.0f,0.0f,0.0f);\n#ifdef REFRACTED_ENVIRONMENT\n#ifdef ANISOTROPIC_BASE\nvar forwardScatteredEnvironmentLight: vec3f=sampleRadianceAnisotropic(transmission_roughness_alpha,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,baseGeoInfo\n#ifdef GEOMETRY_THIN_WALLED\n,viewDirectionW\n#else\n,normalW\n#endif\n,viewDirectionW\n,fragmentInputs.vPositionW\n,noise\n,true \n#ifdef GEOMETRY_THIN_WALLED\n,1.05f \n#else\n,specular_ior \n#endif\n,reflectionSampler\n,reflectionSamplerSampler\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n);\n#else\nvar forwardScatteredEnvironmentLight: vec3f=vec3f(0.,0.,0.);\n#ifdef DISPERSION\nfor (var i: i32=0; i<3; i++) {var iblRefractionCoords: vec3f=refractedViewVectors[i];\n#else\nvar iblRefractionCoords: vec3f=refractedViewVector;\n#endif\n#ifdef REFRACTED_ENVIRONMENT_OPPOSITEZ\niblRefractionCoords.z*=-1.0f;\n#endif\n#ifdef REFRACTED_ENVIRONMENT_LOCAL_CUBE\niblRefractionCoords=parallaxCorrectNormal(fragmentInputs.vPositionW,refractedViewVector,uniforms.refractionSize,uniforms.refractionPosition);\n#endif\niblRefractionCoords=(uniforms.reflectionMatrix*vec4f(iblRefractionCoords,0.0f)).xyz;\n#ifdef DISPERSION\nforwardScatteredEnvironmentLight[i]=sampleRadiance(transmission_roughness_alpha,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,baseGeoInfo\n,reflectionSampler\n,reflectionSamplerSampler\n,iblRefractionCoords\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n)[i];\n#else\nforwardScatteredEnvironmentLight=sampleRadiance(transmission_roughness_alpha,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,baseGeoInfo\n,reflectionSampler\n,reflectionSamplerSampler\n,iblRefractionCoords\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n);\n#endif\n#ifdef DISPERSION\n}\n#endif\n#endif\n#ifdef REFRACTED_BACKGROUND\n#ifdef GEOMETRY_THIN_WALLED\nforwardScatteredEnvironmentLight=mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight.rgb,0.2*transmission_roughness_alpha);\n#else\nforwardScatteredEnvironmentLight=max(slab_translucent_background.rgb,mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight,transmission_roughness_alpha));\n#endif\n#endif\n#ifdef SCATTERING\n#ifdef GEOMETRY_THIN_WALLED\nvar scatterVector: vec3f=normalW;\n#else\n#if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION)\nvar scatterVector: vec3f=mix(uniforms.vReflectionDominantDirection,normalW,max3(iso_scatter_density));\n#else\nvar scatterVector: vec3f=normalW;\n#endif\nscatterVector=mix(viewDirectionW,scatterVector,back_to_iso_scattering_blend);\n#endif\n#if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(GEOMETRY_THIN_WALLED)\nvar scatteredEnvironmentLight: vec3f=scattered_light_from_irradiance_texture;\n#else\nvar scatteredEnvironmentLight: vec3f=sampleIrradiance(\nscatterVector\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#if defined(GEOMETRY_THIN_WALLED)\n,base_diffuse_roughness\n,subsurface_color.rgb\n#else\n,1.0f\n,volumeParams.multi_scatter_color\n#endif\n);\n#endif\n#ifdef GEOMETRY_THIN_WALLED\nlet forward_scattered_light: vec3f=forwardScatteredEnvironmentLight*transmission_tint*volumeParams.multi_scatter_color;let back_scattered_light: vec3f=scatteredEnvironmentLight*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(back_scattered_light,forward_scattered_light,0.5f+0.5f*volumeParams.anisotropy);\n#else\nlet forward_scattered_light: vec3f=forwardScatteredEnvironmentLight*volume_absorption;let back_scattered_light: vec3f=mix(forward_scattered_light,scatteredEnvironmentLight*backscatter_color,iso_scatter_density);let iso_scattered_light: vec3f=mix(forward_scattered_light,scatteredEnvironmentLight*volumeParams.multi_scatter_color,iso_scatter_density);slab_translucent_base_ibl=mix(back_scattered_light,iso_scattered_light,back_to_iso_scattering_blend);slab_translucent_base_ibl=mix(slab_translucent_base_ibl,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;\n#endif\n#else\nslab_translucent_base_ibl+=forwardScatteredEnvironmentLight*transmission_tint*volume_absorption;\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_IBLLAYERCOMPOSITION\nslab_diffuse_ibl*=ambient_occlusion;slab_metal_ibl*=specular_ambient_occlusion;slab_glossy_ibl*=specular_ambient_occlusion;slab_coat_ibl*=coat_specular_ambient_occlusion;let material_dielectric_base_ibl: vec3f=mix(slab_diffuse_ibl*base_color.rgb,slab_translucent_base_ibl,surface_translucency_weight);let material_dielectric_gloss_ibl: vec3f=material_dielectric_base_ibl*(1.0-dielectricIblFresnel)+slab_glossy_ibl*dielectricIblColoredFresnel;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));\n#ifdef FUZZ\nslab_fuzz_ibl*=min(vec3(specular_ambient_occlusion),ambient_occlusion);material_surface_ibl=layer(material_coated_base_ibl,slab_fuzz_ibl,fuzzIblFresnel*fuzz_weight,vec3f(1.0f),fuzz_color);\n#else\nmaterial_surface_ibl=material_coated_base_ibl;\n#endif\n#elif defined(REFRACTED_BACKGROUND)\nlet black=vec3f(0.0f);var slab_translucent_base_ibl: vec3f=vec3f(0.0f);\n#ifdef GEOMETRY_THIN_WALLED\n#ifdef SCATTERING\nlet forward_scattered_light: vec3f=slab_translucent_background.rgb*transmission_tint*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(black,forward_scattered_light,0.5f+0.5f*volumeParams.anisotropy);\n#else\nslab_translucent_base_ibl=slab_translucent_background.rgb*transmission_tint;\n#endif\n#else\n#ifdef SCATTERING\nlet forward_scattered_light: vec3f=slab_translucent_background.rgb*volume_absorption;let iso_scattered_light: vec3f=(1.0f-iso_scatter_density)*forward_scattered_light;slab_translucent_base_ibl=mix(black,iso_scattered_light,back_to_iso_scattering_blend);slab_translucent_base_ibl=mix(slab_translucent_base_ibl,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;\n#else\nslab_translucent_base_ibl=slab_translucent_background.rgb*volume_absorption*transmission_tint;\n#endif\n#endif\nlet material_dielectric_base_ibl: vec3f=mix(black,slab_translucent_base_ibl.rgb,surface_translucency_weight);let material_dielectric_gloss_ibl: vec3f=material_dielectric_base_ibl*(baseGeoInfo.NdotV);let material_base_substrate_ibl: vec3f=mix(material_dielectric_gloss_ibl,black,base_metalness);let material_coated_base_ibl: vec3f=layer(material_base_substrate_ibl,black,coatIblFresnel,coatAbsorption,vec3f(1.0f));material_surface_ibl=material_coated_base_ibl;\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrEnvironmentLightingWGSL = { name, shader };\n"]}
|
|
@@ -206,17 +206,19 @@ environmentRadiance=vec4f(accumulatedRadiance/vec3f(total_weight),1.0f);
|
|
|
206
206
|
#endif
|
|
207
207
|
environmentRadiance=vec4f(environmentRadiance.rgb*reflectionInfos.xxx,environmentRadiance.a);return environmentRadiance.rgb;}
|
|
208
208
|
#endif
|
|
209
|
+
#endif
|
|
209
210
|
#ifdef ENVIRONMENTBRDF
|
|
210
|
-
fn
|
|
211
|
+
fn computeDielectricIblFresnel(reflectance: ReflectanceParams,environmentBrdf: vec3f)->f32
|
|
212
|
+
{let dielectricIblFresnel: f32=getReflectanceFromBRDFWithEnvLookup(vec3f(reflectance.F0),vec3f(reflectance.F90),environmentBrdf).r;let dielectricECF: f32=1.0+reflectance.F0*(1.0/environmentBrdf.y-1.0);return clamp(dielectricIblFresnel*dielectricECF,0.0,1.0);}
|
|
213
|
+
fn computeConductorIblFresnel(reflectance: ReflectanceParams,environmentBrdf: vec3f)->vec3f
|
|
211
214
|
{
|
|
212
215
|
#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
|
|
213
|
-
let
|
|
216
|
+
let openPBRBrdf: vec3f=vec3f(environmentBrdf.xy,environmentBrdf.z/BRDF_Z_SCALE);let b: vec3f =getF82B(reflectance.coloredF0,reflectance.coloredF90);let E_F82: vec3f=getF82DirectionalAlbedo(reflectance.coloredF0,vec3f(1.0),b,openPBRBrdf);let F_avg: vec3f=getF82AverageFresnel(reflectance.coloredF0,b);let ECF: vec3f =vec3f(1.0)+F_avg*(vec3f(1.0)/openPBRBrdf.y-vec3f(1.0));return clamp(E_F82*ECF,vec3f(0.0),vec3f(1.0));
|
|
214
217
|
#else
|
|
215
218
|
return getReflectanceFromBRDFLookup(reflectance.coloredF0,reflectance.coloredF90,environmentBrdf);
|
|
216
219
|
#endif
|
|
217
220
|
}
|
|
218
221
|
#endif
|
|
219
|
-
#endif
|
|
220
222
|
`;
|
|
221
223
|
// Sideeffect
|
|
222
224
|
if (!ShaderStore.IncludesShadersStoreWGSL[name]) {
|