コード例 #1
0
MaterialSystemMaterial_t GetMatIDFromDisp( mapdispinfo_t *pMapDisp )
{
	texinfo_t *pTexInfo = &texinfo[pMapDisp->face.texinfo];
	dtexdata_t *pTexData = GetTexData( pTexInfo->texdata );
	MaterialSystemMaterial_t matID = FindOriginalMaterial( TexDataStringTable_GetString( pTexData->nameStringTableID ), NULL, true );
	return matID;
}
コード例 #2
0
//-----------------------------------------------------------------------------
// Purpose: Finds or adds a texdata for the specified name
// Input  : *pName - texture name
// Output : int index into dtexdata array
//-----------------------------------------------------------------------------
int FindTexData( const char *pName_ )
{
	char *pName = ( char * )_alloca( strlen( pName_ ) + 1 );
	strcpy( pName, pName_ );
	int i, output;
	bool found;
	dtexdata_t *pTexData;
	MaterialSystemMaterial_t matID;

	for ( i = 0; i < numtexdata; i++ )
	{
		char const *tableName = TexDataStringTable_GetString( GetTexData( i )->nameStringTableID );

		if ( !strcmp( pName, tableName ) )
		{
			return i;
		}
	}

	output = numtexdata;
	if ( numtexdata >= MAX_MAP_TEXDATA )
	{
		Error( "MAX_MAP_TEXDATA" );
	}
	pTexData = GetTexData( output );
	numtexdata++;


	// Save the name of the material.
	pTexData->nameStringTableID = TexDataStringTable_AddOrFindString( pName );
	// Get the width, height, view_width, view_height, and reflectivity from the material system.
	matID = FindOriginalMaterial( pName, &found );
	if( matID == MATERIAL_NOT_FOUND || (!found) )
	{
		qprintf( "WARNING: material not found: \"%s\"\n", pName );
		return -1;
	}

	GetMaterialDimensions( matID, &pTexData->width, &pTexData->height );
	pTexData->view_width = pTexData->width;  // undone: what is this?
	pTexData->view_height = pTexData->height;  // undone: what is this?
	
	GetMaterialReflectivity( matID, pTexData->reflectivity.Base() );
	g_SurfaceProperties[output] = GetSurfaceProperties( matID, pName );

#if 0
	Msg( "reflectivity: %f %f %f\n", 
		pTexData->reflectivity[0],
		pTexData->reflectivity[1],
		pTexData->reflectivity[2] );
#endif

	return output;
}
コード例 #3
0
ファイル: textures.cpp プロジェクト: 0xFEEDC0DE64/UltraGame
//-----------------------------------------------------------------------------
// Purpose: Finds or adds a texdata for the specified name
// Input  : *pName - texture name
// Output : int index into dtexdata array
//-----------------------------------------------------------------------------
int FindOrCreateTexData( const char *pName_ )
{
	char *pName = ( char * )_alloca( strlen( pName_ ) + 1 );
	strcpy( pName, pName_ );

	int nOutput = FindTexData( pName );
	if ( nOutput >= 0 )
		return nOutput;

	// Didn't find it, add a new one
	nOutput = numtexdata;
	if ( numtexdata >= MAX_MAP_TEXDATA )
	{
		Error( "Too many unique texture mappings, max = %d\n", MAX_MAP_TEXDATA );
	}
	dtexdata_t *pTexData = GetTexData( nOutput );
	numtexdata++;

	// Save the name of the material.
	pTexData->nameStringTableID = TexDataStringTable_AddOrFindString( pName );

	// Get the width, height, view_width, view_height, and reflectivity from the material system.
	bool bFound;
	MaterialSystemMaterial_t matID = FindOriginalMaterial( pName, &bFound );
	if ( matID == MATERIAL_NOT_FOUND || (!bFound) )
	{
		qprintf( "WARNING: material not found: \"%s\"\n", pName );
		return nOutput;
	}

	GetMaterialDimensions( matID, &pTexData->width, &pTexData->height );
	pTexData->view_width = pTexData->width;  // undone: what is this?
	pTexData->view_height = pTexData->height;  // undone: what is this?
	
	GetMaterialReflectivity( matID, pTexData->reflectivity.Base() );
	g_SurfaceProperties[nOutput] = GetSurfaceProperties( matID, pName );

#if 0
	Msg( "reflectivity: %f %f %f\n", 
		pTexData->reflectivity[0],
		pTexData->reflectivity[1],
		pTexData->reflectivity[2] );
#endif

	return nOutput;
}
コード例 #4
0
ファイル: textures.cpp プロジェクト: 0xFEEDC0DE64/UltraGame
//-----------------------------------------------------------------------------
// Purpose: Finds or adds a texdata for the specified name ( same as below except
//   instead of finding the named texture, copies the settings from the passed
//  in sourceTexture. )
// Used for creation of one off .vmt files for water surface textures
// Input  : *pName - texture name
// Output : int index into dtexdata array
//-----------------------------------------------------------------------------
int FindAliasedTexData( const char *pName_, dtexdata_t *sourceTexture )
{
	char *pName = ( char * )_alloca( strlen( pName_ ) + 1 );
	strcpy( pName, pName_ );
	strlwr( pName );
	int i, output;
	bool found;
	dtexdata_t *pTexData;
	MaterialSystemMaterial_t matID;

	for ( i = 0; i < numtexdata; i++ )
	{
		if ( !strcmp( pName, TexDataStringTable_GetString( GetTexData( i )->nameStringTableID ) ) )
			return i;
	}


	output = numtexdata;
	if ( numtexdata >= MAX_MAP_TEXDATA )
	{
		Error( "Too many unique texture mappings, max = %d\n", MAX_MAP_TEXDATA );
	}
	pTexData = GetTexData( output );
	numtexdata++;

	// Save the name of the material.
	pTexData->nameStringTableID = TexDataStringTable_AddOrFindString( pName );

	// Get the width, height, view_width, view_height, and reflectivity from the material system.
	matID = FindOriginalMaterial( TexDataStringTable_GetString( sourceTexture->nameStringTableID ), &found, false );
	if( matID == MATERIAL_NOT_FOUND || (!found) )
	{
		qprintf( "WARNING: material not found: \"%s\"\n", pName );
		return -1;
	}

	GetMaterialDimensions( matID, &pTexData->width, &pTexData->height );
	pTexData->view_width = pTexData->width;  // undone: what is this?
	pTexData->view_height = pTexData->height;  // undone: what is this?
	
	GetMaterialReflectivity( matID, pTexData->reflectivity.Base() );
	g_SurfaceProperties[output] = GetSurfaceProperties( matID, pName );

	return output;
}
コード例 #5
0
ファイル: textures.cpp プロジェクト: 0xFEEDC0DE64/UltraGame
int	FindMiptex (const char *name)
{
	int		i;
	MaterialSystemMaterial_t matID;
	const char *propVal, *propVal2;
	int opacity;
	bool found;
		
	for (i=0 ; i<nummiptex ; i++)
	{
		if (!strcmp (name, textureref[i].name))
		{
			return i;
		}
	}
	if (nummiptex == MAX_MAP_TEXTURES)
		Error ("Too many unique textures, max %d", MAX_MAP_TEXTURES);
	strcpy (textureref[i].name, name);

	textureref[i].lightmapWorldUnitsPerLuxel = 0.0f;
	textureref[i].flags = 0;
	textureref[i].contents = 0;

	matID = FindOriginalMaterial( name, &found );
	if( matID == MATERIAL_NOT_FOUND )
	{
		return 0;
	}

	if (!found)
		Warning("Material not found!: %s\n", name );

	// HANDLE ALL OF THE STUFF THAT ISN'T RENDERED WITH THE MATERIAL THAT IS ONE IT.
	
	// handle sky
	if( ( propVal = GetMaterialVar( matID, "%compileSky" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= SURF_SKY | SURF_NOLIGHT;
	}
	else if( ( propVal = GetMaterialVar( matID, "%compile2DSky" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= SURF_SKY | SURF_SKY2D | SURF_NOLIGHT;
	}
	// handle hint brushes
	else if ( ( propVal = GetMaterialVar( matID, "%compileHint" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT | SURF_HINT;
	}
	// handle skip faces
	else if ( ( propVal = GetMaterialVar( matID, "%compileSkip" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT | SURF_SKIP;
	}
	// handle origin brushes
	else if ( ( propVal = GetMaterialVar( matID, "%compileOrigin" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].contents |= CONTENTS_ORIGIN | CONTENTS_DETAIL;
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
	}
	// handle clip brushes
	else if ( ( propVal = GetMaterialVar( matID, "%compileClip" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].contents |= CONTENTS_PLAYERCLIP | CONTENTS_MONSTERCLIP;
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
	}
	else if ( ( propVal = GetMaterialVar( matID, "%playerClip" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].contents |= CONTENTS_PLAYERCLIP;
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
	}
	// handle npc clip brushes
	else if ( ( propVal = GetMaterialVar( matID, "%compileNpcClip" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].contents |= CONTENTS_MONSTERCLIP;
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
	}
	// handle surface lights which are meant to 
	else if ( ( propVal = GetMaterialVar( matID, "%compileNoChop" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= SURF_NOCHOP;
	}
	// handle triggers
	else if ( ( propVal = GetMaterialVar( matID, "%compileTrigger" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= ( SURF_NOLIGHT | SURF_TRIGGER );
		if ( g_NodrawTriggers )
		{
			textureref[i].flags |= SURF_NODRAW;
		}
	}
	// handle nolight surfs (except water)
	else if ( (( propVal = GetMaterialVar( matID, "%compileNoLight" ) ) && StringIsTrue( propVal )) && 
		!(( propVal2 = GetMaterialVar( matID, "%compileWater" ) ) && StringIsTrue( propVal2 ) ) )
	{
		textureref[i].flags |= SURF_NOLIGHT;
	}
	else
	{
		// HANDLE ALL OF THE STUFF THAT IS RENDERED WITH THE MATERIAL THAT IS ON IT.

		// Handle ladders.
		if ( ( propVal = GetMaterialVar( matID, "%compileLadder" ) ) &&	StringIsTrue( propVal ) )
		{
			textureref[i].contents |= CONTENTS_LADDER;
		}

		// handle wet materials
		if ( ( propVal = GetMaterialVar( matID, "%noPortal" ) ) &&
			StringIsTrue( propVal ) )
		{
			textureref[i].flags |= SURF_NOPORTAL;
		}

		if ( ( propVal = GetMaterialVar( matID, "%compilePassBullets" ) ) && StringIsTrue( propVal ) )
		{
			// change contents to grate, so bullets pass through
			// NOTE: This has effects on visibility too!
			textureref[i].contents &= ~CONTENTS_SOLID;
			textureref[i].contents |= CONTENTS_GRATE;
		}

		if( g_BumpAll || GetMaterialShaderPropertyBool( matID, UTILMATLIB_NEEDS_BUMPED_LIGHTMAPS ) )
		{
			textureref[i].flags |= SURF_BUMPLIGHT;
		}
		
		if( GetMaterialShaderPropertyBool( matID, UTILMATLIB_NEEDS_LIGHTMAP ) )
		{
			textureref[i].flags &= ~SURF_NOLIGHT;
		}
		else if( !g_bLightIfMissing )
		{
			textureref[i].flags |= SURF_NOLIGHT;
		}
		// handle nodraw faces/brushes
		if ( ( propVal = GetMaterialVar( matID, "%compileNoDraw" ) ) && StringIsTrue( propVal ) )
		{								    
			//		textureref[i].contents |= CONTENTS_DETAIL;
			textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
		}

		// Just a combination of nodraw + pass bullets, makes things easier
		if ( ( propVal = GetMaterialVar( matID, "%compileInvisible" ) ) && StringIsTrue( propVal ) )
		{								    
			// change contents to grate, so bullets pass through
			// NOTE: This has effects on visibility too!
			textureref[i].contents &= ~CONTENTS_SOLID;
			textureref[i].contents |= CONTENTS_GRATE;
			textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
		}

		bool checkWindow = true;
		// handle non solid
		if ( ( propVal = GetMaterialVar( matID, "%compileNonsolid" ) ) && StringIsTrue( propVal ) )
		{
			textureref[i].contents = CONTENTS_OPAQUE;
			// Non-Solid can't be a window either!
			checkWindow = false;
		}
		// handle block LOS
		if ( ( propVal = GetMaterialVar( matID, "%compileBlockLOS" ) ) && StringIsTrue( propVal ) )
		{
			textureref[i].contents = CONTENTS_BLOCKLOS;

			// BlockLOS can't be a window either!
			checkWindow = false;
		}

		if ( ( propVal = GetMaterialVar( matID, "%compileDetail" ) ) &&
			StringIsTrue( propVal ) )
		{
			textureref[i].contents |= CONTENTS_DETAIL;
		}

		bool bKeepLighting = ( ( propVal = GetMaterialVar( matID, "%compileKeepLight" ) ) &&
			StringIsTrue( propVal ) );

		// handle materials that want to be treated as water.
		if ( ( propVal = GetMaterialVar( matID, "%compileWater" ) ) &&
			StringIsTrue( propVal ) )
		{
			textureref[i].contents &= ~(CONTENTS_SOLID|CONTENTS_DETAIL);
			textureref[i].contents |= CONTENTS_WATER;
			textureref[i].flags |= SURF_WARP | SURF_NOSHADOWS | SURF_NODECALS;

			if ( g_DisableWaterLighting && !bKeepLighting )
			{
				textureref[i].flags |= SURF_NOLIGHT;
			}

			// Set this so that we can check at the end of the process the presence of a a WaterLODControl entity.
			g_bHasWater = true;
		}
		const char *pShaderName = GetMaterialShaderName(matID);
		if ( !bKeepLighting && !Q_strncasecmp( pShaderName, "water", 5 ) || !Q_strncasecmp( pShaderName, "UnlitGeneric", 12 ) )
		{
			//if ( !(textureref[i].flags & SURF_NOLIGHT) )
			//	Warning("Forcing lit materal %s to nolight\n", name );
			textureref[i].flags |= SURF_NOLIGHT;
		}

		if ( ( propVal = GetMaterialVar( matID, "%compileSlime" ) ) &&
			StringIsTrue( propVal ) )
		{
			textureref[i].contents &= ~(CONTENTS_SOLID|CONTENTS_DETAIL);
			textureref[i].contents |= CONTENTS_SLIME;
			textureref[i].flags |= SURF_NODECALS;
			// Set this so that we can check at the end of the process the presence of a a WaterLODControl entity.
			g_bHasWater = true;
		}
	
		opacity = GetMaterialShaderPropertyInt( matID, UTILMATLIB_OPACITY );
		
		if ( checkWindow && opacity != UTILMATLIB_OPAQUE )
		{
			// transparent *and solid* brushes that aren't grates or water must be windows
			if ( !(textureref[i].contents & (CONTENTS_GRATE|CONTENTS_WATER)) )
			{
				textureref[i].contents |= CONTENTS_WINDOW;
			}

			textureref[i].contents &= ~CONTENTS_SOLID;
			
			// this affects engine primitive sorting, SURF_TRANS means sort as a translucent primitive
			if ( opacity == UTILMATLIB_TRANSLUCENT )
			{
				textureref[i].flags |= SURF_TRANS;
			}
			
		}
		if ( textureref[i].flags & SURF_NOLIGHT )
		{
			textureref[i].flags &= ~SURF_BUMPLIGHT;
		}
	}

	nummiptex++;

	return i;
}
コード例 #6
0
//-----------------------------------------------------------------------------
// Places Detail Objects in the level
//-----------------------------------------------------------------------------
void EmitDetailModels()
{
	StartPacifier("Placing detail props : ");

	// Place stuff on each face
	dface_t* pFace = dfaces;
	for (int j = 0; j < numfaces; ++j)
	{
		UpdatePacifier( (float)j / (float)numfaces );

		// Get at the material associated with this face
		texinfo_t* pTexInfo = &texinfo[pFace[j].texinfo];
		dtexdata_t* pTexData = GetTexData( pTexInfo->texdata );

		// Try to get at the material
		bool found;
		MaterialSystemMaterial_t handle = 
			FindOriginalMaterial( TexDataStringTable_GetString( pTexData->nameStringTableID ), 
						  &found, false );
		if (!found)
			continue;

		// See if its got any detail objects on it
		const char* pDetailType = GetMaterialVar( handle, "%detailtype" );
		if (!pDetailType)
			continue;

		// Get the detail type...
		DetailObject_t search;
		search.m_Name = pDetailType;
		int objectType = s_DetailObjectDict.Find(search);
		if (objectType < 0)
		{
			Warning("Material %s uses unknown detail object type %s!\n",	
				TexDataStringTable_GetString( pTexData->nameStringTableID ),
				pDetailType);
			continue;
		}

		// Emit objects on a particular face
		DetailObject_t& detail = s_DetailObjectDict[objectType];

		if (pFace[j].dispinfo < 0)
		{
			EmitDetailObjectsOnFace( &pFace[j], detail );
		}
		else
		{
			// Get a CCoreDispInfo. All we need is the triangles and lightmap texture coordinates.
			mapdispinfo_t *pMapDisp = &mapdispinfo[pFace[j].dispinfo];
			CCoreDispInfo coreDispInfo;
			DispMapToCoreDispInfo( pMapDisp, &coreDispInfo, &pFace[j] );

			EmitDetailObjectsOnDisplacementFace( &pFace[j], detail, coreDispInfo );
		}
	}

	// Emit specifically specified detail props
	Vector origin;
	QAngle angles;
	Vector2D pos[2];
	Vector2D tex[2];
	for (int i = 0; i < num_entities; ++i)
	{
		char* pEntity = ValueForKey(&entities[i], "classname");
		if (!strcmp(pEntity, "detail_prop") || !strcmp(pEntity, "prop_detail"))
		{
			GetVectorForKey( &entities[i], "origin", origin );
			GetAnglesForKey( &entities[i], "angles", angles );
			char* pModelName = ValueForKey( &entities[i], "model" );
			int nOrientation = IntForKey( &entities[i], "detailOrientation" );

			AddDetailToLump( pModelName, origin, angles, nOrientation );

			// strip this ent from the .bsp file
			entities[i].epairs = 0;
			continue;
		}

		if (!strcmp(pEntity, "prop_detail_sprite"))
		{
			GetVectorForKey( &entities[i], "origin", origin );
			GetAnglesForKey( &entities[i], "angles", angles );
			int nOrientation = IntForKey( &entities[i], "detailOrientation" );
			GetVector2DForKey( &entities[i], "position_ul", pos[0] );
			GetVector2DForKey( &entities[i], "position_lr", pos[1] );
			GetVector2DForKey( &entities[i], "tex_ul", tex[0] );
			GetVector2DForKey( &entities[i], "tex_size", tex[1] );
			float flTextureSize = FloatForKey( &entities[i], "tex_total_size" );

			tex[1].x += tex[0].x - 0.5f;
			tex[1].y += tex[0].y - 0.5f;
			tex[0].x += 0.5f;
			tex[0].y += 0.5f;
			tex[0] /= flTextureSize;
			tex[1] /= flTextureSize;

			AddDetailSpriteToLump( origin, angles, nOrientation, pos, tex, 1.0f );

			// strip this ent from the .bsp file
			entities[i].epairs = 0;
			continue;
		}
	}

	EndPacifier( true );
}
コード例 #7
0
int	FindMiptex (const char *name)
{
	int		i;
	MaterialSystemMaterial_t matID;
	const char *propVal;
	int opacity;
	bool found;
		
	for (i=0 ; i<nummiptex ; i++)
	{
		if (!strcmp (name, textureref[i].name))
		{
			return i;
		}
	}
	if (nummiptex == MAX_MAP_TEXTURES)
		Error ("MAX_MAP_TEXTURES");
	strcpy (textureref[i].name, name);

	textureref[i].lightmapWorldUnitsPerLuxel = 0.0f;
	textureref[i].flags = 0;
	textureref[i].contents = 0;

	matID = FindOriginalMaterial( name, &found );
	if( matID == MATERIAL_NOT_FOUND )
	{
		return 0;
	}

	if (!found)
		Warning("Material not found!: %s\n", name );

	// HANDLE ALL OF THE STUFF THAT ISN'T RENDERED WITH THE MATERIAL THAT IS ONE IT.
	
	// handle sky
	if( ( propVal = GetMaterialVar( matID, "%compileSky" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= SURF_SKY | SURF_NOLIGHT;
	}
	// handle hint brushes
	else if ( ( propVal = GetMaterialVar( matID, "%compileHint" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT | SURF_HINT;
	}
	// handle skip faces
	else if ( ( propVal = GetMaterialVar( matID, "%compileSkip" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT | SURF_SKIP;
	}
	// handle origin brushes
	else if ( ( propVal = GetMaterialVar( matID, "%compileOrigin" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].contents |= CONTENTS_ORIGIN | CONTENTS_DETAIL;
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
	}
	// handle clip brushes
	else if ( ( propVal = GetMaterialVar( matID, "%compileClip" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].contents |= CONTENTS_PLAYERCLIP | CONTENTS_MONSTERCLIP;
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
	}
	// handle npc clip brushes
	else if ( ( propVal = GetMaterialVar( matID, "%compileNpcClip" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].contents |= CONTENTS_MONSTERCLIP;
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
	}
	// handle triggers
	else if ( ( propVal = GetMaterialVar( matID, "%compileTrigger" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= SURF_NOLIGHT;
	}
	else if ( ( propVal = GetMaterialVar( matID, "%compilePlayerControlClip" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].contents |= CONTENTS_DETAIL | CONTENTS_MIST;
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
	}
	else
	{
		// HANDLE ALL OF THE STUFF THAT IS RENDERED WITH THE MATERIAL THAT IS ON IT.

		// Handle ladders.
		if ( ( propVal = GetMaterialVar( matID, "%compileLadder" ) ) &&	StringIsTrue( propVal ) )
		{
			textureref[i].contents |= CONTENTS_LADDER;
		}

		// handle wet materials
		if ( ( propVal = GetMaterialVar( matID, "%compileWet" ) ) &&
			StringIsTrue( propVal ) )
		{
			textureref[i].flags |= SURF_WET;
		}

		if ( ( propVal = GetMaterialVar( matID, "%compilePassBullets" ) ) && StringIsTrue( propVal ) )
		{
			// change contents to grate, so bullets pass through
			// NOTE: This has effects on visibility too!
			textureref[i].contents &= ~CONTENTS_SOLID;
			textureref[i].contents |= CONTENTS_GRATE;
		}

		if( g_BumpAll || GetMaterialShaderPropertyBool( matID, UTILMATLIB_NEEDS_BUMPED_LIGHTMAPS ) )
		{
			textureref[i].flags |= SURF_BUMPLIGHT;
		}
		
		if( GetMaterialShaderPropertyBool( matID, UTILMATLIB_NEEDS_LIGHTMAP ) )
		{
			textureref[i].flags &= ~SURF_NOLIGHT;
		}
		else if( !g_bLightIfMissing )
		{
			textureref[i].flags |= SURF_NOLIGHT;
		}

		// handle nodraw faces/brushes
		if ( ( propVal = GetMaterialVar( matID, "%compileNoDraw" ) ) && StringIsTrue( propVal ) )
		{								    
			//		textureref[i].contents |= CONTENTS_DETAIL;
			textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
		}

		// Just a combination of nodraw + pass bullets, makes things easier
		if ( ( propVal = GetMaterialVar( matID, "%compileInvisible" ) ) && StringIsTrue( propVal ) )
		{								    
			// change contents to grate, so bullets pass through
			// NOTE: This has effects on visibility too!
			textureref[i].contents &= ~CONTENTS_SOLID;
			textureref[i].contents |= CONTENTS_GRATE;
			textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
		}

		bool checkWindow = true;
		// handle non solid
		if ( ( propVal = GetMaterialVar( matID, "%compileNonsolid" ) ) &&
			StringIsTrue( propVal ) )
		{
			textureref[i].contents = CONTENTS_OPAQUE;
			
			// Non-Solid can't be a window either!
			checkWindow = false;
		}

		if ( ( propVal = GetMaterialVar( matID, "%compileDetail" ) ) &&
			StringIsTrue( propVal ) )
		{
			textureref[i].contents |= CONTENTS_DETAIL;
		}

		// handle materials that want to be treated as water.
		if ( ( propVal = GetMaterialVar( matID, "%compileWater" ) ) &&
			StringIsTrue( propVal ) )
		{
			textureref[i].contents &= ~(CONTENTS_SOLID|CONTENTS_DETAIL);
			textureref[i].contents |= CONTENTS_WATER;
			textureref[i].flags |= SURF_WARP;
		}
		if ( ( propVal = GetMaterialVar( matID, "%compileSlime" ) ) &&
			StringIsTrue( propVal ) )
		{
			textureref[i].contents &= ~(CONTENTS_SOLID|CONTENTS_DETAIL);
			textureref[i].contents |= CONTENTS_SLIME;
			//textureref[i].flags |= SURF_WARP;
		}
	
		opacity = GetMaterialShaderPropertyInt( matID, UTILMATLIB_OPACITY );
		
		if ( checkWindow && opacity != UTILMATLIB_OPAQUE )
		{
			// transparent *and solid* brushes that aren't grates or water must be windows
			if ( !(textureref[i].contents & (CONTENTS_GRATE|CONTENTS_WATER)) )
			{
				textureref[i].contents |= CONTENTS_WINDOW;
			}

			textureref[i].contents &= ~CONTENTS_SOLID;
			
			// this affects engine primitive sorting, SURF_TRANS means sort as a translucent primitive
			if ( opacity == UTILMATLIB_TRANSLUCENT )
			{
				textureref[i].flags |= SURF_TRANS;
			}
			
		}

	}

	nummiptex++;

	return i;
}