Precise texture addressing
- From: Murrgon <murrgon@xxxxxxxxxxx>
- Date: Wed, 23 Jan 2008 14:02:37 -0500
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
.
- Follow-Ups:
- Re: Precise texture addressing
- From: Murrgon
- Re: Precise texture addressing
- From: Richard [Microsoft Direct3D MVP]
- Re: Precise texture addressing
- Prev by Date: Re: Is it possible to use DXUT GUI components out of the sample framework?
- Next by Date: Re: Is it possible to use DXUT GUI components out of the sample framework?
- Previous by thread: Re: Is it possible to use DXUT GUI components out of the sample framework?
- Next by thread: Re: Precise texture addressing
- Index(es):
Relevant Pages
|