Bug 2660 - skybox rendering has black seams caused by incorrect glTexParameter
Status: RESOLVED FIXED
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Video
Version: unspecified
Hardware: PC All
: P2 minor
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL: http://www.planetgargoyle.com/crap/ar...
Depends on:
Blocks:
 
Reported: 2006-04-16 19:48 EDT by Forest 'LordHavoc' Hale
Modified: 2007-05-21 11:26:22 EDT
1 user (show)

See Also:



Description Forest 'LordHavoc' Hale 2006-04-16 19:48:32 EDT
ioq3 (and q3 itself) incorrectly uses GL_CLAMP on skybox textures, causing black seams, it should use GL_CLAMP_TO_EDGE.

First a bit of background info:
GL_CLAMP blends to a border color for all texture fetches off the edge of the image, by default this color is black, this is normally used for decals on airplane wings in crusty old OpenGL 1.0 apps.

GL_CLAMP_TO_EDGE uses only the edge texels when texture fetches are off the edge of the image, this causes the image to streak outward, looking rather like barcodes coming off the image in 4 directions, this is normally used for skybox textures to avoid repeat behavior (which would have texels from the other side of the image appearing where they don't belong).

3Dfx and NVIDIA have incorrectly interpreted GL_CLAMP as GL_CLAMP_TO_EDGE for many years, ATI correctly interprets this, and NVIDIA has an option in the windows driver panel to use compliant GL_CLAMP behavior.

GL_CLAMP_TO_EDGE is an extension but is supported on any card that supports Direct3D 5 or later.

Here is the relevant #define
#define GL_CLAMP_TO_EDGE 0x812F
Comment 1 Forest 'LordHavoc' Hale 2006-04-16 19:54:19 EDT
(In reply to comment #0)
> GL_CLAMP_TO_EDGE is an extension but is supported on any card that supports
> Direct3D 5 or later.

I forgot to mention, the engine's use of GL_CLAMP can simply be replaced with GL_CLAMP_TO_EDGE without any extension or error checks, because no card pre-DX5 can even run Quake3, and no one with that old a card can expect it to look correct anyway.
Comment 2 Erik Auerswald 2006-04-16 22:05:46 EDT
A quick grep indicates that the ioq3 code already uses GL_CLAMP_TO_EDGE for the skybox (when the symbol is defined, which is the case for the SDL build).
Comment 3 Thilo Schulz 2006-04-19 23:47:38 EDT
The SDL version is fixed.
The windows version is not, as it doesn't use SDL.
Comment 4 Tim Angus 2006-04-22 18:25:49 EDT
This was fixed long ago. The only reason it may not work is if the GL headers used for compilation do not define GL_CLAMP_TO_EDGE. I'm pretty uncomfortable with #define'ing arbitrary GL constants in ioq3 itself. I know this happens already for several things, but it really shouldn't... it's horrible.

Unless this is actually a genuine bug, it should be closed. Comment within a week or so, or I'll close it.
Comment 5 Thilo Schulz 2006-04-27 11:12:35 EDT
I added the #define to qgl.h, it will only get defined if the GL_CLAMP_TO_EDGE is not already defined, though.

If you still don't like it at all you can remove it (sorry, didn't read your comment about this until i committed the hack and wanted to close the bug) but I suggest to leave the "hack" commented in there and put up information about it in the README so users have a choice to enable this if needed. I can understand that not everyone really wants to replace his system OpenGL headers just to get rid of that bug.
Comment 6 Ryan C. Gordon 2007-05-21 11:26:22 EDT
Setting a QA contact on all ioquake3 bugs, even resolved ones. Sorry if you get a flood of email from this, it should only happen once. Apologies for the incovenience.

--ryan.