Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7516521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:09:23+00:00 2026-05-30T01:09:23+00:00

I’m using floats to specify texture coordinates, in the range 0-1. OpenGL likes things

  • 0

I’m using floats to specify texture coordinates, in the range 0-1. OpenGL likes things in this range, and I’m fine specifying coordinates this way, but I’m concerned when I start using larger textures (say up 4096 or 8192 pixels), that I may start losing precision. For example, if I want to specify a coordinate of (1,1) in a 8192x8192px texture, that would map to 1/8192=0.0001220703125. That seems to evaluate to 0.000122070313 as a float though… I’m concerned that my OpenGL shader won’t map that to the same pixel I intended.

I could keep the coordinates as integers in pixels for awhile, but sooner or later I have to convert it (perhaps as late as in the shader itself). Is there a workaround for this, or is this something I should even be concerned about?


Multiplying it back out, I get 1.000000004096 which I guess would still be interpreted as 1? Actually, OpenGL does blending if its not a whole number, doesn’t it? Perhaps not with “nearest neighbour”, but with “linear” it ought to.

1/4096f * 4096 =   1, error = 0
1/8192f * 8192 =   1.000000004096, error =  0.000000004096
1/16384f * 16384 = 1.0000000008192, error = 0.0000000008192
1/32768f * 32768 = 0.9999999991808, error = 0.0000000008192
...
1/1048576f * 1048576 = 0.9999999827968, error = 0.0000000172032

(I’m using Visual Studio’s debugger to compute the float, and then multiplying it back out with Calculator)

Is the lesson here that the error is negligible for any reasonably sized texture?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:09:25+00:00Added an answer on May 30, 2026 at 1:09 am

    That seems to evaluate to 0.000122070313 as a float though… I’m concerned that my OpenGL shader won’t map that to the same pixel I intended.

    You should not be concerned. Floating point is called floating point because the decimal floats. You get ~7 digits of precision for your mantissa, more or less regardless of how large or small the float is.

    The float isn’t stored as 0.000122070313; it’s stored as 1.22070313×10^-4. The mantissa is 1.22070313, the exponent is -4. If the exponent were -8 instead, you would have the same precision.

    Your exponent, with single-precision floats, can go down to + or – ~38. That is, you can have 38 zeros between the decimal and the first non-zero digit of the mantissa.

    So no, you shouldn’t be concerned.

    The only thing that should concern you would be the precision of the interpolated value and the precision in the texture fetching. But these have nothing to do with the precision of data you store your texture coordinates in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.