mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-21 19:21:47 +00:00
Fix up alias-16 support.
After getting in contact with serplord, I now know that the sw alias loading was correct. Turns out the gl loaders was mostly correct, just a mistaken subtract rather than add. And with that, I can implement alias-16 support in glsl. better yet, since all the work is done in the loader, the renderer doesn't know anything about it :) However, I need to create some 16-bit models for testing.
This commit is contained in:
parent
c6bcd7aedb
commit
6f18035c12
6 changed files with 27 additions and 13 deletions
|
@ -31,10 +31,12 @@
|
||||||
#ifndef __QF_GLSL_qf_alias_h
|
#ifndef __QF_GLSL_qf_alias_h
|
||||||
#define __QF_GLSL_qf_alias_h
|
#define __QF_GLSL_qf_alias_h
|
||||||
|
|
||||||
|
#include "QF/GLSL/types.h"
|
||||||
|
|
||||||
typedef struct aliasvrt_s {
|
typedef struct aliasvrt_s {
|
||||||
short st[2];
|
GLshort st[2];
|
||||||
short normal[3];
|
GLshort normal[3];
|
||||||
byte vertex[3];
|
GLushort vertex[3];
|
||||||
} aliasvrt_t;
|
} aliasvrt_t;
|
||||||
|
|
||||||
void R_InitAlias (void);
|
void R_InitAlias (void);
|
||||||
|
|
|
@ -518,7 +518,13 @@ Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s, i
|
||||||
trivertx_t *pv = poseverts[i];
|
trivertx_t *pv = poseverts[i];
|
||||||
for (j = 0; j < numorder; j++) {
|
for (j = 0; j < numorder; j++) {
|
||||||
trivertx16_t v;
|
trivertx16_t v;
|
||||||
VectorMultSub (pv[vertexorder[j] + hdr->mdl.numverts].v,
|
// convert MD16's split coordinates into something a little
|
||||||
|
// saner. The first chunk of vertices is fully compatible with
|
||||||
|
// IDPO alias models (even the scale). The second chunk is the
|
||||||
|
// fractional bits of the vertex, giving 8.8. However, it's
|
||||||
|
// easier for us to multiply everything by 256 and adjust the
|
||||||
|
// model scale appropriately
|
||||||
|
VectorMultAdd (pv[vertexorder[j] + hdr->mdl.numverts].v,
|
||||||
256, pv[vertexorder[j]].v, v.v);
|
256, pv[vertexorder[j]].v, v.v);
|
||||||
v.lightnormalindex =
|
v.lightnormalindex =
|
||||||
poseverts[i][vertexorder[j]].lightnormalindex;
|
poseverts[i][vertexorder[j]].lightnormalindex;
|
||||||
|
|
|
@ -81,6 +81,8 @@ Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum, qboolean group,
|
||||||
void
|
void
|
||||||
Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
|
Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
|
||||||
{
|
{
|
||||||
|
if (hdr->mdl.ident == HEADER_MDL16)
|
||||||
|
VectorScale (hdr->mdl.scale, 1/256.0, hdr->mdl.scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -146,7 +148,12 @@ Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s,
|
||||||
for (i = 0, pose = 0; i < hdr->numposes; i++, pose += numverts) {
|
for (i = 0, pose = 0; i < hdr->numposes; i++, pose += numverts) {
|
||||||
for (j = 0; j < hdr->mdl.numverts; j++) {
|
for (j = 0; j < hdr->mdl.numverts; j++) {
|
||||||
pv = &poseverts[i][j];
|
pv = &poseverts[i][j];
|
||||||
VectorCopy (pv->v, verts[pose + j].vertex);
|
if (extra) {
|
||||||
|
VectorMultAdd (pv[hdr->numposes].v, 256, pv->v,
|
||||||
|
verts[pose + j].vertex);
|
||||||
|
} else {
|
||||||
|
VectorCopy (pv->v, verts[pose + j].vertex);
|
||||||
|
}
|
||||||
verts[pose + j].st[0] = st[j].s;
|
verts[pose + j].st[0] = st[j].s;
|
||||||
verts[pose + j].st[1] = st[j].t;
|
verts[pose + j].st[1] = st[j].t;
|
||||||
VectorScale (vertex_normals[pv->lightnormalindex], 32767,
|
VectorScale (vertex_normals[pv->lightnormalindex], 32767,
|
||||||
|
|
|
@ -78,13 +78,10 @@ process_frame (maliasframedesc_t *frame, int posenum, int extra)
|
||||||
frame_verts = Hunk_AllocName (size, loadname);
|
frame_verts = Hunk_AllocName (size, loadname);
|
||||||
frame->frame = (byte *) frame_verts - (byte *) pheader;
|
frame->frame = (byte *) frame_verts - (byte *) pheader;
|
||||||
|
|
||||||
// I'm really not sure what the format of md16 is, but for now, I'll
|
// The low-order 8 bits (actually, fractional) are completely separate
|
||||||
// assume the sw renderer is correct (I believe that's what serplord
|
// from the high-order bits (see R_AliasTransformFinalVert16 in
|
||||||
// was using when he developed it), which means the low-order 8 bits
|
// sw_ralias.c), but in adjacant arrays. This means we can get away with
|
||||||
// (actually, fractional) are completely separate from the high-order
|
// just one memcpy as there are non endian issues.
|
||||||
// bits (see R_AliasTransformFinalVert16 in sw_ralias.c), but in
|
|
||||||
// adjacant arrays. This means we can get away with just one memcpy
|
|
||||||
// as there are non endian issues.
|
|
||||||
memcpy (frame_verts, poseverts[posenum], size);
|
memcpy (frame_verts, poseverts[posenum], size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -538,6 +538,8 @@ R_DrawAliasModel (entity_t *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paliashdr->mdl.ident == HEADER_MDL16) {
|
if (paliashdr->mdl.ident == HEADER_MDL16) {
|
||||||
|
// because we multipled by 256 when we loaded the verts, we have to
|
||||||
|
// scale by 1/256 when drawing.
|
||||||
VectorScale (paliashdr->mdl.scale, e->scale / 256.0, scale);
|
VectorScale (paliashdr->mdl.scale, e->scale / 256.0, scale);
|
||||||
vo = GL_GetAliasFrameVerts16 (paliashdr, e);
|
vo = GL_GetAliasFrameVerts16 (paliashdr, e);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -165,7 +165,7 @@ set_arrays (const shaderparam_t *vert, const shaderparam_t *norm,
|
||||||
const shaderparam_t *st, aliasvrt_t *pose)
|
const shaderparam_t *st, aliasvrt_t *pose)
|
||||||
{
|
{
|
||||||
byte *pose_offs = (byte *) pose;
|
byte *pose_offs = (byte *) pose;
|
||||||
qfglVertexAttribPointer (vert->location, 3, GL_UNSIGNED_BYTE,
|
qfglVertexAttribPointer (vert->location, 3, GL_UNSIGNED_SHORT,
|
||||||
0, sizeof (aliasvrt_t),
|
0, sizeof (aliasvrt_t),
|
||||||
pose_offs + field_offset (aliasvrt_t, vertex));
|
pose_offs + field_offset (aliasvrt_t, vertex));
|
||||||
qfglVertexAttribPointer (norm->location, 3, GL_SHORT,
|
qfglVertexAttribPointer (norm->location, 3, GL_SHORT,
|
||||||
|
|
Loading…
Reference in a new issue