mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
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:
parent
f3884c659c
commit
d1419c30db
4 changed files with 100 additions and 2 deletions
|
@ -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
|
||||
|
|
50
libs/video/renderer/glsl/glsl_alias.c
Normal file
50
libs/video/renderer/glsl/glsl_alias.c
Normal 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)
|
||||
{
|
||||
}
|
24
libs/video/renderer/glsl/quakemdl.frag
Normal file
24
libs/video/renderer/glsl/quakemdl.frag
Normal 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));
|
||||
}
|
24
libs/video/renderer/glsl/quakemdl.vert
Normal file
24
libs/video/renderer/glsl/quakemdl.vert
Normal 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;
|
||||
}
|
Loading…
Reference in a new issue