@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
|
@@ -1,1112 +0,0 @@
|
|
|
1
|
-
import { Material, type MaterialUniformDescriptor, type RenderState } from "./Material";
|
|
2
|
-
import { DEFAULT_PBR_ENVIRONMENT_INTENSITY, DEFAULT_PBR_PROCEDURAL_ENVIRONMENT_MAP } from "./PBRLightingDefaults";
|
|
3
|
-
import { Sampler } from "./Sampler";
|
|
4
|
-
import {
|
|
5
|
-
DEFAULT_TEXTURED_PBR_CLEARCOAT_SPECULAR_TEXTURES_VARIANT,
|
|
6
|
-
DEFAULT_TEXTURED_PBR_CLEARCOAT_TEXTURES_VARIANT,
|
|
7
|
-
DEFAULT_TEXTURED_PBR_CLEARCOAT_TRANSMISSION_VOLUME_TEXTURES_VARIANT,
|
|
8
|
-
DEFAULT_TEXTURED_PBR_IRIDESCENCE_TEXTURES_VARIANT,
|
|
9
|
-
DEFAULT_TEXTURED_PBR_SHADER_NAME,
|
|
10
|
-
DEFAULT_TEXTURED_PBR_SPECULAR_SHEEN_ANISOTROPY_IRIDESCENCE_TEXTURES_VARIANT,
|
|
11
|
-
DEFAULT_TEXTURED_PBR_SPECULAR_SHEEN_ANISOTROPY_TEXTURES_VARIANT,
|
|
12
|
-
DEFAULT_TEXTURED_PBR_TRANSMISSION_VOLUME_TEXTURES_VARIANT
|
|
13
|
-
} from "./ShaderLibrary";
|
|
14
|
-
import { Texture } from "./Texture";
|
|
15
|
-
import { TextureBinding } from "./TextureBinding";
|
|
16
|
-
|
|
17
|
-
export type TexturedPBRTextureSlot =
|
|
18
|
-
| "baseColor"
|
|
19
|
-
| "normal"
|
|
20
|
-
| "metallicRoughness"
|
|
21
|
-
| "occlusion"
|
|
22
|
-
| "emissive"
|
|
23
|
-
| "clearcoat"
|
|
24
|
-
| "clearcoatRoughness"
|
|
25
|
-
| "clearcoatNormal"
|
|
26
|
-
| "transmission"
|
|
27
|
-
| "diffuseTransmission"
|
|
28
|
-
| "diffuseTransmissionColor"
|
|
29
|
-
| "volumeThickness"
|
|
30
|
-
| "specular"
|
|
31
|
-
| "specularColor"
|
|
32
|
-
| "sheenColor"
|
|
33
|
-
| "sheenRoughness"
|
|
34
|
-
| "anisotropy"
|
|
35
|
-
| "iridescence"
|
|
36
|
-
| "iridescenceThickness";
|
|
37
|
-
|
|
38
|
-
export interface TexturedPBRMaterialOptions {
|
|
39
|
-
readonly name?: string;
|
|
40
|
-
readonly baseColor?: readonly [number, number, number, number];
|
|
41
|
-
readonly renderState?: Partial<RenderState>;
|
|
42
|
-
readonly metallic?: number;
|
|
43
|
-
readonly roughness?: number;
|
|
44
|
-
readonly environmentColor?: readonly [number, number, number];
|
|
45
|
-
readonly environmentIntensity?: number;
|
|
46
|
-
readonly proceduralEnvironmentMap?: TexturedPBRProceduralEnvironmentMapOptions;
|
|
47
|
-
readonly environmentMapTexture?: TextureBinding;
|
|
48
|
-
readonly environmentMapIntensity?: number;
|
|
49
|
-
readonly environmentMapSpecularIntensity?: number;
|
|
50
|
-
readonly materialEnvironmentSpecularScale?: number;
|
|
51
|
-
readonly environmentMapRotation?: number;
|
|
52
|
-
readonly environmentMapMipCount?: number;
|
|
53
|
-
readonly environmentBrdfLutTexture?: TextureBinding;
|
|
54
|
-
readonly emissiveColor?: readonly [number, number, number];
|
|
55
|
-
readonly emissiveStrength?: number;
|
|
56
|
-
readonly textureTexCoords?: Readonly<Partial<Record<TexturedPBRTextureSlot, number>>>;
|
|
57
|
-
readonly baseColorTexture?: Texture;
|
|
58
|
-
readonly baseColorSampler?: Sampler;
|
|
59
|
-
readonly baseColorTextureTransform?: {
|
|
60
|
-
readonly offset?: readonly [number, number];
|
|
61
|
-
readonly scale?: readonly [number, number];
|
|
62
|
-
readonly rotation?: number;
|
|
63
|
-
};
|
|
64
|
-
readonly normalTexture?: Texture;
|
|
65
|
-
readonly normalSampler?: Sampler;
|
|
66
|
-
readonly normalTextureTransform?: {
|
|
67
|
-
readonly offset?: readonly [number, number];
|
|
68
|
-
readonly scale?: readonly [number, number];
|
|
69
|
-
readonly rotation?: number;
|
|
70
|
-
};
|
|
71
|
-
readonly normalScale?: number;
|
|
72
|
-
readonly metallicRoughnessTexture?: Texture;
|
|
73
|
-
readonly metallicRoughnessSampler?: Sampler;
|
|
74
|
-
readonly metallicRoughnessTextureTransform?: {
|
|
75
|
-
readonly offset?: readonly [number, number];
|
|
76
|
-
readonly scale?: readonly [number, number];
|
|
77
|
-
readonly rotation?: number;
|
|
78
|
-
};
|
|
79
|
-
readonly occlusionTexture?: Texture;
|
|
80
|
-
readonly occlusionSampler?: Sampler;
|
|
81
|
-
readonly occlusionTextureTransform?: {
|
|
82
|
-
readonly offset?: readonly [number, number];
|
|
83
|
-
readonly scale?: readonly [number, number];
|
|
84
|
-
readonly rotation?: number;
|
|
85
|
-
};
|
|
86
|
-
readonly occlusionStrength?: number;
|
|
87
|
-
readonly emissiveTexture?: Texture;
|
|
88
|
-
readonly emissiveSampler?: Sampler;
|
|
89
|
-
readonly emissiveTextureTransform?: {
|
|
90
|
-
readonly offset?: readonly [number, number];
|
|
91
|
-
readonly scale?: readonly [number, number];
|
|
92
|
-
readonly rotation?: number;
|
|
93
|
-
};
|
|
94
|
-
readonly clearcoatFactor?: number;
|
|
95
|
-
readonly clearcoatTexture?: Texture;
|
|
96
|
-
readonly clearcoatSampler?: Sampler;
|
|
97
|
-
readonly clearcoatTextureTransform?: {
|
|
98
|
-
readonly offset?: readonly [number, number];
|
|
99
|
-
readonly scale?: readonly [number, number];
|
|
100
|
-
readonly rotation?: number;
|
|
101
|
-
};
|
|
102
|
-
readonly clearcoatRoughnessFactor?: number;
|
|
103
|
-
readonly clearcoatRoughnessTexture?: Texture;
|
|
104
|
-
readonly clearcoatRoughnessSampler?: Sampler;
|
|
105
|
-
readonly clearcoatRoughnessTextureTransform?: {
|
|
106
|
-
readonly offset?: readonly [number, number];
|
|
107
|
-
readonly scale?: readonly [number, number];
|
|
108
|
-
readonly rotation?: number;
|
|
109
|
-
};
|
|
110
|
-
readonly clearcoatNormalTexture?: Texture;
|
|
111
|
-
readonly clearcoatNormalSampler?: Sampler;
|
|
112
|
-
readonly clearcoatNormalTextureTransform?: {
|
|
113
|
-
readonly offset?: readonly [number, number];
|
|
114
|
-
readonly scale?: readonly [number, number];
|
|
115
|
-
readonly rotation?: number;
|
|
116
|
-
};
|
|
117
|
-
readonly clearcoatNormalScale?: number;
|
|
118
|
-
readonly transmissionFactor?: number;
|
|
119
|
-
readonly transmissionTexture?: Texture;
|
|
120
|
-
readonly transmissionSampler?: Sampler;
|
|
121
|
-
readonly transmissionTextureTransform?: {
|
|
122
|
-
readonly offset?: readonly [number, number];
|
|
123
|
-
readonly scale?: readonly [number, number];
|
|
124
|
-
readonly rotation?: number;
|
|
125
|
-
};
|
|
126
|
-
readonly transmissionFallbackEnergy?: number;
|
|
127
|
-
readonly diffuseTransmissionFactor?: number;
|
|
128
|
-
readonly diffuseTransmissionTexture?: Texture;
|
|
129
|
-
readonly diffuseTransmissionSampler?: Sampler;
|
|
130
|
-
readonly diffuseTransmissionTextureTransform?: {
|
|
131
|
-
readonly offset?: readonly [number, number];
|
|
132
|
-
readonly scale?: readonly [number, number];
|
|
133
|
-
readonly rotation?: number;
|
|
134
|
-
};
|
|
135
|
-
readonly diffuseTransmissionColorFactor?: readonly [number, number, number];
|
|
136
|
-
readonly diffuseTransmissionColorTexture?: Texture;
|
|
137
|
-
readonly diffuseTransmissionColorSampler?: Sampler;
|
|
138
|
-
readonly diffuseTransmissionColorTextureTransform?: {
|
|
139
|
-
readonly offset?: readonly [number, number];
|
|
140
|
-
readonly scale?: readonly [number, number];
|
|
141
|
-
readonly rotation?: number;
|
|
142
|
-
};
|
|
143
|
-
readonly volumeThicknessFactor?: number;
|
|
144
|
-
readonly volumeThicknessTexture?: Texture;
|
|
145
|
-
readonly volumeThicknessSampler?: Sampler;
|
|
146
|
-
readonly volumeThicknessTextureTransform?: {
|
|
147
|
-
readonly offset?: readonly [number, number];
|
|
148
|
-
readonly scale?: readonly [number, number];
|
|
149
|
-
readonly rotation?: number;
|
|
150
|
-
};
|
|
151
|
-
readonly volumeAttenuationDistance?: number;
|
|
152
|
-
readonly volumeAttenuationColor?: readonly [number, number, number];
|
|
153
|
-
readonly transmissionParallaxStrength?: number;
|
|
154
|
-
readonly transmissionParallaxBoxMin?: readonly [number, number, number];
|
|
155
|
-
readonly transmissionParallaxBoxMax?: readonly [number, number, number];
|
|
156
|
-
readonly transmissionBounceCount?: number;
|
|
157
|
-
readonly transmissionCausticStrength?: number;
|
|
158
|
-
readonly transmissionBackdropTexture?: TextureBinding;
|
|
159
|
-
readonly transmissionBackdropStrength?: number;
|
|
160
|
-
readonly transmissionBackdropResolution?: readonly [number, number];
|
|
161
|
-
readonly transmissionBackdropMipCount?: number;
|
|
162
|
-
readonly transmissionBackdropRefractionScale?: number;
|
|
163
|
-
readonly ior?: number;
|
|
164
|
-
readonly specularFactor?: number;
|
|
165
|
-
readonly specularTexture?: Texture;
|
|
166
|
-
readonly specularSampler?: Sampler;
|
|
167
|
-
readonly specularTextureTransform?: {
|
|
168
|
-
readonly offset?: readonly [number, number];
|
|
169
|
-
readonly scale?: readonly [number, number];
|
|
170
|
-
readonly rotation?: number;
|
|
171
|
-
};
|
|
172
|
-
readonly specularColorFactor?: readonly [number, number, number];
|
|
173
|
-
readonly specularColorTexture?: Texture;
|
|
174
|
-
readonly specularColorSampler?: Sampler;
|
|
175
|
-
readonly specularColorTextureTransform?: {
|
|
176
|
-
readonly offset?: readonly [number, number];
|
|
177
|
-
readonly scale?: readonly [number, number];
|
|
178
|
-
readonly rotation?: number;
|
|
179
|
-
};
|
|
180
|
-
readonly sheenColorFactor?: readonly [number, number, number];
|
|
181
|
-
readonly sheenColorTexture?: Texture;
|
|
182
|
-
readonly sheenColorSampler?: Sampler;
|
|
183
|
-
readonly sheenColorTextureTransform?: {
|
|
184
|
-
readonly offset?: readonly [number, number];
|
|
185
|
-
readonly scale?: readonly [number, number];
|
|
186
|
-
readonly rotation?: number;
|
|
187
|
-
};
|
|
188
|
-
readonly sheenRoughnessFactor?: number;
|
|
189
|
-
readonly sheenRoughnessTexture?: Texture;
|
|
190
|
-
readonly sheenRoughnessSampler?: Sampler;
|
|
191
|
-
readonly sheenRoughnessTextureTransform?: {
|
|
192
|
-
readonly offset?: readonly [number, number];
|
|
193
|
-
readonly scale?: readonly [number, number];
|
|
194
|
-
readonly rotation?: number;
|
|
195
|
-
};
|
|
196
|
-
readonly anisotropyStrength?: number;
|
|
197
|
-
readonly anisotropyRotation?: number;
|
|
198
|
-
readonly anisotropyTexture?: Texture;
|
|
199
|
-
readonly anisotropySampler?: Sampler;
|
|
200
|
-
readonly anisotropyTextureTransform?: {
|
|
201
|
-
readonly offset?: readonly [number, number];
|
|
202
|
-
readonly scale?: readonly [number, number];
|
|
203
|
-
readonly rotation?: number;
|
|
204
|
-
};
|
|
205
|
-
readonly iridescenceFactor?: number;
|
|
206
|
-
readonly iridescenceTexture?: Texture;
|
|
207
|
-
readonly iridescenceSampler?: Sampler;
|
|
208
|
-
readonly iridescenceTextureTransform?: {
|
|
209
|
-
readonly offset?: readonly [number, number];
|
|
210
|
-
readonly scale?: readonly [number, number];
|
|
211
|
-
readonly rotation?: number;
|
|
212
|
-
};
|
|
213
|
-
readonly iridescenceIor?: number;
|
|
214
|
-
readonly iridescenceThicknessMinimum?: number;
|
|
215
|
-
readonly iridescenceThicknessMaximum?: number;
|
|
216
|
-
readonly iridescenceThicknessTexture?: Texture;
|
|
217
|
-
readonly iridescenceThicknessSampler?: Sampler;
|
|
218
|
-
readonly iridescenceThicknessTextureTransform?: {
|
|
219
|
-
readonly offset?: readonly [number, number];
|
|
220
|
-
readonly scale?: readonly [number, number];
|
|
221
|
-
readonly rotation?: number;
|
|
222
|
-
};
|
|
223
|
-
readonly dispersion?: number;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export interface TexturedPBRProceduralEnvironmentMapOptions {
|
|
227
|
-
readonly skyColor: readonly [number, number, number];
|
|
228
|
-
readonly horizonColor: readonly [number, number, number];
|
|
229
|
-
readonly groundColor: readonly [number, number, number];
|
|
230
|
-
readonly specularColor: readonly [number, number, number];
|
|
231
|
-
readonly intensity: number;
|
|
232
|
-
readonly specularIntensity: number;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
const BASE_TEXTURED_PBR_SHADER_TEXTURE_SLOTS: readonly TexturedPBRTextureSlot[] = [
|
|
236
|
-
"baseColor",
|
|
237
|
-
"normal",
|
|
238
|
-
"metallicRoughness",
|
|
239
|
-
"occlusion",
|
|
240
|
-
"emissive"
|
|
241
|
-
];
|
|
242
|
-
|
|
243
|
-
const CLEARCOAT_TEXTURE_SLOTS: readonly TexturedPBRTextureSlot[] = [
|
|
244
|
-
"clearcoat",
|
|
245
|
-
"clearcoatRoughness",
|
|
246
|
-
"clearcoatNormal"
|
|
247
|
-
];
|
|
248
|
-
|
|
249
|
-
const TRANSMISSION_VOLUME_TEXTURE_SLOTS: readonly TexturedPBRTextureSlot[] = [
|
|
250
|
-
"transmission",
|
|
251
|
-
"diffuseTransmission",
|
|
252
|
-
"diffuseTransmissionColor",
|
|
253
|
-
"volumeThickness"
|
|
254
|
-
];
|
|
255
|
-
|
|
256
|
-
const SPECULAR_TEXTURE_SLOTS: readonly TexturedPBRTextureSlot[] = [
|
|
257
|
-
"specular",
|
|
258
|
-
"specularColor"
|
|
259
|
-
];
|
|
260
|
-
|
|
261
|
-
const SHEEN_ANISOTROPY_TEXTURE_SLOTS: readonly TexturedPBRTextureSlot[] = [
|
|
262
|
-
"sheenColor",
|
|
263
|
-
"sheenRoughness",
|
|
264
|
-
"anisotropy"
|
|
265
|
-
];
|
|
266
|
-
|
|
267
|
-
const IRIDESCENCE_TEXTURE_SLOTS: readonly TexturedPBRTextureSlot[] = [
|
|
268
|
-
"iridescence",
|
|
269
|
-
"iridescenceThickness"
|
|
270
|
-
];
|
|
271
|
-
|
|
272
|
-
export function texturedPbrShaderActiveTextureSlots(shaderVariant?: string): readonly TexturedPBRTextureSlot[] {
|
|
273
|
-
const slots = new Set<TexturedPBRTextureSlot>(BASE_TEXTURED_PBR_SHADER_TEXTURE_SLOTS);
|
|
274
|
-
if (
|
|
275
|
-
shaderVariant === DEFAULT_TEXTURED_PBR_CLEARCOAT_TEXTURES_VARIANT ||
|
|
276
|
-
shaderVariant === DEFAULT_TEXTURED_PBR_CLEARCOAT_TRANSMISSION_VOLUME_TEXTURES_VARIANT ||
|
|
277
|
-
shaderVariant === DEFAULT_TEXTURED_PBR_CLEARCOAT_SPECULAR_TEXTURES_VARIANT
|
|
278
|
-
) {
|
|
279
|
-
for (const slot of CLEARCOAT_TEXTURE_SLOTS) slots.add(slot);
|
|
280
|
-
}
|
|
281
|
-
if (
|
|
282
|
-
shaderVariant === DEFAULT_TEXTURED_PBR_TRANSMISSION_VOLUME_TEXTURES_VARIANT ||
|
|
283
|
-
shaderVariant === DEFAULT_TEXTURED_PBR_CLEARCOAT_TRANSMISSION_VOLUME_TEXTURES_VARIANT
|
|
284
|
-
) {
|
|
285
|
-
for (const slot of TRANSMISSION_VOLUME_TEXTURE_SLOTS) slots.add(slot);
|
|
286
|
-
}
|
|
287
|
-
if (
|
|
288
|
-
shaderVariant === DEFAULT_TEXTURED_PBR_SPECULAR_SHEEN_ANISOTROPY_TEXTURES_VARIANT ||
|
|
289
|
-
shaderVariant === DEFAULT_TEXTURED_PBR_SPECULAR_SHEEN_ANISOTROPY_IRIDESCENCE_TEXTURES_VARIANT ||
|
|
290
|
-
shaderVariant === DEFAULT_TEXTURED_PBR_CLEARCOAT_SPECULAR_TEXTURES_VARIANT
|
|
291
|
-
) {
|
|
292
|
-
for (const slot of SPECULAR_TEXTURE_SLOTS) slots.add(slot);
|
|
293
|
-
}
|
|
294
|
-
if (
|
|
295
|
-
shaderVariant === DEFAULT_TEXTURED_PBR_SPECULAR_SHEEN_ANISOTROPY_TEXTURES_VARIANT ||
|
|
296
|
-
shaderVariant === DEFAULT_TEXTURED_PBR_SPECULAR_SHEEN_ANISOTROPY_IRIDESCENCE_TEXTURES_VARIANT
|
|
297
|
-
) {
|
|
298
|
-
for (const slot of SHEEN_ANISOTROPY_TEXTURE_SLOTS) slots.add(slot);
|
|
299
|
-
}
|
|
300
|
-
if (
|
|
301
|
-
shaderVariant === DEFAULT_TEXTURED_PBR_IRIDESCENCE_TEXTURES_VARIANT ||
|
|
302
|
-
shaderVariant === DEFAULT_TEXTURED_PBR_SPECULAR_SHEEN_ANISOTROPY_IRIDESCENCE_TEXTURES_VARIANT
|
|
303
|
-
) {
|
|
304
|
-
for (const slot of IRIDESCENCE_TEXTURE_SLOTS) slots.add(slot);
|
|
305
|
-
}
|
|
306
|
-
return [...slots];
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
export function isTexturedPbrTextureSlotShaderActive(slot: TexturedPBRTextureSlot, shaderVariant?: string): boolean {
|
|
310
|
-
return texturedPbrShaderActiveTextureSlots(shaderVariant).includes(slot);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
export class TexturedPBRMaterial extends Material {
|
|
314
|
-
constructor(options: TexturedPBRMaterialOptions = {}) {
|
|
315
|
-
const baseColor = options.baseColor ?? [1, 1, 1, 1];
|
|
316
|
-
const environmentColor = options.environmentColor ?? [1, 1, 1];
|
|
317
|
-
const proceduralEnvironmentMap: TexturedPBRProceduralEnvironmentMapOptions = options.proceduralEnvironmentMap ?? DEFAULT_PBR_PROCEDURAL_ENVIRONMENT_MAP;
|
|
318
|
-
const emissiveColor = options.emissiveColor ?? [0, 0, 0];
|
|
319
|
-
const specularColorFactor = options.specularColorFactor ?? [1, 1, 1];
|
|
320
|
-
const diffuseTransmissionColorFactor = options.diffuseTransmissionColorFactor ?? [1, 1, 1];
|
|
321
|
-
const sheenColorFactor = options.sheenColorFactor ?? [0, 0, 0];
|
|
322
|
-
const volumeAttenuationColor = options.volumeAttenuationColor ?? [1, 1, 1];
|
|
323
|
-
const transmissionParallaxBoxMin = options.transmissionParallaxBoxMin ?? [-1, -1, -1];
|
|
324
|
-
const transmissionParallaxBoxMax = options.transmissionParallaxBoxMax ?? [1, 1, 1];
|
|
325
|
-
const transmissionBackdropResolution = options.transmissionBackdropResolution ?? [1, 1];
|
|
326
|
-
const shaderVariant = texturedPbrShaderVariant(options);
|
|
327
|
-
const hasTransmissionBackdrop = Boolean(options.transmissionBackdropTexture);
|
|
328
|
-
if (hasTransmissionBackdrop && shaderVariant) {
|
|
329
|
-
throw new Error("TexturedPBRMaterial transmissionBackdropTexture currently requires the base textured PBR shader variant; combine advanced extension texture variants through a dedicated transmission pass.");
|
|
330
|
-
}
|
|
331
|
-
const transmissionBackdropUniformSchema: readonly MaterialUniformDescriptor[] = hasTransmissionBackdrop ? [
|
|
332
|
-
{ name: "u_transmissionBackdropTexture", kind: "texture2d", required: false },
|
|
333
|
-
{ name: "u_transmissionBackdropEnabled", kind: "float" },
|
|
334
|
-
{ name: "u_transmissionBackdropStrength", kind: "float" },
|
|
335
|
-
{ name: "u_transmissionBackdropResolution", kind: "vec2" },
|
|
336
|
-
{ name: "u_transmissionBackdropMipCount", kind: "float" },
|
|
337
|
-
{ name: "u_transmissionBackdropRefractionScale", kind: "float" }
|
|
338
|
-
] : [];
|
|
339
|
-
validateColor4(baseColor, "baseColor");
|
|
340
|
-
validateColor3(environmentColor, "environmentColor");
|
|
341
|
-
validateProceduralEnvironmentMap(proceduralEnvironmentMap);
|
|
342
|
-
validateNonNegative(options.environmentMapIntensity ?? 0, "environmentMapIntensity");
|
|
343
|
-
validateNonNegative(options.environmentMapSpecularIntensity ?? 0, "environmentMapSpecularIntensity");
|
|
344
|
-
validateFinite(options.environmentMapRotation ?? 0, "environmentMapRotation");
|
|
345
|
-
validateMipCount(options.environmentMapMipCount ?? 1, "environmentMapMipCount");
|
|
346
|
-
validateColor3(emissiveColor, "emissiveColor");
|
|
347
|
-
validateNonNegativeColor3(specularColorFactor, "specularColorFactor");
|
|
348
|
-
validateColor3(diffuseTransmissionColorFactor, "diffuseTransmissionColorFactor");
|
|
349
|
-
validateColor3(sheenColorFactor, "sheenColorFactor");
|
|
350
|
-
validateColor3(volumeAttenuationColor, "volumeAttenuationColor");
|
|
351
|
-
validateUnit(options.metallic ?? 0, "metallic");
|
|
352
|
-
validateUnit(options.roughness ?? 0.5, "roughness");
|
|
353
|
-
validateNonNegative(options.environmentIntensity ?? DEFAULT_PBR_ENVIRONMENT_INTENSITY, "environmentIntensity");
|
|
354
|
-
validateUnit(options.clearcoatFactor ?? 0, "clearcoatFactor");
|
|
355
|
-
validateUnit(options.clearcoatRoughnessFactor ?? 0, "clearcoatRoughnessFactor");
|
|
356
|
-
validateUnit(options.transmissionFactor ?? 0, "transmissionFactor");
|
|
357
|
-
validateUnit(options.diffuseTransmissionFactor ?? 0, "diffuseTransmissionFactor");
|
|
358
|
-
validateUnit(options.transmissionFallbackEnergy ?? 0.08, "transmissionFallbackEnergy");
|
|
359
|
-
validateNonNegative(options.volumeThicknessFactor ?? 0, "volumeThicknessFactor");
|
|
360
|
-
validatePositive(options.volumeAttenuationDistance ?? 1_000_000, "volumeAttenuationDistance");
|
|
361
|
-
validateUnit(options.transmissionParallaxStrength ?? 0, "transmissionParallaxStrength");
|
|
362
|
-
validateFiniteVec3(transmissionParallaxBoxMin, "transmissionParallaxBoxMin");
|
|
363
|
-
validateFiniteVec3(transmissionParallaxBoxMax, "transmissionParallaxBoxMax");
|
|
364
|
-
if (transmissionParallaxBoxMin.some((component, index) => component >= transmissionParallaxBoxMax[index]!)) {
|
|
365
|
-
throw new RangeError("TexturedPBRMaterial transmissionParallaxBoxMin must be lower than transmissionParallaxBoxMax");
|
|
366
|
-
}
|
|
367
|
-
validateNonNegative(options.transmissionBounceCount ?? 0, "transmissionBounceCount");
|
|
368
|
-
validateNonNegative(options.transmissionCausticStrength ?? 0, "transmissionCausticStrength");
|
|
369
|
-
validateUnit(options.transmissionBackdropStrength ?? 0, "transmissionBackdropStrength");
|
|
370
|
-
validatePositiveVec2(transmissionBackdropResolution, "transmissionBackdropResolution");
|
|
371
|
-
validateMipCount(options.transmissionBackdropMipCount ?? 1, "transmissionBackdropMipCount");
|
|
372
|
-
validateNonNegative(options.transmissionBackdropRefractionScale ?? 0.035, "transmissionBackdropRefractionScale");
|
|
373
|
-
validateUnit(options.specularFactor ?? 1, "specularFactor");
|
|
374
|
-
validateUnit(options.sheenRoughnessFactor ?? 0, "sheenRoughnessFactor");
|
|
375
|
-
validateUnit(options.anisotropyStrength ?? 0, "anisotropyStrength");
|
|
376
|
-
validateFinite(options.anisotropyRotation ?? 0, "anisotropyRotation");
|
|
377
|
-
validateUnit(options.iridescenceFactor ?? 0, "iridescenceFactor");
|
|
378
|
-
validateIridescenceIOR(options.iridescenceIor ?? 1.3);
|
|
379
|
-
const iridescenceThicknessMinimum = options.iridescenceThicknessMinimum ?? 100;
|
|
380
|
-
const iridescenceThicknessMaximum = options.iridescenceThicknessMaximum ?? 400;
|
|
381
|
-
validateNonNegative(iridescenceThicknessMinimum, "iridescenceThicknessMinimum");
|
|
382
|
-
validateNonNegative(iridescenceThicknessMaximum, "iridescenceThicknessMaximum");
|
|
383
|
-
if (iridescenceThicknessMaximum < iridescenceThicknessMinimum) {
|
|
384
|
-
throw new RangeError("TexturedPBRMaterial iridescenceThicknessMaximum must be greater than or equal to iridescenceThicknessMinimum");
|
|
385
|
-
}
|
|
386
|
-
validateNonNegative(options.dispersion ?? 0, "dispersion");
|
|
387
|
-
validateIOR(options.ior ?? 1.5);
|
|
388
|
-
validateNonNegative(options.emissiveStrength ?? 1, "emissiveStrength");
|
|
389
|
-
const normalScale = options.normalScale ?? 1;
|
|
390
|
-
if (!Number.isFinite(normalScale) || normalScale < 0) {
|
|
391
|
-
throw new RangeError("TexturedPBRMaterial normalScale must be finite and non-negative");
|
|
392
|
-
}
|
|
393
|
-
const occlusionStrength = options.occlusionStrength ?? 1;
|
|
394
|
-
validateUnit(occlusionStrength, "occlusionStrength");
|
|
395
|
-
const clearcoatNormalScale = options.clearcoatNormalScale ?? 1;
|
|
396
|
-
if (!Number.isFinite(clearcoatNormalScale) || clearcoatNormalScale < 0) {
|
|
397
|
-
throw new RangeError("TexturedPBRMaterial clearcoatNormalScale must be finite and non-negative");
|
|
398
|
-
}
|
|
399
|
-
const requiresTangentFrame = Boolean(options.normalTexture || options.clearcoatNormalTexture);
|
|
400
|
-
|
|
401
|
-
super({
|
|
402
|
-
name: options.name ?? "textured-pbr",
|
|
403
|
-
shaderKey: DEFAULT_TEXTURED_PBR_SHADER_NAME,
|
|
404
|
-
shaderVariant,
|
|
405
|
-
renderState: options.renderState,
|
|
406
|
-
parameters: {
|
|
407
|
-
u_baseColor: baseColor,
|
|
408
|
-
u_metallic: options.metallic ?? 0,
|
|
409
|
-
u_roughness: options.roughness ?? 0.5,
|
|
410
|
-
u_environmentColor: environmentColor,
|
|
411
|
-
u_environmentIntensity: options.environmentIntensity ?? DEFAULT_PBR_ENVIRONMENT_INTENSITY,
|
|
412
|
-
u_environmentSkyColor: proceduralEnvironmentMap.skyColor,
|
|
413
|
-
u_environmentHorizonColor: proceduralEnvironmentMap.horizonColor,
|
|
414
|
-
u_environmentGroundColor: proceduralEnvironmentMap.groundColor,
|
|
415
|
-
u_environmentSpecularColor: proceduralEnvironmentMap.specularColor,
|
|
416
|
-
u_environmentMapIntensity: proceduralEnvironmentMap.intensity,
|
|
417
|
-
u_environmentSpecularIntensity: proceduralEnvironmentMap.specularIntensity,
|
|
418
|
-
u_environmentMapTexture: options.environmentMapTexture ?? new TextureBinding({ name: "u_environmentMapTexture", required: false }),
|
|
419
|
-
u_environmentMapTextureEnabled: options.environmentMapTexture ? 1 : 0,
|
|
420
|
-
u_environmentMapTextureIntensity: options.environmentMapIntensity ?? 0,
|
|
421
|
-
u_environmentMapTextureSpecularIntensity: options.environmentMapSpecularIntensity ?? 0,
|
|
422
|
-
u_materialEnvironmentSpecularScale: options.materialEnvironmentSpecularScale ?? 1,
|
|
423
|
-
u_environmentMapTextureRotation: options.environmentMapRotation ?? 0,
|
|
424
|
-
u_environmentMapTextureMipCount: options.environmentMapMipCount ?? 1,
|
|
425
|
-
u_environmentMapTextureEncoding: 0,
|
|
426
|
-
u_environmentBrdfLutTexture: options.environmentBrdfLutTexture ?? new TextureBinding({ name: "u_environmentBrdfLutTexture", required: false }),
|
|
427
|
-
u_environmentBrdfLutEnabled: options.environmentBrdfLutTexture ? 1 : 0,
|
|
428
|
-
u_emissiveColor: emissiveColor,
|
|
429
|
-
u_emissiveStrength: options.emissiveStrength ?? 1,
|
|
430
|
-
u_clearcoatFactor: options.clearcoatFactor ?? 0,
|
|
431
|
-
u_clearcoatRoughnessFactor: options.clearcoatRoughnessFactor ?? 0,
|
|
432
|
-
u_transmissionFactor: options.transmissionFactor ?? 0,
|
|
433
|
-
u_diffuseTransmissionFactor: options.diffuseTransmissionFactor ?? 0,
|
|
434
|
-
u_diffuseTransmissionColorFactor: diffuseTransmissionColorFactor,
|
|
435
|
-
u_transmissionFallbackEnergy: options.transmissionFallbackEnergy ?? 0.08,
|
|
436
|
-
u_volumeThicknessFactor: options.volumeThicknessFactor ?? 0,
|
|
437
|
-
u_volumeAttenuationDistance: options.volumeAttenuationDistance ?? 1_000_000,
|
|
438
|
-
u_volumeAttenuationColor: volumeAttenuationColor,
|
|
439
|
-
u_transmissionParallaxStrength: options.transmissionParallaxStrength ?? 0,
|
|
440
|
-
u_transmissionParallaxBoxMin: transmissionParallaxBoxMin,
|
|
441
|
-
u_transmissionParallaxBoxMax: transmissionParallaxBoxMax,
|
|
442
|
-
u_transmissionBounceCount: options.transmissionBounceCount ?? 0,
|
|
443
|
-
u_transmissionCausticStrength: options.transmissionCausticStrength ?? 0,
|
|
444
|
-
u_transmissionBackdropTexture: options.transmissionBackdropTexture ?? new TextureBinding({ name: "u_transmissionBackdropTexture", required: false }),
|
|
445
|
-
u_transmissionBackdropEnabled: options.transmissionBackdropTexture ? 1 : 0,
|
|
446
|
-
u_transmissionBackdropStrength: options.transmissionBackdropStrength ?? 0,
|
|
447
|
-
u_transmissionBackdropResolution: transmissionBackdropResolution,
|
|
448
|
-
u_transmissionBackdropMipCount: options.transmissionBackdropMipCount ?? options.transmissionBackdropTexture?.texture?.textureLevels.length ?? 1,
|
|
449
|
-
u_transmissionBackdropRefractionScale: options.transmissionBackdropRefractionScale ?? 0.035,
|
|
450
|
-
u_ior: options.ior ?? 1.5,
|
|
451
|
-
u_specularFactor: options.specularFactor ?? 1,
|
|
452
|
-
u_specularColorFactor: specularColorFactor,
|
|
453
|
-
u_sheenColorFactor: sheenColorFactor,
|
|
454
|
-
u_sheenRoughnessFactor: options.sheenRoughnessFactor ?? 0,
|
|
455
|
-
u_anisotropyStrength: options.anisotropyStrength ?? 0,
|
|
456
|
-
u_anisotropyRotation: options.anisotropyRotation ?? 0,
|
|
457
|
-
u_iridescenceFactor: options.iridescenceFactor ?? 0,
|
|
458
|
-
u_iridescenceIor: options.iridescenceIor ?? 1.3,
|
|
459
|
-
u_iridescenceThicknessMinimum: iridescenceThicknessMinimum,
|
|
460
|
-
u_iridescenceThicknessMaximum: iridescenceThicknessMaximum,
|
|
461
|
-
u_dispersion: options.dispersion ?? 0,
|
|
462
|
-
u_lightCount: 0,
|
|
463
|
-
u_lightData: new Float32Array(0),
|
|
464
|
-
u_baseColorTexture: new TextureBinding({
|
|
465
|
-
name: "u_baseColorTexture",
|
|
466
|
-
texture: options.baseColorTexture ?? defaultWhiteTexture(),
|
|
467
|
-
sampler: options.baseColorSampler,
|
|
468
|
-
required: true,
|
|
469
|
-
expectedColorSpace: "srgb",
|
|
470
|
-
transform: options.baseColorTextureTransform
|
|
471
|
-
}),
|
|
472
|
-
u_baseColorTextureEnabled: options.baseColorTexture ? 1 : 0,
|
|
473
|
-
u_baseColorTextureOffset: options.baseColorTextureTransform?.offset ?? [0, 0],
|
|
474
|
-
u_baseColorTextureScale: options.baseColorTextureTransform?.scale ?? [1, 1],
|
|
475
|
-
u_baseColorTextureRotation: options.baseColorTextureTransform?.rotation ?? 0,
|
|
476
|
-
u_baseColorTextureTexCoord: textureTexCoord(options.textureTexCoords, "baseColor"),
|
|
477
|
-
u_baseColorTextureWrap: samplerWrapMode(options.baseColorSampler),
|
|
478
|
-
u_normalTexture: new TextureBinding({
|
|
479
|
-
name: "u_normalTexture",
|
|
480
|
-
texture: options.normalTexture ?? defaultFlatNormalTexture(),
|
|
481
|
-
sampler: options.normalSampler,
|
|
482
|
-
required: true,
|
|
483
|
-
expectedColorSpace: "linear",
|
|
484
|
-
transform: options.normalTextureTransform
|
|
485
|
-
}),
|
|
486
|
-
u_normalTextureEnabled: options.normalTexture ? 1 : 0,
|
|
487
|
-
u_normalTextureOffset: options.normalTextureTransform?.offset ?? [0, 0],
|
|
488
|
-
u_normalTextureScale: options.normalTextureTransform?.scale ?? [1, 1],
|
|
489
|
-
u_normalTextureRotation: options.normalTextureTransform?.rotation ?? 0,
|
|
490
|
-
u_normalTextureTexCoord: textureTexCoord(options.textureTexCoords, "normal"),
|
|
491
|
-
u_normalTextureWrap: samplerWrapMode(options.normalSampler),
|
|
492
|
-
u_normalScale: normalScale,
|
|
493
|
-
u_metallicRoughnessTexture: new TextureBinding({
|
|
494
|
-
name: "u_metallicRoughnessTexture",
|
|
495
|
-
texture: options.metallicRoughnessTexture ?? defaultMetallicRoughnessTexture(),
|
|
496
|
-
sampler: options.metallicRoughnessSampler,
|
|
497
|
-
required: true,
|
|
498
|
-
expectedColorSpace: "linear",
|
|
499
|
-
transform: options.metallicRoughnessTextureTransform
|
|
500
|
-
}),
|
|
501
|
-
u_metallicRoughnessTextureEnabled: options.metallicRoughnessTexture ? 1 : 0,
|
|
502
|
-
u_metallicRoughnessTextureOffset: options.metallicRoughnessTextureTransform?.offset ?? [0, 0],
|
|
503
|
-
u_metallicRoughnessTextureScale: options.metallicRoughnessTextureTransform?.scale ?? [1, 1],
|
|
504
|
-
u_metallicRoughnessTextureRotation: options.metallicRoughnessTextureTransform?.rotation ?? 0,
|
|
505
|
-
u_metallicRoughnessTextureTexCoord: textureTexCoord(options.textureTexCoords, "metallicRoughness"),
|
|
506
|
-
u_metallicRoughnessTextureWrap: samplerWrapMode(options.metallicRoughnessSampler),
|
|
507
|
-
u_occlusionTexture: new TextureBinding({
|
|
508
|
-
name: "u_occlusionTexture",
|
|
509
|
-
texture: options.occlusionTexture ?? defaultLinearWhiteTexture("default-occlusion"),
|
|
510
|
-
sampler: options.occlusionSampler,
|
|
511
|
-
required: true,
|
|
512
|
-
expectedColorSpace: "linear",
|
|
513
|
-
transform: options.occlusionTextureTransform
|
|
514
|
-
}),
|
|
515
|
-
u_occlusionTextureEnabled: options.occlusionTexture ? 1 : 0,
|
|
516
|
-
u_occlusionTextureOffset: options.occlusionTextureTransform?.offset ?? [0, 0],
|
|
517
|
-
u_occlusionTextureScale: options.occlusionTextureTransform?.scale ?? [1, 1],
|
|
518
|
-
u_occlusionTextureRotation: options.occlusionTextureTransform?.rotation ?? 0,
|
|
519
|
-
u_occlusionTextureTexCoord: textureTexCoord(options.textureTexCoords, "occlusion"),
|
|
520
|
-
u_occlusionTextureWrap: samplerWrapMode(options.occlusionSampler),
|
|
521
|
-
u_occlusionStrength: occlusionStrength,
|
|
522
|
-
u_emissiveTexture: new TextureBinding({
|
|
523
|
-
name: "u_emissiveTexture",
|
|
524
|
-
texture: options.emissiveTexture ?? defaultWhiteTexture(),
|
|
525
|
-
sampler: options.emissiveSampler,
|
|
526
|
-
required: true,
|
|
527
|
-
expectedColorSpace: "srgb",
|
|
528
|
-
transform: options.emissiveTextureTransform
|
|
529
|
-
}),
|
|
530
|
-
u_emissiveTextureEnabled: options.emissiveTexture ? 1 : 0,
|
|
531
|
-
u_emissiveTextureOffset: options.emissiveTextureTransform?.offset ?? [0, 0],
|
|
532
|
-
u_emissiveTextureScale: options.emissiveTextureTransform?.scale ?? [1, 1],
|
|
533
|
-
u_emissiveTextureRotation: options.emissiveTextureTransform?.rotation ?? 0,
|
|
534
|
-
u_emissiveTextureTexCoord: textureTexCoord(options.textureTexCoords, "emissive"),
|
|
535
|
-
u_emissiveTextureWrap: samplerWrapMode(options.emissiveSampler),
|
|
536
|
-
u_clearcoatTexture: new TextureBinding({
|
|
537
|
-
name: "u_clearcoatTexture",
|
|
538
|
-
texture: options.clearcoatTexture ?? defaultLinearWhiteTexture("default-clearcoat"),
|
|
539
|
-
sampler: options.clearcoatSampler,
|
|
540
|
-
required: true,
|
|
541
|
-
expectedColorSpace: "linear",
|
|
542
|
-
transform: options.clearcoatTextureTransform
|
|
543
|
-
}),
|
|
544
|
-
u_clearcoatTextureEnabled: options.clearcoatTexture ? 1 : 0,
|
|
545
|
-
u_clearcoatTextureOffset: options.clearcoatTextureTransform?.offset ?? [0, 0],
|
|
546
|
-
u_clearcoatTextureScale: options.clearcoatTextureTransform?.scale ?? [1, 1],
|
|
547
|
-
u_clearcoatTextureRotation: options.clearcoatTextureTransform?.rotation ?? 0,
|
|
548
|
-
u_clearcoatTextureTexCoord: textureTexCoord(options.textureTexCoords, "clearcoat"),
|
|
549
|
-
u_clearcoatTextureWrap: samplerWrapMode(options.clearcoatSampler),
|
|
550
|
-
u_clearcoatRoughnessTexture: new TextureBinding({
|
|
551
|
-
name: "u_clearcoatRoughnessTexture",
|
|
552
|
-
texture: options.clearcoatRoughnessTexture ?? defaultLinearWhiteTexture("default-clearcoat-roughness"),
|
|
553
|
-
sampler: options.clearcoatRoughnessSampler,
|
|
554
|
-
required: true,
|
|
555
|
-
expectedColorSpace: "linear",
|
|
556
|
-
transform: options.clearcoatRoughnessTextureTransform
|
|
557
|
-
}),
|
|
558
|
-
u_clearcoatRoughnessTextureEnabled: options.clearcoatRoughnessTexture ? 1 : 0,
|
|
559
|
-
u_clearcoatRoughnessTextureOffset: options.clearcoatRoughnessTextureTransform?.offset ?? [0, 0],
|
|
560
|
-
u_clearcoatRoughnessTextureScale: options.clearcoatRoughnessTextureTransform?.scale ?? [1, 1],
|
|
561
|
-
u_clearcoatRoughnessTextureRotation: options.clearcoatRoughnessTextureTransform?.rotation ?? 0,
|
|
562
|
-
u_clearcoatRoughnessTextureTexCoord: textureTexCoord(options.textureTexCoords, "clearcoatRoughness"),
|
|
563
|
-
u_clearcoatRoughnessTextureWrap: samplerWrapMode(options.clearcoatRoughnessSampler),
|
|
564
|
-
u_clearcoatNormalTexture: new TextureBinding({
|
|
565
|
-
name: "u_clearcoatNormalTexture",
|
|
566
|
-
texture: options.clearcoatNormalTexture ?? defaultFlatNormalTexture(),
|
|
567
|
-
sampler: options.clearcoatNormalSampler,
|
|
568
|
-
required: true,
|
|
569
|
-
expectedColorSpace: "linear",
|
|
570
|
-
transform: options.clearcoatNormalTextureTransform
|
|
571
|
-
}),
|
|
572
|
-
u_clearcoatNormalTextureEnabled: options.clearcoatNormalTexture ? 1 : 0,
|
|
573
|
-
u_clearcoatNormalTextureOffset: options.clearcoatNormalTextureTransform?.offset ?? [0, 0],
|
|
574
|
-
u_clearcoatNormalTextureScale: options.clearcoatNormalTextureTransform?.scale ?? [1, 1],
|
|
575
|
-
u_clearcoatNormalTextureRotation: options.clearcoatNormalTextureTransform?.rotation ?? 0,
|
|
576
|
-
u_clearcoatNormalTextureTexCoord: textureTexCoord(options.textureTexCoords, "clearcoatNormal"),
|
|
577
|
-
u_clearcoatNormalTextureWrap: samplerWrapMode(options.clearcoatNormalSampler),
|
|
578
|
-
u_clearcoatNormalScale: clearcoatNormalScale,
|
|
579
|
-
u_transmissionTexture: new TextureBinding({
|
|
580
|
-
name: "u_transmissionTexture",
|
|
581
|
-
texture: options.transmissionTexture ?? defaultLinearWhiteTexture("default-transmission"),
|
|
582
|
-
sampler: options.transmissionSampler,
|
|
583
|
-
required: true,
|
|
584
|
-
expectedColorSpace: "linear",
|
|
585
|
-
transform: options.transmissionTextureTransform
|
|
586
|
-
}),
|
|
587
|
-
u_transmissionTextureEnabled: options.transmissionTexture ? 1 : 0,
|
|
588
|
-
u_transmissionTextureOffset: options.transmissionTextureTransform?.offset ?? [0, 0],
|
|
589
|
-
u_transmissionTextureScale: options.transmissionTextureTransform?.scale ?? [1, 1],
|
|
590
|
-
u_transmissionTextureRotation: options.transmissionTextureTransform?.rotation ?? 0,
|
|
591
|
-
u_transmissionTextureTexCoord: textureTexCoord(options.textureTexCoords, "transmission"),
|
|
592
|
-
u_transmissionTextureWrap: samplerWrapMode(options.transmissionSampler),
|
|
593
|
-
u_diffuseTransmissionTexture: new TextureBinding({
|
|
594
|
-
name: "u_diffuseTransmissionTexture",
|
|
595
|
-
texture: options.diffuseTransmissionTexture ?? defaultLinearWhiteTexture("default-diffuse-transmission"),
|
|
596
|
-
sampler: options.diffuseTransmissionSampler,
|
|
597
|
-
required: true,
|
|
598
|
-
expectedColorSpace: "linear",
|
|
599
|
-
transform: options.diffuseTransmissionTextureTransform
|
|
600
|
-
}),
|
|
601
|
-
u_diffuseTransmissionTextureEnabled: options.diffuseTransmissionTexture ? 1 : 0,
|
|
602
|
-
u_diffuseTransmissionTextureOffset: options.diffuseTransmissionTextureTransform?.offset ?? [0, 0],
|
|
603
|
-
u_diffuseTransmissionTextureScale: options.diffuseTransmissionTextureTransform?.scale ?? [1, 1],
|
|
604
|
-
u_diffuseTransmissionTextureRotation: options.diffuseTransmissionTextureTransform?.rotation ?? 0,
|
|
605
|
-
u_diffuseTransmissionTextureTexCoord: textureTexCoord(options.textureTexCoords, "diffuseTransmission"),
|
|
606
|
-
u_diffuseTransmissionTextureWrap: samplerWrapMode(options.diffuseTransmissionSampler),
|
|
607
|
-
u_diffuseTransmissionColorTexture: new TextureBinding({
|
|
608
|
-
name: "u_diffuseTransmissionColorTexture",
|
|
609
|
-
texture: options.diffuseTransmissionColorTexture ?? defaultWhiteTexture("default-diffuse-transmission-color"),
|
|
610
|
-
sampler: options.diffuseTransmissionColorSampler,
|
|
611
|
-
required: true,
|
|
612
|
-
expectedColorSpace: "srgb",
|
|
613
|
-
transform: options.diffuseTransmissionColorTextureTransform
|
|
614
|
-
}),
|
|
615
|
-
u_diffuseTransmissionColorTextureEnabled: options.diffuseTransmissionColorTexture ? 1 : 0,
|
|
616
|
-
u_diffuseTransmissionColorTextureOffset: options.diffuseTransmissionColorTextureTransform?.offset ?? [0, 0],
|
|
617
|
-
u_diffuseTransmissionColorTextureScale: options.diffuseTransmissionColorTextureTransform?.scale ?? [1, 1],
|
|
618
|
-
u_diffuseTransmissionColorTextureRotation: options.diffuseTransmissionColorTextureTransform?.rotation ?? 0,
|
|
619
|
-
u_diffuseTransmissionColorTextureTexCoord: textureTexCoord(options.textureTexCoords, "diffuseTransmissionColor"),
|
|
620
|
-
u_diffuseTransmissionColorTextureWrap: samplerWrapMode(options.diffuseTransmissionColorSampler),
|
|
621
|
-
u_volumeThicknessTexture: new TextureBinding({
|
|
622
|
-
name: "u_volumeThicknessTexture",
|
|
623
|
-
texture: options.volumeThicknessTexture ?? defaultLinearWhiteTexture("default-volume-thickness"),
|
|
624
|
-
sampler: options.volumeThicknessSampler,
|
|
625
|
-
required: true,
|
|
626
|
-
expectedColorSpace: "linear",
|
|
627
|
-
transform: options.volumeThicknessTextureTransform
|
|
628
|
-
}),
|
|
629
|
-
u_volumeThicknessTextureEnabled: options.volumeThicknessTexture ? 1 : 0,
|
|
630
|
-
u_volumeThicknessTextureOffset: options.volumeThicknessTextureTransform?.offset ?? [0, 0],
|
|
631
|
-
u_volumeThicknessTextureScale: options.volumeThicknessTextureTransform?.scale ?? [1, 1],
|
|
632
|
-
u_volumeThicknessTextureRotation: options.volumeThicknessTextureTransform?.rotation ?? 0,
|
|
633
|
-
u_volumeThicknessTextureTexCoord: textureTexCoord(options.textureTexCoords, "volumeThickness"),
|
|
634
|
-
u_volumeThicknessTextureWrap: samplerWrapMode(options.volumeThicknessSampler),
|
|
635
|
-
u_specularTexture: new TextureBinding({
|
|
636
|
-
name: "u_specularTexture",
|
|
637
|
-
texture: options.specularTexture ?? defaultLinearWhiteTexture("default-specular"),
|
|
638
|
-
sampler: options.specularSampler,
|
|
639
|
-
required: true,
|
|
640
|
-
expectedColorSpace: "linear",
|
|
641
|
-
transform: options.specularTextureTransform
|
|
642
|
-
}),
|
|
643
|
-
u_specularTextureEnabled: options.specularTexture ? 1 : 0,
|
|
644
|
-
u_specularTextureOffset: options.specularTextureTransform?.offset ?? [0, 0],
|
|
645
|
-
u_specularTextureScale: options.specularTextureTransform?.scale ?? [1, 1],
|
|
646
|
-
u_specularTextureRotation: options.specularTextureTransform?.rotation ?? 0,
|
|
647
|
-
u_specularTextureTexCoord: textureTexCoord(options.textureTexCoords, "specular"),
|
|
648
|
-
u_specularTextureWrap: samplerWrapMode(options.specularSampler),
|
|
649
|
-
u_specularColorTexture: new TextureBinding({
|
|
650
|
-
name: "u_specularColorTexture",
|
|
651
|
-
texture: options.specularColorTexture ?? defaultWhiteTexture("default-specular-color"),
|
|
652
|
-
sampler: options.specularColorSampler,
|
|
653
|
-
required: true,
|
|
654
|
-
expectedColorSpace: "srgb",
|
|
655
|
-
transform: options.specularColorTextureTransform
|
|
656
|
-
}),
|
|
657
|
-
u_specularColorTextureEnabled: options.specularColorTexture ? 1 : 0,
|
|
658
|
-
u_specularColorTextureOffset: options.specularColorTextureTransform?.offset ?? [0, 0],
|
|
659
|
-
u_specularColorTextureScale: options.specularColorTextureTransform?.scale ?? [1, 1],
|
|
660
|
-
u_specularColorTextureRotation: options.specularColorTextureTransform?.rotation ?? 0,
|
|
661
|
-
u_specularColorTextureTexCoord: textureTexCoord(options.textureTexCoords, "specularColor"),
|
|
662
|
-
u_specularColorTextureWrap: samplerWrapMode(options.specularColorSampler),
|
|
663
|
-
u_sheenColorTexture: new TextureBinding({
|
|
664
|
-
name: "u_sheenColorTexture",
|
|
665
|
-
texture: options.sheenColorTexture ?? defaultWhiteTexture("default-sheen-color"),
|
|
666
|
-
sampler: options.sheenColorSampler,
|
|
667
|
-
required: true,
|
|
668
|
-
expectedColorSpace: "srgb",
|
|
669
|
-
transform: options.sheenColorTextureTransform
|
|
670
|
-
}),
|
|
671
|
-
u_sheenColorTextureEnabled: options.sheenColorTexture ? 1 : 0,
|
|
672
|
-
u_sheenColorTextureOffset: options.sheenColorTextureTransform?.offset ?? [0, 0],
|
|
673
|
-
u_sheenColorTextureScale: options.sheenColorTextureTransform?.scale ?? [1, 1],
|
|
674
|
-
u_sheenColorTextureRotation: options.sheenColorTextureTransform?.rotation ?? 0,
|
|
675
|
-
u_sheenColorTextureTexCoord: textureTexCoord(options.textureTexCoords, "sheenColor"),
|
|
676
|
-
u_sheenColorTextureWrap: samplerWrapMode(options.sheenColorSampler),
|
|
677
|
-
u_sheenRoughnessTexture: new TextureBinding({
|
|
678
|
-
name: "u_sheenRoughnessTexture",
|
|
679
|
-
texture: options.sheenRoughnessTexture ?? defaultLinearWhiteTexture("default-sheen-roughness"),
|
|
680
|
-
sampler: options.sheenRoughnessSampler,
|
|
681
|
-
required: true,
|
|
682
|
-
expectedColorSpace: "linear",
|
|
683
|
-
transform: options.sheenRoughnessTextureTransform
|
|
684
|
-
}),
|
|
685
|
-
u_sheenRoughnessTextureEnabled: options.sheenRoughnessTexture ? 1 : 0,
|
|
686
|
-
u_sheenRoughnessTextureOffset: options.sheenRoughnessTextureTransform?.offset ?? [0, 0],
|
|
687
|
-
u_sheenRoughnessTextureScale: options.sheenRoughnessTextureTransform?.scale ?? [1, 1],
|
|
688
|
-
u_sheenRoughnessTextureRotation: options.sheenRoughnessTextureTransform?.rotation ?? 0,
|
|
689
|
-
u_sheenRoughnessTextureTexCoord: textureTexCoord(options.textureTexCoords, "sheenRoughness"),
|
|
690
|
-
u_sheenRoughnessTextureWrap: samplerWrapMode(options.sheenRoughnessSampler),
|
|
691
|
-
u_anisotropyTexture: new TextureBinding({
|
|
692
|
-
name: "u_anisotropyTexture",
|
|
693
|
-
texture: options.anisotropyTexture ?? defaultLinearWhiteTexture("default-anisotropy"),
|
|
694
|
-
sampler: options.anisotropySampler,
|
|
695
|
-
required: true,
|
|
696
|
-
expectedColorSpace: "linear",
|
|
697
|
-
transform: options.anisotropyTextureTransform
|
|
698
|
-
}),
|
|
699
|
-
u_anisotropyTextureEnabled: options.anisotropyTexture ? 1 : 0,
|
|
700
|
-
u_anisotropyTextureOffset: options.anisotropyTextureTransform?.offset ?? [0, 0],
|
|
701
|
-
u_anisotropyTextureScale: options.anisotropyTextureTransform?.scale ?? [1, 1],
|
|
702
|
-
u_anisotropyTextureRotation: options.anisotropyTextureTransform?.rotation ?? 0,
|
|
703
|
-
u_anisotropyTextureTexCoord: textureTexCoord(options.textureTexCoords, "anisotropy"),
|
|
704
|
-
u_anisotropyTextureWrap: samplerWrapMode(options.anisotropySampler),
|
|
705
|
-
u_iridescenceTexture: new TextureBinding({
|
|
706
|
-
name: "u_iridescenceTexture",
|
|
707
|
-
texture: options.iridescenceTexture ?? defaultLinearWhiteTexture("default-iridescence"),
|
|
708
|
-
sampler: options.iridescenceSampler,
|
|
709
|
-
required: true,
|
|
710
|
-
expectedColorSpace: "linear",
|
|
711
|
-
transform: options.iridescenceTextureTransform
|
|
712
|
-
}),
|
|
713
|
-
u_iridescenceTextureEnabled: options.iridescenceTexture ? 1 : 0,
|
|
714
|
-
u_iridescenceTextureOffset: options.iridescenceTextureTransform?.offset ?? [0, 0],
|
|
715
|
-
u_iridescenceTextureScale: options.iridescenceTextureTransform?.scale ?? [1, 1],
|
|
716
|
-
u_iridescenceTextureRotation: options.iridescenceTextureTransform?.rotation ?? 0,
|
|
717
|
-
u_iridescenceTextureTexCoord: textureTexCoord(options.textureTexCoords, "iridescence"),
|
|
718
|
-
u_iridescenceTextureWrap: samplerWrapMode(options.iridescenceSampler),
|
|
719
|
-
u_iridescenceThicknessTexture: new TextureBinding({
|
|
720
|
-
name: "u_iridescenceThicknessTexture",
|
|
721
|
-
texture: options.iridescenceThicknessTexture ?? defaultLinearWhiteTexture("default-iridescence-thickness"),
|
|
722
|
-
sampler: options.iridescenceThicknessSampler,
|
|
723
|
-
required: true,
|
|
724
|
-
expectedColorSpace: "linear",
|
|
725
|
-
transform: options.iridescenceThicknessTextureTransform
|
|
726
|
-
}),
|
|
727
|
-
u_iridescenceThicknessTextureEnabled: options.iridescenceThicknessTexture ? 1 : 0,
|
|
728
|
-
u_iridescenceThicknessTextureOffset: options.iridescenceThicknessTextureTransform?.offset ?? [0, 0],
|
|
729
|
-
u_iridescenceThicknessTextureScale: options.iridescenceThicknessTextureTransform?.scale ?? [1, 1],
|
|
730
|
-
u_iridescenceThicknessTextureRotation: options.iridescenceThicknessTextureTransform?.rotation ?? 0,
|
|
731
|
-
u_iridescenceThicknessTextureTexCoord: textureTexCoord(options.textureTexCoords, "iridescenceThickness"),
|
|
732
|
-
u_iridescenceThicknessTextureWrap: samplerWrapMode(options.iridescenceThicknessSampler),
|
|
733
|
-
u_modelViewProjection: identityMatrix(),
|
|
734
|
-
u_normalMatrix: identityMatrix()
|
|
735
|
-
},
|
|
736
|
-
requiredAttributes: [
|
|
737
|
-
"a_position",
|
|
738
|
-
"a_normal",
|
|
739
|
-
"a_uv",
|
|
740
|
-
...(requiresTangentFrame ? ["a_tangent"] : []),
|
|
741
|
-
...(usesSecondaryTexCoord(options.textureTexCoords) ? ["a_uv1"] : [])
|
|
742
|
-
],
|
|
743
|
-
uniformSchema: [
|
|
744
|
-
{ name: "u_baseColor", kind: "vec4" },
|
|
745
|
-
{ name: "u_metallic", kind: "float" },
|
|
746
|
-
{ name: "u_roughness", kind: "float" },
|
|
747
|
-
{ name: "u_environmentColor", kind: "vec3" },
|
|
748
|
-
{ name: "u_environmentIntensity", kind: "float" },
|
|
749
|
-
{ name: "u_environmentSkyColor", kind: "vec3" },
|
|
750
|
-
{ name: "u_environmentHorizonColor", kind: "vec3" },
|
|
751
|
-
{ name: "u_environmentGroundColor", kind: "vec3" },
|
|
752
|
-
{ name: "u_environmentSpecularColor", kind: "vec3" },
|
|
753
|
-
{ name: "u_environmentMapIntensity", kind: "float" },
|
|
754
|
-
{ name: "u_environmentSpecularIntensity", kind: "float" },
|
|
755
|
-
{ name: "u_environmentMapTexture", kind: "texture2d", required: false },
|
|
756
|
-
{ name: "u_environmentMapTextureEnabled", kind: "float" },
|
|
757
|
-
{ name: "u_environmentMapTextureIntensity", kind: "float" },
|
|
758
|
-
{ name: "u_environmentMapTextureSpecularIntensity", kind: "float" },
|
|
759
|
-
{ name: "u_materialEnvironmentSpecularScale", kind: "float" },
|
|
760
|
-
{ name: "u_environmentMapTextureRotation", kind: "float" },
|
|
761
|
-
{ name: "u_environmentMapTextureMipCount", kind: "float" },
|
|
762
|
-
{ name: "u_environmentMapTextureEncoding", kind: "float" },
|
|
763
|
-
{ name: "u_environmentBrdfLutTexture", kind: "texture2d", required: false },
|
|
764
|
-
{ name: "u_environmentBrdfLutEnabled", kind: "float", required: false },
|
|
765
|
-
{ name: "u_emissiveColor", kind: "vec3" },
|
|
766
|
-
{ name: "u_emissiveStrength", kind: "float" },
|
|
767
|
-
{ name: "u_clearcoatFactor", kind: "float" },
|
|
768
|
-
{ name: "u_clearcoatRoughnessFactor", kind: "float" },
|
|
769
|
-
{ name: "u_transmissionFactor", kind: "float" },
|
|
770
|
-
{ name: "u_diffuseTransmissionFactor", kind: "float" },
|
|
771
|
-
{ name: "u_diffuseTransmissionColorFactor", kind: "vec3" },
|
|
772
|
-
{ name: "u_transmissionFallbackEnergy", kind: "float" },
|
|
773
|
-
{ name: "u_volumeThicknessFactor", kind: "float" },
|
|
774
|
-
{ name: "u_volumeAttenuationDistance", kind: "float" },
|
|
775
|
-
{ name: "u_volumeAttenuationColor", kind: "vec3" },
|
|
776
|
-
{ name: "u_transmissionParallaxStrength", kind: "float" },
|
|
777
|
-
{ name: "u_transmissionParallaxBoxMin", kind: "vec3" },
|
|
778
|
-
{ name: "u_transmissionParallaxBoxMax", kind: "vec3" },
|
|
779
|
-
{ name: "u_transmissionBounceCount", kind: "float" },
|
|
780
|
-
{ name: "u_transmissionCausticStrength", kind: "float" },
|
|
781
|
-
...transmissionBackdropUniformSchema,
|
|
782
|
-
{ name: "u_ior", kind: "float" },
|
|
783
|
-
{ name: "u_specularFactor", kind: "float" },
|
|
784
|
-
{ name: "u_specularColorFactor", kind: "vec3" },
|
|
785
|
-
{ name: "u_sheenColorFactor", kind: "vec3" },
|
|
786
|
-
{ name: "u_sheenRoughnessFactor", kind: "float" },
|
|
787
|
-
{ name: "u_anisotropyStrength", kind: "float" },
|
|
788
|
-
{ name: "u_anisotropyRotation", kind: "float" },
|
|
789
|
-
{ name: "u_iridescenceFactor", kind: "float" },
|
|
790
|
-
{ name: "u_iridescenceIor", kind: "float" },
|
|
791
|
-
{ name: "u_iridescenceThicknessMinimum", kind: "float" },
|
|
792
|
-
{ name: "u_iridescenceThicknessMaximum", kind: "float" },
|
|
793
|
-
{ name: "u_dispersion", kind: "float" },
|
|
794
|
-
{ name: "u_lightCount", kind: "float" },
|
|
795
|
-
{ name: "u_lightData", kind: "any" },
|
|
796
|
-
{ name: "u_baseColorTexture", kind: "texture2d" },
|
|
797
|
-
{ name: "u_baseColorTextureEnabled", kind: "float" },
|
|
798
|
-
{ name: "u_baseColorTextureOffset", kind: "vec2" },
|
|
799
|
-
{ name: "u_baseColorTextureScale", kind: "vec2" },
|
|
800
|
-
{ name: "u_baseColorTextureRotation", kind: "float" },
|
|
801
|
-
{ name: "u_baseColorTextureTexCoord", kind: "float" },
|
|
802
|
-
{ name: "u_baseColorTextureWrap", kind: "vec2" },
|
|
803
|
-
{ name: "u_normalTexture", kind: "texture2d" },
|
|
804
|
-
{ name: "u_normalTextureOffset", kind: "vec2" },
|
|
805
|
-
{ name: "u_normalTextureScale", kind: "vec2" },
|
|
806
|
-
{ name: "u_normalTextureRotation", kind: "float" },
|
|
807
|
-
{ name: "u_normalTextureTexCoord", kind: "float" },
|
|
808
|
-
{ name: "u_normalTextureWrap", kind: "vec2" },
|
|
809
|
-
{ name: "u_normalTextureEnabled", kind: "float" },
|
|
810
|
-
{ name: "u_normalScale", kind: "float" },
|
|
811
|
-
{ name: "u_metallicRoughnessTexture", kind: "texture2d" },
|
|
812
|
-
{ name: "u_metallicRoughnessTextureEnabled", kind: "float" },
|
|
813
|
-
{ name: "u_metallicRoughnessTextureOffset", kind: "vec2" },
|
|
814
|
-
{ name: "u_metallicRoughnessTextureScale", kind: "vec2" },
|
|
815
|
-
{ name: "u_metallicRoughnessTextureRotation", kind: "float" },
|
|
816
|
-
{ name: "u_metallicRoughnessTextureTexCoord", kind: "float" },
|
|
817
|
-
{ name: "u_metallicRoughnessTextureWrap", kind: "vec2" },
|
|
818
|
-
{ name: "u_occlusionTexture", kind: "texture2d" },
|
|
819
|
-
{ name: "u_occlusionTextureEnabled", kind: "float" },
|
|
820
|
-
{ name: "u_occlusionTextureOffset", kind: "vec2" },
|
|
821
|
-
{ name: "u_occlusionTextureScale", kind: "vec2" },
|
|
822
|
-
{ name: "u_occlusionTextureRotation", kind: "float" },
|
|
823
|
-
{ name: "u_occlusionTextureTexCoord", kind: "float" },
|
|
824
|
-
{ name: "u_occlusionTextureWrap", kind: "vec2" },
|
|
825
|
-
{ name: "u_occlusionStrength", kind: "float" },
|
|
826
|
-
{ name: "u_emissiveTexture", kind: "texture2d" },
|
|
827
|
-
{ name: "u_emissiveTextureEnabled", kind: "float" },
|
|
828
|
-
{ name: "u_emissiveTextureOffset", kind: "vec2" },
|
|
829
|
-
{ name: "u_emissiveTextureScale", kind: "vec2" },
|
|
830
|
-
{ name: "u_emissiveTextureRotation", kind: "float" },
|
|
831
|
-
{ name: "u_emissiveTextureTexCoord", kind: "float" },
|
|
832
|
-
{ name: "u_emissiveTextureWrap", kind: "vec2" },
|
|
833
|
-
{ name: "u_clearcoatTexture", kind: "texture2d", required: false },
|
|
834
|
-
{ name: "u_clearcoatTextureEnabled", kind: "float", required: false },
|
|
835
|
-
{ name: "u_clearcoatTextureOffset", kind: "vec2", required: false },
|
|
836
|
-
{ name: "u_clearcoatTextureScale", kind: "vec2", required: false },
|
|
837
|
-
{ name: "u_clearcoatTextureRotation", kind: "float", required: false },
|
|
838
|
-
{ name: "u_clearcoatTextureTexCoord", kind: "float", required: false },
|
|
839
|
-
{ name: "u_clearcoatTextureWrap", kind: "vec2", required: false },
|
|
840
|
-
{ name: "u_clearcoatRoughnessTexture", kind: "texture2d", required: false },
|
|
841
|
-
{ name: "u_clearcoatRoughnessTextureEnabled", kind: "float", required: false },
|
|
842
|
-
{ name: "u_clearcoatRoughnessTextureOffset", kind: "vec2", required: false },
|
|
843
|
-
{ name: "u_clearcoatRoughnessTextureScale", kind: "vec2", required: false },
|
|
844
|
-
{ name: "u_clearcoatRoughnessTextureRotation", kind: "float", required: false },
|
|
845
|
-
{ name: "u_clearcoatRoughnessTextureTexCoord", kind: "float", required: false },
|
|
846
|
-
{ name: "u_clearcoatRoughnessTextureWrap", kind: "vec2", required: false },
|
|
847
|
-
{ name: "u_clearcoatNormalTexture", kind: "texture2d", required: false },
|
|
848
|
-
{ name: "u_clearcoatNormalTextureEnabled", kind: "float", required: false },
|
|
849
|
-
{ name: "u_clearcoatNormalTextureOffset", kind: "vec2", required: false },
|
|
850
|
-
{ name: "u_clearcoatNormalTextureScale", kind: "vec2", required: false },
|
|
851
|
-
{ name: "u_clearcoatNormalTextureRotation", kind: "float", required: false },
|
|
852
|
-
{ name: "u_clearcoatNormalTextureTexCoord", kind: "float", required: false },
|
|
853
|
-
{ name: "u_clearcoatNormalTextureWrap", kind: "vec2", required: false },
|
|
854
|
-
{ name: "u_clearcoatNormalScale", kind: "float" },
|
|
855
|
-
{ name: "u_transmissionTexture", kind: "texture2d", required: false },
|
|
856
|
-
{ name: "u_transmissionTextureEnabled", kind: "float", required: false },
|
|
857
|
-
{ name: "u_transmissionTextureOffset", kind: "vec2", required: false },
|
|
858
|
-
{ name: "u_transmissionTextureScale", kind: "vec2", required: false },
|
|
859
|
-
{ name: "u_transmissionTextureRotation", kind: "float", required: false },
|
|
860
|
-
{ name: "u_transmissionTextureTexCoord", kind: "float", required: false },
|
|
861
|
-
{ name: "u_transmissionTextureWrap", kind: "vec2", required: false },
|
|
862
|
-
{ name: "u_diffuseTransmissionTexture", kind: "texture2d", required: false },
|
|
863
|
-
{ name: "u_diffuseTransmissionTextureEnabled", kind: "float", required: false },
|
|
864
|
-
{ name: "u_diffuseTransmissionTextureOffset", kind: "vec2", required: false },
|
|
865
|
-
{ name: "u_diffuseTransmissionTextureScale", kind: "vec2", required: false },
|
|
866
|
-
{ name: "u_diffuseTransmissionTextureRotation", kind: "float", required: false },
|
|
867
|
-
{ name: "u_diffuseTransmissionTextureTexCoord", kind: "float", required: false },
|
|
868
|
-
{ name: "u_diffuseTransmissionTextureWrap", kind: "vec2", required: false },
|
|
869
|
-
{ name: "u_diffuseTransmissionColorTexture", kind: "texture2d", required: false },
|
|
870
|
-
{ name: "u_diffuseTransmissionColorTextureEnabled", kind: "float", required: false },
|
|
871
|
-
{ name: "u_diffuseTransmissionColorTextureOffset", kind: "vec2", required: false },
|
|
872
|
-
{ name: "u_diffuseTransmissionColorTextureScale", kind: "vec2", required: false },
|
|
873
|
-
{ name: "u_diffuseTransmissionColorTextureRotation", kind: "float", required: false },
|
|
874
|
-
{ name: "u_diffuseTransmissionColorTextureTexCoord", kind: "float", required: false },
|
|
875
|
-
{ name: "u_diffuseTransmissionColorTextureWrap", kind: "vec2", required: false },
|
|
876
|
-
{ name: "u_volumeThicknessTexture", kind: "texture2d", required: false },
|
|
877
|
-
{ name: "u_volumeThicknessTextureEnabled", kind: "float", required: false },
|
|
878
|
-
{ name: "u_volumeThicknessTextureOffset", kind: "vec2", required: false },
|
|
879
|
-
{ name: "u_volumeThicknessTextureScale", kind: "vec2", required: false },
|
|
880
|
-
{ name: "u_volumeThicknessTextureRotation", kind: "float", required: false },
|
|
881
|
-
{ name: "u_volumeThicknessTextureTexCoord", kind: "float", required: false },
|
|
882
|
-
{ name: "u_volumeThicknessTextureWrap", kind: "vec2", required: false },
|
|
883
|
-
{ name: "u_specularTexture", kind: "texture2d", required: false },
|
|
884
|
-
{ name: "u_specularTextureEnabled", kind: "float", required: false },
|
|
885
|
-
{ name: "u_specularTextureOffset", kind: "vec2", required: false },
|
|
886
|
-
{ name: "u_specularTextureScale", kind: "vec2", required: false },
|
|
887
|
-
{ name: "u_specularTextureRotation", kind: "float", required: false },
|
|
888
|
-
{ name: "u_specularTextureTexCoord", kind: "float", required: false },
|
|
889
|
-
{ name: "u_specularTextureWrap", kind: "vec2", required: false },
|
|
890
|
-
{ name: "u_specularColorTexture", kind: "texture2d", required: false },
|
|
891
|
-
{ name: "u_specularColorTextureEnabled", kind: "float", required: false },
|
|
892
|
-
{ name: "u_specularColorTextureOffset", kind: "vec2", required: false },
|
|
893
|
-
{ name: "u_specularColorTextureScale", kind: "vec2", required: false },
|
|
894
|
-
{ name: "u_specularColorTextureRotation", kind: "float", required: false },
|
|
895
|
-
{ name: "u_specularColorTextureTexCoord", kind: "float", required: false },
|
|
896
|
-
{ name: "u_specularColorTextureWrap", kind: "vec2", required: false },
|
|
897
|
-
{ name: "u_sheenColorTexture", kind: "texture2d", required: false },
|
|
898
|
-
{ name: "u_sheenColorTextureEnabled", kind: "float", required: false },
|
|
899
|
-
{ name: "u_sheenColorTextureOffset", kind: "vec2", required: false },
|
|
900
|
-
{ name: "u_sheenColorTextureScale", kind: "vec2", required: false },
|
|
901
|
-
{ name: "u_sheenColorTextureRotation", kind: "float", required: false },
|
|
902
|
-
{ name: "u_sheenColorTextureTexCoord", kind: "float", required: false },
|
|
903
|
-
{ name: "u_sheenColorTextureWrap", kind: "vec2", required: false },
|
|
904
|
-
{ name: "u_sheenRoughnessTexture", kind: "texture2d", required: false },
|
|
905
|
-
{ name: "u_sheenRoughnessTextureEnabled", kind: "float", required: false },
|
|
906
|
-
{ name: "u_sheenRoughnessTextureOffset", kind: "vec2", required: false },
|
|
907
|
-
{ name: "u_sheenRoughnessTextureScale", kind: "vec2", required: false },
|
|
908
|
-
{ name: "u_sheenRoughnessTextureRotation", kind: "float", required: false },
|
|
909
|
-
{ name: "u_sheenRoughnessTextureTexCoord", kind: "float", required: false },
|
|
910
|
-
{ name: "u_sheenRoughnessTextureWrap", kind: "vec2", required: false },
|
|
911
|
-
{ name: "u_anisotropyTexture", kind: "texture2d", required: false },
|
|
912
|
-
{ name: "u_anisotropyTextureEnabled", kind: "float", required: false },
|
|
913
|
-
{ name: "u_anisotropyTextureOffset", kind: "vec2", required: false },
|
|
914
|
-
{ name: "u_anisotropyTextureScale", kind: "vec2", required: false },
|
|
915
|
-
{ name: "u_anisotropyTextureRotation", kind: "float", required: false },
|
|
916
|
-
{ name: "u_anisotropyTextureTexCoord", kind: "float", required: false },
|
|
917
|
-
{ name: "u_anisotropyTextureWrap", kind: "vec2", required: false },
|
|
918
|
-
{ name: "u_iridescenceTexture", kind: "texture2d", required: false },
|
|
919
|
-
{ name: "u_iridescenceTextureEnabled", kind: "float", required: false },
|
|
920
|
-
{ name: "u_iridescenceTextureOffset", kind: "vec2", required: false },
|
|
921
|
-
{ name: "u_iridescenceTextureScale", kind: "vec2", required: false },
|
|
922
|
-
{ name: "u_iridescenceTextureRotation", kind: "float", required: false },
|
|
923
|
-
{ name: "u_iridescenceTextureTexCoord", kind: "float", required: false },
|
|
924
|
-
{ name: "u_iridescenceTextureWrap", kind: "vec2", required: false },
|
|
925
|
-
{ name: "u_iridescenceThicknessTexture", kind: "texture2d", required: false },
|
|
926
|
-
{ name: "u_iridescenceThicknessTextureEnabled", kind: "float", required: false },
|
|
927
|
-
{ name: "u_iridescenceThicknessTextureOffset", kind: "vec2", required: false },
|
|
928
|
-
{ name: "u_iridescenceThicknessTextureScale", kind: "vec2", required: false },
|
|
929
|
-
{ name: "u_iridescenceThicknessTextureRotation", kind: "float", required: false },
|
|
930
|
-
{ name: "u_iridescenceThicknessTextureTexCoord", kind: "float", required: false },
|
|
931
|
-
{ name: "u_iridescenceThicknessTextureWrap", kind: "vec2", required: false },
|
|
932
|
-
{ name: "u_modelViewProjection", kind: "mat4" },
|
|
933
|
-
{ name: "u_normalMatrix", kind: "mat4" }
|
|
934
|
-
]
|
|
935
|
-
});
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
function validateNonNegative(value: number, label: string): void {
|
|
940
|
-
if (!Number.isFinite(value) || value < 0) {
|
|
941
|
-
throw new RangeError(`TexturedPBRMaterial ${label} must be finite and non-negative`);
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
function textureTexCoord(
|
|
946
|
-
texCoords: TexturedPBRMaterialOptions["textureTexCoords"],
|
|
947
|
-
slot: TexturedPBRTextureSlot
|
|
948
|
-
): number {
|
|
949
|
-
const value = texCoords?.[slot] ?? 0;
|
|
950
|
-
if (!Number.isInteger(value) || value < 0 || value > 1) {
|
|
951
|
-
throw new RangeError(`TexturedPBRMaterial ${slot} texCoord must be 0 or 1`);
|
|
952
|
-
}
|
|
953
|
-
return value;
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
function usesSecondaryTexCoord(texCoords: TexturedPBRMaterialOptions["textureTexCoords"]): boolean {
|
|
957
|
-
return Object.values(texCoords ?? {}).some((value) => value === 1);
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
function samplerWrapMode(sampler: Sampler | undefined): readonly [number, number] {
|
|
961
|
-
return [
|
|
962
|
-
addressModeCode(sampler?.addressU ?? "clamp-to-edge"),
|
|
963
|
-
addressModeCode(sampler?.addressV ?? "clamp-to-edge")
|
|
964
|
-
];
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
function addressModeCode(mode: Sampler["addressU"]): number {
|
|
968
|
-
if (mode === "repeat") return 1;
|
|
969
|
-
if (mode === "mirror-repeat") return 2;
|
|
970
|
-
return 0;
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
function texturedPbrShaderVariant(options: TexturedPBRMaterialOptions): string | undefined {
|
|
974
|
-
const hasClearcoatTextures = Boolean(options.clearcoatTexture || options.clearcoatRoughnessTexture || options.clearcoatNormalTexture);
|
|
975
|
-
const hasTransmissionVolumeTextures = Boolean(
|
|
976
|
-
options.transmissionTexture ||
|
|
977
|
-
options.diffuseTransmissionTexture ||
|
|
978
|
-
options.diffuseTransmissionColorTexture ||
|
|
979
|
-
options.volumeThicknessTexture
|
|
980
|
-
);
|
|
981
|
-
const hasSpecularTextures = Boolean(options.specularTexture || options.specularColorTexture);
|
|
982
|
-
const hasSheenAnisotropyTextures = Boolean(
|
|
983
|
-
options.sheenColorTexture ||
|
|
984
|
-
options.sheenRoughnessTexture ||
|
|
985
|
-
options.anisotropyTexture
|
|
986
|
-
);
|
|
987
|
-
const hasSpecularSheenAnisotropyTextures = hasSpecularTextures || hasSheenAnisotropyTextures;
|
|
988
|
-
const hasIridescenceTextures = Boolean(options.iridescenceTexture || options.iridescenceThicknessTexture);
|
|
989
|
-
|
|
990
|
-
if (hasClearcoatTextures && hasSpecularTextures && !hasTransmissionVolumeTextures) {
|
|
991
|
-
return DEFAULT_TEXTURED_PBR_CLEARCOAT_SPECULAR_TEXTURES_VARIANT;
|
|
992
|
-
}
|
|
993
|
-
if (hasClearcoatTextures && hasTransmissionVolumeTextures) {
|
|
994
|
-
return DEFAULT_TEXTURED_PBR_CLEARCOAT_TRANSMISSION_VOLUME_TEXTURES_VARIANT;
|
|
995
|
-
}
|
|
996
|
-
if (hasSpecularSheenAnisotropyTextures && hasIridescenceTextures) {
|
|
997
|
-
return DEFAULT_TEXTURED_PBR_SPECULAR_SHEEN_ANISOTROPY_IRIDESCENCE_TEXTURES_VARIANT;
|
|
998
|
-
}
|
|
999
|
-
if (hasClearcoatTextures) {
|
|
1000
|
-
return DEFAULT_TEXTURED_PBR_CLEARCOAT_TEXTURES_VARIANT;
|
|
1001
|
-
}
|
|
1002
|
-
if (hasTransmissionVolumeTextures) {
|
|
1003
|
-
return DEFAULT_TEXTURED_PBR_TRANSMISSION_VOLUME_TEXTURES_VARIANT;
|
|
1004
|
-
}
|
|
1005
|
-
if (hasSpecularSheenAnisotropyTextures) {
|
|
1006
|
-
return DEFAULT_TEXTURED_PBR_SPECULAR_SHEEN_ANISOTROPY_TEXTURES_VARIANT;
|
|
1007
|
-
}
|
|
1008
|
-
if (hasIridescenceTextures) {
|
|
1009
|
-
return DEFAULT_TEXTURED_PBR_IRIDESCENCE_TEXTURES_VARIANT;
|
|
1010
|
-
}
|
|
1011
|
-
return undefined;
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
function validatePositive(value: number, label: string): void {
|
|
1015
|
-
if (!Number.isFinite(value) || value <= 0) {
|
|
1016
|
-
throw new RangeError(`TexturedPBRMaterial ${label} must be finite and positive`);
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
function validateMipCount(value: number, label: string): void {
|
|
1021
|
-
if (!Number.isInteger(value) || value < 1) {
|
|
1022
|
-
throw new RangeError(`TexturedPBRMaterial ${label} must be a positive integer`);
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
function validateProceduralEnvironmentMap(value: TexturedPBRProceduralEnvironmentMapOptions): void {
|
|
1027
|
-
validateColor3(value.skyColor, "proceduralEnvironmentMap.skyColor");
|
|
1028
|
-
validateColor3(value.horizonColor, "proceduralEnvironmentMap.horizonColor");
|
|
1029
|
-
validateColor3(value.groundColor, "proceduralEnvironmentMap.groundColor");
|
|
1030
|
-
validateColor3(value.specularColor, "proceduralEnvironmentMap.specularColor");
|
|
1031
|
-
validateNonNegative(value.intensity, "proceduralEnvironmentMap.intensity");
|
|
1032
|
-
validateNonNegative(value.specularIntensity, "proceduralEnvironmentMap.specularIntensity");
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
function defaultWhiteTexture(label = "default-white"): Texture {
|
|
1036
|
-
return new Texture({ width: 1, height: 1, colorSpace: "srgb", label, data: new Uint8Array([255, 255, 255, 255]) });
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
function defaultLinearWhiteTexture(label = "default-linear-white"): Texture {
|
|
1040
|
-
return new Texture({ width: 1, height: 1, colorSpace: "linear", label, data: new Uint8Array([255, 255, 255, 255]) });
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
function defaultFlatNormalTexture(): Texture {
|
|
1044
|
-
return new Texture({ width: 1, height: 1, label: "default-flat-normal", data: new Uint8Array([128, 128, 255, 255]) });
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
function defaultMetallicRoughnessTexture(): Texture {
|
|
1048
|
-
return new Texture({ width: 1, height: 1, colorSpace: "linear", label: "default-metallic-roughness", data: new Uint8Array([255, 255, 255, 255]) });
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
function validateUnit(value: number, label: string): void {
|
|
1052
|
-
if (!Number.isFinite(value) || value < 0 || value > 1) {
|
|
1053
|
-
throw new RangeError(`TexturedPBRMaterial ${label} must be finite and within [0, 1]`);
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
function validateFinite(value: number, label: string): void {
|
|
1058
|
-
if (!Number.isFinite(value)) {
|
|
1059
|
-
throw new RangeError(`TexturedPBRMaterial ${label} must be finite`);
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
function validateIOR(value: number): void {
|
|
1064
|
-
if (!Number.isFinite(value) || value < 1) {
|
|
1065
|
-
throw new RangeError("TexturedPBRMaterial ior must be finite and at least 1");
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
function validateIridescenceIOR(value: number): void {
|
|
1070
|
-
if (!Number.isFinite(value) || value < 1 || value > 3) {
|
|
1071
|
-
throw new RangeError("TexturedPBRMaterial iridescenceIor must be finite and within [1, 3]");
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
function validateColor4(value: readonly number[], label: string): void {
|
|
1076
|
-
if (value.length !== 4 || value.some((channel) => !Number.isFinite(channel) || channel < 0 || channel > 1)) {
|
|
1077
|
-
throw new RangeError(`TexturedPBRMaterial ${label} must contain four finite values in [0, 1]`);
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
function validateColor3(value: readonly number[], label: string): void {
|
|
1082
|
-
if (value.length !== 3 || value.some((channel) => !Number.isFinite(channel) || channel < 0 || channel > 1)) {
|
|
1083
|
-
throw new RangeError(`TexturedPBRMaterial ${label} must contain three finite values in [0, 1]`);
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
function validateNonNegativeColor3(value: readonly number[], label: string): void {
|
|
1088
|
-
if (value.length !== 3 || value.some((channel) => !Number.isFinite(channel) || channel < 0)) {
|
|
1089
|
-
throw new RangeError(`TexturedPBRMaterial ${label} must contain three finite non-negative values`);
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
function validateFiniteVec3(value: readonly number[], label: string): void {
|
|
1094
|
-
if (value.length !== 3 || value.some((channel) => !Number.isFinite(channel))) {
|
|
1095
|
-
throw new RangeError(`TexturedPBRMaterial ${label} must contain three finite values`);
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
function validatePositiveVec2(value: readonly number[], label: string): void {
|
|
1100
|
-
if (value.length !== 2 || value.some((channel) => !Number.isFinite(channel) || channel <= 0)) {
|
|
1101
|
-
throw new RangeError(`TexturedPBRMaterial ${label} must contain two finite positive values`);
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
function identityMatrix(): Float32Array {
|
|
1106
|
-
return new Float32Array([
|
|
1107
|
-
1, 0, 0, 0,
|
|
1108
|
-
0, 1, 0, 0,
|
|
1109
|
-
0, 0, 1, 0,
|
|
1110
|
-
0, 0, 0, 1
|
|
1111
|
-
]);
|
|
1112
|
-
}
|