Make a start on alias model rendering.

The vertex and fragment shaders are written, and R_InitAlias is stubbed,
but that's it so far.
This commit is contained in:
Bill Currie 2012-01-01 23:58:12 +09:00
parent f3884c659c
commit d1419c30db
4 changed files with 100 additions and 2 deletions

View file

@ -7,8 +7,8 @@ shader_src= quake2d.frag quakeico.vert quakespr.frag quakespr.vert quaketxt.vert
shader_gen= quake2d.fc quakeico.vc quakespr.fc quakespr.vc quaketxt.vc
glsl_src = \
glsl_draw.c glsl_main.c glsl_particles.c glsl_screen.c glsl_sprite.c \
glsl_textures.c
glsl_alias.c glsl_draw.c glsl_main.c glsl_particles.c glsl_screen.c \
glsl_sprite.c glsl_textures.c
if BUILD_GL
noinst_LTLIBRARIES= libglsl.la

View file

@ -0,0 +1,50 @@
/*
glsl_alias.c
GLSL Alias model rendering
Copyright (C) 2012 Bill Currie <bill@taniwha.org>
Author: Bill Currie <bill@taniwha.org>
Date: 2012/1/1
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
static __attribute__ ((used)) const char rcsid[] = "$Id$";
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include "QF/GLSL/defines.h"
#include "QF/GLSL/funcs.h"
#include "QF/GLSL/qf_alias.h"
VISIBLE void
R_InitAlias (void)
{
}

View file

@ -0,0 +1,24 @@
uniform sampler2D palette;
uniform sampler2D colormap;
uniform sampler2D skin;
uniform float ambient;
uniform float shadelight;
uniform vec3 lightvec;
varying vec3 normal;
varying vec2 st;
varying vec4 color;
void
main (void)
{
float pix = texture2D (skin, st).r;
float light = ambient;
float d;
d = dot (normal, lightvec);
d = min (d, 0.0);
light += d * shadelight;
col = texture2D (colormap, vec2 (pix, light)).r;
gl_FragColor = texture2D (palette, vec2 (col, 0.5));
}

View file

@ -0,0 +1,24 @@
uniform sampler2D normals;
uniform mat4 mvp_mat;
attribute vec4 vcolor;
attribute vec3 stn;
attribute vec3 vertex;
varying vec3 normal;
varying vec2 st;
varying vec4 color;
void
main (void)
{
float nind;
vec3 norma, normb;
gl_Position = mvp_mat * vec4 (vertex, 1.0);
st = stn.st;
nind = stn.p;
norma = texture2D (normals, vec2 (nind, 0.0));
normb = texture2D (normals, vec2 (nind, 1.0));
normal = norma + normb / 256.0;
color = vcolor;
}