From Valve Developer Community
Jump to: navigation, search



It's worth using Visual Studio 2005. In addition to the annoying little libcmtd/crtdbg hacks you have to do to build under VS 2008, code that links against Valve's public libraries and uses STL containers will outright crash when built in a debug configuration (see: vbsp). This is presumably due to ODR violations.


Materials using custom shaders are not handled correctly by vbsp. Because vbsp does not load the game shader DLL, the material system falls back to Wireframe_DX6, and the surface is subsequently flagged as SURF_NOLIGHT. [1]

Tony mentions using a perl script to revert all materials to comparable standard shaders before map compilation. Here's my alternative, which is closer to what Marek proposed:

// vbsp, textures.cpp:181

	bool bSetBUMPLIGHT = g_BumpAll || GetMaterialShaderPropertyBool( matID, UTILMATLIB_NEEDS_BUMPED_LIGHTMAPS );
	bool bClearNOLIGHT = GetMaterialShaderPropertyBool( matID, UTILMATLIB_NEEDS_LIGHTMAP ) != 0;

	// HACK: Check to see if it's an unrecognized custom shader; probably needs lightmaps.
		IMaterial* pMaterial = reinterpret_cast<IMaterial*>(matID);
		const char* shaderName = pMaterial->GetShaderName();

		if ( Q_strcmp("Wireframe_DX6", shaderName) == 0 )
			bClearNOLIGHT = true;

			bool bFoundBump;
			pMaterial->FindVar( "$bump", &bFoundBump, false );
			if (bFoundBump)
				bSetBUMPLIGHT = true;
				Msg( "xxx: Enabling bumped lightmap generation on material '%s'\n", pMaterial->GetName() );
				Msg( "xxx: Enabling NON-bumped lightmap generation on material '%s'\n", pMaterial->GetName() );

		textureref[i].flags |= SURF_BUMPLIGHT;

	if (bClearNOLIGHT)
		textureref[i].flags &= ~SURF_NOLIGHT;
	else if ( !g_bLightIfMissing )
		textureref[i].flags |= SURF_NOLIGHT;


Problem: Rebuilding tier1 results in asserts firing during particle load on the client. (utlbuffer.cpp (220) : Assertion Failed: nSize != 0)
Solution: Don't rebuild tier1. This happens automatically when building vbsp; revert the library after you're finished. It's unclear if Valve added this assertion after building the .lib they shipped with.