Precise texture addressing

Tech-Archive recommends: Fix windows errors by optimizing your registry



We have a class called TexturePage which takes a folder of images of
all the same size and loads them onto a single texture. We use this
for loading animations.

The issue we have is accurately addressing each frame from the texture
that holds all of the images. There is no restriction on the size of
each frame (except that it must fit in a maximum sized texture), so
odd sizes are common.

We are rendering the animations using a single quad of coordinates:
left = -0.5
top = 0.5
right = 0.5
bottom = -0.5

This quad uses the world transformation matrix to be positioned and
scaled according to the size of frame being shown. A texture
transform is used to chose the frame of the animation to show at a
particular time.

We find that we end up having artifacts show up on the edges of the
displayed frame. It shows parts of the previous or next frame in
some cases. Here is how we calculation the bounding box in texture
coordinates of each frame:


dwPageW = width of the texture where the frames are stored
dwPageH = height of the texture where the frames are stored

dwFrameW = width of a single frame
dwFrameH = height of a single frame

dwX = Column index of where the frame is on the texture
dwY = Row index of where the frame is on the texture

fLeft = float(dwX * dwFrameW) / float(dwPageW);
fTop = float(dwY * dwFrameH) / float(dwPageH);
fRight = fLeft + (float(dwFrameW) / float(dwPageW));
fBottom = fTop + (float(dwFrameH) / float(dwPageH));


If each frame is filled to its border, we run into rendering artifacts
as described on some of the frames. What's worse is, if we flip the
quad using a negative scale on the world transform, which frames show
the artifacts changes, yet none of the texture coordinates have been
changed at all.

Is this something that we can adjust for in code, or do we need to do
something like ensure all of the frames have a 1 pixel border?

Thanks
Murrgon
.



Relevant Pages

  • Re: Fast 2D Blit and Fast Texture Upload
    ... and GL_QUADS to upload/blit every frame. ... bufferto GPU's texture memory. ... system memory and use pixel buffer objects. ... The video data from the frame grabber is ...
    (comp.graphics.api.opengl)
  • Re: "Direct3D9: (ERROR) :Error trying to lock driver surface" error when using VMR9
    ... I have to use a separate render loop (not presenting in AP's ... This error comes out even when not using the texture! ... while the 3d render engine doesnt ask for a frame: ... texture from the buffer and signal a new texture in the buffer ...
    (microsoft.public.win32.programmer.directx.video)
  • Texture coordinate floating point precision
    ... We have a "Texture Page" object we use to load animations. ... an animation. ... up with texture coordinates that don't quite work. ... If we want to index the second frame we would calculate the ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Compressed textures
    ... then load the texture into a plain surface in system memory and use ... When a movie is small enough, I readit into system memory as a binary stream defining the texels of different frames. ... Whenever I need a new video frame in the texture, I lock the texture, write the bytes and unlock it. ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Opinions on author websites?
    ... > backgrounds, images and dividers, reading pages built the old-fashioned ... I can put a subtle texture on it, or I can break it up, or both. ... Jacey Bedford ... or any other forum that reprints usenet posts as ...
    (rec.arts.sf.composition)