:: Large 1D lookup ::

vindos

Newcomer
helloo....

Is it possible to do accurate one dimensional look up for a 16 bit data. I mean having a lookup table of size 65536 inside pixel shader and doing an accurate lookup. I assume maximum 1D texture that can be created is 4096. How can i achieve the result by passing a 256 X 256 texture and perform a 1D lookup inside shader??

Thanxxx:smile:
 
I've never done anything like that but I guess you can use the fractional/modf operator to split your 1D texture coordinate in 2 1D texture coordinates.
Assume you have a 256x256 texture you might want to do something like this:
Code:
// index is your 1D coordinate, range 0 - 65535

// compute 2D texture coordinates (u, v)
index = index / 256.0f;
float v = modf( index, index );
float u = index / 256.0f;

// sample 2D texture
float sample = tex2D( sampler, float2( u, v ) );
You might need to offset your UV coordinates by half a texel offset according your 3D API definition of a texel center.
I'm also assuming you just want to use point filtering.
 
Back
Top