Load the skybox faces into the correct cubemap slots.

Quake and GL are rotated relative to each other, so care must be taken
when loading and rendering.
This commit is contained in:
Bill Currie 2012-01-12 15:13:19 +09:00
parent f1eea0176c
commit 6e2d625d36
2 changed files with 10 additions and 3 deletions

View file

@ -1181,14 +1181,16 @@ R_LoadSkys (const char *sky)
{
const char *name;
int i;
// NOTE: quake's world and GL's world are rotated relative to each other
// quake has x right, y in, z up. gl has x right, y up, z out
static const char *sky_suffix[] = { "ft", "bk", "lf", "rt", "up", "dn"};
static int sky_target[] = {
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
};
if (!sky || !*sky)

View file

@ -8,5 +8,10 @@ main (void)
vec3 dir = direction;
dir *= inversesqrt (dot (dir, dir));
gl_FragColor = textureCube(sky, dir);
// NOTE: quake's world and GL's world are rotated relative to each other
// quake has x right, y in, z up. gl has x right, y up, z out
// The textures are loaded with GL's z (quake's y) already negated, so
// all that's needed here is to swizzle y and z.
gl_FragColor = textureCube(sky, dir.xzy);
}