• Register

On May 1st 2019, VRDB.com and SlideDB.com were closed. We no longer support VR, AR, iOS or Android only games. We are focused on PC, console and moddable games. If this is your project and you would like to release it on IndieDB, please contact us with the details.

A massive demonic invasion has overwhelmed the Union Aerospace Corporation's Mars Research Facility, leaving only chaos and horror in its wake. As one of only a few survivors, you must fight your way to hell and back against a horde of evil monsters.

Post tutorial Report RSS Material Shaders for Id Tech 4 (Doom 3)

Using the Textures created in my 'Building Texture maps for Material Shaders using Photoshop' Tutorial, we go through the process of getting a Basic, fully functioning Material Shader working on the Id Tech 4 engine through the use of Doom 3.

Posted by on - Basic Textures


Basic - Material Shaders for Id Tech 4 (Doom 3)


Author : K1chi - k1chi@hotmail.co.uk

 

Table of Contents


    1. Tutorial Overview


    2. Requirements


    3. Reccomended Listening



    1. General Overview


    2. Folder Structure


  1. Step Two - Texture Maps
    1. Location and naming convention

  2. Step Three - Material Shaders
    1. Material Structure
    2. Creating our Material

  3. Step Four - Working Ingame
    1. Setting up the Doom 3 Editor
    2. Applying our Material
    3. Ingame

  4. Step Five - Conclusion
    1. Tutorial Recap
    2. See Also
    3. Resources



Introduction

Tutorial Overview


In this tutorial we are going to cover the steps necassary for creating a basic but super cool Material Shader working on the Id Tech 4 engine. We're using Doom 3 as the base, though much of what I'm going to cover will transfer almost directly over to other Id Tech 4 games, such as ETQW, Quake 4 and Prey. This tutorial does not cover actually building the Texture Maps required for a Material Shader. If this is what you're looking for please take a look at another Tutorial of mine, as it uses the same Texture's I will be incorporating here:

 


Please note (and I say this at the beginning of all tutorials) that there is never only ONE way of doing things, and my way is not necassarily the best for what you want to do. My advice is to use as many resources as possible which you then use those to develop YOUR way of doing things. This is your art so do whatever works best for you, because at the end of the day there is no right or wrong way when it comes to this stuff. Also I like to be quite thorough with my tutorials, so if you're looking for a quick and easy ‘step by step' solution with no babbling you may become quite frustrated with my style of writing, as I try to explain the logic for all my creative decisions as much as possible. However if you're looking for a comprehensive and detailed account of how I personally choose to do things, you've come to the right place.


Requirements

  • Doom 3

    • Cheap as chips now, pick it up anywhere selling games for a good price



    • Really all you need is a piece of basic text editing software, even notepad will do the job quite nicely, but Context is a generally excellent piece of kit and I like to use it whereever I can for coding or scripting.



    • You'll need this to access Doom 3's internal files, and to eventually pack your work together for distribution.



  • A Selection of Texture Maps


  • Adobe Photoshop

    • You'll only need this if you haven't created textures, or if you have but they're saved in any format other than .TGA, which is what Doom 3 requires.





Reccomended Listening


Irrelevant? Yes, but I like to keep this stuff as informal and easy going as possible! During this tutorial I'm listening to:

 

J'menfous

These guys are absolutely wicked. From Geneva in Switzerland, the music's pretty hard to describe, 'crazy' would just about do it. They manage to combine some spectacular musicianship (jumping from time signature to time signature like noone's business), a sound which despite often being comparable to a car wreck is brimming with melody, a genuine, zero-bullshit attitude and monster fun live show into one seriously sweet package. Gigged with them a few times now, awesome folk, awesome music, can never get enough of them.


 

Thankyou for your time, I hope you enjoy the tutorial and please forward any feedback to k1chi@hotmail.co.uk

 


Step One : Getting to Grips with Id Tech 4 (Doom 3)

General Overview


Doom 3 (at the time of writing) is getting on a bit. Released in 2004, the game was at the cutting edge of Graphic Technology, though by comparison is now largely overshadowed by the likes of UE3, CryEngine 2 and its own successor, Id Tech 5.

However while there are some truly fantastic mods approaching on the engine, the above fact, coupled with the judgments many make about the engine's capabilities (largely due to Doom 3's dedication to ultra dark to the point of pitch black settings), means that many overlook what is still essentially a powerful piece of kit, for newer game engines. Enemy Territory: Quake Wars enhanced and faced many of these judgments, but even the initial base of Id Tech 4 is very capable of producing vivid, varied scenes. Take a look at the image below



Please note that i did not create the above image, it is the work of an extremely talented artist who you can find over at www.doom3world.org under the username 'modern'. Yes, this is using Doom 3.


The real benefits to be gained from using Id Tech 4 as a means of presenting your work, are the power of it's visuals (fully dynamic lighting and unified surfaces really brings things to life) and it's surprising level of simplicity. Doom 3 was the first game I ever tried modding and although I've ventured further since then, I am still awestruck by it's user friendly nature. Don't get me wrong it can be rather intimidating at first, but once you tap into the logic you're really only limited by your imagination.


Folder Structure


Ok first and foremost let's just familiarise ourselves with the framework within which we are to be working on this tutorial.

Go into your root folder for Doom 3. Personally I find it makes life alot easier to have Doom 3 installed directly to my hard drive at base level, so in my case the folder I want is:

D:/Doom3

Yes I truly am that simple. Now take a look inside this folder and you'll see another folder called base, so lets open it up. If you've never modded Doom 3 before this folder will only have a few .dll files, maybe a .cfg and a selection of archive files with the suffix .pk4, these are called PAKs.

PAK files basically hold all the assets that the engine uses to run the game. Models, Textures, Scripts, Maps, they're all in here though most are in a compressed format unique to this engine.

To open a PAK file simpley double cllick on it, then use WinRar to view it's contents. If you spend 10 or 15 minutes having a look through the different PAK's you'll quickly get an idea for how things are organised. Now I'm not going to go into massive amounts of detail regarding these because there is simpley no need, all we're interested in is how the Textures and Materials work for Doom 3.

To put things simpley, we are going to put the actual Texture files within a subdirectory of the Texture folder, and our Material's will sit inside the Materials folder, from which they will provide the engine with information on how to render the Textures together.

We're going to put these Textures and Materials directly into Doom 3, so let's exit the PAK files and go back to the Doom3/base directory. Let's just create two new folders, one named Textures and another named Materials. You could just extract these folders straight out of the PAK files, but this could take an age and really isn't necassary for what we're doing.

That's all we need for now so let's just leave it at that, we need to get some real content before we can set anything else up at this level.


Step Two - Texture Maps


Alright then let's punch up Photoshop and bring in our Textures from the previous tutorial.

The only other thing we have to do now that we're working in Doom3 is create an editor image. This is basically a thumbnail, or a preview. For this I just take my diffuse map and shrink it down to 128x128pixels.

We'll assume that this Material is going to be part of a mod in it's own right, so it's therefore likely that there will be other textures, so we need to pick a file name and folder structure which allows us to work efficiently.

I discussed this breifly in the previous Tutorial, and exactly how you save things is up to you. This is the folder structure I have built for these textures to reside in:

D:/Doom3/base/textures/walls/concrete

My logic? First of all we're in the base folder anyway, we're saving a texture, it's a wall texture, and it's concrete. All of our textures in this Shader need to have the same name because they're essentially part of the same Material file, so lets just go with 'crete01'. We use suffix's relative to the Texture Map types to distinguish between them and to avoid overwrite errors.

So let's save our textures using these suffix's. Remember they NEED to be in .TGA format and keep all your file names lowercase.

  • Editor Map = _ed
    • crete01_ed.tga

  • Diffuse Map = _d
    • crete01_d.tga

  • Normal Map = _local
    • crete01_local.tga

  • Specular Map = _s
    • crete01_s.tga

So now we should have a nice collection of files with the following locations (alteast from the base folder onwards):

  • D:/Doom3/base/textures/walls/concrete/crete01_ed.tga
  • D:/Doom3/base/textures/walls/concrete/crete01_d.tga
  • D:/Doom3/base/textures/walls/concrete/crete01_local.tga
  • D:/Doom3/base/textures/walls/concrete/crete01_s.tga

That's all we need for this part of the tutorial, so lets move on to setting up a material to get them working in game!


Step Three - Material Shaders

Material Structure


First allow me to just explain how the Material Shader actually does it's business, because while it can seem a bit daunting at first the actual principle is extremely simple. However just because it's simple doesn't mean it's not brimming with potential. You can do some seriously cool stuff with Id Tech 4's Material Shaders, but these will be covered in a later tutorial, as for now our only concern is the essentials required to have a basic shader working.

If you want to look at things in a really basic sense, you can consider these Material Shaders to be the sum of two parts

  • The Material Name

    • This is quite literally the name and location of the Material within the game engine

  • The Material Stages

    • A selection of lines which tell the Material where it can find each of the required Texture Maps

I'll use an existing Doom 3 Material as an example. See below:



Note that the normalmap is actually refered to as bumpmap, the logic of using two different definitions for a single asset is beyond me. The section highlighted in red is the title of our Material. Notice how it isn't just a filename though, but infact includes an address. You can think of this as a 'virtual folder structure', because although it is a structure which does not physically exist on your harddrive, it does exist within the engine.

The section highlighted in green defines which textures are to be used for each stage of the Material. Each of these stages consists of two parts,

  • (on the left half) The Texture Map Definition
    • This tells the engine what texture map to use, for example Diffuse or Normal.

  • (on the right half) The Texture Map Location
    • This tells the engine which texture you want to use for this definition.

What's cool about this is that you can easily use the same texture on multiple different Material Shaders. Say for example you have a metal texture which is quite dirty, but then you have another one which is identical but for having a slightly more shiney surface. You could just create a new Material Name, use the same Normal and Diffuse Definitions as before, but just refer to a different specular map to create the desired effect.

Here I have drawn a diagram which basically expresses this visually. This is pretty much how the game engine is going to read our Material file too, by loading specific Texture Maps as instructed by the Stages in the Material Shader, and bringing them together to form one final product.



Don't worry about some of the extra files they're probably left-overs from during development or used by different Materials. Now we basically understand how Id Tech 4 reads Material Shaders and what rules we need to follow to create our own, it's time to actually build one and get it working in game.


Creating our Material


Alright jump into your the folder with your textures (as stated above this should ideally be something like base/textures/walls/concrete. Whatever you go with BE SURE to remember it as it'll be very important here) and it's contents should look similar to this (I have added the actual texture images from the last tutorial, just as a reminder of which are which)



Let's get this Material file built.

We need to open up Context, start a new document and save it in our materials folder as walls.mtr. Note that it NEEDS to be saved in MTR format so that the Game Engine can read it. Also note that you don't need an entire .mtr file for each Material Shader you want. We can place as many Material Shaders as desired into a single .mtr file, but for the purpose of organisation it makes sense to segregate them logically, into something like : walls.mtr, floors.mtr, doors.mtr and onwards.


First Create the Material Definition


On the first line of our Material Shader file we type textures/walls/concrete/crete01. Just to reitterate, this tells the engine that this current Material is entitled 'Crete01' and is to be located within a folder called 'Concrete', which is within a folder called 'Walls'' all of which fall into the 'Textures' folder. We now have this





Then add the Editor image


We need to define which file is to be used as the Editor Image. First of all you have to add an open curly bracket to the next line down (one of these - { ) so the Material knows to include everything which is about to follow. First of all we have to type qer_editorimage because thats the texture we're currently adding. If you remember back we saved our Editor Image at this location : D:/Doom3/base/textures/walls/concrete/crete01_ed.tga, but because we're already inside the base folder we only need to include the directory starting from the Textures Folder. We move in a tab or so from the qer_editorimage text, and type 'textures/walls/concrete/create01_ed.tga', giving us a Material Shader which now looks like this


 


Then we add the Diffuse Map


Now we'll add the Diffuse Map. You may have noticed that the above example from within Doom 3 actually add's the Normal Map here, but the order really isn't that important I just like to have the Diffuse Map first as I see it as being the most important.

We jump to the next line down and repeat the process, only this time we first type diffusemap, followed by the location of our Diffuse Map which inthis case is 'textures/walls/concrete/create01_d.tga'. Our updated Material Shader now stands at


 


Now for the Normal Map


You'll be getting the hang of things by now I'm sure. Can you guess what comes next? Thats right, we jump down a level, add bumpmap (remember although its referred to as a normal map, for the sake of Materials it's a Bumpmap) followed by the location 'textures/walls/concrete/create01_local.tga'


 


Finally the Specular Map


Once again, down a level, add 'specularmap' followed by the relative location, here being 'textures/walls/concrete/crete01_s.tga'. Once we've done that though we need to jump down another layer and add a close curly bracket (ie this } ) to tell the Engine that this particular Shader is complete. Here is our final Shader



There now the boring stuff is finally done with we can take a look at it running in game!


Step Four - Working Ingame

Setting up the Doom Editor


We need to use the Doom 3 editor to see how our Material Works. Now I'm not going to delve into all the details on how to create rooms and levels in Doom 3, as that'd take a seperate tutorial entirely and there are some excellent ones already. If you haven't ever built a Map in Doom 3 before I strongly suggest you check out one of the following, as they'll tell you all you need to get a basic Room built:


Applying our Material


So we buid our room, select the surface upon to which we wish to apply our texture, then it's just a case of opening the Materials Tab in the Inspector Window, finding the textures folder, and then scrolling through to find our material, which should be residing in textures/walls/conrete/, and named crete01. Click that, and it'll be applied to our surface.

Ingame


So here we have it, our final texture working ingame.



It doesn't look too bad at all, but it can sometimes be difficult to judge wether your texture really works until you have it running alongside others which you have custom built, so below I've just made a quick pair of textures for the marble and ceiling, and set up some different lighting conditions to see how they perform.



It's far easier to gain a more objective perspective now, and already I can see things I'd like to tweak and change, such as the Specular map which ingame, looks a bit too strong. But hey, it works, and for the time it's taken it does the job quite nicely I think.

Below is a screenshot featuring a variety of custom textures I built in this fashion, including the glass and light projected through it onto the floor.



Step Five - Conclusion

Tutorial Recap


We've now gone through everything required to get a custom texture built, and working inside of Doom 3 via a custom Material Shader. However this Tutorial has barely even scratched the surface as to what is possible with Material Shaders within Id Tech 4, we haven't even looked at height maps, integrating reflections and cubemaps, glowmaps, or even more advanced techniques which involve actual distortion shaders to effect the appearance of objects when seen through a texture.

But you should now have a pretty firm grasp on the bare essentials, if you have any queries or feedback please forward them to k1chi@hotmail.co.uk. Thankyou for your time.


See Also




Resources

  • iddevnet
    • Id softwares online documentation for id tech 4, very useful for folk wanting to mod Doom 3 or Quake 4

  • doom3world
    • Awash with talented, helpful people and pleny of excellent Tutorials
Post comment Comments
dinky
dinky

Very well done tutorial for newbies and moderate modders a-like! I love your custom screenshot on page 5. Nice!

Reply Good karma Bad karma+2 votes
Wraiyth
Wraiyth

Fantastic tutorial man, really good to see some well done, detailed tutorials around here :)

Reply Good karma Bad karma+2 votes
flobblob
flobblob

I tried to do a custom weapon and It messed up all of doom 3's shaders.

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: