Send data into float texture without clamping

Hi @Mugen87

I want to know how to create and read float32 datatexture without clamping in three.js and glsl ?
and how is it supposed to read in shader code?

i am using custom shader !!

this is the way, i thought it is but i am sure that i am not fully correct:

 var imageData = new Float32Array(4 * persDatas[threshold].length)

 for(var x=0; x<length; x++)
 {
   var segID = Math.floor((255 * persDatas[threshold][x]) / response.data.max)
   imageData[x] = segID 
 }

var texture = new THREE.DataTexture(
            imageData,
            4104,
            1856,
            THREE.RedFormat,
            THREE.FloatType
        )

and in my shader i will read the texture as:

float segID = sampleTexture(persTexture, vPosition.xy).r

All float32 type i see in three.js are clamped type which clamp value from [0,1.0].

I want the exact value this is put into that position in that texture data.

does that mean i have to send value only into integer to get exact value?

When using floating point textures, you can directly write floats into the texture data. You are not doing this here since you are producing integers.

Besides, please do not ping devs in your questions. That is bad style.

Thank you @Mugen87 i want unclamped float value to be passed into the shader so that i can get rid of precision error !!!

i want to send what segmentation id is each (x,y) is associated with and that value is integer discrete value.

my value is integer and i just want to get 32 bit array so that i can fit large scale data.

what can i do for that?

for 32 bit Int,

is this correct way to do this:

   var imageData = new Uint32Array(persDatas[threshold].length)
   for (var x = 0; x < length; x++) {
            var segID = Math.floor((255 * persDatas[threshold][x]) / response.data.max)
            imageData[x] = segID
    }
  
   var texture = new THREE.DataTexture(
            imageData,
            4104,
            1856,
            THREE.RedFormat,
            THREE.IntType
        )

and to read the texture in custom shader glsl:

  float segID = sampleTexture(persTexture, vPosition.xy).r;

is this correct way to do it?