mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
Correct the orientation of the skybox (for glsl).
It turns out the expected orientation of the sky cube is exactly that of Blender's default cube looked at from the front view (num-1) and the front face being the nearest face. This put's Marcher's sun nicely in the view when exiting the cave.
This commit is contained in:
parent
536ee48a97
commit
14f089d08e
2 changed files with 19 additions and 5 deletions
|
@ -98,6 +98,7 @@ static GLuint skybox_tex;
|
|||
static qboolean skybox_loaded;
|
||||
static quat_t sky_rotation[2];
|
||||
static quat_t sky_velocity;
|
||||
static quat_t sky_fix;
|
||||
static double sky_time;
|
||||
|
||||
static quat_t default_color = { 1, 1, 1, 1 };
|
||||
|
@ -522,8 +523,9 @@ glsl_R_BuildDisplayLists (model_t **models, int num_models)
|
|||
msurface_t *surf;
|
||||
dstring_t *vertices;
|
||||
|
||||
QuatSet (sqrt(0.5), 0, 0, sqrt(0.5), sky_fix); // proper skies
|
||||
QuatSet (1, 0, 0, 0, sky_rotation[0]);
|
||||
QuatSet (1, 0, 0, 0, sky_rotation[1]);
|
||||
QuatCopy (sky_rotation[0], sky_rotation[1]);
|
||||
QuatSet (0, 0, 0, 0, sky_velocity);
|
||||
QuatExp (sky_velocity, sky_velocity);
|
||||
sky_time = vr_data.realtime;
|
||||
|
@ -948,6 +950,7 @@ spin (mat4_t mat)
|
|||
blend = bound (0, (vr_data.realtime - sky_time), 1);
|
||||
|
||||
QuatBlend (sky_rotation[0], sky_rotation[1], blend, q);
|
||||
QuatMult (sky_fix, q, q);
|
||||
Mat4Identity (mat);
|
||||
VectorNegate (r_origin, mat + 12);
|
||||
QuatToMatrix (q, m, 1, 1);
|
||||
|
@ -1325,7 +1328,17 @@ glsl_R_LoadSkys (const char *sky)
|
|||
tex_t *tex;
|
||||
// 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
|
||||
// However, skymaps have lf and rt swapped :/ lf rt
|
||||
// quake order: +x -x +z -z +y -y
|
||||
// gl order: +x -x +y -y +z -z
|
||||
// fizquake orger: -y +y +z -z +x -x
|
||||
// to get from quake order to fitzquake order, all that's needed is
|
||||
// a -90 degree rotation on the (quake) z-axis. This is taken care of in
|
||||
// the sky_matrix setup code.
|
||||
// However, from the player's perspective, skymaps have lf and rt
|
||||
// swapped, but everythink makes sense if looking at the cube from outside
|
||||
// along the positive y axis, with the front of the cube being the nearest
|
||||
// face. This matches nicely with Blender's default cube in front (num-1)
|
||||
// view.
|
||||
static const char *sky_suffix[] = { "ft", "bk", "up", "dn", "rt", "lf"};
|
||||
static int sky_coords[][2] = {
|
||||
{2, 0}, // front
|
||||
|
|
|
@ -30,17 +30,18 @@ main (void)
|
|||
float len;
|
||||
float pix;
|
||||
vec2 flow = vec2 (1.0, 1.0);
|
||||
vec2 st;
|
||||
vec2 st, base;
|
||||
vec3 dir = direction;
|
||||
|
||||
dir.z *= 3.0;
|
||||
len = dot (dir, dir);
|
||||
len = SCALE * inversesqrt (len);
|
||||
|
||||
st = direction.xy * len + flow * realtime / 8.0;
|
||||
base = direction.yx * vec2(1.0, -1.0) * len;
|
||||
st = base + flow * realtime / 8.0;
|
||||
pix = texture2D (trans, st).r;
|
||||
if (pix == 0.0) {
|
||||
st = direction.xy * len + flow * realtime / 16.0;
|
||||
st = base + flow * realtime / 16.0;
|
||||
pix = texture2D (solid, st).r;
|
||||
}
|
||||
gl_FragColor = fogBlend (texture2D (palette, vec2 (pix, 0.0)));
|
||||
|
|
Loading…
Reference in a new issue