Sign in to follow this  

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this