2
0
Эх сурвалжийг харах

WebGPURenderer: support integer vertex attributes in WebGLBackend (#26974)

Co-authored-by: aardgoose <[email protected]>
aardgoose 1 жил өмнө
parent
commit
5766d3edf6

+ 9 - 1
examples/jsm/renderers/webgl/WebGLBackend.js

@@ -681,7 +681,15 @@ class WebGLBackend extends Backend {
 
 			}
 
-			gl.vertexAttribPointer( i, attribute.itemSize, attributeData.type, false, stride, offset );
+			if ( attributeData.isFloat ) {
+
+				gl.vertexAttribPointer( i, attribute.itemSize, attributeData.type, false, stride, offset );
+
+			} else {
+
+				gl.vertexAttribIPointer( i, attribute.itemSize, attributeData.type, stride, offset );
+
+			}
 
 			if ( attribute.isInstancedBufferAttribute && ! attribute.isInterleavedBufferAttribute ) {
 

+ 6 - 1
examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js

@@ -36,16 +36,19 @@ class WebGLAttributeUtils {
 		//attribute.onUploadCallback();
 
 		let type;
+		let isFloat = false;
 
 		if ( array instanceof Float32Array ) {
 
 			type = gl.FLOAT;
+			isFloat = true;
 
 		} else if ( array instanceof Uint16Array ) {
 
 			if ( attribute.isFloat16BufferAttribute ) {
 
 				type = gl.HALF_FLOAT;
+				isFloat = true;
 
 			} else {
 
@@ -86,7 +89,9 @@ class WebGLAttributeUtils {
 		backend.set( attribute, {
 			bufferGPU,
 			type,
-			bytesPerElement: array.BYTES_PER_ELEMENT
+			bytesPerElement: array.BYTES_PER_ELEMENT,
+			version: attribute.version,
+			isFloat
 		} );
 
 	}