1 /* -------------------------------------------------------------------------------
3 Copyright (C) 1999-2007 id Software, Inc. and contributors.
4 For a list of contributors, see the accompanying CONTRIBUTORS file.
6 This file is part of GtkRadiant.
8 GtkRadiant is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 GtkRadiant is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GtkRadiant; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 ----------------------------------------------------------------------------------
24 This code has been altered significantly from its original form, to support
25 several games based on the Quake III Arena engine, in the form of "Q3Map2."
27 ------------------------------------------------------------------------------- */
42 /* -------------------------------------------------------------------------------
46 ------------------------------------------------------------------------------- */
50 runs the fur processing algorithm on a map drawsurface
53 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 ) {
66 numLayers = ds->shaderInfo->furNumLayers;
67 offset = ds->shaderInfo->furOffset;
68 fade = ds->shaderInfo->furFade * 255.0f;
71 //% Sys_FPrintf( SYS_VRB, "Fur(): layers: %d offset: %f fade: %f %s\n",
72 //% numLayers, offset, fade, ds->shaderInfo->shader );
75 for ( j = 0; j < ds->numVerts; j++ )
77 /* get surface vert */
80 /* offset is scaled by original vertex alpha */
81 a = (float) dv->color[ 0 ][ 3 ] / 255.0;
84 VectorMA( dv->xyz, ( offset * a ), dv->normal, dv->xyz );
87 /* wash, rinse, repeat */
88 for ( i = 1; i < numLayers; i++ )
90 /* clone the surface */
91 fur = CloneSurface( ds, ds->shaderInfo );
100 for ( j = 0; j < fur->numVerts; j++ )
102 /* get surface vert */
103 dv = &ds->verts[ j ];
105 /* offset is scaled by original vertex alpha */
106 a = (float) dv->color[ 0 ][ 3 ] / 255.0;
109 dv = &fur->verts[ j ];
112 VectorMA( dv->xyz, ( offset * a * i ), dv->normal, dv->xyz );
115 for ( k = 0; k < MAX_LIGHTMAPS; k++ )
117 a = (float) dv->color[ k ][ 3 ] - fade;
119 dv->color[ k ][ 3 ] = 255;
122 dv->color[ k ][ 3 ] = 0;
125 dv->color[ k ][ 3 ] = a;