Load all the alias vertex data as bytes.

I had forgotten I wanted to do it this way.
This commit is contained in:
Bill Currie 2012-01-02 13:41:12 +09:00
parent a57835866a
commit 540bccbc27
4 changed files with 11 additions and 10 deletions

View file

@ -32,8 +32,8 @@
#define __QF_GLSL_qf_alias_h
typedef struct aliasvrt_s {
vec3_t vertex;
vec3_t stn;
byte vertex[3];
byte stn[3];
} aliasvrt_t;
void R_InitAlias (void);

View file

@ -98,12 +98,9 @@ Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s,
int numtris;
int i, j;
int pose;
float w, h;
numverts = hdr->mdl.numverts;
numtris = hdr->mdl.numtris;
w = hdr->mdl.skinwidth;
h = hdr->mdl.skinheight;
// copy triangles before editing them
tris = malloc (numtris * sizeof (mtriangle_t));
@ -144,7 +141,7 @@ Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s,
for (j = 0; j < hdr->mdl.numverts; j++) {
pv = &poseverts[i][j];
VectorCopy (pv->v, verts[pose + j].vertex);
VectorSet (st[j].s / w, st[j].t / h, pv->lightnormalindex,
VectorSet (st[j].s, st[j].t, pv->lightnormalindex,
verts[pose + j].stn);
// duplicate any verts that are marked for duplication by the
// stvert setup, using the modified st coordinates
@ -152,8 +149,8 @@ Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s,
// the vertex position and normal are duplicated, only s and t
// are not (and really, only s, but this feels cleaner)
verts[pose + indexmap[j]] = verts[pose + j];
verts[pose + indexmap[j]].stn[0] = st[indexmap[j]].s / w;
verts[pose + indexmap[j]].stn[1] = st[indexmap[j]].t / h;
verts[pose + indexmap[j]].stn[0] = st[indexmap[j]].s;
verts[pose + indexmap[j]].stn[1] = st[indexmap[j]].t;
}
}
}

View file

@ -66,6 +66,7 @@ static struct {
shaderparam_t normals;
shaderparam_t mvp_matrix;
shaderparam_t norm_matrix;
shaderparam_t skin_size;
shaderparam_t color;
shaderparam_t stn;
shaderparam_t vertex;
@ -80,6 +81,7 @@ static struct {
{"normals", 1},
{"mvp_mat", 1},
{"norm_mat", 1},
{"skin_size", 1},
{"vcolor", 0},
{"stn", 0},
{"vertex", 0},
@ -130,6 +132,7 @@ R_InitAlias (void)
GL_ResolveShaderParam (quake_mdl.program, &quake_mdl.normals);
GL_ResolveShaderParam (quake_mdl.program, &quake_mdl.mvp_matrix);
GL_ResolveShaderParam (quake_mdl.program, &quake_mdl.norm_matrix);
GL_ResolveShaderParam (quake_mdl.program, &quake_mdl.skin_size);
GL_ResolveShaderParam (quake_mdl.program, &quake_mdl.color);
GL_ResolveShaderParam (quake_mdl.program, &quake_mdl.stn);
GL_ResolveShaderParam (quake_mdl.program, &quake_mdl.vertex);

View file

@ -1,6 +1,7 @@
uniform sampler2D normals;
uniform mat4 mvp_mat;
uniform mat3 norm_mat;
uniform vec2 skin_size;
attribute vec4 vcolor;
attribute vec3 stn;
@ -16,8 +17,8 @@ main (void)
float nind;
vec3 norma, normb;
gl_Position = mvp_mat * vec4 (vertex, 1.0);
st = stn.st;
nind = stn.p;
st = stn.st / skin_size;
nind = stn.p / 162.0;
norma = texture2D (normals, vec2 (0.0, nind)).xyz;
normb = texture2D (normals, vec2 (1.0, nind)).xyz;
normal = norm_mat * (2.0 * norma + normb / 128.0 - vec3 (1.0, 1.0, 1.0));