I have custom shader where i have to send a segmentation id associated to each pixel in (x,y) position.
Now i am sending that as a texture and getting that data as:
float segID = sampleTexture(persTexture, vPosition.xy).r;
and the segmentation id is encoded as “r” in a texture but the problem here is that since the type is float32, if in any case i have segmentation id more than 255, i can’t send that with texture because i can’t put this data in texture.
Is there any way i can solve this?
can i have storage buffer or any hack to this?
var uniforms = {
// some other uniforms
persTexture: { type: 't', value: new THREE.Texture() },
//some other uniforms
}
and data is put as:
var imageData = new Uint8Array(4 * persDatas[threshold].length)
for (var x = 0; x < persDatas[threshold].length; x++) {
var segID = Math.floor((255 * persDatas[threshold][x]) / response.data.max)
imageData[x * 4] = segID
imageData[x * 4 + 1] = segID
imageData[x * 4 + 2] = segID
imageData[x * 4 + 3] = 255
}
var texture = new THREE.DataTexture(imageData, 4104, 1856)
texture.needsUpdate = true
persTextures[threshold] = texture
uniforms.persTexture.value = texture
can anyone help on this please??