[SOLVED]OpenGL edges of textures

Posts: 30
Joined: 2010.08
Post: #1
I've finally got pixel-perfect rasterization of my textures on integer tex coords for my 2d game (pong). At first I used GL_NEAREST, but that looked bad because you could tell it was jumping from one pixel to the next. So I used GL_LINEAR, and it looked great, the pixels smoothly transition, fading in to the next location (which you can see when the ball speed is very slow). However, the edges of the ball don't do this. They just disappear on one side and appear on the other. I guess this is because they are on the edges of the texture so there isn't enough neighbours to interpolate the colour, but what else can I do? I tried adding a 1 pixel alpha border around the textures and that worked, but it's a big hassle and it messes things up when the viewport is resized.

I'm pretty sure this isn't what AA is for, but I tried it anyway and it did work like I wanted it to sort of, but it didn't seem to be interpolating every frame, more like 3-4 times per second, even with 16 super/multi samples.

Quote this message in a reply
Posts: 1,234
Joined: 2002.10
Post: #2
Vertex coordinates are quantized during rasterization to integral pixels (or MSAA samples.)
Texture coordinates are interpolated during rasterization; you see sub-pixel filtering within each pixel that was produced by rasterization.

You need an alpha border.
Quote this message in a reply
Posts: 30
Joined: 2010.08
Post: #3
Ok I was thinking that when I resized the window and use glViewport, it would be the alpha border would be double. But I was confusing my input with OpenGL's output. The thing I was worrying about was the ball rebounding off the alpha border, before it appears to actually hit, but I just need to make sure my game logic rects don't include the alpha border.

Thanks for the quick reply.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Preventing texture from creating transparent gaps on edges ardowz 3 5,355 Jan 21, 2014 11:28 AM
Last Post: SethWillits
  Create Aquaria-like terrain- texturing edges AndyKorth 3 9,018 Jul 31, 2011 08:13 PM
Last Post: FlamingHairball
  Replacing edges with degenerate quads (for shadow volumes) Coyote 9 13,959 Jan 15, 2010 07:08 PM
Last Post: Coyote
  OpenGL Image Textures mikey 52 47,840 Jun 30, 2009 10:42 AM
Last Post: AnotherJake
  Dealing with inverted textures in OpenGL johncmurphy 7 10,798 Jun 15, 2009 08:11 AM
Last Post: Skorche