mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 09:51:41 +00:00
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:
parent
f1eea0176c
commit
6e2d625d36
2 changed files with 10 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue