mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-11 10:10:48 +00:00
Load the alias model shaders.
This commit is contained in:
parent
df3d9fe4df
commit
fd67f3500b
5 changed files with 70 additions and 6 deletions
|
@ -3,8 +3,12 @@ AUTOMAKE_OPTIONS= foreign
|
||||||
AM_CFLAGS= @PREFER_PIC@
|
AM_CFLAGS= @PREFER_PIC@
|
||||||
INCLUDES= -I$(top_srcdir)/include $(GLX_CFLAGS)
|
INCLUDES= -I$(top_srcdir)/include $(GLX_CFLAGS)
|
||||||
|
|
||||||
shader_src= quake2d.frag quakeico.vert quakespr.frag quakespr.vert quaketxt.vert
|
shader_src= \
|
||||||
shader_gen= quake2d.fc quakeico.vc quakespr.fc quakespr.vc quaketxt.vc
|
quake2d.frag quakeico.vert quakemdl.frag quakemdl.vert quakespr.frag \
|
||||||
|
quakespr.vert quaketxt.vert
|
||||||
|
shader_gen= \
|
||||||
|
quake2d.fc quakeico.vc quakemdl.fc quakemdl.vc quakespr.fc quakespr.vc \
|
||||||
|
quaketxt.vc
|
||||||
|
|
||||||
glsl_src = \
|
glsl_src = \
|
||||||
glsl_alias.c glsl_draw.c glsl_main.c glsl_particles.c glsl_screen.c \
|
glsl_alias.c glsl_draw.c glsl_main.c glsl_particles.c glsl_screen.c \
|
||||||
|
|
|
@ -43,8 +43,65 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
||||||
#include "QF/GLSL/defines.h"
|
#include "QF/GLSL/defines.h"
|
||||||
#include "QF/GLSL/funcs.h"
|
#include "QF/GLSL/funcs.h"
|
||||||
#include "QF/GLSL/qf_alias.h"
|
#include "QF/GLSL/qf_alias.h"
|
||||||
|
#include "QF/GLSL/qf_vid.h"
|
||||||
|
|
||||||
|
static const char quakemdl_vert[] =
|
||||||
|
#include "quakemdl.vc"
|
||||||
|
;
|
||||||
|
|
||||||
|
static const char quakemdl_frag[] =
|
||||||
|
#include "quakemdl.fc"
|
||||||
|
;
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
int program;
|
||||||
|
shaderparam_t normals;
|
||||||
|
shaderparam_t mvp_matrix;
|
||||||
|
shaderparam_t norm_matrix;
|
||||||
|
shaderparam_t color;
|
||||||
|
shaderparam_t stn;
|
||||||
|
shaderparam_t vertex;
|
||||||
|
shaderparam_t palette;
|
||||||
|
shaderparam_t colormap;
|
||||||
|
shaderparam_t skin;
|
||||||
|
shaderparam_t ambient;
|
||||||
|
shaderparam_t shadelight;
|
||||||
|
shaderparam_t lightvec;
|
||||||
|
} quake_mdl = {
|
||||||
|
0,
|
||||||
|
{"normals", 1},
|
||||||
|
{"mvp_mat", 1},
|
||||||
|
{"norm_mat", 1},
|
||||||
|
{"vcolor", 0},
|
||||||
|
{"stn", 0},
|
||||||
|
{"vertex", 0},
|
||||||
|
{"palette", 1},
|
||||||
|
{"colormap", 1},
|
||||||
|
{"skin", 1},
|
||||||
|
{"ambient", 1},
|
||||||
|
{"shadelight", 1},
|
||||||
|
{"lightvec", 1},
|
||||||
|
};
|
||||||
|
|
||||||
VISIBLE void
|
VISIBLE void
|
||||||
R_InitAlias (void)
|
R_InitAlias (void)
|
||||||
{
|
{
|
||||||
|
int vert;
|
||||||
|
int frag;
|
||||||
|
vert = GL_CompileShader ("quakemdl.vert", quakemdl_vert, GL_VERTEX_SHADER);
|
||||||
|
frag = GL_CompileShader ("quakemdl.frag", quakemdl_frag,
|
||||||
|
GL_FRAGMENT_SHADER);
|
||||||
|
quake_mdl.program = GL_LinkProgram ("quakemdl", vert, frag);
|
||||||
|
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.color);
|
||||||
|
GL_ResolveShaderParam (quake_mdl.program, &quake_mdl.stn);
|
||||||
|
GL_ResolveShaderParam (quake_mdl.program, &quake_mdl.vertex);
|
||||||
|
GL_ResolveShaderParam (quake_mdl.program, &quake_mdl.palette);
|
||||||
|
GL_ResolveShaderParam (quake_mdl.program, &quake_mdl.colormap);
|
||||||
|
GL_ResolveShaderParam (quake_mdl.program, &quake_mdl.skin);
|
||||||
|
GL_ResolveShaderParam (quake_mdl.program, &quake_mdl.ambient);
|
||||||
|
GL_ResolveShaderParam (quake_mdl.program, &quake_mdl.shadelight);
|
||||||
|
GL_ResolveShaderParam (quake_mdl.program, &quake_mdl.lightvec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
||||||
#include "QF/sys.h"
|
#include "QF/sys.h"
|
||||||
|
|
||||||
#include "QF/GLSL/funcs.h"
|
#include "QF/GLSL/funcs.h"
|
||||||
|
#include "QF/GLSL/qf_alias.h"
|
||||||
#include "QF/GLSL/qf_textures.h"
|
#include "QF/GLSL/qf_textures.h"
|
||||||
|
|
||||||
#include "gl_draw.h"
|
#include "gl_draw.h"
|
||||||
|
@ -301,6 +302,7 @@ VISIBLE void
|
||||||
R_Init (void)
|
R_Init (void)
|
||||||
{
|
{
|
||||||
R_InitParticles ();
|
R_InitParticles ();
|
||||||
|
R_InitAlias ();
|
||||||
R_InitSprites ();
|
R_InitSprites ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ main (void)
|
||||||
{
|
{
|
||||||
float pix = texture2D (skin, st).r;
|
float pix = texture2D (skin, st).r;
|
||||||
float light = ambient;
|
float light = ambient;
|
||||||
float d;
|
float d, col;
|
||||||
|
|
||||||
d = dot (normal, lightvec);
|
d = dot (normal, lightvec);
|
||||||
d = min (d, 0.0);
|
d = min (d, 0.0);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
uniform sampler2D normals;
|
uniform sampler2D normals;
|
||||||
uniform mat4 mvp_mat;
|
uniform mat4 mvp_mat;
|
||||||
|
uniform mat3 norm_mat;
|
||||||
|
|
||||||
attribute vec4 vcolor;
|
attribute vec4 vcolor;
|
||||||
attribute vec3 stn;
|
attribute vec3 stn;
|
||||||
|
@ -17,8 +18,8 @@ main (void)
|
||||||
gl_Position = mvp_mat * vec4 (vertex, 1.0);
|
gl_Position = mvp_mat * vec4 (vertex, 1.0);
|
||||||
st = stn.st;
|
st = stn.st;
|
||||||
nind = stn.p;
|
nind = stn.p;
|
||||||
norma = texture2D (normals, vec2 (nind, 0.0));
|
norma = texture2D (normals, vec2 (nind, 0.0)).xyz;
|
||||||
normb = texture2D (normals, vec2 (nind, 1.0));
|
normb = texture2D (normals, vec2 (nind, 1.0)).xyz;
|
||||||
normal = norma + normb / 256.0;
|
normal = norm_mat * (norma + normb / 256.0);
|
||||||
color = vcolor;
|
color = vcolor;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue