getting uv-Coordinates from THREE.js DataTexture
I am trying to implement a small Volumerenderer with THREE.js. For that I
have a large(at least 65000 elements) array with intensity-values(too
large to pass as a uniform array) to the shader where raycasting and all
that will happen. I wanted to use THREE.DataTexture for that but I don't
seem to have any uv-coordinates in the shader and get the following error:
Error: WebGL: vertexAttribPointer: must have valid GL_ARRAY_BUFFER binding
Error: WebGL: drawArrays: bound vertex attribute buffers do not have
sufficient size for given first and count
This is my setup:
In the init-function:
var data = new Uint8Array(textureArray);
var texture = new THREE.DataTexture(data, 128, 128, THREE.AlphaFormat);
texture.needsUpdate = true;
uniforms = {
texture: {type: "t", value: texture}
}
in the vertex-shader:
varying vec2 vUv;
void main(){
vUv = uv;
}
in the fragment-shader:
uniform sampler2D texture;
varying vec2 vUv;
The shaders are for a THREE.ShaderMaterial on a particleSystem. Everything
works fine as long as i don't have the vUv = uv assignment in the the
vertex-shader and the Texture works when I put it on a Cube like this:
cube = new THREE.CubeGeometry(10,10,10);
material = new THREE.BasicMaterial({map: texture});
mesh = new THREE.Mesh(cube, material);
scene.add(mesh);
Has anybody had a similar problem or an idea where my mistake could be?
No comments:
Post a Comment