Ver código fonte

better way of using uniforms. Plus bit of cleanup.

Almar Klein 6 anos atrás
pai
commit
c49241a388

+ 3 - 1
examples/js/shaders/VolumeShader.js

@@ -11,7 +11,9 @@ THREE.VolumeRenderShader1 = {
         "u_size": { value: [1, 1, 1] },
         "u_renderstyle": { value: 0 },
         "u_renderthreshold": { value: 0.5 },
-        "u_clim": { value: [0.0, 1.0] }
+        "u_clim": { value: [0.0, 1.0] },
+        "u_data": { value: null },
+        "u_cmdata": { value: null }
     },
     vertexShader: [
         'varying vec4 v_nearpos;',

+ 6 - 14
examples/webgl_materials_texture3d_volume.html

@@ -133,8 +133,8 @@
 				volmaterial.side = THREE.BackSide;  // The volume shader uses the backface as its "reference point"
 
 				// Apply standard volume material uniform info
-				volmaterial.uniforms.u_data = { type: 't', value: texture };
-				volmaterial.uniforms.u_size = { type: 'v3', value: [ volume.xLength, volume.yLength, volume.zLength ] };
+				volmaterial.uniforms.u_data.value = texture;
+				volmaterial.uniforms.u_size.value = [ volume.xLength, volume.yLength, volume.zLength ];
 
 				// Geometry for the volume
 				var volgeometry = new THREE.BoxGeometry( volume.xLength, volume.yLength, volume.zLength );
@@ -194,10 +194,10 @@
 
 			config = this.volumeConfig;
 
-			this.volmaterial.uniforms.u_clim = { type: 'v2', value: [ config.clim1, config.clim2 ] };
-			this.volmaterial.uniforms.u_renderstyle = { type: 'int', value: config.renderstyle == 'mip' ? 0 : 1 }; // 0: MIP, 1: ISO
-			this.volmaterial.uniforms.u_renderthreshold = { type: 'f', value: config.isothreshold };  // For ISO renderstyle
-			this.volmaterial.uniforms.u_cmdata = { type: 't', value: this.cmtextures[config.colormap] };
+			this.volmaterial.uniforms.u_clim.value = [ config.clim1, config.clim2 ];
+			this.volmaterial.uniforms.u_renderstyle.value = config.renderstyle == 'mip' ? 0 : 1; // 0: MIP, 1: ISO
+			this.volmaterial.uniforms.u_renderthreshold.value = config.isothreshold;  // For ISO renderstyle
+			this.volmaterial.uniforms.u_cmdata.value = this.cmtextures[config.colormap];
 
 			this.volmaterial.needsUpdate = true;
 
@@ -236,14 +236,6 @@
 
 		}
 
-		function rotateAroundWorldAxis(object, axis, radians) {
-			var rotWorldMatrix = new THREE.Matrix4();
-			rotWorldMatrix.makeRotationAxis( axis.normalize(), radians );
-
-			object.applyMatrix( rotWorldMatrix );
-
-		}
-
 		function setupInset () {
 			var insetWidth = 150,
 				insetHeight = 150;