Surface Files
In 3D World Studio, textures are applied to brush faces for preview purposes. Games, of course, use much more advanced multi-textured-parallax-mapped surfaces and that is where surface files are used. When the content pipeline builds a .3dw file, it loads surface files based on your textures. If you apply 'Nature\GrassyKnoll.png' to a brush face, the surface file 'GrassyKnoll.xml' is loaded, which must be in the same folder as the .3dw file being built.

Here is a sample surface file:
<?xml version="1.0" encoding="utf-8"?>
<surface effect="Effects\Terrain.fx" assetName="Content\Effects\Terrain">
	<texture parameter="Layer1DiffuseTexture" assetName="Content\Textures\grass_01">Textures\grass_01.jpg</texture>
	<texture parameter="Layer2DiffuseTexture" assetName="Content\Textures\sand_03">Textures\sand_03.jpg</texture>
</surface>


Asset Name
You can omit the asset name of the surface file. When the assetName attribute is not set, the default of 'folder + filename - extension' is used. Thus, the effect in the following file would have an XNA Content Name of 'Effects\Terrain' and the textures would be 'Textures\grass_01' and 'Textures\sand_03':
<?xml version="1.0" encoding="utf-8"?>
<surface effect="Effects\Terrain.fx">
	<texture parameter="Layer1DiffuseTexture">Textures\grass_01.jpg</texture>
	<texture parameter="Layer2DiffuseTexture">Textures\sand_03.jpg</texture>
</surface>

If you needed to load the effect in XNA to set some parameters, for instance, you could then use this code from your game:
Effect effect = this.ContentManager.Load<Effect>(@"Effects\Terrain")
effect.Parameters["MyParam"].SetValue(myValue);


Notes:
  • Each <texture /> node must relate to a texture parameter in the .fx file.
  • the assetName attributes are the names you will use at run time if you need to load these assets manually. Typically you should only have to load the .fx file (using the Load<Effect>("Content\Effects\Terrain"); syntax if you need to set special parameters, or more commonly, the WorldViewProjection value each frame.
  • To repeat, you must set the WVP matrix each frame.
  • You can have multiple brushes which all specify the same .fx file but different textures - these will be sorted and handled automatically for you.
  • Terrains load surface files based on their names, so a terrain named 'LargeOutdoorSetting' uses 'LargeOutdoorSetting.xml'.
  • All surface files must have the .xml extension and reside in the same folder as your .3dw file.
  • You do not need to deploy these .xml files with your application, if it makes it easier to debug/program them, you can add them to your project as non-content pipeline assets set to 'do not copy.'

Last edited May 8, 2007 at 11:46 PM by Johnnylightbulb, version 2

Comments

No comments yet.