@aura3d/rendering 1.3.3 → 1.4.1
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/dist/ForwardPass.js +7 -1
- package/dist/ForwardPass.js.map +1 -1
- package/dist/MorphTarget.d.ts +1 -0
- package/dist/MorphTarget.d.ts.map +1 -1
- package/dist/MorphTarget.js.map +1 -1
- package/dist/Renderer.js +7 -1
- package/dist/Renderer.js.map +1 -1
- package/package.json +38 -4
- package/src/ArchitecturalLightingFixtures.ts +0 -241
- package/src/ArchitecturalMaterialCatalog.ts +0 -130
- package/src/ArchitecturalMeasurementFixtures.ts +0 -155
- package/src/BRDFLut.ts +0 -47
- package/src/CameraFraming.ts +0 -200
- package/src/CanonicalSceneFixtures.ts +0 -95
- package/src/CascadedShadowMaps.ts +0 -449
- package/src/ColorManagement.ts +0 -127
- package/src/CullingFixtures.ts +0 -280
- package/src/DecalGeometry.ts +0 -26
- package/src/DepthPass.ts +0 -110
- package/src/EnvironmentBackgroundPass.ts +0 -194
- package/src/EnvironmentBackgroundResources.ts +0 -309
- package/src/EnvironmentLighting.ts +0 -96
- package/src/EnvironmentMapResources.ts +0 -1026
- package/src/EnvironmentPipeline.ts +0 -69
- package/src/EnvironmentPlatform.ts +0 -1306
- package/src/EnvironmentPreset.ts +0 -155
- package/src/Exposure.ts +0 -66
- package/src/ExternalParityRenderPreset.ts +0 -725
- package/src/ForwardPass.ts +0 -1663
- package/src/FrameVisualMetrics.ts +0 -301
- package/src/Geometry.ts +0 -461
- package/src/GeometryPrimitives.ts +0 -2
- package/src/HDRRenderPipeline.ts +0 -94
- package/src/IBL.ts +0 -86
- package/src/IndexBuffer.ts +0 -57
- package/src/InstancedPBRMaterial.ts +0 -186
- package/src/InstancedUnlitMaterial.ts +0 -60
- package/src/Instancing.ts +0 -19
- package/src/LightCollector.ts +0 -82
- package/src/LightUniforms.ts +0 -47
- package/src/LightingDebug.ts +0 -80
- package/src/LightingDefaults.ts +0 -79
- package/src/LightingRig.ts +0 -301
- package/src/LineGeometry.ts +0 -2
- package/src/Material.ts +0 -209
- package/src/MaterialBinding.ts +0 -131
- package/src/MaterialInstance.ts +0 -59
- package/src/MaterialPresets.ts +0 -272
- package/src/MorphTarget.ts +0 -123
- package/src/MorphTargetPlan.ts +0 -178
- package/src/MorphUnlitMaterial.ts +0 -60
- package/src/NormalMappedPBRMaterial.ts +0 -188
- package/src/OceanFixtures.ts +0 -318
- package/src/PBRLightingDefaults.ts +0 -12
- package/src/PBRMaterial.ts +0 -442
- package/src/PMREM.ts +0 -53
- package/src/PbrReference.ts +0 -681
- package/src/PostProcessPass.ts +0 -2507
- package/src/ProceduralTextureFixtures.ts +0 -393
- package/src/ProductTurntableFixtures.ts +0 -815
- package/src/Raycaster.ts +0 -21
- package/src/ReflectionProbe.ts +0 -13
- package/src/ReflectionSurfaces.ts +0 -219
- package/src/RenderBackend.ts +0 -43
- package/src/RenderDebugViews.ts +0 -138
- package/src/RenderDevice.ts +0 -836
- package/src/RenderGraph.ts +0 -194
- package/src/RenderPass.ts +0 -27
- package/src/RenderPipeline.ts +0 -101
- package/src/RenderQueue.ts +0 -12
- package/src/RenderState.ts +0 -12
- package/src/Renderer.ts +0 -2626
- package/src/RendererDebugOverlay.ts +0 -80
- package/src/RendererFeatureGates.ts +0 -150
- package/src/RendererPostprocessPlan.ts +0 -279
- package/src/RendererTiming.ts +0 -251
- package/src/RendererVisualPipelineReport.ts +0 -836
- package/src/ResourceLifecycle.ts +0 -21
- package/src/Sampler.ts +0 -37
- package/src/SceneOptimization.ts +0 -518
- package/src/ShaderChunks.ts +0 -393
- package/src/ShaderLibrary.ts +0 -2766
- package/src/ShaderModule.ts +0 -36
- package/src/ShaderPreprocessor.ts +0 -260
- package/src/ShaderReflection.ts +0 -201
- package/src/ShadowMap.ts +0 -237
- package/src/ShadowPass.ts +0 -198
- package/src/ShadowProjection.ts +0 -115
- package/src/SkinnedLitMaterial.ts +0 -397
- package/src/SkinnedUnlitMaterial.ts +0 -63
- package/src/SkinningBounds.ts +0 -131
- package/src/SpaceEnvironmentFixtures.ts +0 -200
- package/src/SpriteGeometry.ts +0 -21
- package/src/StereoCameraRig.ts +0 -127
- package/src/StereoEffects.ts +0 -274
- package/src/TerrainFixtures.ts +0 -180
- package/src/Texture.ts +0 -307
- package/src/TextureBinding.ts +0 -91
- package/src/TexturedPBRMaterial.ts +0 -1112
- package/src/TexturedUnlitMaterial.ts +0 -67
- package/src/ToneMapping.ts +0 -105
- package/src/UniformBinder.ts +0 -16
- package/src/UniformLayout.ts +0 -129
- package/src/UnlitMaterial.ts +0 -75
- package/src/VegetationFixtures.ts +0 -314
- package/src/VertexBuffer.ts +0 -120
- package/src/VertexFormat.ts +0 -171
- package/src/VoxelWorldFixtures.ts +0 -280
- package/src/WeatherFixtures.ts +0 -223
- package/src/WebGL2Device.ts +0 -2280
- package/src/WebGL2StateCache.ts +0 -330
- package/src/WebGPUDevice.ts +0 -2877
- package/src/WebGPURenderToTextureProof.ts +0 -139
- package/src/advanced-runtime/AdvancedRenderer.ts +0 -73
- package/src/advanced-runtime/index.ts +0 -9
- package/src/animation/AnimationMaterialStyle.ts +0 -32
- package/src/animation/AnimationRenderPreset.ts +0 -45
- package/src/animation/AnimationToonMaterial.ts +0 -387
- package/src/animation/AnimationVisualQuality.ts +0 -71
- package/src/animation/applyAnimationRenderPreset.ts +0 -180
- package/src/animation/index.ts +0 -5
- package/src/cinematic/BloomPass.ts +0 -26
- package/src/cinematic/CinematicDepthComposition.ts +0 -30
- package/src/cinematic/CinematicEvidence.ts +0 -123
- package/src/cinematic/CinematicLightingRig.ts +0 -144
- package/src/cinematic/CinematicMaterialPresets.ts +0 -130
- package/src/cinematic/CinematicPostProcess.ts +0 -83
- package/src/cinematic/DepthHazePass.ts +0 -30
- package/src/cinematic/EmissivePracticalLightSystem.ts +0 -45
- package/src/cinematic/FilmGrainPass.ts +0 -24
- package/src/cinematic/FogVolumeSystem.ts +0 -30
- package/src/cinematic/GlowCardSystem.ts +0 -44
- package/src/cinematic/RainParticleSystem.ts +0 -151
- package/src/cinematic/VignettePass.ts +0 -25
- package/src/cinematic/WetReflectionApproximation.ts +0 -27
- package/src/cinematic/index.ts +0 -14
- package/src/effects/CollisionModule.ts +0 -64
- package/src/effects/ColorModule.ts +0 -60
- package/src/effects/ForceModule.ts +0 -25
- package/src/effects/GPUParticleBackend.ts +0 -569
- package/src/effects/Particle.ts +0 -108
- package/src/effects/ParticleDiagnostics.ts +0 -224
- package/src/effects/ParticleEffectPresets.ts +0 -147
- package/src/effects/ParticleEmitter.ts +0 -326
- package/src/effects/ParticleModule.ts +0 -26
- package/src/effects/ParticleRenderPass.ts +0 -117
- package/src/effects/ParticleRenderer.ts +0 -132
- package/src/effects/ParticleSystem.ts +0 -333
- package/src/effects/SizeModule.ts +0 -56
- package/src/effects/TrailModule.ts +0 -72
- package/src/effects/VelocityModule.ts +0 -75
- package/src/effects/index.ts +0 -15
- package/src/index.ts +0 -925
- package/src/materials/AlphaSorting.ts +0 -30
- package/src/materials/MaterialExtensions.ts +0 -42
- package/src/materials/PhysicalMaterial.ts +0 -133
- package/src/materials/TransmissionPass.ts +0 -51
- package/src/performance/BVH.ts +0 -18
- package/src/performance/Batcher.ts +0 -2
- package/src/performance/FrustumCuller.ts +0 -9
- package/src/performance/LOD.ts +0 -20
- package/src/performance/Octree.ts +0 -10
- package/src/performance/RenderItemSorting.ts +0 -170
- package/src/performance/RendererStats.ts +0 -43
- package/src/performance/ResourceBudget.ts +0 -44
- package/src/postprocess/BloomPass.ts +0 -28
- package/src/postprocess/CinematicDiagnostics.ts +0 -642
- package/src/postprocess/ColorGradingPass.ts +0 -24
- package/src/postprocess/DepthOfFieldPass.ts +0 -12
- package/src/postprocess/EffectComposer.ts +0 -349
- package/src/postprocess/SSAOPass.ts +0 -20
- package/src/postprocess/index.ts +0 -34
- package/src/production-runtime/AnimationControlsPipeline.ts +0 -77
- package/src/production-runtime/PBRHDRPipeline.ts +0 -381
- package/src/production-runtime/ProductionEffectsPipeline.ts +0 -85
- package/src/production-runtime/ProductionRendererTypes.ts +0 -136
- package/src/production-runtime/ProductionRuntimeRenderer.ts +0 -172
- package/src/production-runtime/ProductionWebGL2Renderer.ts +0 -313
- package/src/production-runtime/ProductionWebGPURenderer.ts +0 -396
- package/src/production-runtime/TransmissionBackdropCapture.ts +0 -130
- package/src/production-runtime/animation/MorphTargetRenderer.ts +0 -2
- package/src/production-runtime/animation/SkinningRenderer.ts +0 -2
- package/src/production-runtime/backends/RendererBackend.ts +0 -17
- package/src/production-runtime/backends/WebGL2RendererBackend.ts +0 -30
- package/src/production-runtime/backends/WebGPURendererBackend.ts +0 -24
- package/src/production-runtime/backends/webgl2/WebGL2Buffer.ts +0 -2
- package/src/production-runtime/backends/webgl2/WebGL2Capabilities.ts +0 -2
- package/src/production-runtime/backends/webgl2/WebGL2RenderTarget.ts +0 -2
- package/src/production-runtime/backends/webgl2/WebGL2Shader.ts +0 -2
- package/src/production-runtime/backends/webgl2/WebGL2StateCache.ts +0 -1
- package/src/production-runtime/backends/webgl2/WebGL2Texture.ts +0 -2
- package/src/production-runtime/backends/webgpu/WebGPUBuffer.ts +0 -2
- package/src/production-runtime/backends/webgpu/WebGPUCapabilities.ts +0 -2
- package/src/production-runtime/backends/webgpu/WebGPURenderTarget.ts +0 -2
- package/src/production-runtime/backends/webgpu/WebGPUShader.ts +0 -2
- package/src/production-runtime/backends/webgpu/WebGPUTexture.ts +0 -2
- package/src/production-runtime/color/ColorManagement.ts +0 -3
- package/src/production-runtime/color/ToneMapping.ts +0 -7
- package/src/production-runtime/diagnostics/FrameCapture.ts +0 -2
- package/src/production-runtime/diagnostics/GPUCapabilities.ts +0 -2
- package/src/production-runtime/diagnostics/RendererStats.ts +0 -2
- package/src/production-runtime/environment/EnvironmentMap.ts +0 -1
- package/src/production-runtime/environment/HDRLoader.ts +0 -57
- package/src/production-runtime/environment/PMREMGenerator.ts +0 -713
- package/src/production-runtime/framegraph/FrameGraph.ts +0 -18
- package/src/production-runtime/framegraph/RenderPass.ts +0 -15
- package/src/production-runtime/geometry/ProjectedDecalGeometry.ts +0 -439
- package/src/production-runtime/index.ts +0 -127
- package/src/production-runtime/lights/LightManager.ts +0 -7
- package/src/production-runtime/lights/ShadowMapRenderer.ts +0 -5
- package/src/production-runtime/materials/GLTFMaterialAdapter.ts +0 -6
- package/src/production-runtime/materials/GLTFPBRMaterialAdapter.ts +0 -2
- package/src/production-runtime/materials/MaterialCompiler.ts +0 -7
- package/src/production-runtime/materials/MaterialTextureBindings.ts +0 -5
- package/src/production-runtime/materials/PBRMaterial.ts +0 -2
- package/src/production-runtime/materials/PBRShaderFeatures.ts +0 -2
- package/src/production-runtime/passes/ContactShadowPass.ts +0 -184
- package/src/production-runtime/passes/DepthPrepass.ts +0 -7
- package/src/production-runtime/passes/OpaquePass.ts +0 -7
- package/src/production-runtime/passes/ShadowPass.ts +0 -7
- package/src/production-runtime/passes/SkyboxPass.ts +0 -7
- package/src/production-runtime/passes/ToneMappingPass.ts +0 -7
- package/src/production-runtime/passes/TransparentPass.ts +0 -7
- package/src/production-runtime/postprocess/BloomPass.ts +0 -51
- package/src/production-runtime/postprocess/ColorGradingPass.ts +0 -49
- package/src/production-runtime/postprocess/DOFPass.ts +0 -47
- package/src/production-runtime/postprocess/FXAAPass.ts +0 -53
- package/src/production-runtime/postprocess/ProductionEffectComposer.ts +0 -78
- package/src/production-runtime/postprocess/ProductionPostProcessTypes.ts +0 -174
- package/src/production-runtime/postprocess/SSAOPass.ts +0 -45
- package/src/production-runtime/resources/GPUBuffer.ts +0 -2
- package/src/production-runtime/resources/GPUTexture.ts +0 -2
- package/src/production-runtime/resources/RenderTarget.ts +0 -3
- package/src/production-runtime/resources/ResourceCache.ts +0 -7
- package/src/production-runtime/scene/Camera.ts +0 -1
- package/src/production-runtime/scene/Lights.ts +0 -2
- package/src/production-runtime/scene/RenderableMesh.ts +0 -2
- package/src/production-runtime/scene/RenderablePrimitive.ts +0 -1
- package/src/production-runtime/scene/RenderableScene.ts +0 -4
- package/src/production-runtime/shaders/ShaderProgramLibrary.ts +0 -7
- package/src/production-runtime/shaders/chunks/brdf.glsl +0 -2
- package/src/production-runtime/shaders/chunks/ibl.glsl +0 -3
- package/src/production-runtime/shaders/chunks/pbr.frag.glsl +0 -47
- package/src/production-runtime/shaders/chunks/pbr.vert.glsl +0 -8
- package/src/production-runtime/shaders/chunks/shadows.glsl +0 -2
- package/src/production-runtime/shaders/wgsl/pbr.wgsl +0 -3
- package/src/production-runtime/shaders/wgsl/postprocess.wgsl +0 -2
- package/src/production-runtime/shaders/wgsl/skybox.wgsl +0 -2
- package/src/shaders/depth.frag.glsl +0 -5
- package/src/shaders/depth.vert.glsl +0 -8
- package/src/shaders/pbr-direct.frag.glsl +0 -687
- package/src/shaders/pbr-direct.vert.glsl +0 -18
- package/src/shaders/unlit.frag.glsl +0 -18
- package/src/shaders/unlit.vert.glsl +0 -13
- package/src/shadows/CascadedShadowPipeline.ts +0 -53
- package/src/shadows/ContactShadows.ts +0 -106
- package/src/shadows/ShadowDebugViews.ts +0 -46
- package/src/threejs-compatibility/InstancingSystem.ts +0 -17
- package/src/threejs-compatibility/LightingSystem.ts +0 -22
- package/src/threejs-compatibility/MaterialSystem.ts +0 -9
- package/src/threejs-compatibility/RenderTargetSystem.ts +0 -35
- package/src/threejs-compatibility/RendererDiagnostics.ts +0 -61
- package/src/threejs-compatibility/SceneRenderer.ts +0 -34
- package/src/threejs-compatibility/ShadowSystem.ts +0 -19
- package/src/threejs-compatibility/TextureSystem.ts +0 -19
- package/src/threejs-compatibility/ThreeCompatRenderer.ts +0 -90
- package/src/threejs-compatibility/TransparencySystem.ts +0 -19
- package/src/threejs-compatibility/index.ts +0 -29
- package/src/threejs-compatibility/performance/BVH.ts +0 -14
- package/src/threejs-compatibility/performance/FrustumCulling.ts +0 -10
- package/src/threejs-compatibility/performance/Instancing.ts +0 -4
- package/src/threejs-compatibility/performance/LODSystem.ts +0 -16
- package/src/threejs-compatibility/performance/OcclusionCulling.ts +0 -6
- package/src/threejs-compatibility/performance/RaycastAcceleration.ts +0 -12
- package/src/threejs-compatibility/performance/RendererProfiler.ts +0 -19
- package/src/threejs-compatibility/performance/TextureStreaming.ts +0 -4
- package/src/threejs-compatibility/performance/index.ts +0 -12
- package/src/threejs-compatibility/postprocess/BloomPass.ts +0 -16
- package/src/threejs-compatibility/postprocess/ColorGradingPass.ts +0 -16
- package/src/threejs-compatibility/postprocess/DepthOfFieldPass.ts +0 -21
- package/src/threejs-compatibility/postprocess/EffectComposer.ts +0 -14
- package/src/threejs-compatibility/postprocess/FXAAPass.ts +0 -15
- package/src/threejs-compatibility/postprocess/MotionBlurPass.ts +0 -20
- package/src/threejs-compatibility/postprocess/OutlinePass.ts +0 -21
- package/src/threejs-compatibility/postprocess/PostProcessTypes.ts +0 -169
- package/src/threejs-compatibility/postprocess/RenderPass.ts +0 -9
- package/src/threejs-compatibility/postprocess/SMAAPass.ts +0 -15
- package/src/threejs-compatibility/postprocess/SSAOPass.ts +0 -21
- package/src/threejs-compatibility/postprocess/ShaderPass.ts +0 -7
- package/src/threejs-compatibility/postprocess/TAAPass.ts +0 -15
- package/src/threejs-compatibility/postprocess/VignettePass.ts +0 -16
- package/src/threejs-compatibility/postprocess/index.ts +0 -15
- package/src/threejs-compatibility/shaders/NodeMaterial.ts +0 -21
- package/src/threejs-compatibility/shaders/RawShaderMaterial.ts +0 -6
- package/src/threejs-compatibility/shaders/ShaderDiagnostics.ts +0 -17
- package/src/threejs-compatibility/shaders/ShaderMaterial.ts +0 -18
- package/src/threejs-compatibility/shaders/ThreeCompatShaderChunks.ts +0 -6
- package/src/threejs-compatibility/shaders/Uniforms.ts +0 -18
- package/src/threejs-compatibility/shaders/index.ts +0 -9
- package/src/threejs-compatibility/vfx/GPUPointCloud.ts +0 -7
- package/src/threejs-compatibility/vfx/LineRenderer.ts +0 -13
- package/src/threejs-compatibility/vfx/ParticleSystem.ts +0 -23
- package/src/threejs-compatibility/vfx/SpriteSystem.ts +0 -14
- package/src/threejs-compatibility/vfx/TrailRenderer.ts +0 -8
- package/src/threejs-compatibility/vfx/VFXDiagnostics.ts +0 -23
- package/src/threejs-compatibility/vfx/index.ts +0 -9
- package/src/threejs-example-parity/index.ts +0 -205
- package/src/webgpu/WebGPUBuffer.ts +0 -1
- package/src/webgpu/WebGPUCompute.ts +0 -2
- package/src/webgpu/WebGPUPipelineCache.ts +0 -15
- package/src/webgpu/WebGPUPostProcess.ts +0 -2
- package/src/webgpu/WebGPUTexture.ts +0 -2
- package/tsconfig.json +0 -26
- package/vitest.config.ts +0 -20
package/src/PBRMaterial.ts
DELETED
|
@@ -1,442 +0,0 @@
|
|
|
1
|
-
import { Material, type RenderState } from "./Material";
|
|
2
|
-
import { DEFAULT_PBR_ENVIRONMENT_INTENSITY, DEFAULT_PBR_PROCEDURAL_ENVIRONMENT_MAP } from "./PBRLightingDefaults";
|
|
3
|
-
import { TextureBinding } from "./TextureBinding";
|
|
4
|
-
|
|
5
|
-
export const DEFAULT_PBR_SHADER_NAME = "aura3d/pbr-direct";
|
|
6
|
-
export const DEFAULT_PBR_SHADER_MARKER = "@aura3d-shader:pbr-direct";
|
|
7
|
-
|
|
8
|
-
export interface PBRMaterialOptions {
|
|
9
|
-
readonly name?: string;
|
|
10
|
-
readonly baseColor?: readonly [number, number, number, number];
|
|
11
|
-
readonly renderState?: Partial<RenderState>;
|
|
12
|
-
readonly metallic?: number;
|
|
13
|
-
readonly roughness?: number;
|
|
14
|
-
readonly environmentColor?: readonly [number, number, number];
|
|
15
|
-
readonly environmentIntensity?: number;
|
|
16
|
-
readonly proceduralEnvironmentMap?: PBRProceduralEnvironmentMapOptions;
|
|
17
|
-
readonly environmentMapTexture?: TextureBinding;
|
|
18
|
-
readonly environmentMapIntensity?: number;
|
|
19
|
-
readonly environmentMapSpecularIntensity?: number;
|
|
20
|
-
readonly environmentMapRotation?: number;
|
|
21
|
-
readonly environmentMapMipCount?: number;
|
|
22
|
-
readonly environmentBrdfLutTexture?: TextureBinding;
|
|
23
|
-
readonly emissiveColor?: readonly [number, number, number];
|
|
24
|
-
readonly emissiveStrength?: number;
|
|
25
|
-
readonly clearcoatFactor?: number;
|
|
26
|
-
readonly clearcoatRoughnessFactor?: number;
|
|
27
|
-
readonly transmissionFactor?: number;
|
|
28
|
-
readonly diffuseTransmissionFactor?: number;
|
|
29
|
-
readonly diffuseTransmissionColorFactor?: readonly [number, number, number];
|
|
30
|
-
readonly transmissionFallbackEnergy?: number;
|
|
31
|
-
readonly volumeThicknessFactor?: number;
|
|
32
|
-
readonly volumeAttenuationDistance?: number;
|
|
33
|
-
readonly volumeAttenuationColor?: readonly [number, number, number];
|
|
34
|
-
readonly transmissionParallaxStrength?: number;
|
|
35
|
-
readonly transmissionParallaxBoxMin?: readonly [number, number, number];
|
|
36
|
-
readonly transmissionParallaxBoxMax?: readonly [number, number, number];
|
|
37
|
-
readonly transmissionBounceCount?: number;
|
|
38
|
-
readonly transmissionCausticStrength?: number;
|
|
39
|
-
readonly ior?: number;
|
|
40
|
-
readonly specularFactor?: number;
|
|
41
|
-
readonly specularColorFactor?: readonly [number, number, number];
|
|
42
|
-
readonly sheenColorFactor?: readonly [number, number, number];
|
|
43
|
-
readonly sheenRoughnessFactor?: number;
|
|
44
|
-
readonly anisotropyStrength?: number;
|
|
45
|
-
readonly anisotropyRotation?: number;
|
|
46
|
-
readonly iridescenceFactor?: number;
|
|
47
|
-
readonly iridescenceIor?: number;
|
|
48
|
-
readonly iridescenceThicknessMinimum?: number;
|
|
49
|
-
readonly iridescenceThicknessMaximum?: number;
|
|
50
|
-
readonly dispersion?: number;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface PBRProceduralEnvironmentMapOptions {
|
|
54
|
-
readonly skyColor: readonly [number, number, number];
|
|
55
|
-
readonly horizonColor: readonly [number, number, number];
|
|
56
|
-
readonly groundColor: readonly [number, number, number];
|
|
57
|
-
readonly specularColor: readonly [number, number, number];
|
|
58
|
-
readonly intensity: number;
|
|
59
|
-
readonly specularIntensity: number;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export class PBRMaterial extends Material {
|
|
63
|
-
constructor(options: PBRMaterialOptions = {}) {
|
|
64
|
-
const baseColor = options.baseColor ?? [1, 1, 1, 1];
|
|
65
|
-
const environmentColor = options.environmentColor ?? [1, 1, 1];
|
|
66
|
-
const proceduralEnvironmentMap: PBRProceduralEnvironmentMapOptions = options.proceduralEnvironmentMap ?? DEFAULT_PBR_PROCEDURAL_ENVIRONMENT_MAP;
|
|
67
|
-
const emissiveColor = options.emissiveColor ?? [0, 0, 0];
|
|
68
|
-
const specularColorFactor = options.specularColorFactor ?? [1, 1, 1];
|
|
69
|
-
const diffuseTransmissionColorFactor = options.diffuseTransmissionColorFactor ?? [1, 1, 1];
|
|
70
|
-
const sheenColorFactor = options.sheenColorFactor ?? [0, 0, 0];
|
|
71
|
-
const volumeAttenuationColor = options.volumeAttenuationColor ?? [1, 1, 1];
|
|
72
|
-
const transmissionParallaxBoxMin = options.transmissionParallaxBoxMin ?? [-1, -1, -1];
|
|
73
|
-
const transmissionParallaxBoxMax = options.transmissionParallaxBoxMax ?? [1, 1, 1];
|
|
74
|
-
validateColor4(baseColor, "baseColor");
|
|
75
|
-
validateColor3(environmentColor, "environmentColor");
|
|
76
|
-
validateProceduralEnvironmentMap(proceduralEnvironmentMap);
|
|
77
|
-
validateNonNegative(options.environmentMapIntensity ?? 0, "environmentMapIntensity");
|
|
78
|
-
validateNonNegative(options.environmentMapSpecularIntensity ?? 0, "environmentMapSpecularIntensity");
|
|
79
|
-
validateFinite(options.environmentMapRotation ?? 0, "environmentMapRotation");
|
|
80
|
-
validateMipCount(options.environmentMapMipCount ?? 1);
|
|
81
|
-
validateColor3(emissiveColor, "emissiveColor");
|
|
82
|
-
validateNonNegativeColor3(specularColorFactor, "specularColorFactor");
|
|
83
|
-
validateColor3(diffuseTransmissionColorFactor, "diffuseTransmissionColorFactor");
|
|
84
|
-
validateColor3(sheenColorFactor, "sheenColorFactor");
|
|
85
|
-
validateColor3(volumeAttenuationColor, "volumeAttenuationColor");
|
|
86
|
-
validateUnit(options.metallic ?? 0, "metallic");
|
|
87
|
-
validateUnit(options.roughness ?? 0.5, "roughness");
|
|
88
|
-
validateNonNegative(options.environmentIntensity ?? DEFAULT_PBR_ENVIRONMENT_INTENSITY, "environmentIntensity");
|
|
89
|
-
validateUnit(options.clearcoatFactor ?? 0, "clearcoatFactor");
|
|
90
|
-
validateUnit(options.clearcoatRoughnessFactor ?? 0, "clearcoatRoughnessFactor");
|
|
91
|
-
validateUnit(options.transmissionFactor ?? 0, "transmissionFactor");
|
|
92
|
-
validateUnit(options.diffuseTransmissionFactor ?? 0, "diffuseTransmissionFactor");
|
|
93
|
-
validateUnit(options.transmissionFallbackEnergy ?? 0.08, "transmissionFallbackEnergy");
|
|
94
|
-
validateNonNegative(options.volumeThicknessFactor ?? 0, "volumeThicknessFactor");
|
|
95
|
-
validatePositive(options.volumeAttenuationDistance ?? 1_000_000, "volumeAttenuationDistance");
|
|
96
|
-
validateUnit(options.transmissionParallaxStrength ?? 0, "transmissionParallaxStrength");
|
|
97
|
-
validateFiniteVec3(transmissionParallaxBoxMin, "transmissionParallaxBoxMin");
|
|
98
|
-
validateFiniteVec3(transmissionParallaxBoxMax, "transmissionParallaxBoxMax");
|
|
99
|
-
if (transmissionParallaxBoxMin.some((component, index) => component >= transmissionParallaxBoxMax[index]!)) {
|
|
100
|
-
throw new RangeError("PBR transmissionParallaxBoxMin must be lower than transmissionParallaxBoxMax");
|
|
101
|
-
}
|
|
102
|
-
validateNonNegative(options.transmissionBounceCount ?? 0, "transmissionBounceCount");
|
|
103
|
-
validateNonNegative(options.transmissionCausticStrength ?? 0, "transmissionCausticStrength");
|
|
104
|
-
validateUnit(options.specularFactor ?? 1, "specularFactor");
|
|
105
|
-
validateUnit(options.sheenRoughnessFactor ?? 0, "sheenRoughnessFactor");
|
|
106
|
-
validateUnit(options.anisotropyStrength ?? 0, "anisotropyStrength");
|
|
107
|
-
validateFinite(options.anisotropyRotation ?? 0, "anisotropyRotation");
|
|
108
|
-
validateUnit(options.iridescenceFactor ?? 0, "iridescenceFactor");
|
|
109
|
-
validateIridescenceIOR(options.iridescenceIor ?? 1.3);
|
|
110
|
-
const iridescenceThicknessMinimum = options.iridescenceThicknessMinimum ?? 100;
|
|
111
|
-
const iridescenceThicknessMaximum = options.iridescenceThicknessMaximum ?? 400;
|
|
112
|
-
validateNonNegative(iridescenceThicknessMinimum, "iridescenceThicknessMinimum");
|
|
113
|
-
validateNonNegative(iridescenceThicknessMaximum, "iridescenceThicknessMaximum");
|
|
114
|
-
if (iridescenceThicknessMaximum < iridescenceThicknessMinimum) {
|
|
115
|
-
throw new RangeError("PBR iridescenceThicknessMaximum must be greater than or equal to iridescenceThicknessMinimum");
|
|
116
|
-
}
|
|
117
|
-
validateNonNegative(options.dispersion ?? 0, "dispersion");
|
|
118
|
-
validateIOR(options.ior ?? 1.5);
|
|
119
|
-
validateNonNegative(options.emissiveStrength ?? 1, "emissiveStrength");
|
|
120
|
-
|
|
121
|
-
super({
|
|
122
|
-
name: options.name ?? "pbr",
|
|
123
|
-
shaderKey: DEFAULT_PBR_SHADER_NAME,
|
|
124
|
-
renderState: options.renderState,
|
|
125
|
-
parameters: {
|
|
126
|
-
u_baseColor: baseColor,
|
|
127
|
-
u_metallic: options.metallic ?? 0,
|
|
128
|
-
u_roughness: options.roughness ?? 0.5,
|
|
129
|
-
u_environmentColor: environmentColor,
|
|
130
|
-
u_environmentIntensity: options.environmentIntensity ?? DEFAULT_PBR_ENVIRONMENT_INTENSITY,
|
|
131
|
-
u_environmentSkyColor: proceduralEnvironmentMap.skyColor,
|
|
132
|
-
u_environmentHorizonColor: proceduralEnvironmentMap.horizonColor,
|
|
133
|
-
u_environmentGroundColor: proceduralEnvironmentMap.groundColor,
|
|
134
|
-
u_environmentSpecularColor: proceduralEnvironmentMap.specularColor,
|
|
135
|
-
u_environmentMapIntensity: proceduralEnvironmentMap.intensity,
|
|
136
|
-
u_environmentSpecularIntensity: proceduralEnvironmentMap.specularIntensity,
|
|
137
|
-
u_environmentMapTexture: options.environmentMapTexture ?? new TextureBinding({ name: "u_environmentMapTexture", required: false }),
|
|
138
|
-
u_environmentMapTextureEnabled: options.environmentMapTexture ? 1 : 0,
|
|
139
|
-
u_environmentMapTextureIntensity: options.environmentMapIntensity ?? 0,
|
|
140
|
-
u_environmentMapTextureSpecularIntensity: options.environmentMapSpecularIntensity ?? 0,
|
|
141
|
-
u_environmentMapTextureRotation: options.environmentMapRotation ?? 0,
|
|
142
|
-
u_environmentMapTextureMipCount: options.environmentMapMipCount ?? 1,
|
|
143
|
-
u_environmentMapTextureEncoding: 0,
|
|
144
|
-
u_environmentBrdfLutTexture: options.environmentBrdfLutTexture ?? new TextureBinding({ name: "u_environmentBrdfLutTexture", required: false }),
|
|
145
|
-
u_environmentBrdfLutEnabled: options.environmentBrdfLutTexture ? 1 : 0,
|
|
146
|
-
u_emissiveColor: emissiveColor,
|
|
147
|
-
u_emissiveStrength: options.emissiveStrength ?? 1,
|
|
148
|
-
u_clearcoatFactor: options.clearcoatFactor ?? 0,
|
|
149
|
-
u_clearcoatRoughnessFactor: options.clearcoatRoughnessFactor ?? 0,
|
|
150
|
-
u_transmissionFactor: options.transmissionFactor ?? 0,
|
|
151
|
-
u_diffuseTransmissionFactor: options.diffuseTransmissionFactor ?? 0,
|
|
152
|
-
u_diffuseTransmissionColorFactor: diffuseTransmissionColorFactor,
|
|
153
|
-
u_transmissionFallbackEnergy: options.transmissionFallbackEnergy ?? 0.08,
|
|
154
|
-
u_volumeThicknessFactor: options.volumeThicknessFactor ?? 0,
|
|
155
|
-
u_volumeAttenuationDistance: options.volumeAttenuationDistance ?? 1_000_000,
|
|
156
|
-
u_volumeAttenuationColor: volumeAttenuationColor,
|
|
157
|
-
u_transmissionParallaxStrength: options.transmissionParallaxStrength ?? 0,
|
|
158
|
-
u_transmissionParallaxBoxMin: transmissionParallaxBoxMin,
|
|
159
|
-
u_transmissionParallaxBoxMax: transmissionParallaxBoxMax,
|
|
160
|
-
u_transmissionBounceCount: options.transmissionBounceCount ?? 0,
|
|
161
|
-
u_transmissionCausticStrength: options.transmissionCausticStrength ?? 0,
|
|
162
|
-
u_ior: options.ior ?? 1.5,
|
|
163
|
-
u_specularFactor: options.specularFactor ?? 1,
|
|
164
|
-
u_specularColorFactor: specularColorFactor,
|
|
165
|
-
u_sheenColorFactor: sheenColorFactor,
|
|
166
|
-
u_sheenRoughnessFactor: options.sheenRoughnessFactor ?? 0,
|
|
167
|
-
u_anisotropyStrength: options.anisotropyStrength ?? 0,
|
|
168
|
-
u_anisotropyRotation: options.anisotropyRotation ?? 0,
|
|
169
|
-
u_iridescenceFactor: options.iridescenceFactor ?? 0,
|
|
170
|
-
u_iridescenceIor: options.iridescenceIor ?? 1.3,
|
|
171
|
-
u_iridescenceThicknessMinimum: iridescenceThicknessMinimum,
|
|
172
|
-
u_iridescenceThicknessMaximum: iridescenceThicknessMaximum,
|
|
173
|
-
u_dispersion: options.dispersion ?? 0,
|
|
174
|
-
u_lightCount: 0,
|
|
175
|
-
u_lightData: new Float32Array(0),
|
|
176
|
-
u_modelViewProjection: identityMatrix(),
|
|
177
|
-
u_normalMatrix: identityMatrix()
|
|
178
|
-
},
|
|
179
|
-
requiredAttributes: ["a_position", "a_normal"],
|
|
180
|
-
uniformSchema: [
|
|
181
|
-
{ name: "u_baseColor", kind: "vec4" },
|
|
182
|
-
{ name: "u_metallic", kind: "float" },
|
|
183
|
-
{ name: "u_roughness", kind: "float" },
|
|
184
|
-
{ name: "u_environmentColor", kind: "vec3" },
|
|
185
|
-
{ name: "u_environmentIntensity", kind: "float" },
|
|
186
|
-
{ name: "u_environmentSkyColor", kind: "vec3" },
|
|
187
|
-
{ name: "u_environmentHorizonColor", kind: "vec3" },
|
|
188
|
-
{ name: "u_environmentGroundColor", kind: "vec3" },
|
|
189
|
-
{ name: "u_environmentSpecularColor", kind: "vec3" },
|
|
190
|
-
{ name: "u_environmentMapIntensity", kind: "float" },
|
|
191
|
-
{ name: "u_environmentSpecularIntensity", kind: "float" },
|
|
192
|
-
{ name: "u_environmentMapTexture", kind: "texture2d", required: false },
|
|
193
|
-
{ name: "u_environmentMapTextureEnabled", kind: "float" },
|
|
194
|
-
{ name: "u_environmentMapTextureIntensity", kind: "float" },
|
|
195
|
-
{ name: "u_environmentMapTextureSpecularIntensity", kind: "float" },
|
|
196
|
-
{ name: "u_environmentMapTextureRotation", kind: "float" },
|
|
197
|
-
{ name: "u_environmentMapTextureMipCount", kind: "float" },
|
|
198
|
-
{ name: "u_environmentMapTextureEncoding", kind: "float" },
|
|
199
|
-
{ name: "u_environmentBrdfLutTexture", kind: "texture2d", required: false },
|
|
200
|
-
{ name: "u_environmentBrdfLutEnabled", kind: "float", required: false },
|
|
201
|
-
{ name: "u_emissiveColor", kind: "vec3" },
|
|
202
|
-
{ name: "u_emissiveStrength", kind: "float" },
|
|
203
|
-
{ name: "u_clearcoatFactor", kind: "float" },
|
|
204
|
-
{ name: "u_clearcoatRoughnessFactor", kind: "float" },
|
|
205
|
-
{ name: "u_transmissionFactor", kind: "float" },
|
|
206
|
-
{ name: "u_diffuseTransmissionFactor", kind: "float" },
|
|
207
|
-
{ name: "u_diffuseTransmissionColorFactor", kind: "vec3" },
|
|
208
|
-
{ name: "u_transmissionFallbackEnergy", kind: "float" },
|
|
209
|
-
{ name: "u_volumeThicknessFactor", kind: "float" },
|
|
210
|
-
{ name: "u_volumeAttenuationDistance", kind: "float" },
|
|
211
|
-
{ name: "u_volumeAttenuationColor", kind: "vec3" },
|
|
212
|
-
{ name: "u_transmissionParallaxStrength", kind: "float" },
|
|
213
|
-
{ name: "u_transmissionParallaxBoxMin", kind: "vec3" },
|
|
214
|
-
{ name: "u_transmissionParallaxBoxMax", kind: "vec3" },
|
|
215
|
-
{ name: "u_transmissionBounceCount", kind: "float" },
|
|
216
|
-
{ name: "u_transmissionCausticStrength", kind: "float" },
|
|
217
|
-
{ name: "u_ior", kind: "float" },
|
|
218
|
-
{ name: "u_specularFactor", kind: "float" },
|
|
219
|
-
{ name: "u_specularColorFactor", kind: "vec3" },
|
|
220
|
-
{ name: "u_sheenColorFactor", kind: "vec3" },
|
|
221
|
-
{ name: "u_sheenRoughnessFactor", kind: "float" },
|
|
222
|
-
{ name: "u_anisotropyStrength", kind: "float" },
|
|
223
|
-
{ name: "u_anisotropyRotation", kind: "float" },
|
|
224
|
-
{ name: "u_iridescenceFactor", kind: "float" },
|
|
225
|
-
{ name: "u_iridescenceIor", kind: "float" },
|
|
226
|
-
{ name: "u_iridescenceThicknessMinimum", kind: "float" },
|
|
227
|
-
{ name: "u_iridescenceThicknessMaximum", kind: "float" },
|
|
228
|
-
{ name: "u_dispersion", kind: "float" },
|
|
229
|
-
{ name: "u_lightCount", kind: "float" },
|
|
230
|
-
{ name: "u_lightData", kind: "any" },
|
|
231
|
-
{ name: "u_modelViewProjection", kind: "mat4" },
|
|
232
|
-
{ name: "u_normalMatrix", kind: "mat4" }
|
|
233
|
-
]
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
set baseColor(value: readonly [number, number, number, number]) {
|
|
238
|
-
validateColor4(value, "baseColor");
|
|
239
|
-
this.setParameter("u_baseColor", value);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
get baseColor(): readonly [number, number, number, number] {
|
|
243
|
-
return this.getParameter("u_baseColor") as readonly [number, number, number, number];
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
set metallic(value: number) {
|
|
247
|
-
validateUnit(value, "metallic");
|
|
248
|
-
this.setParameter("u_metallic", value);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
get metallic(): number {
|
|
252
|
-
return this.getParameter("u_metallic") as number;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
set roughness(value: number) {
|
|
256
|
-
validateUnit(value, "roughness");
|
|
257
|
-
this.setParameter("u_roughness", value);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
get roughness(): number {
|
|
261
|
-
return this.getParameter("u_roughness") as number;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
set environmentColor(value: readonly [number, number, number]) {
|
|
265
|
-
validateColor3(value, "environmentColor");
|
|
266
|
-
this.setParameter("u_environmentColor", value);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
get environmentColor(): readonly [number, number, number] {
|
|
270
|
-
return this.getParameter("u_environmentColor") as readonly [number, number, number];
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
set environmentIntensity(value: number) {
|
|
274
|
-
validateNonNegative(value, "environmentIntensity");
|
|
275
|
-
this.setParameter("u_environmentIntensity", value);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
get environmentIntensity(): number {
|
|
279
|
-
return this.getParameter("u_environmentIntensity") as number;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
set proceduralEnvironmentMap(value: PBRProceduralEnvironmentMapOptions) {
|
|
283
|
-
validateProceduralEnvironmentMap(value);
|
|
284
|
-
this.setParameter("u_environmentSkyColor", value.skyColor);
|
|
285
|
-
this.setParameter("u_environmentHorizonColor", value.horizonColor);
|
|
286
|
-
this.setParameter("u_environmentGroundColor", value.groundColor);
|
|
287
|
-
this.setParameter("u_environmentSpecularColor", value.specularColor);
|
|
288
|
-
this.setParameter("u_environmentMapIntensity", value.intensity);
|
|
289
|
-
this.setParameter("u_environmentSpecularIntensity", value.specularIntensity);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
get proceduralEnvironmentMap(): PBRProceduralEnvironmentMapOptions {
|
|
293
|
-
return {
|
|
294
|
-
skyColor: this.getParameter("u_environmentSkyColor") as readonly [number, number, number],
|
|
295
|
-
horizonColor: this.getParameter("u_environmentHorizonColor") as readonly [number, number, number],
|
|
296
|
-
groundColor: this.getParameter("u_environmentGroundColor") as readonly [number, number, number],
|
|
297
|
-
specularColor: this.getParameter("u_environmentSpecularColor") as readonly [number, number, number],
|
|
298
|
-
intensity: this.getParameter("u_environmentMapIntensity") as number,
|
|
299
|
-
specularIntensity: this.getParameter("u_environmentSpecularIntensity") as number
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
set environmentMapTexture(value: TextureBinding | null) {
|
|
304
|
-
this.setParameter("u_environmentMapTexture", value ?? new TextureBinding({ name: "u_environmentMapTexture", required: false }));
|
|
305
|
-
this.setParameter("u_environmentMapTextureEnabled", value ? 1 : 0);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
get environmentMapTexture(): TextureBinding | null {
|
|
309
|
-
const value = this.getParameter("u_environmentMapTexture");
|
|
310
|
-
return value instanceof TextureBinding && value.texture ? value : null;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
set environmentMapIntensity(value: number) {
|
|
314
|
-
validateNonNegative(value, "environmentMapIntensity");
|
|
315
|
-
this.setParameter("u_environmentMapTextureIntensity", value);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
get environmentMapIntensity(): number {
|
|
319
|
-
return this.getParameter("u_environmentMapTextureIntensity") as number;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
set environmentMapSpecularIntensity(value: number) {
|
|
323
|
-
validateNonNegative(value, "environmentMapSpecularIntensity");
|
|
324
|
-
this.setParameter("u_environmentMapTextureSpecularIntensity", value);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
get environmentMapSpecularIntensity(): number {
|
|
328
|
-
return this.getParameter("u_environmentMapTextureSpecularIntensity") as number;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
set environmentMapRotation(value: number) {
|
|
332
|
-
validateFinite(value, "environmentMapRotation");
|
|
333
|
-
this.setParameter("u_environmentMapTextureRotation", value);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
get environmentMapRotation(): number {
|
|
337
|
-
return this.getParameter("u_environmentMapTextureRotation") as number;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
set environmentMapMipCount(value: number) {
|
|
341
|
-
validateMipCount(value);
|
|
342
|
-
this.setParameter("u_environmentMapTextureMipCount", value);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
get environmentMapMipCount(): number {
|
|
346
|
-
return this.getParameter("u_environmentMapTextureMipCount") as number;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
set environmentBrdfLutTexture(value: TextureBinding | null) {
|
|
350
|
-
this.setParameter("u_environmentBrdfLutTexture", value ?? new TextureBinding({ name: "u_environmentBrdfLutTexture", required: false }));
|
|
351
|
-
this.setParameter("u_environmentBrdfLutEnabled", value ? 1 : 0);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
get environmentBrdfLutTexture(): TextureBinding | null {
|
|
355
|
-
const value = this.getParameter("u_environmentBrdfLutTexture");
|
|
356
|
-
return value instanceof TextureBinding && value.texture ? value : null;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
function validateNonNegative(value: number, label: string): void {
|
|
361
|
-
if (!Number.isFinite(value) || value < 0) {
|
|
362
|
-
throw new RangeError(`PBR ${label} must be finite and non-negative`);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
function validatePositive(value: number, label: string): void {
|
|
367
|
-
if (!Number.isFinite(value) || value <= 0) {
|
|
368
|
-
throw new RangeError(`PBR ${label} must be finite and positive`);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
function validateUnit(value: number, label: string): void {
|
|
373
|
-
if (!Number.isFinite(value) || value < 0 || value > 1) {
|
|
374
|
-
throw new RangeError(`PBR ${label} must be finite and within [0, 1]`);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
function validateFinite(value: number, label: string): void {
|
|
379
|
-
if (!Number.isFinite(value)) {
|
|
380
|
-
throw new RangeError(`PBR ${label} must be finite`);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function validateIOR(value: number): void {
|
|
385
|
-
if (!Number.isFinite(value) || value < 1) {
|
|
386
|
-
throw new RangeError("PBR ior must be finite and at least 1");
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
function validateIridescenceIOR(value: number): void {
|
|
391
|
-
if (!Number.isFinite(value) || value < 1 || value > 3) {
|
|
392
|
-
throw new RangeError("PBR iridescenceIor must be finite and within [1, 3]");
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
function validateColor4(value: readonly number[], label: string): void {
|
|
397
|
-
if (value.length !== 4 || value.some((channel) => !Number.isFinite(channel) || channel < 0 || channel > 1)) {
|
|
398
|
-
throw new RangeError(`PBR ${label} must contain four finite values in [0, 1]`);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
function validateColor3(value: readonly number[], label: string): void {
|
|
403
|
-
if (value.length !== 3 || value.some((channel) => !Number.isFinite(channel) || channel < 0 || channel > 1)) {
|
|
404
|
-
throw new RangeError(`PBR ${label} must contain three finite values in [0, 1]`);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
function validateNonNegativeColor3(value: readonly number[], label: string): void {
|
|
409
|
-
if (value.length !== 3 || value.some((channel) => !Number.isFinite(channel) || channel < 0)) {
|
|
410
|
-
throw new RangeError(`PBR ${label} must contain three finite non-negative values`);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
function validateFiniteVec3(value: readonly number[], label: string): void {
|
|
415
|
-
if (value.length !== 3 || value.some((channel) => !Number.isFinite(channel))) {
|
|
416
|
-
throw new RangeError(`PBR ${label} must contain three finite values`);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
function validateProceduralEnvironmentMap(value: PBRProceduralEnvironmentMapOptions): void {
|
|
421
|
-
validateColor3(value.skyColor, "proceduralEnvironmentMap.skyColor");
|
|
422
|
-
validateColor3(value.horizonColor, "proceduralEnvironmentMap.horizonColor");
|
|
423
|
-
validateColor3(value.groundColor, "proceduralEnvironmentMap.groundColor");
|
|
424
|
-
validateColor3(value.specularColor, "proceduralEnvironmentMap.specularColor");
|
|
425
|
-
validateNonNegative(value.intensity, "proceduralEnvironmentMap.intensity");
|
|
426
|
-
validateNonNegative(value.specularIntensity, "proceduralEnvironmentMap.specularIntensity");
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
function validateMipCount(value: number): void {
|
|
430
|
-
if (!Number.isInteger(value) || value < 1) {
|
|
431
|
-
throw new RangeError("PBR environmentMapMipCount must be a positive integer");
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
function identityMatrix(): Float32Array {
|
|
436
|
-
return new Float32Array([
|
|
437
|
-
1, 0, 0, 0,
|
|
438
|
-
0, 1, 0, 0,
|
|
439
|
-
0, 0, 1, 0,
|
|
440
|
-
0, 0, 0, 1
|
|
441
|
-
]);
|
|
442
|
-
}
|
package/src/PMREM.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
generateSpecularPrefilterMipLevels,
|
|
3
|
-
type Rgba8EnvironmentMapSource
|
|
4
|
-
} from "./EnvironmentMapResources";
|
|
5
|
-
import type { TextureMipLevelDescriptor } from "./Texture";
|
|
6
|
-
|
|
7
|
-
export interface ExternalParityPmremLevel {
|
|
8
|
-
readonly level: number;
|
|
9
|
-
readonly width: number;
|
|
10
|
-
readonly height: number;
|
|
11
|
-
readonly roughness: number;
|
|
12
|
-
readonly byteLength: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface ExternalParityPmrem {
|
|
16
|
-
readonly textureLabel: string;
|
|
17
|
-
readonly mipLevels: readonly TextureMipLevelDescriptor[];
|
|
18
|
-
readonly levels: readonly ExternalParityPmremLevel[];
|
|
19
|
-
readonly diagnostics: {
|
|
20
|
-
readonly mipCount: number;
|
|
21
|
-
readonly maxRoughness: number;
|
|
22
|
-
readonly totalByteLength: number;
|
|
23
|
-
readonly directionalReflectionReady: boolean;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function createExternalParityPmrem(
|
|
28
|
-
source: Rgba8EnvironmentMapSource,
|
|
29
|
-
options: { readonly levels?: number; readonly blurRadius?: number; readonly textureLabel?: string } = {}
|
|
30
|
-
): ExternalParityPmrem {
|
|
31
|
-
const mipLevels = generateSpecularPrefilterMipLevels(source, {
|
|
32
|
-
levels: options.levels ?? 6,
|
|
33
|
-
blurRadius: options.blurRadius ?? 3
|
|
34
|
-
});
|
|
35
|
-
const levels = mipLevels.map((level, index) => ({
|
|
36
|
-
level: index,
|
|
37
|
-
width: level.width,
|
|
38
|
-
height: level.height,
|
|
39
|
-
roughness: Number((index / Math.max(1, mipLevels.length - 1)).toFixed(4)),
|
|
40
|
-
byteLength: level.data.byteLength
|
|
41
|
-
}));
|
|
42
|
-
return {
|
|
43
|
-
textureLabel: options.textureLabel ?? "external-parity-pmrem-specular",
|
|
44
|
-
mipLevels,
|
|
45
|
-
levels,
|
|
46
|
-
diagnostics: {
|
|
47
|
-
mipCount: mipLevels.length,
|
|
48
|
-
maxRoughness: levels.at(-1)?.roughness ?? 0,
|
|
49
|
-
totalByteLength: levels.reduce((sum, level) => sum + level.byteLength, 0),
|
|
50
|
-
directionalReflectionReady: mipLevels.length >= 4 && mipLevels[0]!.width > mipLevels.at(-1)!.width
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|