|
@@ -8,6 +8,7 @@ import WebGPURenderPipelines from './WebGPURenderPipelines.js';
|
|
|
import WebGPUComputePipelines from './WebGPUComputePipelines.js';
|
|
|
import WebGPUBindings from './WebGPUBindings.js';
|
|
|
import WebGPURenderLists from './WebGPURenderLists.js';
|
|
|
+import WebGPURenderStates from './WebGPURenderStates.js';
|
|
|
import WebGPUTextures from './WebGPUTextures.js';
|
|
|
import WebGPUBackground from './WebGPUBackground.js';
|
|
|
import WebGPUNodes from './nodes/WebGPUNodes.js';
|
|
@@ -105,11 +106,14 @@ class WebGPURenderer {
|
|
|
this._renderPipelines = null;
|
|
|
this._computePipelines = null;
|
|
|
this._renderLists = null;
|
|
|
+ this._renderStates = null;
|
|
|
this._textures = null;
|
|
|
this._background = null;
|
|
|
|
|
|
this._renderPassDescriptor = null;
|
|
|
|
|
|
+ this._currentRenderState = null;
|
|
|
+
|
|
|
this._currentRenderList = null;
|
|
|
this._opaqueSort = null;
|
|
|
this._transparentSort = null;
|
|
@@ -185,6 +189,7 @@ class WebGPURenderer {
|
|
|
this._renderPipelines = new WebGPURenderPipelines( this, device, parameters.sampleCount, this._nodes );
|
|
|
this._bindings = this._renderPipelines.bindings = new WebGPUBindings( device, this._info, this._properties, this._textures, this._renderPipelines, this._computePipelines, this._attributes, this._nodes );
|
|
|
this._renderLists = new WebGPURenderLists();
|
|
|
+ this._renderStates = new WebGPURenderStates();
|
|
|
this._background = new WebGPUBackground( this );
|
|
|
|
|
|
//
|
|
@@ -225,6 +230,9 @@ class WebGPURenderer {
|
|
|
this._currentRenderList = this._renderLists.get( scene, camera );
|
|
|
this._currentRenderList.init();
|
|
|
|
|
|
+ this._currentRenderState = this._renderStates.get( scene );
|
|
|
+ this._currentRenderState.init();
|
|
|
+
|
|
|
this._projectObject( scene, camera, 0 );
|
|
|
|
|
|
this._currentRenderList.finish();
|
|
@@ -303,13 +311,17 @@ class WebGPURenderer {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // light node
|
|
|
+
|
|
|
+ const lightNode = this._currentRenderState.getLightNode();
|
|
|
+
|
|
|
// process render lists
|
|
|
|
|
|
const opaqueObjects = this._currentRenderList.opaque;
|
|
|
const transparentObjects = this._currentRenderList.transparent;
|
|
|
|
|
|
- if ( opaqueObjects.length > 0 ) this._renderObjects( opaqueObjects, camera, scene, passEncoder );
|
|
|
- if ( transparentObjects.length > 0 ) this._renderObjects( transparentObjects, camera, scene, passEncoder );
|
|
|
+ if ( opaqueObjects.length > 0 ) this._renderObjects( opaqueObjects, camera, scene, lightNode, passEncoder );
|
|
|
+ if ( transparentObjects.length > 0 ) this._renderObjects( transparentObjects, camera, scene, lightNode, passEncoder );
|
|
|
|
|
|
// finish render pass
|
|
|
|
|
@@ -581,6 +593,7 @@ class WebGPURenderer {
|
|
|
this._bindings.dispose();
|
|
|
this._info.dispose();
|
|
|
this._renderLists.dispose();
|
|
|
+ this._renderStates.dispose();
|
|
|
this._textures.dispose();
|
|
|
|
|
|
}
|
|
@@ -634,6 +647,7 @@ class WebGPURenderer {
|
|
|
_projectObject( object, camera, groupOrder ) {
|
|
|
|
|
|
const currentRenderList = this._currentRenderList;
|
|
|
+ const currentRenderState = this._currentRenderState;
|
|
|
|
|
|
if ( object.visible === false ) return;
|
|
|
|
|
@@ -651,7 +665,7 @@ class WebGPURenderer {
|
|
|
|
|
|
} else if ( object.isLight ) {
|
|
|
|
|
|
- //currentRenderState.pushLight( object );
|
|
|
+ currentRenderState.pushLight( object );
|
|
|
|
|
|
if ( object.castShadow ) {
|
|
|
|
|
@@ -736,7 +750,7 @@ class WebGPURenderer {
|
|
|
|
|
|
}
|
|
|
|
|
|
- _renderObjects( renderList, camera, scene, passEncoder ) {
|
|
|
+ _renderObjects( renderList, camera, scene, lightNode, passEncoder ) {
|
|
|
|
|
|
// process renderable objects
|
|
|
|
|
@@ -758,6 +772,7 @@ class WebGPURenderer {
|
|
|
|
|
|
const objectProperties = this._properties.get( object );
|
|
|
|
|
|
+ objectProperties.lightNode = lightNode;
|
|
|
objectProperties.fogNode = scene.fogNode;
|
|
|
|
|
|
if ( camera.isArrayCamera ) {
|