2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
\r
5 This file is part of GtkRadiant.
\r
7 GtkRadiant is free software; you can redistribute it and/or modify
\r
8 it under the terms of the GNU General Public License as published by
\r
9 the Free Software Foundation; either version 2 of the License, or
\r
10 (at your option) any later version.
\r
12 GtkRadiant is distributed in the hope that it will be useful,
\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 GNU General Public License for more details.
\r
17 You should have received a copy of the GNU General Public License
\r
18 along with GtkRadiant; if not, write to the Free Software
\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\r
21 ----------------------------------------------------------------------------------
\r
23 This code has been altered significantly from its original form, to support
\r
24 several games based on the Quake III Arena engine, in the form of "Q3Map2."
\r
26 ------------------------------------------------------------------------------- */
\r
31 #define SURFACE_FUR_C
\r
41 /* -------------------------------------------------------------------------------
\r
45 ------------------------------------------------------------------------------- */
\r
49 runs the fur processing algorithm on a map drawsurface
\r
52 void Fur( mapDrawSurface_t *ds )
\r
54 int i, j, k, numLayers;
\r
55 float offset, fade, a;
\r
56 mapDrawSurface_t *fur;
\r
61 if( ds == NULL || ds->fur || ds->shaderInfo->furNumLayers < 1 )
\r
64 /* get basic info */
\r
65 numLayers = ds->shaderInfo->furNumLayers;
\r
66 offset = ds->shaderInfo->furOffset;
\r
67 fade = ds->shaderInfo->furFade * 255.0f;
\r
70 //% Sys_FPrintf( SYS_VRB, "Fur(): layers: %d offset: %f fade: %f %s\n",
\r
71 //% numLayers, offset, fade, ds->shaderInfo->shader );
\r
73 /* initial offset */
\r
74 for( j = 0; j < ds->numVerts; j++ )
\r
76 /* get surface vert */
\r
77 dv = &ds->verts[ j ];
\r
79 /* offset is scaled by original vertex alpha */
\r
80 a = (float) dv->color[ 0 ][ 3 ] / 255.0;
\r
83 VectorMA( dv->xyz, (offset * a), dv->normal, dv->xyz );
\r
86 /* wash, rinse, repeat */
\r
87 for( i = 1; i < numLayers; i++ )
\r
89 /* clone the surface */
\r
90 fur = CloneSurface( ds, ds->shaderInfo );
\r
97 /* walk the verts */
\r
98 for( j = 0; j < fur->numVerts; j++ )
\r
100 /* get surface vert */
\r
101 dv = &ds->verts[ j ];
\r
103 /* offset is scaled by original vertex alpha */
\r
104 a = (float) dv->color[ 0 ][ 3 ] / 255.0;
\r
107 dv = &fur->verts[ j ];
\r
110 VectorMA( dv->xyz, (offset * a * i), dv->normal, dv->xyz );
\r
113 for( k = 0; k < MAX_LIGHTMAPS; k++ )
\r
115 a = (float) dv->color[ k ][ 3 ] - fade;
\r
117 dv->color[ k ][ 3 ] = 255;
\r
119 dv->color[ k ][ 3 ] = 0;
\r
121 dv->color[ k ][ 3 ] = a;
\r