• Advertisement
Sign in to follow this  

How to initiate stop and starting point in a lookup table binary search routine

This topic is 4171 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have implemented a binary search routine for a lookup table in a shader, it search one row at a time and conceptually looks like the code below; but I’m a bit confused how to initiate the stop and staring points. Should I offset them +/- fHalfPixel, nothing or something else?
float2 vStart = float2(0.0f, 0.0f);
float2 vEnd = float2(0.0f, 0.0f);
// How should I initiate vStart and vEnd?
float fDif1;
float fDif2;
for(i=0; i<iNumOfItr; i++)
   fDif1 = abs(tex2D(vStart).x - fSoughtAfter);
   fDif2 = abs(tex2D(vEnd).x - fSoughtAfter);
   if(fDif1 < fDif2)
      vEnd.x = (vStart.x + vEnd.x) * 0.5f;
      vStart.x = (vStart.x + vEnd.x) * 0.5f;

Thanks [Edited by - 51mon on October 22, 2006 2:57:27 PM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement