@@ -12,7 +12,7 @@ import {
1212 genMeshCube , setAmbientLight , setDirectionalLight ,
1313} from "bloom/models" ;
1414import {
15- enableShadows , addPointLight , createSceneNode , attachModelToNode ,
15+ enableShadows , addPointLight , addShadowedPointLight , createSceneNode , attachModelToNode ,
1616 setSceneNodeTransform , setSceneNodeColor , setSceneNodePbr ,
1717 setSceneNodeCastShadow , setSceneNodeReceiveShadow ,
1818} from "bloom/scene" ;
@@ -21,14 +21,19 @@ import { mat4Identity, mat4Translate, mat4Scale } from "bloom/math";
2121const argv : string [ ] = getCommandLineArgs ( ) ;
2222const config = parseQualityRun ( argv ) ;
2323let vsmGpuCasterFixture = false ;
24+ let vsmLocalLightsFixture = false ;
25+ let vsmLocalReferenceFixture = false ;
2426for ( let i = 0 ; i < argv . length ; i = i + 1 ) {
2527 if ( argv [ i ] === "--vsm-gpu-casters" ) vsmGpuCasterFixture = true ;
28+ if ( argv [ i ] === "--vsm-local-lights" ) vsmLocalLightsFixture = true ;
29+ if ( argv [ i ] === "--vsm-local-reference" ) vsmLocalReferenceFixture = true ;
2630}
2731
28- const GRID_X = vsmGpuCasterFixture ? 32 : 128 ;
29- const GRID_Z = vsmGpuCasterFixture ? 16 : 80 ;
32+ const localLightLayout = vsmLocalLightsFixture || vsmLocalReferenceFixture ;
33+ const GRID_X = localLightLayout ? 16 : ( vsmGpuCasterFixture ? 32 : 128 ) ;
34+ const GRID_Z = localLightLayout ? 16 : ( vsmGpuCasterFixture ? 16 : 80 ) ;
3035const DRAW_COUNT = GRID_X * GRID_Z ;
31- const LIGHT_COUNT = 192 ;
36+ const LIGHT_COUNT = localLightLayout ? 128 : 192 ;
3237
3338initWindow ( 1280 , 720 , "Bloom Quality: 10k Draws + Many Lights" , 0 ) ;
3439if ( config !== null ) resize ( 1280 , 720 , 1280 , 720 ) ;
@@ -42,6 +47,18 @@ enableShadows();
4247const quality : QualityRun | null = config !== null ? new QualityRun ( config ) : null ;
4348
4449const cube = genMeshCube ( 1 , 1 , 1 ) ;
50+ if ( localLightLayout ) {
51+ const floor = createSceneNode ( ) ;
52+ attachModelToNode ( floor , cube . handle , 0 ) ;
53+ let floorTransform = mat4Identity ( ) ;
54+ floorTransform = mat4Translate ( floorTransform , { x : 0 , y : - 0.15 , z : 0 } ) ;
55+ floorTransform = mat4Scale ( floorTransform , { x : 14 , y : 0.2 , z : 10 } ) ;
56+ setSceneNodeTransform ( floor , floorTransform ) ;
57+ setSceneNodeColor ( floor , 125 , 130 , 138 ) ;
58+ setSceneNodePbr ( floor , 0.72 , 0.0 ) ;
59+ setSceneNodeCastShadow ( floor , false ) ;
60+ setSceneNodeReceiveShadow ( floor , true ) ;
61+ }
4562for ( let i = 0 ; i < DRAW_COUNT ; i = i + 1 ) {
4663 const xIndex = i % GRID_X ;
4764 const zIndex = Math . floor ( i / GRID_X ) ;
@@ -63,7 +80,7 @@ for (let i = 0; i < DRAW_COUNT; i = i + 1) {
6380 setSceneNodePbr ( node , 0.22 + ( xIndex % 6 ) * 0.12 , ( zIndex % 9 === 0 ) ? 0.8 : 0.05 ) ;
6481 // The ordinary 10k case stays focused on main-view submission. The opt-in
6582 // 512-node VSM oracle stays below the per-page compatibility cap.
66- setSceneNodeCastShadow ( node , vsmGpuCasterFixture ) ;
83+ setSceneNodeCastShadow ( node , vsmGpuCasterFixture || localLightLayout ) ;
6784 setSceneNodeReceiveShadow ( node , true ) ;
6885}
6986
@@ -72,31 +89,50 @@ while (!windowShouldClose()) {
7289 const capture = quality !== null ? quality . beginFrame ( ) : false ;
7390 fixtureFrame = fixtureFrame + 1 ;
7491 beginDrawing ( ) ;
75- setAmbientLight ( { r : 105 , g : 115 , b : 135 , a : 255 } , 0.25 ) ;
92+ setAmbientLight (
93+ { r : 105 , g : 115 , b : 135 , a : 255 } ,
94+ localLightLayout ? 0.08 : 0.25 ,
95+ ) ;
7696 setDirectionalLight (
7797 vsmGpuCasterFixture && Math . floor ( fixtureFrame / 30 ) % 2 !== 0
7898 ? { x : - 0.28 , y : 0.90 , z : 0.34 }
7999 : { x : - 0.4 , y : 0.85 , z : 0.3 } ,
80100 { r : 255 , g : 244 , b : 228 , a : 255 } ,
81- 1.4 ,
101+ localLightLayout ? 0.15 : 1.4 ,
82102 ) ;
83103 for ( let i = 0 ; i < LIGHT_COUNT ; i = i + 1 ) {
84- const col = i % 24 ;
85- const row = Math . floor ( i / 24 ) ;
104+ const columns = localLightLayout ? 16 : 24 ;
105+ const col = i % columns ;
106+ const row = Math . floor ( i / columns ) ;
86107 const hue = i % 3 ;
87- addPointLight (
88- ( col - 11.5 ) * 3.3 ,
89- 2.0 + ( i % 4 ) * 0.6 ,
90- ( row - 3.5 ) * 6.0 ,
91- 5.5 ,
108+ const priorityLocalLight = localLightLayout && i < 5 ;
109+ const args = [
110+ priorityLocalLight ? 0.0
111+ : ( localLightLayout ? ( col - 7.5 ) * 1.0 : ( col - 11.5 ) * 3.3 ) ,
112+ priorityLocalLight ? 6.0 : 2.0 + ( i % 4 ) * 0.6 ,
113+ priorityLocalLight ? 4.0
114+ : ( localLightLayout ? ( row - 3.5 ) * 1.8 : ( row - 3.5 ) * 6.0 ) ,
115+ priorityLocalLight ? 15.0 : ( localLightLayout ? 4.5 : 5.5 ) ,
92116 hue === 0 ? 1.0 : 0.2 ,
93117 hue === 1 ? 1.0 : 0.25 ,
94118 hue === 2 ? 1.0 : 0.2 ,
95- 3.0 ,
96- ) ;
119+ priorityLocalLight ? 2.0 : ( localLightLayout ? 8.0 : 3.0 ) ,
120+ ] as const ;
121+ if ( vsmLocalLightsFixture ) {
122+ if ( ! addShadowedPointLight ( ...args ) && fixtureFrame === 1 ) {
123+ throw new Error ( `shadowed point-light request ${ i } was rejected` ) ;
124+ }
125+ } else if (
126+ ! vsmLocalReferenceFixture
127+ || i < 5
128+ ) {
129+ addPointLight ( ...args ) ;
130+ }
97131 }
98132 beginMode3D ( {
99- position : { x : 0 , y : 38 , z : 52 } ,
133+ position : localLightLayout
134+ ? { x : 0 , y : 9 , z : 17 }
135+ : { x : 0 , y : 38 , z : 52 } ,
100136 target : { x : 0 , y : 0 , z : 0 } ,
101137 up : { x : 0 , y : 1 , z : 0 } ,
102138 fovy : 58 ,
0 commit comments