@aura3d/rendering 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +38 -4
- package/AGENTS.md +0 -46
- 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 -1668
- 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 -124
- 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 -2631
- 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,393 +0,0 @@
|
|
|
1
|
-
import { Texture, type TextureColorSpace } from "./Texture";
|
|
2
|
-
|
|
3
|
-
export type ProceduralTextureFixtureKind =
|
|
4
|
-
| "metallic-paint"
|
|
5
|
-
| "metallic-roughness-map"
|
|
6
|
-
| "racing-stripes"
|
|
7
|
-
| "racing-number-decal"
|
|
8
|
-
| "carbon-fiber"
|
|
9
|
-
| "tire-tread"
|
|
10
|
-
| "concrete-asphalt"
|
|
11
|
-
| "sci-fi-panel"
|
|
12
|
-
| "wood-plank"
|
|
13
|
-
| "marble"
|
|
14
|
-
| "starfield-nebula"
|
|
15
|
-
| "normal-from-height";
|
|
16
|
-
|
|
17
|
-
export interface ProceduralTextureFixtureOptions {
|
|
18
|
-
readonly width?: number;
|
|
19
|
-
readonly height?: number;
|
|
20
|
-
readonly seed?: number;
|
|
21
|
-
readonly label?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface ProceduralTextureFixture {
|
|
25
|
-
readonly id: ProceduralTextureFixtureKind;
|
|
26
|
-
readonly label: string;
|
|
27
|
-
readonly width: number;
|
|
28
|
-
readonly height: number;
|
|
29
|
-
readonly seed: number;
|
|
30
|
-
readonly semantic: "albedo" | "normal" | "metallic-roughness" | "emissive-background";
|
|
31
|
-
readonly colorSpace: TextureColorSpace;
|
|
32
|
-
readonly data: Uint8Array;
|
|
33
|
-
readonly hash: string;
|
|
34
|
-
readonly knownLimits: readonly string[];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const DEFAULT_SIZE = 96;
|
|
38
|
-
const DEFAULT_SEEDS: Readonly<Record<ProceduralTextureFixtureKind, number>> = {
|
|
39
|
-
"metallic-paint": 0x8a41_1201,
|
|
40
|
-
"metallic-roughness-map": 0x8a41_1211,
|
|
41
|
-
"racing-stripes": 0x8a41_1210,
|
|
42
|
-
"racing-number-decal": 0x8a41_1212,
|
|
43
|
-
"carbon-fiber": 0x8a41_1202,
|
|
44
|
-
"tire-tread": 0x8a41_1203,
|
|
45
|
-
"concrete-asphalt": 0x8a41_1204,
|
|
46
|
-
"sci-fi-panel": 0x8a41_1205,
|
|
47
|
-
"wood-plank": 0x8a41_1206,
|
|
48
|
-
"marble": 0x8a41_1207,
|
|
49
|
-
"starfield-nebula": 0x8a41_1208,
|
|
50
|
-
"normal-from-height": 0x8a41_1209
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const proceduralTextureFixtureKinds: readonly ProceduralTextureFixtureKind[] = [
|
|
54
|
-
"metallic-paint",
|
|
55
|
-
"metallic-roughness-map",
|
|
56
|
-
"racing-stripes",
|
|
57
|
-
"racing-number-decal",
|
|
58
|
-
"carbon-fiber",
|
|
59
|
-
"tire-tread",
|
|
60
|
-
"concrete-asphalt",
|
|
61
|
-
"sci-fi-panel",
|
|
62
|
-
"wood-plank",
|
|
63
|
-
"marble",
|
|
64
|
-
"starfield-nebula",
|
|
65
|
-
"normal-from-height"
|
|
66
|
-
] as const;
|
|
67
|
-
|
|
68
|
-
export function createProceduralTextureFixture(kind: ProceduralTextureFixtureKind, options: ProceduralTextureFixtureOptions = {}): ProceduralTextureFixture {
|
|
69
|
-
const width = options.width ?? DEFAULT_SIZE;
|
|
70
|
-
const height = options.height ?? DEFAULT_SIZE;
|
|
71
|
-
if (!Number.isInteger(width) || width < 8 || !Number.isInteger(height) || height < 8) {
|
|
72
|
-
throw new RangeError("Procedural texture fixtures require integer dimensions >= 8.");
|
|
73
|
-
}
|
|
74
|
-
const seed = options.seed ?? DEFAULT_SEEDS[kind];
|
|
75
|
-
if (!Number.isInteger(seed)) {
|
|
76
|
-
throw new RangeError("Procedural texture fixture seed must be an integer.");
|
|
77
|
-
}
|
|
78
|
-
const data = kind === "normal-from-height" ? normalFromHeightMap(width, height, seed) : new Uint8Array(width * height * 4);
|
|
79
|
-
if (kind !== "normal-from-height") {
|
|
80
|
-
const generator = generatorFor(kind);
|
|
81
|
-
for (let y = 0; y < height; y += 1) {
|
|
82
|
-
for (let x = 0; x < width; x += 1) {
|
|
83
|
-
const index = (y * width + x) * 4;
|
|
84
|
-
const color = generator(x, y, width, height, seed);
|
|
85
|
-
data[index] = color[0];
|
|
86
|
-
data[index + 1] = color[1];
|
|
87
|
-
data[index + 2] = color[2];
|
|
88
|
-
data[index + 3] = color[3];
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
const descriptor = descriptorFor(kind);
|
|
93
|
-
return {
|
|
94
|
-
id: kind,
|
|
95
|
-
label: options.label ?? `external-parity-procedural-${kind}`,
|
|
96
|
-
width,
|
|
97
|
-
height,
|
|
98
|
-
seed,
|
|
99
|
-
semantic: descriptor.semantic,
|
|
100
|
-
colorSpace: descriptor.colorSpace,
|
|
101
|
-
data,
|
|
102
|
-
hash: hashRgba8(data),
|
|
103
|
-
knownLimits: [
|
|
104
|
-
"Deterministic procedural fixture for browser evidence, not a production scanned material.",
|
|
105
|
-
"Generated locally from seeded math; no external texture license or photogrammetry claim is made."
|
|
106
|
-
]
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export function createProceduralTexture(kind: ProceduralTextureFixtureKind, options: ProceduralTextureFixtureOptions = {}): Texture {
|
|
111
|
-
const fixture = createProceduralTextureFixture(kind, options);
|
|
112
|
-
return new Texture({
|
|
113
|
-
width: fixture.width,
|
|
114
|
-
height: fixture.height,
|
|
115
|
-
colorSpace: fixture.colorSpace,
|
|
116
|
-
label: fixture.label,
|
|
117
|
-
data: fixture.data
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export function createProceduralTextureFixtureManifest(options: ProceduralTextureFixtureOptions = {}): readonly Omit<ProceduralTextureFixture, "data">[] {
|
|
122
|
-
return proceduralTextureFixtureKinds.map((kind) => {
|
|
123
|
-
const { data: _data, ...fixture } = createProceduralTextureFixture(kind, options);
|
|
124
|
-
return fixture;
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export function normalFromHeightMap(width: number, height: number, seed = DEFAULT_SEEDS["normal-from-height"]): Uint8Array {
|
|
129
|
-
const heights = new Float32Array(width * height);
|
|
130
|
-
for (let y = 0; y < height; y += 1) {
|
|
131
|
-
for (let x = 0; x < width; x += 1) {
|
|
132
|
-
heights[y * width + x] = layeredNoise(x / width, y / height, seed, 5);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
const data = new Uint8Array(width * height * 4);
|
|
136
|
-
for (let y = 0; y < height; y += 1) {
|
|
137
|
-
for (let x = 0; x < width; x += 1) {
|
|
138
|
-
const left = heights[y * width + ((x + width - 1) % width)] ?? 0;
|
|
139
|
-
const right = heights[y * width + ((x + 1) % width)] ?? 0;
|
|
140
|
-
const down = heights[((y + height - 1) % height) * width + x] ?? 0;
|
|
141
|
-
const up = heights[((y + 1) % height) * width + x] ?? 0;
|
|
142
|
-
const normal = normalize([-((right - left) * 3.5), 1, -((up - down) * 3.5)]);
|
|
143
|
-
const index = (y * width + x) * 4;
|
|
144
|
-
data[index] = byte(normal[0] * 0.5 + 0.5);
|
|
145
|
-
data[index + 1] = byte(normal[1] * 0.5 + 0.5);
|
|
146
|
-
data[index + 2] = byte(normal[2] * 0.5 + 0.5);
|
|
147
|
-
data[index + 3] = 255;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return data;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export function hashRgba8(data: Uint8Array): string {
|
|
154
|
-
let hash = 0x811c9dc5;
|
|
155
|
-
for (const value of data) {
|
|
156
|
-
hash ^= value;
|
|
157
|
-
hash = Math.imul(hash, 0x01000193) >>> 0;
|
|
158
|
-
}
|
|
159
|
-
return hash.toString(16).padStart(8, "0");
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
type Rgba = readonly [number, number, number, number];
|
|
163
|
-
type Generator = (x: number, y: number, width: number, height: number, seed: number) => Rgba;
|
|
164
|
-
|
|
165
|
-
function generatorFor(kind: ProceduralTextureFixtureKind): Generator {
|
|
166
|
-
switch (kind) {
|
|
167
|
-
case "metallic-paint":
|
|
168
|
-
return metallicPaint;
|
|
169
|
-
case "metallic-roughness-map":
|
|
170
|
-
return metallicRoughnessMap;
|
|
171
|
-
case "racing-stripes":
|
|
172
|
-
return racingStripes;
|
|
173
|
-
case "racing-number-decal":
|
|
174
|
-
return racingNumberDecal;
|
|
175
|
-
case "carbon-fiber":
|
|
176
|
-
return carbonFiber;
|
|
177
|
-
case "tire-tread":
|
|
178
|
-
return tireTread;
|
|
179
|
-
case "concrete-asphalt":
|
|
180
|
-
return concreteAsphalt;
|
|
181
|
-
case "sci-fi-panel":
|
|
182
|
-
return sciFiPanel;
|
|
183
|
-
case "wood-plank":
|
|
184
|
-
return woodPlank;
|
|
185
|
-
case "marble":
|
|
186
|
-
return marble;
|
|
187
|
-
case "starfield-nebula":
|
|
188
|
-
return starfieldNebula;
|
|
189
|
-
case "normal-from-height":
|
|
190
|
-
return () => [128, 255, 128, 255];
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function descriptorFor(kind: ProceduralTextureFixtureKind): Pick<ProceduralTextureFixture, "semantic" | "colorSpace"> {
|
|
195
|
-
if (kind === "normal-from-height") return { semantic: "normal", colorSpace: "linear" };
|
|
196
|
-
if (kind === "metallic-roughness-map") return { semantic: "metallic-roughness", colorSpace: "linear" };
|
|
197
|
-
if (kind === "starfield-nebula") return { semantic: "emissive-background", colorSpace: "srgb" };
|
|
198
|
-
return { semantic: "albedo", colorSpace: "srgb" };
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function metallicPaint(x: number, y: number, width: number, height: number, seed: number): Rgba {
|
|
202
|
-
const u = x / width;
|
|
203
|
-
const v = y / height;
|
|
204
|
-
const flake = Math.pow(layeredNoise(u * 15.3, v * 15.3, seed, 4), 8);
|
|
205
|
-
const stripe = Math.sin((u + v * 0.12) * Math.PI * 9) > 0.86 ? 0.16 : 0;
|
|
206
|
-
return [byte(0.64 + flake * 0.34 + stripe), byte(0.06 + flake * 0.18), byte(0.1 + flake * 0.22), 255];
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function metallicRoughnessMap(x: number, y: number, width: number, height: number, seed: number): Rgba {
|
|
210
|
-
const u = x / width;
|
|
211
|
-
const v = y / height;
|
|
212
|
-
const brushed = Math.sin((u * 22 + v * 2.5) * Math.PI) * 0.5 + 0.5;
|
|
213
|
-
const panelEdge = x % 32 < 2 || y % 32 < 2 ? 0.16 : 0;
|
|
214
|
-
const flake = Math.pow(layeredNoise(u * 11.5, v * 11.5, seed, 4), 4);
|
|
215
|
-
const roughness = 0.28 + brushed * 0.22 + panelEdge + flake * 0.12;
|
|
216
|
-
const metallic = 0.52 + flake * 0.28 - panelEdge * 0.2;
|
|
217
|
-
return [255, byte(roughness), byte(metallic), 255];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function racingStripes(x: number, y: number, width: number, height: number, seed: number): Rgba {
|
|
221
|
-
const u = x / width;
|
|
222
|
-
const v = y / height;
|
|
223
|
-
const centerStripe = Math.abs(u - 0.5) < 0.055;
|
|
224
|
-
const sideStripe = Math.abs(u - 0.37) < 0.025 || Math.abs(u - 0.63) < 0.025;
|
|
225
|
-
const diagonalAccent = Math.abs(((u + v * 0.22 + noise2(u * 4, v * 4, seed) * 0.015) % 1) - 0.18) < 0.012;
|
|
226
|
-
if (centerStripe || sideStripe) return [248, 250, 244, 255];
|
|
227
|
-
if (diagonalAccent) return [32, 38, 48, 255];
|
|
228
|
-
return [186, 14, 28, 255];
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function racingNumberDecal(x: number, y: number, width: number, height: number, seed: number): Rgba {
|
|
232
|
-
const u = x / Math.max(1, width - 1);
|
|
233
|
-
const v = y / Math.max(1, height - 1);
|
|
234
|
-
const plate = roundedBox(u, v, 0.1, 0.18, 0.8, 0.64, 0.055);
|
|
235
|
-
if (!plate) return [0, 0, 0, 0];
|
|
236
|
-
const border = roundedBoxBorder(u, v, 0.1, 0.18, 0.8, 0.64, 0.055, 0.045);
|
|
237
|
-
const stripe = Math.abs(v - 0.5) < 0.035 && u > 0.14 && u < 0.86;
|
|
238
|
-
const digit = sevenSegmentDigit(u, v, 0.23, 0.27, 0.2, 0.46, 3) || sevenSegmentDigit(u, v, 0.56, 0.27, 0.2, 0.46, 7);
|
|
239
|
-
const speckle = noise2(u * 18, v * 18, seed) * 0.04;
|
|
240
|
-
if (digit) return [byte(0.02 + speckle), byte(0.025 + speckle), byte(0.035 + speckle), 255];
|
|
241
|
-
if (border || stripe) return [186, 14, 28, 255];
|
|
242
|
-
return [byte(0.9 + speckle), byte(0.91 + speckle), byte(0.86 + speckle), 248];
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
function carbonFiber(x: number, y: number, width: number, height: number, seed: number): Rgba {
|
|
246
|
-
const weaveA = ((Math.floor(x / 5) + Math.floor(y / 5)) % 2) === 0 ? 1 : 0;
|
|
247
|
-
const weaveB = Math.sin((x + y) * 0.72) * 0.5 + 0.5;
|
|
248
|
-
const n = noise2(x / width * 18, y / height * 18, seed);
|
|
249
|
-
const shade = 0.08 + weaveA * 0.12 + weaveB * 0.08 + n * 0.05;
|
|
250
|
-
return [byte(shade * 0.72), byte(shade * 0.78), byte(shade), 255];
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function tireTread(x: number, y: number, width: number, height: number, seed: number): Rgba {
|
|
254
|
-
const center = Math.abs((x / width) - 0.5);
|
|
255
|
-
const grooves = Math.sin((y / height) * Math.PI * 24 + center * 11) > 0.48 ? 0.16 : 0;
|
|
256
|
-
const shoulder = center > 0.34 ? -0.08 : 0;
|
|
257
|
-
const n = noise2(x / width * 24, y / height * 24, seed) * 0.06;
|
|
258
|
-
const shade = 0.12 + grooves + shoulder + n;
|
|
259
|
-
return [byte(shade), byte(shade), byte(shade * 0.96), 255];
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function concreteAsphalt(x: number, y: number, width: number, height: number, seed: number): Rgba {
|
|
263
|
-
const n = layeredNoise(x / width * 7, y / height * 7, seed, 5);
|
|
264
|
-
const speckle = noise2(x * 0.91, y * 0.91, seed ^ 0x55aa) > 0.82 ? 0.18 : 0;
|
|
265
|
-
const shade = 0.28 + n * 0.32 + speckle;
|
|
266
|
-
return [byte(shade * 0.92), byte(shade * 0.94), byte(shade), 255];
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function sciFiPanel(x: number, y: number, width: number, height: number, seed: number): Rgba {
|
|
270
|
-
const u = x / width;
|
|
271
|
-
const v = y / height;
|
|
272
|
-
const grid = x % 24 < 2 || y % 24 < 2 ? 0.18 : 0;
|
|
273
|
-
const inset = (x % 48 > 8 && x % 48 < 40 && y % 48 > 8 && y % 48 < 40) ? 0.08 : -0.02;
|
|
274
|
-
const diode = distance2(u, v, 0.78, 0.28) < 0.0018 ? 0.78 : 0;
|
|
275
|
-
const n = noise2(u * 8, v * 8, seed) * 0.05;
|
|
276
|
-
return [byte(0.1 + grid + inset + n), byte(0.16 + grid + inset + diode + n), byte(0.2 + grid + inset + diode * 0.7 + n), 255];
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
function woodPlank(x: number, y: number, width: number, height: number, seed: number): Rgba {
|
|
280
|
-
const u = x / width;
|
|
281
|
-
const v = y / height;
|
|
282
|
-
const plank = Math.floor(v * 6);
|
|
283
|
-
const grain = Math.sin((u * 22 + layeredNoise(u * 5, v * 3 + plank, seed, 4) * 9) * Math.PI) * 0.5 + 0.5;
|
|
284
|
-
const seam = Math.abs((v * 6) % 1) < 0.035 ? -0.16 : 0;
|
|
285
|
-
return [byte(0.5 + grain * 0.22 + seam), byte(0.28 + grain * 0.14 + seam), byte(0.12 + grain * 0.08 + seam), 255];
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
function marble(x: number, y: number, width: number, height: number, seed: number): Rgba {
|
|
289
|
-
const u = x / width;
|
|
290
|
-
const v = y / height;
|
|
291
|
-
const turbulence = layeredNoise(u * 4.2, v * 4.2, seed, 5);
|
|
292
|
-
const vein = Math.pow(Math.abs(Math.sin((u * 6 + v * 3 + turbulence * 2.4) * Math.PI)), 9);
|
|
293
|
-
return [byte(0.82 - vein * 0.32 + turbulence * 0.1), byte(0.8 - vein * 0.34 + turbulence * 0.08), byte(0.76 - vein * 0.32 + turbulence * 0.12), 255];
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
function starfieldNebula(x: number, y: number, width: number, height: number, seed: number): Rgba {
|
|
297
|
-
const u = x / width;
|
|
298
|
-
const v = y / height;
|
|
299
|
-
const nebula = Math.pow(layeredNoise(u * 2.2 + 8, v * 2.2 - 3, seed, 5), 2.2);
|
|
300
|
-
const star = hashUnit(Math.floor(u * 220), Math.floor(v * 140), seed) > 0.996 ? 1 : 0;
|
|
301
|
-
const dust = hashUnit(Math.floor(u * 90), Math.floor(v * 70), seed ^ 0xa11ce) > 0.985 ? 0.45 : 0;
|
|
302
|
-
return [byte(0.03 + nebula * 0.32 + star + dust), byte(0.04 + nebula * 0.12 + star + dust), byte(0.08 + nebula * 0.46 + star + dust * 0.8), 255];
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function sevenSegmentDigit(u: number, v: number, x: number, y: number, width: number, height: number, digit: 3 | 7): boolean {
|
|
306
|
-
const du = (u - x) / width;
|
|
307
|
-
const dv = (v - y) / height;
|
|
308
|
-
if (du < 0 || du > 1 || dv < 0 || dv > 1) return false;
|
|
309
|
-
const thickness = 0.16;
|
|
310
|
-
const horizontal = du > thickness * 0.65 && du < 1 - thickness * 0.65;
|
|
311
|
-
const verticalTop = dv > thickness * 0.45 && dv < 0.5 - thickness * 0.15;
|
|
312
|
-
const verticalBottom = dv > 0.5 + thickness * 0.15 && dv < 1 - thickness * 0.45;
|
|
313
|
-
const top = horizontal && dv < thickness;
|
|
314
|
-
const middle = horizontal && Math.abs(dv - 0.5) < thickness * 0.5;
|
|
315
|
-
const bottom = horizontal && dv > 1 - thickness;
|
|
316
|
-
const upperRight = du > 1 - thickness && verticalTop;
|
|
317
|
-
const lowerRight = du > 1 - thickness && verticalBottom;
|
|
318
|
-
if (digit === 3) return top || middle || bottom || upperRight || lowerRight;
|
|
319
|
-
const diagonal = Math.abs(du + dv * 0.42 - 0.95) < thickness * 0.3 && dv > 0.12;
|
|
320
|
-
return top || upperRight || lowerRight || diagonal;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function roundedBox(u: number, v: number, x: number, y: number, width: number, height: number, radius: number): boolean {
|
|
324
|
-
if (u < x || u > x + width || v < y || v > y + height) return false;
|
|
325
|
-
const cx = u < x + radius ? x + radius : u > x + width - radius ? x + width - radius : u;
|
|
326
|
-
const cy = v < y + radius ? y + radius : v > y + height - radius ? y + height - radius : v;
|
|
327
|
-
return distance2(u, v, cx, cy) <= radius * radius;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
function roundedBoxBorder(u: number, v: number, x: number, y: number, width: number, height: number, radius: number, thickness: number): boolean {
|
|
331
|
-
return roundedBox(u, v, x, y, width, height, radius) && !roundedBox(u, v, x + thickness, y + thickness, width - thickness * 2, height - thickness * 2, Math.max(0, radius - thickness));
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
function layeredNoise(x: number, y: number, seed: number, octaves: number): number {
|
|
335
|
-
let amplitude = 0.5;
|
|
336
|
-
let frequency = 1;
|
|
337
|
-
let value = 0;
|
|
338
|
-
let total = 0;
|
|
339
|
-
for (let octave = 0; octave < octaves; octave += 1) {
|
|
340
|
-
value += smoothNoise(x * frequency, y * frequency, seed + octave * 1013) * amplitude;
|
|
341
|
-
total += amplitude;
|
|
342
|
-
amplitude *= 0.5;
|
|
343
|
-
frequency *= 2;
|
|
344
|
-
}
|
|
345
|
-
return total > 0 ? value / total : 0;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function smoothNoise(x: number, y: number, seed: number): number {
|
|
349
|
-
const x0 = Math.floor(x);
|
|
350
|
-
const y0 = Math.floor(y);
|
|
351
|
-
const tx = smoothstep(x - x0);
|
|
352
|
-
const ty = smoothstep(y - y0);
|
|
353
|
-
const a = hashUnit(x0, y0, seed);
|
|
354
|
-
const b = hashUnit(x0 + 1, y0, seed);
|
|
355
|
-
const c = hashUnit(x0, y0 + 1, seed);
|
|
356
|
-
const d = hashUnit(x0 + 1, y0 + 1, seed);
|
|
357
|
-
return mix(mix(a, b, tx), mix(c, d, tx), ty);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
function noise2(x: number, y: number, seed: number): number {
|
|
361
|
-
return smoothNoise(x, y, seed);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
function hashUnit(x: number, y: number, seed: number): number {
|
|
365
|
-
let value = (seed ^ Math.imul(x, 0x27d4eb2d) ^ Math.imul(y, 0x165667b1)) >>> 0;
|
|
366
|
-
value ^= value >>> 15;
|
|
367
|
-
value = Math.imul(value, 0x85ebca6b) >>> 0;
|
|
368
|
-
value ^= value >>> 13;
|
|
369
|
-
value = Math.imul(value, 0xc2b2ae35) >>> 0;
|
|
370
|
-
value ^= value >>> 16;
|
|
371
|
-
return value / 0xffffffff;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
function normalize(value: readonly [number, number, number]): readonly [number, number, number] {
|
|
375
|
-
const length = Math.hypot(value[0], value[1], value[2]) || 1;
|
|
376
|
-
return [value[0] / length, value[1] / length, value[2] / length];
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
function smoothstep(value: number): number {
|
|
380
|
-
return value * value * (3 - 2 * value);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
function mix(left: number, right: number, amount: number): number {
|
|
384
|
-
return left + (right - left) * amount;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
function byte(value: number): number {
|
|
388
|
-
return Math.max(0, Math.min(255, Math.round(value * 255)));
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
function distance2(x: number, y: number, cx: number, cy: number): number {
|
|
392
|
-
return (x - cx) ** 2 + (y - cy) ** 2;
|
|
393
|
-
}
|