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