Implement particles as points.

Unfortunately, the maximum point size on Intel hardwar seems to be 1, so I
can't tell if the colors are right.

This is largely just a hacked version of GL's particle code.
This commit is contained in:
Bill Currie 2012-01-19 10:38:05 +09:00
parent 63893b6a2f
commit 5e1a80e016
6 changed files with 1752 additions and 174 deletions

View file

@ -0,0 +1,42 @@
/*
qf_particles.h
GLSL specific particles stuff
Copyright (C) 2012 Bill Currie <bill@taniwha.org>
Author: Bill Currie <bill@taniwha.org>
Date: 2012/1/15
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
$Id$
*/
#ifndef __QF_GLSL_qf_bsp_h
#define __QF_GLSL_qf_bsp_h
#include "QF/GLSL/types.h"
typedef struct {
float texcoord[2];
float vertex[3];
byte color[4];
} partvert_t;
#endif//__QF_GLSL_qf_bsp_h

View file

@ -5,12 +5,12 @@ INCLUDES= -I$(top_srcdir)/include $(GLX_CFLAGS)
shader_src= \
quake2d.frag quakebsp.frag quakebsp.vert quakeico.vert quakemdl.frag \
quakemdl.vert quakeskb.frag quakeski.frag quakesky.vert \
quakespr.frag quakespr.vert quaketrb.frag quaketxt.vert
quakemdl.vert quakepnt.frag quakepnt.vert quakeskb.frag quakeski.frag \
quakesky.vert quakespr.frag quakespr.vert quaketrb.frag quaketxt.vert
shader_gen= \
quake2d.fc quakebsp.fc quakebsp.vc quakeico.vc quakemdl.fc quakemdl.vc \
quakeskb.fc quakeski.fc quakesky.vc quakespr.fc quakespr.vc quaketrb.fc \
quaketxt.vc
quakepnt.fc quakepnt.vc quakeskb.fc quakeski.fc quakesky.vc quakespr.fc \
quakespr.vc quaketrb.fc quaketxt.vc
glsl_src = \
glsl_alias.c glsl_bsp.c glsl_draw.c glsl_lightmap.c glsl_main.c \

View file

@ -218,6 +218,7 @@ R_RenderView (void)
R_DrawSky ();
R_RenderEntities ();
R_DrawWaterSurfaces ();
R_DrawParticles ();
R_DrawViewModel ();
}

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,6 @@
//precision mediump float;
uniform sampler2D palette;
varying float color;
void
@ -6,5 +8,5 @@ main (void)
{
if (color == 1.0)
discard;
gl_FragColor = texture2D (palette, vec2 (pix, 0.0));
gl_FragColor = texture2D (palette, vec2 (color, 0.0));
}

View file

@ -1,18 +1,19 @@
uniform mat4 mvp_mat;
attribute float vcolor;
/** Vertex position.
x, y, z, c
c is the color of the point.
*/
attribute vec4 vertex;
attribute vec3 vertex;
varying float color;
void
main (void)
{
gl_Position = mvp_mat * vec4 (vertex.xyz, 1.0);
gl_Position = mvp_mat * vec4 (vertex, 1.0);
gl_PointSize = max (1, 32768.0 * abs (1.0 / gl_Position.z));
color = vertex.w;
color = vcolor;
}