Jump to content
  • Advertisement
Sign in to follow this  

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

This topic is 4290 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

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!