Volumetric rendering got popular theese days and many modern effects such as volumeric fog, godrays, procedural clouds are built from base 3D noise. Usually it is low-resolution perlin/worley noise at various octaves combined into multiple layers. For example, Lost Squad uses 128x128x128 3D noise texture to build procedural clouds.
But it's not immidiately clear how to compile such texture into Source. VTFEditor won't help you with that, moreover, it may corrupt your texture or render it with artifacts so forget about VTFEditor at all - we are going to work with vtex.exe only.
An example 3D texture we use to build our procedural clouds.
Notice the amount of Slices there which means this is a 3D texture with 128 layers
1. It is supposed that you already know how to create a 3D texture. Tutorial won't cover the process of creation it, but it's not hard, more like just time consuming.
2. Generate n-amount of 2D layers of your future 3D texture or split existing 3D texture into multiple 2D layers (if you are using Photoshop you might need to export each layer in Photoshop as separate file. To do this go to File->Scripts->Export each layer as separate file...). Make sure each layer is a .tga image file (or .psd if you really want to). Then you must give a name to each layer using the following format:
where yourfilename - is any name (but make sure the name is not too long, because vtex.exe has limit of 2048 characters per line and if you try to compile high amount of layers it may fail to process compile command if you specify all file names in it) and x - is a frame number (starting from 0). NOTE: amount of layers must be power of 2 as well!
3. Go to materialsrc folder of your mod (if you don't have this folder - create it), create some subfolder in it, for example 'volumetric' and put your .tga layers there.
4. Create a .txt file with the name of your 3D texture (without _zxxx stuff) where you need to write:
where n is amount of layers.
NOTE: you can also specify each filename if you really want to. It will look like this:
in other words, put all filenames of your layers there and make sure you don't have spaces between commas and file names. But it may not work with older versions of vtex.exe.
5. Add a line containing
It's very important to turn compression off or 3D textures might not work correctly. NOTE: for some reason, vtex.exe compiles textures with BGRA8888 format instead of RGBA8888. Keep that in mind!
6. Go to game-you-modding bin folder (for example Source SDK Base 2013/bin) and find vtex.exe. For better usability, make a shorcut of it in your materialsrc folder with .tga's and .txt. NOTE: I suggest using CS:GO's or Insurgency's vtex.exe instead of Alien Swarm's one since it is more up-to-date and faster than ASw's mess.
7. Drag-n-drop your .txt on vtex.exe shortcut and enjoy. A volumetric texture should appear in yourmod materials/volumetric fodler.
That's pretty much all of it! Hope this tutorial was useful for you and happy volumetring!
The following images are our results of procedural clouds generated from 3D Perlin-Worley noise in realtime.