Skip to content

Commit 5a918bf

Browse files
committed
opengl1: Fix skybox in OpenGL 1.1
Fix six image skybox having a black border around the sides of the sky when using OpenGL 1.1 (using CL_CLAMP instead of GL_CLAMP_TO_EDGE). It's technically visible in q3dm10 but it's more obvious in Team Arena maps such as mpteam6.
1 parent f9547e4 commit 5a918bf

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

code/renderergl1/tr_sky.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,17 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max
387387
static void DrawSkyBox( shader_t *shader )
388388
{
389389
int i;
390+
float w_offset, w_scale;
391+
float h_offset, h_scale;
390392

391393
sky_min = 0;
392394
sky_max = 1;
393395

394396
Com_Memset( s_skyTexCoords, 0, sizeof( s_skyTexCoords ) );
395397

398+
w_offset = h_offset = 0;
399+
w_scale = h_scale = 1;
400+
396401
for (i=0 ; i<6 ; i++)
397402
{
398403
int sky_mins_subd[2], sky_maxs_subd[2];
@@ -432,6 +437,15 @@ static void DrawSkyBox( shader_t *shader )
432437
else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS )
433438
sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS;
434439

440+
if ( !haveClampToEdge )
441+
{
442+
w_offset = 0.5f / shader->sky.outerbox[sky_texorder[i]]->width;
443+
h_offset = 0.5f / shader->sky.outerbox[sky_texorder[i]]->height;
444+
445+
w_scale = 1.0f - w_offset * 2;
446+
h_scale = 1.0f - h_offset * 2;
447+
}
448+
435449
//
436450
// iterate through the subdivisions
437451
//
@@ -444,6 +458,12 @@ static void DrawSkyBox( shader_t *shader )
444458
i,
445459
s_skyTexCoords[t][s],
446460
s_skyPoints[t][s] );
461+
462+
s_skyTexCoords[t][s][0] *= w_scale;
463+
s_skyTexCoords[t][s][0] += w_offset;
464+
465+
s_skyTexCoords[t][s][1] *= h_scale;
466+
s_skyTexCoords[t][s][1] += h_offset;
447467
}
448468
}
449469

0 commit comments

Comments
 (0)