Results 1 to 2 of 2

Thread: Is this how to calculate texture atlas coordinates

  1. #1
    Senior Member Regular Contributor
    Join Date
    Jun 2006
    Location
    Edinburgh - Scotland
    Posts
    146

    Is this how to calculate texture atlas coordinates

    If I have a texture atlas, TexSize x TexSize square, and I want to access a Width x Height image at X,Y then are the texture coordinates
    Code :
    bottom left = X/TexSize, Y/TexSize
    top right   = (X+Width)/TexSize, (Y+Height)/TexSize
    The reason I ask is I have a 32x32 "texture atlas" with a 1x8 pixel vertical line starting at pixel 16,4. If I try and draw a rectangle filling it with the 1x8 line then some of it's right and top row of pixels sample past the edge of the 1x8 line (i.e. the pixels from column 17 and the pixel from row 12 of the "atlas").

    The problem is only on a board with Mali 55, the same test works on my desktop, so I'm hoping it's a driver issue, but
    I've seen posts about adjusting for the texel center so I've started to doubt my coordinate calcluation.

    Thanks.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jun 2006
    Location
    Edinburgh - Scotland
    Posts
    146

    Re: Is this how to calculate texture atlas coordinates

    To answer my own question. There is both a bug in the Mali driver and in my calculation. To sample the center of the texel 0.5 needs added to the X,Y (since 0,0 is the bottom left corner of the first texel, so 0.5/texWidth 0.5/texHeight is the center of the first texel).

    Also, the width and height need adjusted by one i.e. the coordinates specify an infinitely thin line through the centre of the texels rather than a 1 rectangle as I was previously doing.


Similar Threads

  1. Replies: 3
    Last Post: 10-24-2017, 12:46 PM
  2. Replies: 2
    Last Post: 06-21-2017, 07:24 AM
  3. Calculate u in camera coordinates glulookat
    By debinair in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 09-30-2013, 07:59 PM
  4. how to calculate coordinates of rect by image dimension
    By zydgyy in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 08-21-2012, 12:28 AM
  5. How to calculate the texture coordinates?
    By MJS in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-17-2006, 07:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean