浏览代码

WebGPUBindings: Improve comments.

Mugen87 4 年之前
父节点
当前提交
c95ea0b9ba
共有 2 个文件被更改,包括 16 次插入9 次删除
  1. 13 9
      examples/jsm/renderers/webgpu/WebGPUBindings.js
  2. 3 0
      examples/jsm/renderers/webgpu/WebGPUUniformsGroup.js

+ 13 - 9
examples/jsm/renderers/webgpu/WebGPUBindings.js

@@ -227,7 +227,9 @@ class WebGPUBindings {
 
 		const bindings = [];
 
-		// ubos
+		// UBOs
+
+		// model
 
 		const modelViewUniform = new Matrix4Uniform( 'modelMatrix' );
 		const modelViewMatrixUniform = new Matrix4Uniform( 'modelViewMatrix' );
@@ -243,12 +245,14 @@ class WebGPUBindings {
 
 		} );
 
-		// opacity
-
-		const opacityUniform = new FloatUniform( 'opacity', 1 );
+		// camera
 
 		const cameraGroup = this.sharedUniformsGroups.get( 'cameraUniforms' );
 
+		// material (opacity for testing)
+
+		const opacityUniform = new FloatUniform( 'opacity', 1 );
+
 		const opacityGroup = new WebGPUUniformsGroup();
 		opacityGroup.setName( 'opacityUniforms' );
 		opacityGroup.addUniform( opacityUniform );
@@ -262,17 +266,17 @@ class WebGPUBindings {
 
 		} );
 
-		// samplers
+		// sampler
 
 		const diffuseSampler = new WebGPUSampler();
 		diffuseSampler.setName( 'map' );
 
-		// textures
+		// texture
 
 		const diffuseTexture = new WebGPUSampledTexture();
 		diffuseTexture.setName( 'map' );
 
-		//
+		// the order of WebGPUBinding objects must match the binding order in the shader
 
 		bindings.push( modelGroup );
 		bindings.push( cameraGroup );
@@ -288,7 +292,7 @@ class WebGPUBindings {
 
 		const bindings = [];
 
-		// ubos
+		// UBOs
 
 		const modelViewUniform = new Matrix4Uniform( 'modelMatrix' );
 		const modelViewMatrixUniform = new Matrix4Uniform( 'modelViewMatrix' );
@@ -319,7 +323,7 @@ class WebGPUBindings {
 
 		const bindings = [];
 
-		// ubos
+		// UBOs
 
 		const modelViewUniform = new Matrix4Uniform( 'modelMatrix' );
 		const modelViewMatrixUniform = new Matrix4Uniform( 'modelViewMatrix' );

+ 3 - 0
examples/jsm/renderers/webgpu/WebGPUUniformsGroup.js

@@ -7,6 +7,9 @@ class WebGPUUniformsGroup extends WebGPUBinding {
 		super();
 
 		this.name = '';
+
+		 // the order of uniforms in this array must match the order of uniforms in the shader
+
 		this.uniforms = [];
 
 		this.onBeforeUpdate = function () {};