rayzee 11.8.0 → 11.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -6
- package/dist/{ArchiveImporter-_sJm5uaK.js → ArchiveImporter-BJxszU_k.js} +1549 -1232
- package/dist/{BidirectionalIntegrator-Dzt4Z97x.js → BidirectionalIntegrator-DWg66vAd.js} +240 -240
- package/dist/{BufferLayout-xPRH9jYD.js → BufferLayout-Bzgccg1o.js} +1 -0
- package/dist/{ColorManagement-30MfpHwQ.js → ColorManagement-B_HjAiy2.js} +1 -1
- package/dist/{EngineIssues-xljoXM0E.js → EngineIssues-CfJiBaNj.js} +1 -0
- package/dist/{NeuralRetouch-BKQCsmEs.js → NeuralRetouch-BD9E-Yht.js} +1 -1
- package/dist/{NeuralSuperRes-C4ymq68e.js → NeuralSuperRes-C8Mf3tJX.js} +1 -1
- package/dist/{PathTracer-C_to_i40.js → PathTracer-DeE9UJ1n.js} +3433 -3363
- package/dist/{PhysicalSky-bMHbm_7H.js → PhysicalSky-cKy75-oR.js} +45 -45
- package/dist/{RayzeeRenderer-B_aB6VTJ.js → RayzeeRenderer-CzLyBA3G.js} +13 -8
- package/dist/{SceneMetadata-CSmlJW4c.js → SceneMetadata-C17UfOEp.js} +1 -1
- package/dist/{SolarLimb-bZE6y63S.js → SolarLimb-DRYy8tln.js} +184 -172
- package/dist/addons/archives.es.js +1 -1
- package/dist/addons/bidirectional.es.js +1 -1
- package/dist/addons/color.es.js +1 -1
- package/dist/addons/physical-sky.es.js +1 -1
- package/dist/addons/storage.es.js +1 -1
- package/dist/{openStorage-B085D9FR.js → openStorage-CdyVjmps.js} +1 -1
- package/dist/rayzee-core.es.js +7 -7
- package/dist/rayzee.es.js +567 -559
- package/dist/rayzee.umd.js +106 -101
- package/dist/{sceneCachePolicy-D_uBSbQF.js → sceneCachePolicy-ywbGKHD3.js} +9 -6
- package/package.json +1 -1
- package/src/EngineDefaults.js +1 -0
- package/src/EngineIssues.js +1 -0
- package/src/Passes/OIDNTemporalHistory.js +1 -1
- package/src/Processor/ArchiveImporter.js +83 -21
- package/src/Processor/AssetLoader.js +7 -0
- package/src/Processor/BufferLayout.js +3 -3
- package/src/Processor/GeometryExtractor.js +12 -4
- package/src/Processor/MaterialPacking.js +2 -2
- package/src/Processor/PBRT/PBRTMaterials.js +47 -12
- package/src/Processor/PBRT/PBRTParser.js +144 -22
- package/src/Processor/PBRT/PBRTSceneBuilder.js +287 -67
- package/src/Processor/PBRT/PBRTTextureBake.js +191 -9
- package/src/Processor/PBRT/index.js +19 -4
- package/src/Processor/SceneProcessor.js +42 -26
- package/src/RayzeeRenderer.js +4 -2
- package/src/Stages/DenoiserSettings.js +0 -4
- package/src/Stages/NRD.js +53 -24
- package/src/Stages/NormalDepth.js +5 -3
- package/src/Stages/PathTracer.js +2 -0
- package/src/Stages/PathTracerStage.js +5 -1
- package/src/Storage/SceneGraphCodec.js +6 -3
- package/src/TSL/BVHTraversal.js +33 -20
- package/src/TSL/Common.js +25 -8
- package/src/TSL/Displacement.js +66 -113
- package/src/TSL/LightsDirect.js +33 -11
- package/src/TSL/SceneResources.js +8 -0
- package/src/TSL/ShadeKernel.js +2 -2
- package/src/TSL/Struct.js +1 -0
- package/src/managers/MaterialDataManager.js +11 -0
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* film: { xresolution, yresolution, filename } | null,
|
|
15
15
|
* camera: { type, params, cameraToWorld:number[16] } | null,
|
|
16
16
|
* namedMaterials: Map<name, { type, params }>,
|
|
17
|
-
* namedTextures: Map<name, { dataType, class, params }>,
|
|
17
|
+
* namedTextures: Map<name, { dataType, class, params, ctm? }>, (ctm: where a position mapping was declared)
|
|
18
18
|
* shapes: [ { type, params, ctm, ctmEnd?, material, areaLight, reverseOrientation } ],
|
|
19
19
|
* lights: [ { type, params, ctm } ],
|
|
20
20
|
* instances: Map<name, { name, count, matrices, matricesEnd? }>,
|
|
@@ -68,6 +68,101 @@ const NUMERIC_STORAGE = {
|
|
|
68
68
|
rgb: Float32Array
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
+
// The directive `ParamUsage.translate` is in, and each directive open until `ParamUsage.finish`.
|
|
72
|
+
let current = null;
|
|
73
|
+
const scopes = new Map();
|
|
74
|
+
|
|
75
|
+
/** A directive's parameter, counted as used: every translator reads through this, as pbrt-v4's lookups mark theirs. */
|
|
76
|
+
export function param( params, name ) {
|
|
77
|
+
|
|
78
|
+
if ( current !== null && current.params === params ) current.read.push( name );
|
|
79
|
+
else if ( scopes.size !== 0 ) scopes.get( params )?.read.push( name );
|
|
80
|
+
return params?.[ name ];
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A parameter read but not honoured exactly: a texture's mean where the engine takes one value,
|
|
86
|
+
* a default for a type it cannot read.
|
|
87
|
+
*/
|
|
88
|
+
export function approximated( params, name ) {
|
|
89
|
+
|
|
90
|
+
const scope = current !== null && current.params === params ? current : scopes.get( params );
|
|
91
|
+
if ( scope ) ( scope.approximated ??= new Set() ).add( name );
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* What one load did not honour, as pbrt's ReportUnused: each translated directive's parameters that nothing looked up,
|
|
97
|
+
* or that were approximated, counted per `directive type: name`. Holds nothing per directive once it is accounted for.
|
|
98
|
+
*/
|
|
99
|
+
export class ParamUsage {
|
|
100
|
+
|
|
101
|
+
constructor() {
|
|
102
|
+
|
|
103
|
+
this.unused = new Map();
|
|
104
|
+
this.approximated = new Map();
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Runs `read`, which looks up every parameter it uses before it returns, and accounts for the directive at once.
|
|
110
|
+
* `consumed` names one read before, where nothing counted it. A directive left open is accounted for by `finish`.
|
|
111
|
+
*/
|
|
112
|
+
translate( params, label, read, consumed = null ) {
|
|
113
|
+
|
|
114
|
+
if ( scopes.has( params ) ) return read();
|
|
115
|
+
const outer = current;
|
|
116
|
+
const scope = current = { params, label, approximated: null, read: [ consumed ] };
|
|
117
|
+
try {
|
|
118
|
+
|
|
119
|
+
return read();
|
|
120
|
+
|
|
121
|
+
} finally {
|
|
122
|
+
|
|
123
|
+
current = outer;
|
|
124
|
+
for ( const name in params ) this._count( scope, name, ! scope.read.includes( name ) );
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Accounts for a directive read across awaits, from here to `finish`. */
|
|
131
|
+
open( params, label, consumed = null ) {
|
|
132
|
+
|
|
133
|
+
if ( params && ! scopes.has( params ) ) scopes.set( params, { usage: this, label, approximated: null, read: [ consumed ] } );
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** @returns {{unused: Object<string, number>, approximated: Object<string, number>}} */
|
|
138
|
+
finish() {
|
|
139
|
+
|
|
140
|
+
for ( const [ params, scope ] of scopes ) {
|
|
141
|
+
|
|
142
|
+
if ( scope.usage !== this ) continue;
|
|
143
|
+
scopes.delete( params );
|
|
144
|
+
for ( const name in params ) this._count( scope, name, ! scope.read.includes( name ) );
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const flat = ( counts ) => [ ...counts ].flatMap( ( [ label, byName ] ) => [ ...byName ].map( ( [ name, n ] ) => [ `${label}: ${name}`, n ] ) );
|
|
149
|
+
const sorted = ( counts ) => Object.fromEntries( flat( counts ).sort( ( a, b ) => ( a[ 0 ] < b[ 0 ] ? - 1 : 1 ) ) );
|
|
150
|
+
return { unused: sorted( this.unused ), approximated: sorted( this.approximated ) };
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
_count( scope, name, unused ) {
|
|
155
|
+
|
|
156
|
+
const counts = scope.approximated?.has( name ) ? this.approximated : unused ? this.unused : null;
|
|
157
|
+
if ( ! counts ) return;
|
|
158
|
+
let byName = counts.get( scope.label );
|
|
159
|
+
if ( ! byName ) counts.set( scope.label, byName = new Map() );
|
|
160
|
+
byName.set( name, ( byName.get( name ) ?? 0 ) + 1 );
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
|
|
71
166
|
export class PBRTParser {
|
|
72
167
|
|
|
73
168
|
/**
|
|
@@ -90,6 +185,7 @@ export class PBRTParser {
|
|
|
90
185
|
// is the parse itself, so a limit applied later saves nothing.
|
|
91
186
|
this.maxPlacements = opts.maxPlacements ?? Infinity;
|
|
92
187
|
this.instanceIncludes = opts.instanceIncludes !== false;
|
|
188
|
+
this.usage = opts.usage ?? null;
|
|
93
189
|
this._includes = new Map();
|
|
94
190
|
this._stateIds = new WeakMap();
|
|
95
191
|
this._nextStateId = 1;
|
|
@@ -598,14 +694,18 @@ export class PBRTParser {
|
|
|
598
694
|
|
|
599
695
|
case 'Film': {
|
|
600
696
|
|
|
601
|
-
this._expectString( 'Film type' );
|
|
697
|
+
const type = this._expectString( 'Film type' );
|
|
602
698
|
const params = this._parseParams();
|
|
603
|
-
this.
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
699
|
+
this._translate( params, `${name} ${type}`, () => {
|
|
700
|
+
|
|
701
|
+
this.ir.film = {
|
|
702
|
+
xresolution: this._num( param( params, 'xresolution' ), 1280 ),
|
|
703
|
+
yresolution: this._num( param( params, 'yresolution' ), 720 ),
|
|
704
|
+
resolutionGiven: Boolean( params.xresolution || params.yresolution ),
|
|
705
|
+
filename: this._str( param( params, 'filename' ), null )
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
} );
|
|
609
709
|
break;
|
|
610
710
|
|
|
611
711
|
}
|
|
@@ -613,18 +713,26 @@ export class PBRTParser {
|
|
|
613
713
|
// What the scene asks the renderer for; reported, not applied (PBRTSceneBuilder renderRequest).
|
|
614
714
|
case 'Integrator': {
|
|
615
715
|
|
|
616
|
-
this._expectString( 'Integrator type' );
|
|
716
|
+
const type = this._expectString( 'Integrator type' );
|
|
617
717
|
const params = this._parseParams();
|
|
618
|
-
|
|
718
|
+
this._translate( params, `${name} ${type}`, () => {
|
|
719
|
+
|
|
720
|
+
if ( params.maxdepth ) this.ir.integrator = { maxdepth: this._num( param( params, 'maxdepth' ), 5 ) };
|
|
721
|
+
|
|
722
|
+
} );
|
|
619
723
|
break;
|
|
620
724
|
|
|
621
725
|
}
|
|
622
726
|
|
|
623
727
|
case 'Sampler': {
|
|
624
728
|
|
|
625
|
-
this._expectString( 'Sampler type' );
|
|
729
|
+
const type = this._expectString( 'Sampler type' );
|
|
626
730
|
const params = this._parseParams();
|
|
627
|
-
|
|
731
|
+
this._translate( params, `${name} ${type}`, () => {
|
|
732
|
+
|
|
733
|
+
if ( params.pixelsamples ) this.ir.sampler = { pixelsamples: this._num( param( params, 'pixelsamples' ), 16 ) };
|
|
734
|
+
|
|
735
|
+
} );
|
|
628
736
|
break;
|
|
629
737
|
|
|
630
738
|
}
|
|
@@ -633,11 +741,17 @@ export class PBRTParser {
|
|
|
633
741
|
case 'PixelFilter':
|
|
634
742
|
case 'Filter':
|
|
635
743
|
case 'Accelerator':
|
|
636
|
-
case 'ColorSpace':
|
|
637
|
-
|
|
638
|
-
this.
|
|
744
|
+
case 'ColorSpace': {
|
|
745
|
+
|
|
746
|
+
const type = this._peek()?.type === TokenType.STRING ? this._next().value : '';
|
|
747
|
+
this._translate( this._parseParams(), `${name} ${type}` );
|
|
639
748
|
break;
|
|
640
749
|
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
// `Option "type name" value`: one parameter, no type before it.
|
|
753
|
+
case 'Option': this._translate( this._parseParams(), name ); break;
|
|
754
|
+
|
|
641
755
|
// ── world block ──
|
|
642
756
|
case 'WorldBegin':
|
|
643
757
|
this.ctm = M.identity();
|
|
@@ -669,7 +783,14 @@ export class PBRTParser {
|
|
|
669
783
|
case 'ReverseOrientation': this.state.reverseOrientation = ! this.state.reverseOrientation; break;
|
|
670
784
|
|
|
671
785
|
// `Attribute "target" params` — v4 default-setting; ignored for MVP.
|
|
672
|
-
case 'Attribute':
|
|
786
|
+
case 'Attribute': {
|
|
787
|
+
|
|
788
|
+
const target = this._expectString( 'Attribute target' );
|
|
789
|
+
this._translate( this._parseParams(), `${name} ${target}` );
|
|
790
|
+
break;
|
|
791
|
+
|
|
792
|
+
}
|
|
793
|
+
|
|
673
794
|
case 'ActiveTransform': {
|
|
674
795
|
|
|
675
796
|
const t = this._next();
|
|
@@ -744,7 +865,9 @@ export class PBRTParser {
|
|
|
744
865
|
const dataType = this._expectString( 'Texture data type' ); // float | spectrum
|
|
745
866
|
const texClass = this._expectString( 'Texture class' ); // imagemap | scale | ...
|
|
746
867
|
const params = this._parseParams();
|
|
747
|
-
|
|
868
|
+
const def = { dataType, class: texClass, params };
|
|
869
|
+
if ( this._str( params.mapping, 'uv' ) !== 'uv' ) def.ctm = this._ctmSnapshot();
|
|
870
|
+
this.ir.namedTextures.set( texName, def );
|
|
748
871
|
break;
|
|
749
872
|
|
|
750
873
|
}
|
|
@@ -839,7 +962,7 @@ export class PBRTParser {
|
|
|
839
962
|
default:
|
|
840
963
|
this._warnUnknown( name );
|
|
841
964
|
// Best effort: swallow any trailing parameter list to stay in sync.
|
|
842
|
-
this._parseParams();
|
|
965
|
+
this._translate( this._parseParams(), name );
|
|
843
966
|
break;
|
|
844
967
|
|
|
845
968
|
}
|
|
@@ -992,11 +1115,10 @@ export class PBRTParser {
|
|
|
992
1115
|
|
|
993
1116
|
}
|
|
994
1117
|
|
|
995
|
-
|
|
1118
|
+
/** Runs `read` over a directive's parameters, and counts what it leaves unread: all of them by default. */
|
|
1119
|
+
_translate( params, label, read = () => {} ) {
|
|
996
1120
|
|
|
997
|
-
|
|
998
|
-
if ( this._peek() && this._peek().type === TokenType.STRING ) this._next();
|
|
999
|
-
this._parseParams();
|
|
1121
|
+
return this.usage ? this.usage.translate( params, label, read ) : read();
|
|
1000
1122
|
|
|
1001
1123
|
}
|
|
1002
1124
|
|