@gnsx/three 0.186.10 → 0.186.11
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/build/three.webgpu.js +774 -15
- package/build/three.webgpu.nodes.js +774 -15
- package/examples/jsm/inspector/tabs/Settings.js +2 -1
- package/package.json +1 -1
- package/src/materials/nodes/NodeMaterial.js +7 -2
- package/src/nodes/display/LODColorationDebug.js +162 -0
- package/src/renderers/common/DebugViewLegend.js +560 -0
- package/src/renderers/common/Renderer.js +40 -1
|
@@ -148,6 +148,7 @@ class Settings extends Parameters {
|
|
|
148
148
|
'Shader Complexity': 'shaderComplexity',
|
|
149
149
|
'Lighting Complexity': 'lightingComplexity',
|
|
150
150
|
'Shadow Caster': 'shadowCaster',
|
|
151
|
+
'LOD Coloration': 'lodColoration',
|
|
151
152
|
'Double Side': 'doubleSide',
|
|
152
153
|
'Overdraw': 'overdraw',
|
|
153
154
|
'Shader Complexity & Overdraw': 'shaderComplexityAndOverdraw',
|
|
@@ -196,7 +197,7 @@ class Settings extends Parameters {
|
|
|
196
197
|
const renderer = this.inspector.getRenderer();
|
|
197
198
|
const view = renderer !== null && renderer.debug !== undefined ? renderer.debug.view : null;
|
|
198
199
|
|
|
199
|
-
if ( view === 'none' || view === 'wireframe' || view === 'shaderComplexity' || view === 'lightingComplexity' || view === 'overdraw' || view === 'shaderComplexityAndOverdraw' || view === 'bufferVisualization' || view === 'lightingOnly' || view === 'detailLighting' || view === 'drawCall' || view === 'frontBackFace' || view === 'shadowCaster' || view === 'doubleSide' ) {
|
|
200
|
+
if ( view === 'none' || view === 'wireframe' || view === 'shaderComplexity' || view === 'lightingComplexity' || view === 'overdraw' || view === 'shaderComplexityAndOverdraw' || view === 'bufferVisualization' || view === 'lightingOnly' || view === 'detailLighting' || view === 'drawCall' || view === 'frontBackFace' || view === 'shadowCaster' || view === 'lodColoration' || view === 'doubleSide' ) {
|
|
200
201
|
|
|
201
202
|
if ( this._debugViewState.view !== view ) {
|
|
202
203
|
|
package/package.json
CHANGED
|
@@ -33,6 +33,7 @@ import { DEBUG_VIEW_DETAIL_LIGHTING, DEBUG_VIEW_LIGHTING_ONLY, applyLightingDebu
|
|
|
33
33
|
import { DEBUG_VIEW_DRAW_CALL, applyDrawCallDebug } from '../../nodes/display/DrawCallDebug.js';
|
|
34
34
|
import { DEBUG_VIEW_FRONT_BACK_FACE, applyFrontBackFaceDebug } from '../../nodes/display/FrontBackFaceDebug.js';
|
|
35
35
|
import { DEBUG_VIEW_SHADOW_CASTER, applyShadowCasterDebug } from '../../nodes/display/ShadowCasterDebug.js';
|
|
36
|
+
import { DEBUG_VIEW_LOD_COLORATION, applyLODColorationDebug } from '../../nodes/display/LODColorationDebug.js';
|
|
36
37
|
import { DEBUG_VIEW_DOUBLE_SIDE, applyDoubleSideDebug } from '../../nodes/display/DoubleSideDebug.js';
|
|
37
38
|
|
|
38
39
|
/**
|
|
@@ -585,6 +586,10 @@ class NodeMaterial extends Material {
|
|
|
585
586
|
|
|
586
587
|
applyShadowCasterDebug( builder, this );
|
|
587
588
|
|
|
589
|
+
} else if ( renderer.debug.view === DEBUG_VIEW_LOD_COLORATION && this.isShadowPassMaterial !== true ) {
|
|
590
|
+
|
|
591
|
+
applyLODColorationDebug( builder, this );
|
|
592
|
+
|
|
588
593
|
} else if ( renderer.debug.view === DEBUG_VIEW_DOUBLE_SIDE && this.isShadowPassMaterial !== true ) {
|
|
589
594
|
|
|
590
595
|
applyDoubleSideDebug( builder, this );
|
|
@@ -1047,7 +1052,7 @@ class NodeMaterial extends Material {
|
|
|
1047
1052
|
setupNormal( builder ) {
|
|
1048
1053
|
|
|
1049
1054
|
// WITH_GENESYS
|
|
1050
|
-
if ( ( builder.renderer.debug.view === DEBUG_VIEW_LIGHTING_ONLY || builder.renderer.debug.view === DEBUG_VIEW_DRAW_CALL || builder.renderer.debug.view === DEBUG_VIEW_FRONT_BACK_FACE || builder.renderer.debug.view === DEBUG_VIEW_SHADOW_CASTER || builder.renderer.debug.view === DEBUG_VIEW_DOUBLE_SIDE ) && this.isShadowPassMaterial !== true && this.fragmentNode === null ) {
|
|
1055
|
+
if ( ( builder.renderer.debug.view === DEBUG_VIEW_LIGHTING_ONLY || builder.renderer.debug.view === DEBUG_VIEW_DRAW_CALL || builder.renderer.debug.view === DEBUG_VIEW_FRONT_BACK_FACE || builder.renderer.debug.view === DEBUG_VIEW_SHADOW_CASTER || builder.renderer.debug.view === DEBUG_VIEW_LOD_COLORATION || builder.renderer.debug.view === DEBUG_VIEW_DOUBLE_SIDE ) && this.isShadowPassMaterial !== true && this.fragmentNode === null ) {
|
|
1051
1056
|
|
|
1052
1057
|
return lightingOnlyNormal();
|
|
1053
1058
|
|
|
@@ -1252,7 +1257,7 @@ class NodeMaterial extends Material {
|
|
|
1252
1257
|
// WITH_GENESYS
|
|
1253
1258
|
// Lighting only and draw call substitute a plain lit material, so emissive is dropped.
|
|
1254
1259
|
// Detail lighting keeps it.
|
|
1255
|
-
if ( ( builder.renderer.debug.view === DEBUG_VIEW_LIGHTING_ONLY || builder.renderer.debug.view === DEBUG_VIEW_DRAW_CALL || builder.renderer.debug.view === DEBUG_VIEW_FRONT_BACK_FACE || builder.renderer.debug.view === DEBUG_VIEW_SHADOW_CASTER || builder.renderer.debug.view === DEBUG_VIEW_DOUBLE_SIDE ) && this.isShadowPassMaterial !== true ) {
|
|
1260
|
+
if ( ( builder.renderer.debug.view === DEBUG_VIEW_LIGHTING_ONLY || builder.renderer.debug.view === DEBUG_VIEW_DRAW_CALL || builder.renderer.debug.view === DEBUG_VIEW_FRONT_BACK_FACE || builder.renderer.debug.view === DEBUG_VIEW_SHADOW_CASTER || builder.renderer.debug.view === DEBUG_VIEW_LOD_COLORATION || builder.renderer.debug.view === DEBUG_VIEW_DOUBLE_SIDE ) && this.isShadowPassMaterial !== true ) {
|
|
1256
1261
|
|
|
1257
1262
|
return outgoingLightNode;
|
|
1258
1263
|
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// WITH_GENESYS
|
|
2
|
+
// LOD coloration. Each drawn LOD tier gets a fixed color from the palette, then lit.
|
|
3
|
+
// !WITH_GENESYS
|
|
4
|
+
|
|
5
|
+
import { Color } from '../../math/Color.js';
|
|
6
|
+
import { diffuseColor, diffuseContribution, metalness, roughness, specularColor, specularColorBlended, specularF90, clearcoat, sheen, iridescence, anisotropy, transmission, retroreflectivity } from '../core/PropertyNode.js';
|
|
7
|
+
import { uniform } from '../core/UniformNode.js';
|
|
8
|
+
import { float, vec3 } from '../tsl/TSLCore.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* LOD coloration. Colors geometry by its active LOD index, then lights that color.
|
|
12
|
+
* Matches Unreal `LODColorationColors` from `BaseEngine.ini`.
|
|
13
|
+
*
|
|
14
|
+
* @type {string}
|
|
15
|
+
*/
|
|
16
|
+
export const DEBUG_VIEW_LOD_COLORATION = 'lodColoration';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Default palette when `renderer.debug.lodColorationColors` is not set.
|
|
20
|
+
* Unreal: white, red, green, blue, yellow, fuchsia, cyan, purple.
|
|
21
|
+
*
|
|
22
|
+
* @type {Color[]}
|
|
23
|
+
*/
|
|
24
|
+
export const DEFAULT_LOD_COLORATION_COLORS = [
|
|
25
|
+
new Color( 1, 1, 1 ),
|
|
26
|
+
new Color( 1, 0, 0 ),
|
|
27
|
+
new Color( 0, 1, 0 ),
|
|
28
|
+
new Color( 0, 0, 1 ),
|
|
29
|
+
new Color( 1, 1, 0 ),
|
|
30
|
+
new Color( 1, 0, 1 ),
|
|
31
|
+
new Color( 0, 1, 1 ),
|
|
32
|
+
new Color( 0.5, 0, 0.5 ),
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const INVALID_LOD_COLOR = new Color( 1, 0, 1 );
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Resolves the LOD index used for coloration on a drawn object.
|
|
39
|
+
* `userData.lodColorationIndex` on the object or an ancestor wins (Genesys instanced LOD tiers).
|
|
40
|
+
* Otherwise the nearest `THREE.LOD` parent is consulted: the level object that owns the draw,
|
|
41
|
+
* or the parent's current level as a fallback.
|
|
42
|
+
*
|
|
43
|
+
* @param {?Object3D} object - The drawn object.
|
|
44
|
+
* @return {number} LOD index, or `-1` when no palette entry should be used.
|
|
45
|
+
*/
|
|
46
|
+
export function resolveLODColorationIndex( object ) {
|
|
47
|
+
|
|
48
|
+
if ( object === null ) return - 1;
|
|
49
|
+
|
|
50
|
+
let node = object;
|
|
51
|
+
|
|
52
|
+
while ( node !== null ) {
|
|
53
|
+
|
|
54
|
+
const tagged = node.userData.lodColorationIndex;
|
|
55
|
+
|
|
56
|
+
if ( typeof tagged === 'number' && Number.isFinite( tagged ) ) {
|
|
57
|
+
|
|
58
|
+
return tagged;
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
node = node.parent;
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
node = object;
|
|
67
|
+
|
|
68
|
+
while ( node !== null ) {
|
|
69
|
+
|
|
70
|
+
const parent = node.parent;
|
|
71
|
+
|
|
72
|
+
if ( parent !== null && parent.isLOD === true ) {
|
|
73
|
+
|
|
74
|
+
const levels = parent.levels;
|
|
75
|
+
|
|
76
|
+
for ( let i = 0; i < levels.length; i ++ ) {
|
|
77
|
+
|
|
78
|
+
const levelObject = levels[ i ].object;
|
|
79
|
+
|
|
80
|
+
if ( levelObject === object || levelObject.getObjectById( object.id ) !== undefined ) {
|
|
81
|
+
|
|
82
|
+
return i;
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return parent.getCurrentLevel();
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
node = parent;
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return 0;
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param {Color} color - Destination color.
|
|
102
|
+
* @param {?Object3D} object - The drawn object.
|
|
103
|
+
* @param {Renderer~DebugConfig} debug - Renderer debug state.
|
|
104
|
+
* @return {Color} `color`.
|
|
105
|
+
*/
|
|
106
|
+
function writeLODColorationColor( color, object, debug ) {
|
|
107
|
+
|
|
108
|
+
const index = resolveLODColorationIndex( object );
|
|
109
|
+
const palette = debug.lodColorationColors ?? DEFAULT_LOD_COLORATION_COLORS;
|
|
110
|
+
|
|
111
|
+
if ( index < 0 || index >= palette.length ) {
|
|
112
|
+
|
|
113
|
+
return color.copy( INVALID_LOD_COLOR );
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return color.copy( palette[ index ] );
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Replaces albedo with the LOD palette color after the material has written its channels.
|
|
123
|
+
*
|
|
124
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
125
|
+
* @param {NodeMaterial} material - The node material being set up.
|
|
126
|
+
*/
|
|
127
|
+
export function applyLODColorationDebug( builder, material ) {
|
|
128
|
+
|
|
129
|
+
const colorNode = uniform( new Color() ).onObjectUpdate( ( { object }, self ) => {
|
|
130
|
+
|
|
131
|
+
if ( object === null ) return;
|
|
132
|
+
|
|
133
|
+
return writeLODColorationColor( self.value, object, builder.renderer.debug );
|
|
134
|
+
|
|
135
|
+
} );
|
|
136
|
+
|
|
137
|
+
diffuseColor.rgb.assign( colorNode );
|
|
138
|
+
|
|
139
|
+
if ( material.lights !== true ) return;
|
|
140
|
+
|
|
141
|
+
metalness.assign( float( 0 ) );
|
|
142
|
+
diffuseContribution.assign( colorNode );
|
|
143
|
+
roughness.assign( float( 1 ) );
|
|
144
|
+
specularColor.assign( vec3( 0 ) );
|
|
145
|
+
specularColorBlended.assign( vec3( 0 ) );
|
|
146
|
+
specularF90.assign( float( 0 ) );
|
|
147
|
+
|
|
148
|
+
builder.context.ambientOcclusion = null;
|
|
149
|
+
|
|
150
|
+
if ( material.useClearcoat === true ) clearcoat.assign( float( 0 ) );
|
|
151
|
+
|
|
152
|
+
if ( material.useSheen === true ) sheen.assign( vec3( 0 ) );
|
|
153
|
+
|
|
154
|
+
if ( material.useIridescence === true ) iridescence.assign( float( 0 ) );
|
|
155
|
+
|
|
156
|
+
if ( material.useAnisotropy === true ) anisotropy.assign( float( 0 ) );
|
|
157
|
+
|
|
158
|
+
if ( material.useTransmission === true ) transmission.assign( float( 0 ) );
|
|
159
|
+
|
|
160
|
+
if ( material.useRetroreflection === true ) retroreflectivity.assign( float( 0 ) );
|
|
161
|
+
|
|
162
|
+
}
|