@meimu/mutracer 0.1.1 → 0.1.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/dist/assets/bvh.worker.js +1 -1
- package/dist/mutracer.umd.js +522 -520
- package/docs/materials.md +27 -7
- package/docs/threejs.md +13 -2
- package/docs/viewer.md +53 -0
- package/lib/oidn.d.ts +1 -1
- package/lib/oidnBundledWeights.cdn.d.ts +2 -2
- package/lib/renderer/MaterialTable.d.ts +1 -0
- package/lib/renderer/MaterialTable.js +2 -1
- package/lib/renderer/MaterialTable.js.map +1 -1
- package/lib/renderer/WGPUBloomPass.js +8 -8
- package/lib/renderer/WGPUJNLMDenoiser.js +2 -2
- package/lib/renderer/WGPURayTraceOutput.js +5 -5
- package/lib/renderer/WGPURayTracePass.js +1 -1
- package/lib/renderer/WGPURayTracePass.js.map +1 -1
- package/lib/renderer/WGPURenderingPipeline.js +4 -4
- package/lib/renderer/WebGLJNLMDenoiser.js +2 -2
- package/lib/renderer/WebGLRayTracePass.js +3 -1
- package/lib/renderer/WebGLRayTracePass.js.map +1 -1
- package/lib/renderer/glsl/chunks/envMap.glsl.js +5 -5
- package/lib/renderer/glsl/chunks/intersect.glsl.js +32 -32
- package/lib/renderer/glsl/chunks/materialBuffer.glsl.js +9 -9
- package/lib/renderer/glsl/chunks/openPbrBsdf.glsl.js +30 -30
- package/lib/renderer/glsl/chunks/rand.glsl.js +2 -2
- package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js +4 -4
- package/lib/renderer/glsl/chunks/sampleLight.glsl.js +3 -3
- package/lib/renderer/glsl/chunks/sampleMaterial.glsl.js +4 -4
- package/lib/renderer/glsl/chunks/sampling.glsl.js +3 -3
- package/lib/renderer/glsl/chunks/sobol.glsl.js +3 -3
- package/lib/renderer/glsl/rayTrace.frag.js +3 -3
- package/lib/renderer/glsl/webglPipeline.frag.js +2 -2
- package/lib/renderer/materialComparison.generated.js +5 -0
- package/lib/renderer/materialComparison.generated.js.map +1 -1
- package/lib/renderer/materialLayout.js +2 -1
- package/lib/renderer/materialLayout.js.map +1 -1
- package/lib/renderer/prepareMeshBVH.d.ts +4 -2
- package/lib/renderer/prepareMeshBVH.js +44 -20
- package/lib/renderer/prepareMeshBVH.js.map +1 -1
- package/lib/renderer/wgsl/chunks/common.wgsl.js +2 -2
- package/lib/renderer/wgsl/chunks/envMap.wgsl.js +14 -14
- package/lib/renderer/wgsl/chunks/intersect.wgsl.js +85 -88
- package/lib/renderer/wgsl/chunks/intersect.wgsl.js.map +1 -1
- package/lib/renderer/wgsl/chunks/openPbrBsdf.wgsl.js +34 -34
- package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.d.ts +1 -1
- package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js +51 -46
- package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js.map +1 -1
- package/lib/renderer/wgsl/chunks/rand.wgsl.js +2 -2
- package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js +3 -3
- package/lib/renderer/wgsl/chunks/sampleLight.wgsl.js +4 -4
- package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.js +4 -4
- package/lib/renderer/wgsl/chunks/sampling.wgsl.js +3 -3
- package/lib/renderer/wgsl/chunks/sobol.wgsl.js +3 -3
- package/lib/renderer/wgsl/compose.frag.wgsl.js +2 -2
- package/lib/renderer/wgsl/customDenoise.wgsl.js +4 -4
- package/lib/renderer/wgsl/offlineAdaptive.compute.js +10 -10
- package/lib/renderer/wgsl/rayTrace.compute.js +7 -7
- package/lib/scene/OpenPBRMaterial.d.ts +4 -2
- package/lib/scene/OpenPBRMaterial.js +4 -2
- package/lib/scene/OpenPBRMaterial.js.map +1 -1
- package/lib/scene/openPbrSchema.d.ts +7 -2
- package/lib/scene/openPbrSchema.js +2 -1
- package/lib/scene/openPbrSchema.js.map +1 -1
- package/lib/util/fromTHREE.d.ts +1 -0
- package/lib/util/fromTHREE.js +24 -6
- package/lib/util/fromTHREE.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +1 -1
|
@@ -27,8 +27,8 @@ _padding: f32,
|
|
|
27
27
|
const LUMINANCE = vec3f(0.2126, 0.7152, 0.0722);
|
|
28
28
|
|
|
29
29
|
@compute @workgroup_size(64)
|
|
30
|
-
fn main(@builtin(global_invocation_id)
|
|
31
|
-
let tile =
|
|
30
|
+
fn main(@builtin(global_invocation_id) ud: vec3u) {
|
|
31
|
+
let tile = ud.x;
|
|
32
32
|
let tileCount = params.columns * params.rows;
|
|
33
33
|
if (tile >= tileCount) {
|
|
34
34
|
return;
|
|
@@ -36,16 +36,16 @@ return;
|
|
|
36
36
|
|
|
37
37
|
let tileX = tile % params.columns;
|
|
38
38
|
let tileY = tile / params.columns;
|
|
39
|
-
let
|
|
40
|
-
let
|
|
41
|
-
let
|
|
42
|
-
let
|
|
39
|
+
let ui = tileX * params.tileSize;
|
|
40
|
+
let uj = tileY * params.tileSize;
|
|
41
|
+
let vY = min(ui + params.tileSize, params.width);
|
|
42
|
+
let vZ = min(uj + params.tileSize, params.height);
|
|
43
43
|
var mL = 0.0;
|
|
44
44
|
var iY = 0.0;
|
|
45
45
|
var count = 0u;
|
|
46
46
|
|
|
47
|
-
for (var y =
|
|
48
|
-
for (var x =
|
|
47
|
+
for (var y = uj; y < vZ; y++) {
|
|
48
|
+
for (var x = ui; x < vY; x++) {
|
|
49
49
|
let fM = y * params.width + x;
|
|
50
50
|
let offset = fM * 4u;
|
|
51
51
|
let samples = pilotMoments[offset + 3u];
|
|
@@ -94,8 +94,8 @@ tileMeans[tile] = mean;
|
|
|
94
94
|
tileVariances[tile] = iY;
|
|
95
95
|
tileTargets[tile] = targetSamples;
|
|
96
96
|
|
|
97
|
-
for (var y =
|
|
98
|
-
for (var x =
|
|
97
|
+
for (var y = uj; y < vZ; y++) {
|
|
98
|
+
for (var x = ui; x < vY; x++) {
|
|
99
99
|
textureStore(
|
|
100
100
|
targetTexture,
|
|
101
101
|
vec2i(i32(x), i32(y)),
|
|
@@ -54,7 +54,7 @@ return u32(max(rtUniform.directLightCandidates, 1));
|
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
fn po(
|
|
57
|
+
fn po(wB: u32) -> f32 {
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
|
|
@@ -62,7 +62,7 @@ fn po(wy: u32) -> f32 {
|
|
|
62
62
|
if (SAMPLING_PATTERN == 2) { _ = rand(); }
|
|
63
63
|
let jU = bc.x + bc.y * u32(rtUniform.outputSize.x);
|
|
64
64
|
let key = aq(aq(jU, bd), rtUniform.sequenceSeed);
|
|
65
|
-
let dimension = aq(cE,
|
|
65
|
+
let dimension = aq(cE, wB) ^ 0xa511e9b3u;
|
|
66
66
|
return f32(eg(key ^ dimension) >> 8u) * (1.0 / 16777216.0);
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -103,11 +103,11 @@ ${shadowCatcherAccumulationWGSL}
|
|
|
103
103
|
|
|
104
104
|
fn hH(
|
|
105
105
|
gZ: u32,
|
|
106
|
-
|
|
106
|
+
vk: vec3f,
|
|
107
107
|
normal: vec3f
|
|
108
108
|
) {
|
|
109
109
|
if (rtUniform.varianceMoments != 0) {
|
|
110
|
-
let value = dot(
|
|
110
|
+
let value = dot(vk, luminance);
|
|
111
111
|
outNormal[gZ] += vec4f(value * value, 0.0, 0.0, 1.0);
|
|
112
112
|
}
|
|
113
113
|
else {
|
|
@@ -656,11 +656,11 @@ return back;
|
|
|
656
656
|
}
|
|
657
657
|
|
|
658
658
|
var te = *si;
|
|
659
|
-
var
|
|
660
|
-
|
|
659
|
+
var uw = *ma;
|
|
660
|
+
uw.alpha = 1.0;
|
|
661
661
|
var iQ = *outAux;
|
|
662
662
|
let qL = bw(
|
|
663
|
-
uv, &te, ray, &
|
|
663
|
+
uv, &te, ray, &uw, &iQ
|
|
664
664
|
);
|
|
665
665
|
(*outAux).albedo = mix(gg.albedo, iQ.albedo, coverage);
|
|
666
666
|
let fR = mix(gg.normal, iQ.normal, coverage);
|
|
@@ -207,9 +207,11 @@ export default class OpenPBRMaterial {
|
|
|
207
207
|
displacementUvProjection: UVProjection;
|
|
208
208
|
/** UV scale used with `displacementUvProjection`. Default `1`. */
|
|
209
209
|
displacementUvProjectionScale: number;
|
|
210
|
-
/** Height multiplier in mesh-local
|
|
210
|
+
/** Height multiplier in mesh-local units; 0 removes height variation. Default `0.1`. */
|
|
211
211
|
displacementScale: number;
|
|
212
|
-
/**
|
|
212
|
+
/** Offset added after scaling the height map, along the normal in mesh-local units; requires a displacement map. Default `0`. */
|
|
213
|
+
displacementBias: number;
|
|
214
|
+
/** Ray-marching step in mesh-local units; 0 automatically uses abs(displacementScale) / 32. Default `0`. */
|
|
213
215
|
displacementStepSize: number;
|
|
214
216
|
}
|
|
215
217
|
export declare const materialAlphaModeConstants: {
|
|
@@ -214,9 +214,11 @@ export default class OpenPBRMaterial {
|
|
|
214
214
|
displacementUvProjection = materialDefault('displacementUvProjection');
|
|
215
215
|
/** UV scale used with `displacementUvProjection`. Default `1`. */
|
|
216
216
|
displacementUvProjectionScale = materialDefault('displacementUvProjectionScale');
|
|
217
|
-
/** Height multiplier in mesh-local
|
|
217
|
+
/** Height multiplier in mesh-local units; 0 removes height variation. Default `0.1`. */
|
|
218
218
|
displacementScale = materialDefault('displacementScale');
|
|
219
|
-
/**
|
|
219
|
+
/** Offset added after scaling the height map, along the normal in mesh-local units; requires a displacement map. Default `0`. */
|
|
220
|
+
displacementBias = materialDefault('displacementBias');
|
|
221
|
+
/** Ray-marching step in mesh-local units; 0 automatically uses abs(displacementScale) / 32. Default `0`. */
|
|
220
222
|
displacementStepSize = materialDefault('displacementStepSize');
|
|
221
223
|
}
|
|
222
224
|
export const materialAlphaModeConstants = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenPBRMaterial.js","sourceRoot":"","sources":["../../src/scene/OpenPBRMaterial.ts"],"names":[],"mappings":"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AC","sourcesContent":["import type { Vec2 } from '../types.js';\nimport { ColorRGB } from '../types.js';\nimport type Texture from './Texture.js';\nimport type { ThinFilmMapChannel } from './thinFilmParameters.js';\nimport { materialDefault, applyMaterialParams } from './openPbrSchema.js';\n\nexport type UVProjection = 'none' | 'triplanar' | 'spherical' | 'cylindrical';\nexport type MaterialAlphaMode = 'auto' | 'opaque' | 'mask' | 'blend';\n\nexport type { MaterialTextureName } from './materialTextureNames.js';\n\n/**\n * OpenPBR 1.1 surface material.\n *\n * Property names are camelCase OpenPBR inputs plus documented compatibility names\n * (https://academysoftwarefoundation.github.io/OpenPBR/). Colors are linear\n * RGB. Length-valued inputs (`transmissionDepth`, `subsurfaceRadius`) use\n * scene units; `thinFilmThickness` is in micrometres as in OpenPBR.\n *\n * ```ts\n * const gold = new OpenPBRMaterial({\n * baseColor: [1.0, 0.78, 0.34], baseMetalness: 1, specularRoughness: 0.2\n * });\n * ```\n *\n * Edit parameters in place; the next `engine.update()` detects the changes.\n */\nexport default class OpenPBRMaterial {\n /** Creates a material. Omitted properties use their documented defaults. */\n constructor(params: OpenPBRMaterialParams = {}) {\n applyMaterialParams(this, params);\n }\n\n // Base\n /** Multiplier of diffuse reflection and metallic normal-incidence color; does not scale dielectric specular, transmission or subsurface. Default `1`. */\n baseWeight: number = materialDefault('baseWeight');\n /** Diffuse/metal color. Default `[0.8, 0.8, 0.8]`. */\n baseColor: ColorRGB = materialDefault('baseColor');\n /** Oren-Nayar style roughness of the diffuse lobe. Default `0`. */\n baseDiffuseRoughness: number = materialDefault('baseDiffuseRoughness');\n /** `0` dielectric, `1` metal. Default `0`. */\n baseMetalness: number = materialDefault('baseMetalness');\n\n // Specular\n /** Dielectric specular strength (via IOR) and overall metallic Fresnel multiplier. Default `1`. */\n specularWeight: number = materialDefault('specularWeight');\n /** Dielectric specular tint and metallic F82 near-grazing tint. Default `[1, 1, 1]`. */\n specularColor: ColorRGB = materialDefault('specularColor');\n /** Microfacet roughness, `0` mirror to `1` rough; retains source perceptual roughness in `gltf` anisotropy mode. Default `0.3`. */\n specularRoughness: number = materialDefault('specularRoughness');\n /** Index of refraction. Default `1.5`. */\n specularIor: number = materialDefault('specularIor');\n /**\n * GGX anisotropy strength, 0 to 1 (requires tangents); native OpenPBR or source glTF strength according to specularAnisotropyModel. Default `0`.\n * @deprecated Use specularRoughnessAnisotropy.\n */\n specularAnisotropy: number = materialDefault('specularAnisotropy');\n\n // Transmission\n /** `1` makes the dielectric base fully transmissive (glass). Default `0`. */\n transmissionWeight: number = materialDefault('transmissionWeight');\n /** Transmission tint, or the medium color at `transmissionDepth`. Default `[1, 1, 1]`. */\n transmissionColor: ColorRGB = materialDefault('transmissionColor');\n /** Depth at which `transmissionColor` is reached; `0` tints at the surface. Default `0`. */\n transmissionDepth: number = materialDefault('transmissionDepth');\n /** Volume scattering color of the transmissive medium. Default `[0, 0, 0]`. */\n transmissionScatter: ColorRGB = materialDefault('transmissionScatter');\n /** Henyey-Greenstein anisotropy of the medium, -1 to 1. Default `0`. */\n transmissionScatterAnisotropy: number = materialDefault('transmissionScatterAnisotropy');\n /** Dispersion strength; `> 0` enables spectral rendering. Default `0`. */\n transmissionDispersionScale: number = materialDefault('transmissionDispersionScale');\n /** Abbe number controlling dispersion. Default `20`. */\n transmissionDispersionAbbeNumber: number = materialDefault('transmissionDispersionAbbeNumber');\n\n // Subsurface\n /** Subsurface scattering weight. Default `0`. */\n subsurfaceWeight: number = materialDefault('subsurfaceWeight');\n /** Subsurface color. Default `[0.8, 0.8, 0.8]`. */\n subsurfaceColor: ColorRGB = materialDefault('subsurfaceColor');\n /** Mean free path in scene units. Default `1`. */\n subsurfaceRadius: number = materialDefault('subsurfaceRadius');\n /** Per-channel multiplier of `subsurfaceRadius`. Default `[1, 0.5, 0.25]`. */\n subsurfaceRadiusScale: ColorRGB = materialDefault('subsurfaceRadiusScale');\n /**\n * Scattering anisotropy, -1 to 1. Default `0`.\n * @deprecated Use subsurfaceScatterAnisotropy.\n */\n subsurfaceAnisotropy: number = materialDefault('subsurfaceAnisotropy');\n\n // Fuzz (sheen)\n /** Fuzz (sheen) layer weight. Default `0`. */\n fuzzWeight: number = materialDefault('fuzzWeight');\n /** Fuzz reflection color; substrate attenuation uses white fuzz albedo. Default `[1, 1, 1]`. */\n fuzzColor: ColorRGB = materialDefault('fuzzColor');\n /** Fuzz roughness; imported from Three.js `sheenRoughness`. Default `0.5`. */\n fuzzRoughness: number = materialDefault('fuzzRoughness');\n\n // Coat\n /** Clear coat weight. Default `0`. */\n coatWeight: number = materialDefault('coatWeight');\n /** Squared coat transmittance at normal incidence; colors the base and emission, not coat reflection. Default `[1, 1, 1]`. */\n coatColor: ColorRGB = materialDefault('coatColor');\n /** Coat roughness. Default `0`. */\n coatRoughness: number = materialDefault('coatRoughness');\n /**\n * OpenPBR GGX coat anisotropy, 0 to 1; uses the base geometry tangent. Default `0`.\n * @deprecated Use coatRoughnessAnisotropy.\n */\n coatAnisotropy: number = materialDefault('coatAnisotropy');\n /** Coat index of refraction. Default `1.6`. */\n coatIor: number = materialDefault('coatIor');\n /** Internal-reflection darkening: 0 compensates darkening, 1 is physical; absorption remains at 0. Default `1`. */\n coatDarkening: number = materialDefault('coatDarkening');\n\n // Thin film\n /** Thin-film interference weight (iridescence). Default `0`. */\n thinFilmWeight: number = materialDefault('thinFilmWeight');\n /** Film thickness in micrometres; maximum endpoint when thinFilmMap is present. Default `0.5`. */\n thinFilmThickness: number = materialDefault('thinFilmThickness');\n /** Film index of refraction. Default `1.4`. */\n thinFilmIor: number = materialDefault('thinFilmIor');\n\n /** Thickness at a thinFilmMap sample of zero, in micrometres; ignored without a map. May exceed thinFilmThickness. Default `0`. */\n thinFilmThicknessMinimum: number = materialDefault('thinFilmThicknessMinimum');\n /** Linear channel sampled by thinFilmMap. Default `r`. */\n thinFilmMapChannel: ThinFilmMapChannel = materialDefault('thinFilmMapChannel');\n\n // Emission and geometry\n /** Emission color. Default `[1, 1, 1]`. */\n emissionColor: ColorRGB = materialDefault('emissionColor');\n /** Emitted radiance scale; `0` disables emission. Default `0`. */\n emissionLuminance: number = materialDefault('emissionLuminance');\n /**\n * Coverage, `1` opaque. See `alphaMode`. Default `1`.\n * @deprecated Use geometryOpacity.\n */\n opacity: number = materialDefault('opacity');\n /**\n * Treat the surface as an infinitely thin shell (leaves, paper). Default `false`.\n * @deprecated Use geometryThinWalled.\n */\n thinWalled: boolean = materialDefault('thinWalled');\n /** Disables geometric back-face culling for this material. Default `false`. */\n doubleSided: boolean = materialDefault('doubleSided');\n\n // Textures\n /** Base color texture, multiplied with `baseColor` using Texture color encoding. Default `undefined`. */\n map?: Texture;\n /** Standalone opacity texture sampled from its green channel, matching Three.js. Default `undefined`. */\n alphaMap?: Texture;\n /**\n * Coverage for surface and shadow rays: `opaque` ignores alpha inputs,\n * `mask` uses binary alpha testing, `blend` retains fractional coverage.\n * `auto` derives the mode from the alpha inputs. Default `auto`.\n */\n alphaMode: MaterialAlphaMode = materialDefault('alphaMode');\n /** Alpha-test threshold for `mask` mode; equality is fully covered. Default `0`. */\n alphaCutoff: number = materialDefault('alphaCutoff');\n /** Emission texture multiplied with `emissionColor`. Default `undefined`. */\n emissiveMap?: Texture;\n /** Tangent-space normal map. */\n normalMap?: Texture;\n /** Normal map strength per axis. Default `[1, 1]`. */\n normalScale: Vec2 = materialDefault('normalScale');\n /** glTF-compatible B=metalness, G=specular roughness texture. Default `undefined`. */\n metallicRoughnessMap?: Texture;\n /** Standalone roughness texture sampled from its green channel. Default `undefined`. */\n roughnessMap?: Texture;\n /** Standalone metalness texture sampled from its blue channel. Default `undefined`. */\n metalnessMap?: Texture;\n /** Multiplies transmission weight using the texture's red channel. Default `undefined`. */\n transmissionMap?: Texture;\n /** Linear thickness-range texture; R and zero minimum preserve multiplication semantics. Default `undefined`. */\n thinFilmMap?: Texture;\n\n /** Multiplies coatWeight by the linear red channel. Default `undefined`. */\n coatWeightMap?: Texture;\n /** Multiplies coatRoughness by the linear green channel. Default `undefined`. */\n coatRoughnessMap?: Texture;\n /** Multiplies fuzzColor by RGB channels using Texture color encoding. Default `undefined`. */\n fuzzColorMap?: Texture;\n /** Multiplies fuzzRoughness by the linear alpha channel. Default `undefined`. */\n fuzzRoughnessMap?: Texture;\n /** Multiplies specularWeight by the linear alpha channel. Default `undefined`. */\n specularWeightMap?: Texture;\n /** Multiplies specularColor by RGB channels using Texture color encoding. Default `undefined`. */\n specularColorMap?: Texture;\n\n\n /** Source convention for base specular anisotropy. `gltf` converts textured roughness and strength before coat roughening; `openpbr` uses native parameters. Default `openpbr`. */\n specularAnisotropyModel: 'openpbr' | 'gltf' = 'openpbr';\n /** Linear RG tangent direction and B strength multiplier for the base specular layer. Default `undefined`. */\n anisotropyMap?: Texture;\n /** Independent tangent-space coat normal in linear RGB. Without a map, coat shares the existing shading normal. Default `undefined`. */\n coatNormalMap?: Texture;\n /** XY strength of coatNormalMap; independent of normalScale. Default `[1, 1]`. */\n coatNormalScale: Vec2 = materialDefault('coatNormalScale');\n /** Base direction rotation in radians, counter-clockwise in tangent/bitangent space after RG decoding. Default `0`. */\n specularAnisotropyRotation: number = 0;\n /** Coat direction rotation in radians relative to the geometry tangent. Default `0`. */\n coatAnisotropyRotation: number = 0;\n\n /** GGX roughness anisotropy in [0, 1]; native OpenPBR or source glTF strength according to specularAnisotropyModel. Requires tangents. Default `0`. */\n get specularRoughnessAnisotropy(): number { return this.specularAnisotropy; }\n set specularRoughnessAnisotropy(value: number) { this.specularAnisotropy = value; }\n\n /** OpenPBR coat GGX roughness anisotropy in [0, 1]. Default `0`. */\n get coatRoughnessAnisotropy(): number { return this.coatAnisotropy; }\n set coatRoughnessAnisotropy(value: number) { this.coatAnisotropy = value; }\n\n /** Subsurface scattering anisotropy in [-1, 1]. Default `0`. */\n get subsurfaceScatterAnisotropy(): number { return this.subsurfaceAnisotropy; }\n set subsurfaceScatterAnisotropy(value: number) { this.subsurfaceAnisotropy = value; }\n\n /** Surface coverage; alphaMode controls testing and blending. Default `1`. */\n get geometryOpacity(): number { return this.opacity; }\n set geometryOpacity(value: number) { this.opacity = value; }\n\n /** Treat the surface as an infinitely thin shell. Default `false`. */\n get geometryThinWalled(): boolean { return this.thinWalled; }\n set geometryThinWalled(value: boolean) { this.thinWalled = value; }\n\n // Renderer extensions\n /**\n * Invisible ground that only receives shadows, composited over the\n * background. Default `false`.\n */\n shadowCatcher: boolean = materialDefault('shadowCatcher');\n /** Displays emission without scattering or illuminating other surfaces. Default `false`. */\n unlit: boolean = materialDefault('unlit');\n /** Radius of rounded-edge shading (shader bevel) in scene units. `0` disables it. Default `0`. */\n bevelSize: number = materialDefault('bevelSize');\n /** How map alpha is used: ignored, opacity or transmission. Default `opaque`. */\n mapAlphaUsage: 'opaque' | 'alpha' | 'transmission' = materialDefault('mapAlphaUsage');\n /** Procedural UV projection for textures without (good) UVs. Default `none`. */\n uvProjection: UVProjection = materialDefault('uvProjection');\n /** UV scale used with `uvProjection`. Default `[1, 1]`. */\n uvProjectionScale: Vec2 = materialDefault('uvProjectionScale');\n\n // Displacement\n /** Height texture (red channel) for displacement. Default `undefined`. */\n displacementMap?: Texture;\n /** Procedural UV projection for the displacement map. Default `none`. */\n displacementUvProjection: UVProjection = materialDefault('displacementUvProjection');\n /** UV scale used with `displacementUvProjection`. Default `1`. */\n displacementUvProjectionScale: number = materialDefault('displacementUvProjectionScale');\n /** Height multiplier in mesh-local coordinate units. Default `0.1`. */\n displacementScale: number = materialDefault('displacementScale');\n /** Ray-marching step for projective displacement. Default `0.01`. */\n displacementStepSize: number = materialDefault('displacementStepSize');\n\n}\nexport const materialAlphaModeConstants = {\n opaque: 0,\n mask: 1,\n blend: 2\n} as const;\n\nexport type ResolvedMaterialAlphaMode = Exclude<MaterialAlphaMode, 'auto'>;\n\nexport function resolveMaterialAlphaMode(\n material: OpenPBRMaterial\n): ResolvedMaterialAlphaMode {\n if (material.alphaMode !== 'auto') return material.alphaMode;\n if (material.alphaCutoff > 0) return 'mask';\n if (\n material.opacity < 1 ||\n material.mapAlphaUsage === \"alpha\" ||\n material.alphaMap\n ) {\n return 'blend';\n }\n return 'opaque';\n}\n\nexport { materialKeys, materialTextureKeys, materialGeometryKeys, materialParamKeys, getMaterialHashKey, resetMaterialTextureId } from './openPbrSchema.js';\n\n/** Optional material properties; defaults are documented on OpenPBRMaterial. */\nexport type OpenPBRMaterialParams = Partial<OpenPBRMaterial>;\n"]}
|
|
1
|
+
{"version":3,"file":"OpenPBRMaterial.js","sourceRoot":"","sources":["../../src/scene/OpenPBRMaterial.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAO1E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,4EAA4E;IAC5E,YAAY,SAAgC,EAAE;QAC5C,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,OAAO;IACP,yJAAyJ;IACzJ,UAAU,GAAW,eAAe,CAAC,YAAY,CAAC,CAAC;IACnD,sDAAsD;IACtD,SAAS,GAAa,eAAe,CAAC,WAAW,CAAC,CAAC;IACnD,mEAAmE;IACnE,oBAAoB,GAAW,eAAe,CAAC,sBAAsB,CAAC,CAAC;IACvE,8CAA8C;IAC9C,aAAa,GAAW,eAAe,CAAC,eAAe,CAAC,CAAC;IAEzD,WAAW;IACX,mGAAmG;IACnG,cAAc,GAAW,eAAe,CAAC,gBAAgB,CAAC,CAAC;IAC3D,wFAAwF;IACxF,aAAa,GAAa,eAAe,CAAC,eAAe,CAAC,CAAC;IAC3D,mIAAmI;IACnI,iBAAiB,GAAW,eAAe,CAAC,mBAAmB,CAAC,CAAC;IACjE,0CAA0C;IAC1C,WAAW,GAAW,eAAe,CAAC,aAAa,CAAC,CAAC;IACrD;;;OAGG;IACH,kBAAkB,GAAW,eAAe,CAAC,oBAAoB,CAAC,CAAC;IAEnE,eAAe;IACf,6EAA6E;IAC7E,kBAAkB,GAAW,eAAe,CAAC,oBA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,CAAC,SAAS,CAAC;IAC7D,IAAI,QAAQ,CAAC,WAAW,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC;IAC5C,IACE,QAAQ,CAAC,OAAO,GAAG,CAAC;QACpB,QAAQ,CAAC,aAAa,KAAK,OAAO;QAClC,QAAQ,CAAC,QAAQ,EACjB,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["import type { Vec2 } from '../types.js';\nimport { ColorRGB } from '../types.js';\nimport type Texture from './Texture.js';\nimport type { ThinFilmMapChannel } from './thinFilmParameters.js';\nimport { materialDefault, applyMaterialParams } from './openPbrSchema.js';\n\nexport type UVProjection = 'none' | 'triplanar' | 'spherical' | 'cylindrical';\nexport type MaterialAlphaMode = 'auto' | 'opaque' | 'mask' | 'blend';\n\nexport type { MaterialTextureName } from './materialTextureNames.js';\n\n/**\n * OpenPBR 1.1 surface material.\n *\n * Property names are camelCase OpenPBR inputs plus documented compatibility names\n * (https://academysoftwarefoundation.github.io/OpenPBR/). Colors are linear\n * RGB. Length-valued inputs (`transmissionDepth`, `subsurfaceRadius`) use\n * scene units; `thinFilmThickness` is in micrometres as in OpenPBR.\n *\n * ```ts\n * const gold = new OpenPBRMaterial({\n * baseColor: [1.0, 0.78, 0.34], baseMetalness: 1, specularRoughness: 0.2\n * });\n * ```\n *\n * Edit parameters in place; the next `engine.update()` detects the changes.\n */\nexport default class OpenPBRMaterial {\n /** Creates a material. Omitted properties use their documented defaults. */\n constructor(params: OpenPBRMaterialParams = {}) {\n applyMaterialParams(this, params);\n }\n\n // Base\n /** Multiplier of diffuse reflection and metallic normal-incidence color; does not scale dielectric specular, transmission or subsurface. Default `1`. */\n baseWeight: number = materialDefault('baseWeight');\n /** Diffuse/metal color. Default `[0.8, 0.8, 0.8]`. */\n baseColor: ColorRGB = materialDefault('baseColor');\n /** Oren-Nayar style roughness of the diffuse lobe. Default `0`. */\n baseDiffuseRoughness: number = materialDefault('baseDiffuseRoughness');\n /** `0` dielectric, `1` metal. Default `0`. */\n baseMetalness: number = materialDefault('baseMetalness');\n\n // Specular\n /** Dielectric specular strength (via IOR) and overall metallic Fresnel multiplier. Default `1`. */\n specularWeight: number = materialDefault('specularWeight');\n /** Dielectric specular tint and metallic F82 near-grazing tint. Default `[1, 1, 1]`. */\n specularColor: ColorRGB = materialDefault('specularColor');\n /** Microfacet roughness, `0` mirror to `1` rough; retains source perceptual roughness in `gltf` anisotropy mode. Default `0.3`. */\n specularRoughness: number = materialDefault('specularRoughness');\n /** Index of refraction. Default `1.5`. */\n specularIor: number = materialDefault('specularIor');\n /**\n * GGX anisotropy strength, 0 to 1 (requires tangents); native OpenPBR or source glTF strength according to specularAnisotropyModel. Default `0`.\n * @deprecated Use specularRoughnessAnisotropy.\n */\n specularAnisotropy: number = materialDefault('specularAnisotropy');\n\n // Transmission\n /** `1` makes the dielectric base fully transmissive (glass). Default `0`. */\n transmissionWeight: number = materialDefault('transmissionWeight');\n /** Transmission tint, or the medium color at `transmissionDepth`. Default `[1, 1, 1]`. */\n transmissionColor: ColorRGB = materialDefault('transmissionColor');\n /** Depth at which `transmissionColor` is reached; `0` tints at the surface. Default `0`. */\n transmissionDepth: number = materialDefault('transmissionDepth');\n /** Volume scattering color of the transmissive medium. Default `[0, 0, 0]`. */\n transmissionScatter: ColorRGB = materialDefault('transmissionScatter');\n /** Henyey-Greenstein anisotropy of the medium, -1 to 1. Default `0`. */\n transmissionScatterAnisotropy: number = materialDefault('transmissionScatterAnisotropy');\n /** Dispersion strength; `> 0` enables spectral rendering. Default `0`. */\n transmissionDispersionScale: number = materialDefault('transmissionDispersionScale');\n /** Abbe number controlling dispersion. Default `20`. */\n transmissionDispersionAbbeNumber: number = materialDefault('transmissionDispersionAbbeNumber');\n\n // Subsurface\n /** Subsurface scattering weight. Default `0`. */\n subsurfaceWeight: number = materialDefault('subsurfaceWeight');\n /** Subsurface color. Default `[0.8, 0.8, 0.8]`. */\n subsurfaceColor: ColorRGB = materialDefault('subsurfaceColor');\n /** Mean free path in scene units. Default `1`. */\n subsurfaceRadius: number = materialDefault('subsurfaceRadius');\n /** Per-channel multiplier of `subsurfaceRadius`. Default `[1, 0.5, 0.25]`. */\n subsurfaceRadiusScale: ColorRGB = materialDefault('subsurfaceRadiusScale');\n /**\n * Scattering anisotropy, -1 to 1. Default `0`.\n * @deprecated Use subsurfaceScatterAnisotropy.\n */\n subsurfaceAnisotropy: number = materialDefault('subsurfaceAnisotropy');\n\n // Fuzz (sheen)\n /** Fuzz (sheen) layer weight. Default `0`. */\n fuzzWeight: number = materialDefault('fuzzWeight');\n /** Fuzz reflection color; substrate attenuation uses white fuzz albedo. Default `[1, 1, 1]`. */\n fuzzColor: ColorRGB = materialDefault('fuzzColor');\n /** Fuzz roughness; imported from Three.js `sheenRoughness`. Default `0.5`. */\n fuzzRoughness: number = materialDefault('fuzzRoughness');\n\n // Coat\n /** Clear coat weight. Default `0`. */\n coatWeight: number = materialDefault('coatWeight');\n /** Squared coat transmittance at normal incidence; colors the base and emission, not coat reflection. Default `[1, 1, 1]`. */\n coatColor: ColorRGB = materialDefault('coatColor');\n /** Coat roughness. Default `0`. */\n coatRoughness: number = materialDefault('coatRoughness');\n /**\n * OpenPBR GGX coat anisotropy, 0 to 1; uses the base geometry tangent. Default `0`.\n * @deprecated Use coatRoughnessAnisotropy.\n */\n coatAnisotropy: number = materialDefault('coatAnisotropy');\n /** Coat index of refraction. Default `1.6`. */\n coatIor: number = materialDefault('coatIor');\n /** Internal-reflection darkening: 0 compensates darkening, 1 is physical; absorption remains at 0. Default `1`. */\n coatDarkening: number = materialDefault('coatDarkening');\n\n // Thin film\n /** Thin-film interference weight (iridescence). Default `0`. */\n thinFilmWeight: number = materialDefault('thinFilmWeight');\n /** Film thickness in micrometres; maximum endpoint when thinFilmMap is present. Default `0.5`. */\n thinFilmThickness: number = materialDefault('thinFilmThickness');\n /** Film index of refraction. Default `1.4`. */\n thinFilmIor: number = materialDefault('thinFilmIor');\n\n /** Thickness at a thinFilmMap sample of zero, in micrometres; ignored without a map. May exceed thinFilmThickness. Default `0`. */\n thinFilmThicknessMinimum: number = materialDefault('thinFilmThicknessMinimum');\n /** Linear channel sampled by thinFilmMap. Default `r`. */\n thinFilmMapChannel: ThinFilmMapChannel = materialDefault('thinFilmMapChannel');\n\n // Emission and geometry\n /** Emission color. Default `[1, 1, 1]`. */\n emissionColor: ColorRGB = materialDefault('emissionColor');\n /** Emitted radiance scale; `0` disables emission. Default `0`. */\n emissionLuminance: number = materialDefault('emissionLuminance');\n /**\n * Coverage, `1` opaque. See `alphaMode`. Default `1`.\n * @deprecated Use geometryOpacity.\n */\n opacity: number = materialDefault('opacity');\n /**\n * Treat the surface as an infinitely thin shell (leaves, paper). Default `false`.\n * @deprecated Use geometryThinWalled.\n */\n thinWalled: boolean = materialDefault('thinWalled');\n /** Disables geometric back-face culling for this material. Default `false`. */\n doubleSided: boolean = materialDefault('doubleSided');\n\n // Textures\n /** Base color texture, multiplied with `baseColor` using Texture color encoding. Default `undefined`. */\n map?: Texture;\n /** Standalone opacity texture sampled from its green channel, matching Three.js. Default `undefined`. */\n alphaMap?: Texture;\n /**\n * Coverage for surface and shadow rays: `opaque` ignores alpha inputs,\n * `mask` uses binary alpha testing, `blend` retains fractional coverage.\n * `auto` derives the mode from the alpha inputs. Default `auto`.\n */\n alphaMode: MaterialAlphaMode = materialDefault('alphaMode');\n /** Alpha-test threshold for `mask` mode; equality is fully covered. Default `0`. */\n alphaCutoff: number = materialDefault('alphaCutoff');\n /** Emission texture multiplied with `emissionColor`. Default `undefined`. */\n emissiveMap?: Texture;\n /** Tangent-space normal map. */\n normalMap?: Texture;\n /** Normal map strength per axis. Default `[1, 1]`. */\n normalScale: Vec2 = materialDefault('normalScale');\n /** glTF-compatible B=metalness, G=specular roughness texture. Default `undefined`. */\n metallicRoughnessMap?: Texture;\n /** Standalone roughness texture sampled from its green channel. Default `undefined`. */\n roughnessMap?: Texture;\n /** Standalone metalness texture sampled from its blue channel. Default `undefined`. */\n metalnessMap?: Texture;\n /** Multiplies transmission weight using the texture's red channel. Default `undefined`. */\n transmissionMap?: Texture;\n /** Linear thickness-range texture; R and zero minimum preserve multiplication semantics. Default `undefined`. */\n thinFilmMap?: Texture;\n\n /** Multiplies coatWeight by the linear red channel. Default `undefined`. */\n coatWeightMap?: Texture;\n /** Multiplies coatRoughness by the linear green channel. Default `undefined`. */\n coatRoughnessMap?: Texture;\n /** Multiplies fuzzColor by RGB channels using Texture color encoding. Default `undefined`. */\n fuzzColorMap?: Texture;\n /** Multiplies fuzzRoughness by the linear alpha channel. Default `undefined`. */\n fuzzRoughnessMap?: Texture;\n /** Multiplies specularWeight by the linear alpha channel. Default `undefined`. */\n specularWeightMap?: Texture;\n /** Multiplies specularColor by RGB channels using Texture color encoding. Default `undefined`. */\n specularColorMap?: Texture;\n\n\n /** Source convention for base specular anisotropy. `gltf` converts textured roughness and strength before coat roughening; `openpbr` uses native parameters. Default `openpbr`. */\n specularAnisotropyModel: 'openpbr' | 'gltf' = 'openpbr';\n /** Linear RG tangent direction and B strength multiplier for the base specular layer. Default `undefined`. */\n anisotropyMap?: Texture;\n /** Independent tangent-space coat normal in linear RGB. Without a map, coat shares the existing shading normal. Default `undefined`. */\n coatNormalMap?: Texture;\n /** XY strength of coatNormalMap; independent of normalScale. Default `[1, 1]`. */\n coatNormalScale: Vec2 = materialDefault('coatNormalScale');\n /** Base direction rotation in radians, counter-clockwise in tangent/bitangent space after RG decoding. Default `0`. */\n specularAnisotropyRotation: number = 0;\n /** Coat direction rotation in radians relative to the geometry tangent. Default `0`. */\n coatAnisotropyRotation: number = 0;\n\n /** GGX roughness anisotropy in [0, 1]; native OpenPBR or source glTF strength according to specularAnisotropyModel. Requires tangents. Default `0`. */\n get specularRoughnessAnisotropy(): number { return this.specularAnisotropy; }\n set specularRoughnessAnisotropy(value: number) { this.specularAnisotropy = value; }\n\n /** OpenPBR coat GGX roughness anisotropy in [0, 1]. Default `0`. */\n get coatRoughnessAnisotropy(): number { return this.coatAnisotropy; }\n set coatRoughnessAnisotropy(value: number) { this.coatAnisotropy = value; }\n\n /** Subsurface scattering anisotropy in [-1, 1]. Default `0`. */\n get subsurfaceScatterAnisotropy(): number { return this.subsurfaceAnisotropy; }\n set subsurfaceScatterAnisotropy(value: number) { this.subsurfaceAnisotropy = value; }\n\n /** Surface coverage; alphaMode controls testing and blending. Default `1`. */\n get geometryOpacity(): number { return this.opacity; }\n set geometryOpacity(value: number) { this.opacity = value; }\n\n /** Treat the surface as an infinitely thin shell. Default `false`. */\n get geometryThinWalled(): boolean { return this.thinWalled; }\n set geometryThinWalled(value: boolean) { this.thinWalled = value; }\n\n // Renderer extensions\n /**\n * Invisible ground that only receives shadows, composited over the\n * background. Default `false`.\n */\n shadowCatcher: boolean = materialDefault('shadowCatcher');\n /** Displays emission without scattering or illuminating other surfaces. Default `false`. */\n unlit: boolean = materialDefault('unlit');\n /** Radius of rounded-edge shading (shader bevel) in scene units. `0` disables it. Default `0`. */\n bevelSize: number = materialDefault('bevelSize');\n /** How map alpha is used: ignored, opacity or transmission. Default `opaque`. */\n mapAlphaUsage: 'opaque' | 'alpha' | 'transmission' = materialDefault('mapAlphaUsage');\n /** Procedural UV projection for textures without (good) UVs. Default `none`. */\n uvProjection: UVProjection = materialDefault('uvProjection');\n /** UV scale used with `uvProjection`. Default `[1, 1]`. */\n uvProjectionScale: Vec2 = materialDefault('uvProjectionScale');\n\n // Displacement\n /** Height texture (red channel) for displacement. Default `undefined`. */\n displacementMap?: Texture;\n /** Procedural UV projection for the displacement map. Default `none`. */\n displacementUvProjection: UVProjection = materialDefault('displacementUvProjection');\n /** UV scale used with `displacementUvProjection`. Default `1`. */\n displacementUvProjectionScale: number = materialDefault('displacementUvProjectionScale');\n /** Height multiplier in mesh-local units; 0 removes height variation. Default `0.1`. */\n displacementScale: number = materialDefault('displacementScale');\n /** Offset added after scaling the height map, along the normal in mesh-local units; requires a displacement map. Default `0`. */\n displacementBias: number = materialDefault('displacementBias');\n /** Ray-marching step in mesh-local units; 0 automatically uses abs(displacementScale) / 32. Default `0`. */\n displacementStepSize: number = materialDefault('displacementStepSize');\n\n}\nexport const materialAlphaModeConstants = {\n opaque: 0,\n mask: 1,\n blend: 2\n} as const;\n\nexport type ResolvedMaterialAlphaMode = Exclude<MaterialAlphaMode, 'auto'>;\n\nexport function resolveMaterialAlphaMode(\n material: OpenPBRMaterial\n): ResolvedMaterialAlphaMode {\n if (material.alphaMode !== 'auto') return material.alphaMode;\n if (material.alphaCutoff > 0) return 'mask';\n if (\n material.opacity < 1 ||\n material.mapAlphaUsage === \"alpha\" ||\n material.alphaMap\n ) {\n return 'blend';\n }\n return 'opaque';\n}\n\nexport { materialKeys, materialTextureKeys, materialGeometryKeys, materialParamKeys, getMaterialHashKey, resetMaterialTextureId } from './openPbrSchema.js';\n\n/** Optional material properties; defaults are documented on OpenPBRMaterial. */\nexport type OpenPBRMaterialParams = Partial<OpenPBRMaterial>;\n"]}
|
|
@@ -311,7 +311,7 @@ export declare const openPbrSchema: readonly [{
|
|
|
311
311
|
}, {
|
|
312
312
|
readonly key: "displacementStepSize";
|
|
313
313
|
readonly type: "float";
|
|
314
|
-
readonly default: 0
|
|
314
|
+
readonly default: 0;
|
|
315
315
|
readonly category: "geometry";
|
|
316
316
|
}, {
|
|
317
317
|
readonly key: "thinFilmThicknessMinimum";
|
|
@@ -383,6 +383,11 @@ export declare const openPbrSchema: readonly [{
|
|
|
383
383
|
readonly type: "vec2";
|
|
384
384
|
readonly default: [1, 1];
|
|
385
385
|
readonly category: "param";
|
|
386
|
+
}, {
|
|
387
|
+
readonly key: "displacementBias";
|
|
388
|
+
readonly type: "float";
|
|
389
|
+
readonly default: 0;
|
|
390
|
+
readonly category: "geometry";
|
|
386
391
|
}];
|
|
387
392
|
type Keys<T extends readonly {
|
|
388
393
|
key: PropertyKey;
|
|
@@ -391,7 +396,7 @@ type Keys<T extends readonly {
|
|
|
391
396
|
};
|
|
392
397
|
export declare const materialKeys: Keys<typeof openPbrSchema>;
|
|
393
398
|
export declare const materialTextureKeys: readonly ["map", "alphaMap", "emissiveMap", "normalMap", "metallicRoughnessMap", "roughnessMap", "metalnessMap", "transmissionMap", "thinFilmMap", "displacementMap", "coatWeightMap", "coatRoughnessMap", "fuzzColorMap", "fuzzRoughnessMap", "specularWeightMap", "specularColorMap", "anisotropyMap", "coatNormalMap"];
|
|
394
|
-
export declare const materialGeometryKeys: readonly ["displacementUvProjection", "displacementUvProjectionScale", "displacementScale", "displacementStepSize"];
|
|
399
|
+
export declare const materialGeometryKeys: readonly ["displacementUvProjection", "displacementUvProjectionScale", "displacementScale", "displacementStepSize", "displacementBias"];
|
|
395
400
|
export declare const materialParamKeys: readonly ["baseWeight", "baseColor", "baseDiffuseRoughness", "baseMetalness", "specularWeight", "specularColor", "specularRoughness", "specularIor", "specularAnisotropy", "transmissionWeight", "transmissionColor", "transmissionDepth", "transmissionScatter", "transmissionScatterAnisotropy", "transmissionDispersionScale", "transmissionDispersionAbbeNumber", "subsurfaceWeight", "subsurfaceColor", "subsurfaceRadius", "subsurfaceRadiusScale", "subsurfaceAnisotropy", "fuzzWeight", "fuzzColor", "fuzzRoughness", "coatWeight", "coatColor", "coatRoughness", "coatAnisotropy", "coatIor", "coatDarkening", "thinFilmWeight", "thinFilmThickness", "thinFilmIor", "emissionColor", "emissionLuminance", "opacity", "thinWalled", "doubleSided", "alphaMode", "alphaCutoff", "normalScale", "shadowCatcher", "unlit", "bevelSize", "mapAlphaUsage", "uvProjection", "uvProjectionScale", "thinFilmThicknessMinimum", "thinFilmMapChannel", "specularAnisotropyRotation", "coatAnisotropyRotation", "specularAnisotropyModel", "coatNormalScale"];
|
|
396
401
|
export declare function materialDefault<K extends MaterialKey>(key: K): OpenPBRMaterial[K];
|
|
397
402
|
export declare function applyMaterialParams(material: OpenPBRMaterial, input: OpenPBRMaterialParams): void;
|
|
@@ -85,7 +85,7 @@ export const openPbrSchema = [
|
|
|
85
85
|
{ key: 'displacementUvProjectionScale', type: 'float', default: 1, category: 'geometry' },
|
|
86
86
|
{ key: 'displacementMap', type: 'texture', default: undefined, category: 'texture' },
|
|
87
87
|
{ key: 'displacementScale', type: 'float', default: 0.1, category: 'geometry' },
|
|
88
|
-
{ key: 'displacementStepSize', type: 'float', default: 0
|
|
88
|
+
{ key: 'displacementStepSize', type: 'float', default: 0, category: 'geometry' },
|
|
89
89
|
{ key: 'thinFilmThicknessMinimum', type: 'float', default: 0, category: 'param' },
|
|
90
90
|
{ key: 'thinFilmMapChannel', type: 'enum', default: 'r', category: 'param' },
|
|
91
91
|
{ key: 'coatWeightMap', type: 'texture', default: undefined, category: 'texture' },
|
|
@@ -100,6 +100,7 @@ export const openPbrSchema = [
|
|
|
100
100
|
{ key: 'specularAnisotropyModel', type: 'enum', default: 'openpbr', category: 'param' },
|
|
101
101
|
{ key: 'coatNormalMap', type: 'texture', default: undefined, category: 'texture' },
|
|
102
102
|
{ key: 'coatNormalScale', type: 'vec2', default: [1, 1], category: 'param' },
|
|
103
|
+
{ key: 'displacementBias', type: 'float', default: 0, category: 'geometry' },
|
|
103
104
|
];
|
|
104
105
|
const textureNamesMatch = true;
|
|
105
106
|
void textureNamesMatch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openPbrSchema.js","sourceRoot":"","sources":["../../src/scene/openPbrSchema.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,2BAA2B,EAAE,oBAAoB;IACjD,uBAAuB,EAAE,gBAAgB;IACzC,2BAA2B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AAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,EAAC,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC;AACD,IAAI,SAAS,GAAG,CAAC,CAAC;AAClB,MAAM,cAAc,GAAG,IAAI,OAAO,EAAmB,CAAC;AACtD,MAAM,UAAU,sBAAsB,KAAK,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC;AAC3D,MAAM,UAAU,kBAAkB,CAAC,QAAyB;IAC1D,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,EAAC,GAAG,EAAC,EAAE,EAAE;QACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,KAAK,IAAI,IAAI;YAAE,OAAO,GAAG,CAAC;QAC9B,IAAI,KAAK,YAAY,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YACvE,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,KAAK,CAAE,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAC1D,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC,IAAI,CAAC,KAA0B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5G,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC","sourcesContent":["import type { default as OpenPBRMaterial, OpenPBRMaterialParams } from './OpenPBRMaterial.js';\nimport Texture from './Texture.js';\nimport type { MaterialTextureName } from './materialTextureNames.js';\nimport { specularAnisotropyModelIndex } from './anisotropyParameters.js';\nimport { thinFilmMapChannelIndex } from './thinFilmParameters.js';\n\nexport const materialAliases = {\n specularRoughnessAnisotropy: 'specularAnisotropy',\n coatRoughnessAnisotropy: 'coatAnisotropy',\n subsurfaceScatterAnisotropy: 'subsurfaceAnisotropy',\n geometryOpacity: 'opacity',\n geometryThinWalled: 'thinWalled'\n} as const;\ntype MaterialKey = Exclude<keyof OpenPBRMaterial, keyof typeof materialAliases>;\n// Constructor and Three.js metadata share conflict handling before either mutates storage.\nexport function normalizeMaterialParams(params: OpenPBRMaterialParams | Record<string, unknown>): Record<string, unknown> {\n const normalized: Record<string, unknown> = {...params};\n for (const alias of Object.keys(materialAliases) as (keyof typeof materialAliases)[]) {\n const old = materialAliases[alias];\n if (params[alias] === undefined) continue;\n if (params[old] !== undefined && params[old] !== params[alias]) {\n throw new Error(`Conflicting OpenPBR material parameters: ${alias} and ${old}`);\n }\n Object.assign(normalized, {[old]: params[alias]});\n delete normalized[alias];\n }\n return normalized;\n}\ntype Field = {[K in MaterialKey]: {key: K; type: 'float' | 'color' | 'bool' | 'enum' | 'vec2' | 'texture'; default: OpenPBRMaterial[K]; category: 'param' | 'texture' | 'geometry'}}[MaterialKey];\n// Order is part of the existing deduplication hash contract.\nexport const openPbrSchema = [\n {key: 'baseWeight', type: 'float', default: 1, category: 'param'},\n {key: 'baseColor', type: 'color', default: [0.8, 0.8, 0.8], category: 'param'},\n {key: 'baseDiffuseRoughness', type: 'float', default: 0, category: 'param'},\n {key: 'baseMetalness', type: 'float', default: 0, category: 'param'},\n {key: 'specularWeight', type: 'float', default: 1, category: 'param'},\n {key: 'specularColor', type: 'color', default: [1, 1, 1], category: 'param'},\n {key: 'specularRoughness', type: 'float', default: 0.3, category: 'param'},\n {key: 'specularIor', type: 'float', default: 1.5, category: 'param'},\n {key: 'specularAnisotropy', type: 'float', default: 0, category: 'param'},\n {key: 'transmissionWeight', type: 'float', default: 0, category: 'param'},\n {key: 'transmissionColor', type: 'color', default: [1, 1, 1], category: 'param'},\n {key: 'transmissionDepth', type: 'float', default: 0, category: 'param'},\n {key: 'transmissionScatter', type: 'color', default: [0, 0, 0], category: 'param'},\n {key: 'transmissionScatterAnisotropy', type: 'float', default: 0, category: 'param'},\n {key: 'transmissionDispersionScale', type: 'float', default: 0, category: 'param'},\n {key: 'transmissionDispersionAbbeNumber', type: 'float', default: 20, category: 'param'},\n {key: 'subsurfaceWeight', type: 'float', default: 0, category: 'param'},\n {key: 'subsurfaceColor', type: 'color', default: [0.8, 0.8, 0.8], category: 'param'},\n {key: 'subsurfaceRadius', type: 'float', default: 1, category: 'param'},\n {key: 'subsurfaceRadiusScale', type: 'color', default: [1, 0.5, 0.25], category: 'param'},\n {key: 'subsurfaceAnisotropy', type: 'float', default: 0, category: 'param'},\n {key: 'fuzzWeight', type: 'float', default: 0, category: 'param'},\n {key: 'fuzzColor', type: 'color', default: [1, 1, 1], category: 'param'},\n {key: 'fuzzRoughness', type: 'float', default: 0.5, category: 'param'},\n {key: 'coatWeight', type: 'float', default: 0, category: 'param'},\n {key: 'coatColor', type: 'color', default: [1, 1, 1], category: 'param'},\n {key: 'coatRoughness', type: 'float', default: 0, category: 'param'},\n {key: 'coatAnisotropy', type: 'float', default: 0, category: 'param'},\n {key: 'coatIor', type: 'float', default: 1.6, category: 'param'},\n {key: 'coatDarkening', type: 'float', default: 1, category: 'param'},\n {key: 'thinFilmWeight', type: 'float', default: 0, category: 'param'},\n {key: 'thinFilmThickness', type: 'float', default: 0.5, category: 'param'},\n {key: 'thinFilmIor', type: 'float', default: 1.4, category: 'param'},\n {key: 'emissionColor', type: 'color', default: [1, 1, 1], category: 'param'},\n {key: 'emissionLuminance', type: 'float', default: 0, category: 'param'},\n {key: 'opacity', type: 'float', default: 1, category: 'param'},\n {key: 'thinWalled', type: 'bool', default: false, category: 'param'},\n {key: 'doubleSided', type: 'bool', default: false, category: 'param'},\n {key: 'map', type: 'texture', default: undefined, category: 'texture'},\n {key: 'alphaMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'alphaMode', type: 'enum', default: 'auto', category: 'param'},\n {key: 'alphaCutoff', type: 'float', default: 0, category: 'param'},\n {key: 'emissiveMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'normalMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'normalScale', type: 'vec2', default: [1, 1], category: 'param'},\n {key: 'metallicRoughnessMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'roughnessMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'metalnessMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'transmissionMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'thinFilmMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'shadowCatcher', type: 'bool', default: false, category: 'param'},\n {key: 'unlit', type: 'bool', default: false, category: 'param'},\n {key: 'bevelSize', type: 'float', default: 0, category: 'param'},\n {key: 'mapAlphaUsage', type: 'enum', default: 'opaque', category: 'param'},\n {key: 'uvProjection', type: 'enum', default: 'none', category: 'param'},\n {key: 'uvProjectionScale', type: 'vec2', default: [1, 1], category: 'param'},\n {key: 'displacementUvProjection', type: 'enum', default: 'none', category: 'geometry'},\n {key: 'displacementUvProjectionScale', type: 'float', default: 1, category: 'geometry'},\n {key: 'displacementMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'displacementScale', type: 'float', default: 0.1, category: 'geometry'},\n {key: 'displacementStepSize', type: 'float', default: 0.01, category: 'geometry'},\n {key: 'thinFilmThicknessMinimum', type: 'float', default: 0, category: 'param'},\n {key: 'thinFilmMapChannel', type: 'enum', default: 'r', category: 'param'},\n {key: 'coatWeightMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'coatRoughnessMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'fuzzColorMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'fuzzRoughnessMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'specularWeightMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'specularColorMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'anisotropyMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'specularAnisotropyRotation', type: 'float', default: 0, category: 'param'},\n {key: 'coatAnisotropyRotation', type: 'float', default: 0, category: 'param'},\n {key: 'specularAnisotropyModel', type: 'enum', default: 'openpbr', category: 'param'},\n {key: 'coatNormalMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'coatNormalScale', type: 'vec2', default: [1, 1], category: 'param'},\n] as const satisfies readonly Field[];\ntype SchemaTextureName = Extract<typeof openPbrSchema[number], {type: 'texture'}>['key'];\nconst textureNamesMatch: [Exclude<MaterialTextureName, SchemaTextureName> | Exclude<SchemaTextureName, MaterialTextureName>] extends [never] ? true : never = true;\nvoid textureNamesMatch;\ntype Keys<T extends readonly {key: PropertyKey}[]> = {readonly [I in keyof T]: T[I]['key']};\ntype CategoryKeys<T extends readonly Field[], C extends Field['category'], R extends readonly MaterialKey[] = []> =\n T extends readonly [infer H extends Field, ...infer Rest extends readonly Field[]]\n ? CategoryKeys<Rest, C, H['category'] extends C ? readonly [...R, H['key']] : R> : R;\nexport const materialKeys = openPbrSchema.map(field => field.key) as unknown as Keys<typeof openPbrSchema>;\nfunction categoryKeys<C extends Field['category']>(category: C) {\n return openPbrSchema.filter(field => field.category === category).map(field => field.key) as unknown as CategoryKeys<typeof openPbrSchema, C>;\n}\nexport const materialTextureKeys = categoryKeys('texture');\nexport const materialGeometryKeys = categoryKeys('geometry');\nexport const materialParamKeys = categoryKeys('param');\nconst defaults = new Map<MaterialKey, unknown>(openPbrSchema.map(field => [field.key, field.default]));\nexport function materialDefault<K extends MaterialKey>(key: K): OpenPBRMaterial[K] {\n const value = defaults.get(key);\n return (Array.isArray(value) ? value.slice() : value) as OpenPBRMaterial[K];\n}\nexport function applyMaterialParams(material: OpenPBRMaterial, input: OpenPBRMaterialParams) {\n const params = normalizeMaterialParams(input);\n if (params.thinFilmMapChannel !== undefined) thinFilmMapChannelIndex(params.thinFilmMapChannel);\n if (params.specularAnisotropyModel !== undefined) specularAnisotropyModelIndex(params.specularAnisotropyModel);\n for (const {key} of openPbrSchema) {\n if (params[key] !== undefined) Object.assign(material, {[key]: params[key]});\n }\n}\nlet textureId = 1;\nconst textureWeakMap = new WeakMap<Texture, number>();\nexport function resetMaterialTextureId() { textureId = 1; }\nexport function getMaterialHashKey(material: OpenPBRMaterial) {\n return openPbrSchema.map(({key}) => {\n const value = material[key];\n if (value == null) return '$';\n if (value instanceof Texture) {\n if (!textureWeakMap.has(value)) textureWeakMap.set(value, textureId++);\n return `${textureWeakMap.get(value)!}@${value.version}`;\n }\n if (typeof value === 'string') return value;\n if (typeof value === 'object' && 'length' in value) return Array.from(value as ArrayLike<number>).join('_');\n return value;\n }).join('_');\n}\n"]}
|
|
1
|
+
{"version":3,"file":"openPbrSchema.js","sourceRoot":"","sources":["../../src/scene/openPbrSchema.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,2BAA2B,EAAE,oBAAoB;IACjD,uBAAuB,EAAE,gBAAgB;IACzC,2BAA2B,EAAE,sBAAsB;IACnD,eAAe,EAAE,SAAS;IAC1B,kBAAkB,EAAE,YAAY;CACxB,CAAC;AAEX,2FAA2F;AAC3F,MAAM,UAAU,uBAAuB,CAAC,MAAuD;IAC7F,MAAM,UAAU,GAA4B,EAAC,GAAG,MAAM,EAAC,CAAC;IACxD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAqC,EAAE,CAAC;QACrF,MAAM,GAAG,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,SAAS;YAAE,SAAS;QAC1C,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,MAAM,C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AAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,KAAK,IAAI,IAAI;YAAE,OAAO,GAAG,CAAC;QAC9B,IAAI,KAAK,YAAY,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YACvE,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,KAAK,CAAE,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAC1D,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC,IAAI,CAAC,KAA0B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5G,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC","sourcesContent":["import type { default as OpenPBRMaterial, OpenPBRMaterialParams } from './OpenPBRMaterial.js';\nimport Texture from './Texture.js';\nimport type { MaterialTextureName } from './materialTextureNames.js';\nimport { specularAnisotropyModelIndex } from './anisotropyParameters.js';\nimport { thinFilmMapChannelIndex } from './thinFilmParameters.js';\n\nexport const materialAliases = {\n specularRoughnessAnisotropy: 'specularAnisotropy',\n coatRoughnessAnisotropy: 'coatAnisotropy',\n subsurfaceScatterAnisotropy: 'subsurfaceAnisotropy',\n geometryOpacity: 'opacity',\n geometryThinWalled: 'thinWalled'\n} as const;\ntype MaterialKey = Exclude<keyof OpenPBRMaterial, keyof typeof materialAliases>;\n// Constructor and Three.js metadata share conflict handling before either mutates storage.\nexport function normalizeMaterialParams(params: OpenPBRMaterialParams | Record<string, unknown>): Record<string, unknown> {\n const normalized: Record<string, unknown> = {...params};\n for (const alias of Object.keys(materialAliases) as (keyof typeof materialAliases)[]) {\n const old = materialAliases[alias];\n if (params[alias] === undefined) continue;\n if (params[old] !== undefined && params[old] !== params[alias]) {\n throw new Error(`Conflicting OpenPBR material parameters: ${alias} and ${old}`);\n }\n Object.assign(normalized, {[old]: params[alias]});\n delete normalized[alias];\n }\n return normalized;\n}\ntype Field = {[K in MaterialKey]: {key: K; type: 'float' | 'color' | 'bool' | 'enum' | 'vec2' | 'texture'; default: OpenPBRMaterial[K]; category: 'param' | 'texture' | 'geometry'}}[MaterialKey];\n// Order is part of the existing deduplication hash contract.\nexport const openPbrSchema = [\n {key: 'baseWeight', type: 'float', default: 1, category: 'param'},\n {key: 'baseColor', type: 'color', default: [0.8, 0.8, 0.8], category: 'param'},\n {key: 'baseDiffuseRoughness', type: 'float', default: 0, category: 'param'},\n {key: 'baseMetalness', type: 'float', default: 0, category: 'param'},\n {key: 'specularWeight', type: 'float', default: 1, category: 'param'},\n {key: 'specularColor', type: 'color', default: [1, 1, 1], category: 'param'},\n {key: 'specularRoughness', type: 'float', default: 0.3, category: 'param'},\n {key: 'specularIor', type: 'float', default: 1.5, category: 'param'},\n {key: 'specularAnisotropy', type: 'float', default: 0, category: 'param'},\n {key: 'transmissionWeight', type: 'float', default: 0, category: 'param'},\n {key: 'transmissionColor', type: 'color', default: [1, 1, 1], category: 'param'},\n {key: 'transmissionDepth', type: 'float', default: 0, category: 'param'},\n {key: 'transmissionScatter', type: 'color', default: [0, 0, 0], category: 'param'},\n {key: 'transmissionScatterAnisotropy', type: 'float', default: 0, category: 'param'},\n {key: 'transmissionDispersionScale', type: 'float', default: 0, category: 'param'},\n {key: 'transmissionDispersionAbbeNumber', type: 'float', default: 20, category: 'param'},\n {key: 'subsurfaceWeight', type: 'float', default: 0, category: 'param'},\n {key: 'subsurfaceColor', type: 'color', default: [0.8, 0.8, 0.8], category: 'param'},\n {key: 'subsurfaceRadius', type: 'float', default: 1, category: 'param'},\n {key: 'subsurfaceRadiusScale', type: 'color', default: [1, 0.5, 0.25], category: 'param'},\n {key: 'subsurfaceAnisotropy', type: 'float', default: 0, category: 'param'},\n {key: 'fuzzWeight', type: 'float', default: 0, category: 'param'},\n {key: 'fuzzColor', type: 'color', default: [1, 1, 1], category: 'param'},\n {key: 'fuzzRoughness', type: 'float', default: 0.5, category: 'param'},\n {key: 'coatWeight', type: 'float', default: 0, category: 'param'},\n {key: 'coatColor', type: 'color', default: [1, 1, 1], category: 'param'},\n {key: 'coatRoughness', type: 'float', default: 0, category: 'param'},\n {key: 'coatAnisotropy', type: 'float', default: 0, category: 'param'},\n {key: 'coatIor', type: 'float', default: 1.6, category: 'param'},\n {key: 'coatDarkening', type: 'float', default: 1, category: 'param'},\n {key: 'thinFilmWeight', type: 'float', default: 0, category: 'param'},\n {key: 'thinFilmThickness', type: 'float', default: 0.5, category: 'param'},\n {key: 'thinFilmIor', type: 'float', default: 1.4, category: 'param'},\n {key: 'emissionColor', type: 'color', default: [1, 1, 1], category: 'param'},\n {key: 'emissionLuminance', type: 'float', default: 0, category: 'param'},\n {key: 'opacity', type: 'float', default: 1, category: 'param'},\n {key: 'thinWalled', type: 'bool', default: false, category: 'param'},\n {key: 'doubleSided', type: 'bool', default: false, category: 'param'},\n {key: 'map', type: 'texture', default: undefined, category: 'texture'},\n {key: 'alphaMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'alphaMode', type: 'enum', default: 'auto', category: 'param'},\n {key: 'alphaCutoff', type: 'float', default: 0, category: 'param'},\n {key: 'emissiveMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'normalMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'normalScale', type: 'vec2', default: [1, 1], category: 'param'},\n {key: 'metallicRoughnessMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'roughnessMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'metalnessMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'transmissionMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'thinFilmMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'shadowCatcher', type: 'bool', default: false, category: 'param'},\n {key: 'unlit', type: 'bool', default: false, category: 'param'},\n {key: 'bevelSize', type: 'float', default: 0, category: 'param'},\n {key: 'mapAlphaUsage', type: 'enum', default: 'opaque', category: 'param'},\n {key: 'uvProjection', type: 'enum', default: 'none', category: 'param'},\n {key: 'uvProjectionScale', type: 'vec2', default: [1, 1], category: 'param'},\n {key: 'displacementUvProjection', type: 'enum', default: 'none', category: 'geometry'},\n {key: 'displacementUvProjectionScale', type: 'float', default: 1, category: 'geometry'},\n {key: 'displacementMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'displacementScale', type: 'float', default: 0.1, category: 'geometry'},\n {key: 'displacementStepSize', type: 'float', default: 0, category: 'geometry'},\n {key: 'thinFilmThicknessMinimum', type: 'float', default: 0, category: 'param'},\n {key: 'thinFilmMapChannel', type: 'enum', default: 'r', category: 'param'},\n {key: 'coatWeightMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'coatRoughnessMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'fuzzColorMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'fuzzRoughnessMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'specularWeightMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'specularColorMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'anisotropyMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'specularAnisotropyRotation', type: 'float', default: 0, category: 'param'},\n {key: 'coatAnisotropyRotation', type: 'float', default: 0, category: 'param'},\n {key: 'specularAnisotropyModel', type: 'enum', default: 'openpbr', category: 'param'},\n {key: 'coatNormalMap', type: 'texture', default: undefined, category: 'texture'},\n {key: 'coatNormalScale', type: 'vec2', default: [1, 1], category: 'param'},\n {key: 'displacementBias', type: 'float', default: 0, category: 'geometry'},\n] as const satisfies readonly Field[];\ntype SchemaTextureName = Extract<typeof openPbrSchema[number], {type: 'texture'}>['key'];\nconst textureNamesMatch: [Exclude<MaterialTextureName, SchemaTextureName> | Exclude<SchemaTextureName, MaterialTextureName>] extends [never] ? true : never = true;\nvoid textureNamesMatch;\ntype Keys<T extends readonly {key: PropertyKey}[]> = {readonly [I in keyof T]: T[I]['key']};\ntype CategoryKeys<T extends readonly Field[], C extends Field['category'], R extends readonly MaterialKey[] = []> =\n T extends readonly [infer H extends Field, ...infer Rest extends readonly Field[]]\n ? CategoryKeys<Rest, C, H['category'] extends C ? readonly [...R, H['key']] : R> : R;\nexport const materialKeys = openPbrSchema.map(field => field.key) as unknown as Keys<typeof openPbrSchema>;\nfunction categoryKeys<C extends Field['category']>(category: C) {\n return openPbrSchema.filter(field => field.category === category).map(field => field.key) as unknown as CategoryKeys<typeof openPbrSchema, C>;\n}\nexport const materialTextureKeys = categoryKeys('texture');\nexport const materialGeometryKeys = categoryKeys('geometry');\nexport const materialParamKeys = categoryKeys('param');\nconst defaults = new Map<MaterialKey, unknown>(openPbrSchema.map(field => [field.key, field.default]));\nexport function materialDefault<K extends MaterialKey>(key: K): OpenPBRMaterial[K] {\n const value = defaults.get(key);\n return (Array.isArray(value) ? value.slice() : value) as OpenPBRMaterial[K];\n}\nexport function applyMaterialParams(material: OpenPBRMaterial, input: OpenPBRMaterialParams) {\n const params = normalizeMaterialParams(input);\n if (params.thinFilmMapChannel !== undefined) thinFilmMapChannelIndex(params.thinFilmMapChannel);\n if (params.specularAnisotropyModel !== undefined) specularAnisotropyModelIndex(params.specularAnisotropyModel);\n for (const {key} of openPbrSchema) {\n if (params[key] !== undefined) Object.assign(material, {[key]: params[key]});\n }\n}\nlet textureId = 1;\nconst textureWeakMap = new WeakMap<Texture, number>();\nexport function resetMaterialTextureId() { textureId = 1; }\nexport function getMaterialHashKey(material: OpenPBRMaterial) {\n return openPbrSchema.map(({key}) => {\n const value = material[key];\n if (value == null) return '$';\n if (value instanceof Texture) {\n if (!textureWeakMap.has(value)) textureWeakMap.set(value, textureId++);\n return `${textureWeakMap.get(value)!}@${value.version}`;\n }\n if (typeof value === 'string') return value;\n if (typeof value === 'object' && 'length' in value) return Array.from(value as ArrayLike<number>).join('_');\n return value;\n }).join('_');\n}\n"]}
|
package/lib/util/fromTHREE.d.ts
CHANGED
package/lib/util/fromTHREE.js
CHANGED
|
@@ -139,13 +139,19 @@ function convertMaterial(threeMaterial, textureCache) {
|
|
|
139
139
|
material.emissiveMap = convertTexture(standardMaterial.emissiveMap, textureCache);
|
|
140
140
|
material.normalMap = convertTexture(standardMaterial.normalMap, textureCache);
|
|
141
141
|
material.displacementMap = convertTexture(standardMaterial.displacementMap, textureCache);
|
|
142
|
+
const displacementBias = Number(standardMaterial.displacementBias);
|
|
143
|
+
if (Number.isFinite(displacementBias))
|
|
144
|
+
material.displacementBias = displacementBias;
|
|
142
145
|
const displacementScale = Number(standardMaterial.displacementScale);
|
|
143
|
-
|
|
146
|
+
// Three.js stores 1 even without a height map. Do not turn that inactive
|
|
147
|
+
// default into MuTracer's height when a texture is added after conversion.
|
|
148
|
+
material.displacementScale = Number.isFinite(displacementScale) &&
|
|
149
|
+
(standardMaterial.displacementMap != null || displacementScale !== 1)
|
|
144
150
|
? displacementScale
|
|
145
151
|
: material.displacementScale;
|
|
146
152
|
const displacementStepSize = Number(standardMaterial.userData.mutracerDisplacementStepSize);
|
|
147
153
|
if (Number.isFinite(displacementStepSize)) {
|
|
148
|
-
material.displacementStepSize = Math.max(0
|
|
154
|
+
material.displacementStepSize = Math.max(0, displacementStepSize);
|
|
149
155
|
}
|
|
150
156
|
const uvProjection = standardMaterial.userData
|
|
151
157
|
.mutracerDisplacementUvProjection;
|
|
@@ -255,6 +261,12 @@ function convertMaterial(threeMaterial, textureCache) {
|
|
|
255
261
|
: fallback;
|
|
256
262
|
};
|
|
257
263
|
if (openPbr) {
|
|
264
|
+
for (const key of ['displacementScale', 'displacementBias', 'displacementStepSize']) {
|
|
265
|
+
const value = openPbr[key];
|
|
266
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
267
|
+
material[key] = key === 'displacementStepSize' ? Math.max(0, value) : value;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
258
270
|
if (openPbr.specularAnisotropyModel !== undefined) {
|
|
259
271
|
specularAnisotropyModelIndex(openPbr.specularAnisotropyModel);
|
|
260
272
|
material.specularAnisotropyModel = openPbr.specularAnisotropyModel;
|
|
@@ -944,7 +956,8 @@ function orbitControlsState(camera, controls) {
|
|
|
944
956
|
const state = [camera, controls.update, camera.parent, ...camera.position.toArray(), ...camera.quaternion.toArray(),
|
|
945
957
|
...camera.scale.toArray(), ...camera.up.toArray(), camera.zoom, ...(camera.parent?.matrixWorld.elements ?? [])];
|
|
946
958
|
for (const [key, value] of Object.entries(controls)) {
|
|
947
|
-
|
|
959
|
+
// Pointer-down changes the gesture state without changing the view.
|
|
960
|
+
if (key.startsWith('_') || key === 'state')
|
|
948
961
|
continue;
|
|
949
962
|
const vector = value;
|
|
950
963
|
if (vector?.isVector3)
|
|
@@ -971,10 +984,11 @@ export class THREESync extends Sync {
|
|
|
971
984
|
_store = createConversionStore();
|
|
972
985
|
_disposed = false;
|
|
973
986
|
_started = false;
|
|
987
|
+
_gestureChanged = false;
|
|
974
988
|
_cameraState = [];
|
|
975
989
|
_lastUpdate;
|
|
976
990
|
_idleControlsState;
|
|
977
|
-
_start = () => { this._started = true; this.
|
|
991
|
+
_start = () => { this._started = true; this._gestureChanged = false; };
|
|
978
992
|
_end = () => { this._started = false; };
|
|
979
993
|
/** Subscribes to controls without converting sources or modifying the engine. */
|
|
980
994
|
constructor(engine, _options = {}) {
|
|
@@ -996,7 +1010,9 @@ export class THREESync extends Sync {
|
|
|
996
1010
|
let moving = false, settled = false;
|
|
997
1011
|
if (controls && this._options.updateControls !== false) {
|
|
998
1012
|
const orbitInputs = orbitControlsState(sourceCamera, controls);
|
|
999
|
-
|
|
1013
|
+
// OrbitControls applies pointer movement before synchronization. Keep a
|
|
1014
|
+
// settled camera untouched on pointer-down until its inputs actually change.
|
|
1015
|
+
const idle = (!this._started || !this._gestureChanged) && !controls.autoRotate && orbitInputs && this._idleControlsState && snapshotsEqual(orbitInputs, this._idleControlsState);
|
|
1000
1016
|
if (!idle) {
|
|
1001
1017
|
this._idleControlsState = undefined;
|
|
1002
1018
|
const position = sourceCamera?.position.clone(), rotation = sourceCamera?.quaternion.clone(), zoom = sourceCamera?.zoom;
|
|
@@ -1063,7 +1079,9 @@ export class THREESync extends Sync {
|
|
|
1063
1079
|
this._camera.copy(next);
|
|
1064
1080
|
this.engine.camera = this._camera;
|
|
1065
1081
|
}
|
|
1066
|
-
|
|
1082
|
+
if (this._started && (moving || cameraChanged))
|
|
1083
|
+
this._gestureChanged = true;
|
|
1084
|
+
this.setActive((this._started && this._gestureChanged) || moving || this._store.poseChanged || (cameraChanged && !settled));
|
|
1067
1085
|
}
|
|
1068
1086
|
/** Removes control subscriptions and caches. The last converted objects remain usable. */
|
|
1069
1087
|
dispose() {
|