Jump to content


Photo

Tutorial: Better textures for your materials (WIP, part 2 is up)

tutorial textures materials

17 replies to this topic

#1 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1266 posts

Posted 04 June 2018 - 05:46 AM

*
POPULAR

This tutorial will cover the basics of preparing good textures for your custom materials. Youll get to know how individual textures work in TDM, and how to make them react to light in consistent, controllable way. Ill be using simple opaque materials for most examples. Once you develop decent basic workflow, it's easier to work with transparencies, glow, cubemaps, and other more complex materials.
 
Part 0: Basic premise
 
TDM engine (idTech 4) uses non-PBR workflow. This means that there isn't one correct way of making textures for your materials, they won't be physically correct. In pre-PBR games you have to make materials in relation to your lighting model, and TDM/idTech 4 is no exception here. That said, I think you can have relative flexibility here. As long as you don't use extreme values for your lights, you should be able to use the same materials in daytime and nighttime scenarios.
 
Since the whole thing is a bit relative, it might be a bit overwhelming to figure out a starting point for your workflow. I found its useful to keep in mind a few ground rules (and this will be more important during in-engine tests):
 
1. You need an "average" light value for to establish a frame of reference.
2. Materials have to look correct with default game brightness and gamma settings. Brightness is 1, Gamma is 1.2.
3. Materials have to look correct without any post processing enabled, and they have to look good with default post processing on too. Burned highlights are acceptable for post processing, if the material looks as intended.
 
Keep last two points in mind as you create textures and test them in the engine. First point requires some experiments to see how TDM surfaces, light gem, and AI react to lights. What I found out, is that you can easily use grey (RGB 128, 128, 128) light as a kind of "photo studio light" to ensure that your textures behave correctly in the engine and have proper colors.
One thing you might want to keep in mind as well is falloff textures. My favorite multi-purpose light texture is falloff_exp2, as it seems close to inverse square method of calculating light falloff in other engines. I use it for most light sources, and it seems very good for tests.
 
General workflow suggestion
 
I prefer using Gimp and having each texture saved as .xcf file. I don't have to merge any layers, as Gimp uses "copy visible" option while exporting the result to .tga. Gimp will also remember the path and the filename after exporting, so, if I change something and want to export the updated texture, all I need is to use the Export shortcut (Ctrl+E), and update the textures in the engine with reloadimages command.
 
You'll want to have these files open and available for edition and export simultaneously. That's because all images influence each other, and contribute to the overall look of a surface:
 
Diffuse affects brightness, contrast, saturation, but also specularity and bloom highlights in post processing.
Specular map affects contrast and can emphasize darker areas of the image, even if you don't see a light reflected. It also affects the look and strength of a normalmap.
Normal map affects how specularity works on a surface, it also influences darker areas of the diffuse.
 
Test environment map
 
1. In DarkRadiant, create an empty cubic room that youll texture with your material. Dimensions depend mostly on assumed texture scale. Typically, I use 2048 textures that will be scaled down 8 times (x 0.125), so one tile will occupy in-game space of 256 by 256 units. Since I want to check whether my material tiles properly, I often use a 512 x 512 x 512 cube.
 
2. Place a light in the middle of the room. If your room is a 512 cube, make the radius 512 as well. This way your light will hit the wall in the middle of its falloff. If you want to use more realistic falloff, use light texture falloff_exp2. Set color to RGB 128, 128, 128.
 
3. You dont want the light to decay into complete darkness, thats why you need an ambient_world light. Place another light in the same room, make the radius long enough so it encompasses the whole room. Make it an ambient light (properties -> Classname -> Lights -> atdm:ambient_world; light properties -> light texture -> ambientlightnfo). Set the color to something like RGB 8, 8, 8.
 
4. Apply your material on room walls, place PlayerStart inside, and save your map. Run TDM, compile and run your map.
 
 
Now you have set up environment for testing materials.
 
obraz.png
obraz.png
A test map with example wall material applied.
 
Next part will cover diffuse textures, why its important to manage their color range, and how to do it in consistent manner.


Edited by Judith, 06 June 2018 - 06:58 AM.

  • AluminumHaste, SiyahParsomen, Dragofer and 3 others like this

#2 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1266 posts

Posted 04 June 2018 - 05:46 AM

*
POPULAR

Part 1: Diffuse workflow

This is a difficult texture to make, since it stores so much information. It’s not only about color values: even without specular, diffuse brightness and contrast influence surface specularity and highlights.

Most important thing to keep in mind while making diffuse textures is to maintain consistency in how they react to light. If you don’t control brightness and contrast of your diffuse textures, you’ll encounter problems with the same surface looking strange in different lighting conditions. What is probably even more important, the whole set of your materials will look jarring, if was no consistent rule used to make them.

The most effective way to tackle this problem is to establish a color range that you’ll use for all your diffuse textures. Along with consistency, this will also tackle a problem of displaying your materials on different monitors, and with different user settings (consistent with rule 2 and 3 above). This is called image normalization, and it’s similar to methods used by other media, like movies or television.

You’ve probably noticed that no movie or TV show uses completely dark or fully bright images. This method decreases image contrast a bit, but it gives a lot of leeway to both TV manufacturers (as there are many color and gamma profiles available) and users, who can adjust image settings to their liking. In all those instances the image will look correct.
In fact, my rule for normalizing diffuse textures is a simplified movie and TV standard called rec. 709. What it means in practical terms, is that you want to limit your output color range to 16 for blacks, and 240 for whites. But before that, you need to make sure your diffuse texture uses the whole color range, without clipping blacks or whites, so you don’t cut off any details in both bright parts and shadows.

The most common way to achieve all this is to use Levels tool.

obraz.png

This is my tiled floor texture along with Levels tool. Black shape is a histogram, it represents the amount of pixels in the image along with their brightness value. You can see that there is a lot of space between darkest pixels on the left, and the value of 0, which represents pure black. The same goes for bright pixels and the maximum value of 255. That means my texture doesn’t use full color range, and you can see it on the image itself as the lack of contrast.

To fix this, I have to adjust Input levels.

obraz.png


The image has better contrast, as it uses the whole range now. Now I have to clamp this range between 16 and 240 with Output levels.

obraz.png

Now the image lost a bit of its contrast, but it has room to be modified further in the material (specular and normal), by the engine postprocess settings, and by brightness and gamma settings.

Note that the image used in the example is mostly greyscale with a bit of blue, but if your texture has more vivid colors, you’ll notice that the saturation has increased. That’s what happens when you increase contrast, you have to offset this with by using slight desaturation. In general, unless you’re aiming for a particular style, your diffuse textures should be slightly desaturated, as they will be affected not only by brightness, but also by the color of your lights. Your test environment uses neutral “6500K-like” light that doesn’t occur in the game world. For actual map lighting, you always want to have some color in your lights, whether you’re aiming for incandescent, fluorescent, or anything in-between.
(Note to self: I probably should change example images to something more colorful later)

Next part will cover normalmaps, how they work in TDM and how you can tweak them without breaking their depth information.
  • Bikerdude, AluminumHaste, SiyahParsomen and 3 others like this

#3 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1266 posts

Posted 04 June 2018 - 05:47 AM

Part 2: Normal maps
 
Normal map is a vector map stored in RGB format, where each channel represents shading in one of the dimensions (X, Y, Z). That’s why you can’t treat normalmaps like any other images: using tools like brightness or sharpening can destroy information stored in RGB channels. There are several filters available for making normalmap. There is an old normalmap plugin for Gimp, but I wouldn’t recommend it (see below), you can also try out software like nDo, Crazybump, or nJob. Since nJob is free and pretty good for typical applications, I’m using it as my main tool.
 
To create good normalmaps from 2d images, you need to prepare a heightmap image that will be converted by the filter. Heightmap is a greyscale image, where dark pixels are lows and bright pixels are highs (grey color is kind of middle ground). Heightmap can be based on your diffuse image converted to greyscale, but typically you have to do some more work to get proper results. Applying normalmap filter to color images often will result with wrong look. Classic example is a red brick texture with white grout.
 
obraz.png
 

Most normalmap filters will interpret this as in the lower part of the image:

obraz.png
 

Sometimes a simple value invert will be enough to create correct heightmap. In most cases, your ability to create good normalmaps will depend on how you made your diffuse map. If your diffuse texture is composed from several layers, you will have greater degree of control over the final result.
For example, my tile floor was made with 5 layers:
 
obraz.png


This way I can decide which parts of the image I want to include in the heightmap, and I can regulate their intensity separately. If I had only the final image, the image processed by normalmap filter would result in this:

obraz.png

 

Normalmap filter took all pixels in the image and converted them into depth information. That includes things like stone pattern, dirt, and tile color. That’s not a good result. Here the depth information is mostly grout and some subtle edges taken from the stone pattern to indicate age.

obraz.png

 

 

Example workflow for creating normalmaps

  1. When you finish making your diffuse texture, save all the layers as another .xcf file. This will be your base for heightmap.
  2. Desaturate all the layers, and see if they are representing the height in correct way: dark pixels for cavity and bright pixels for convexity. Adjust layers’ modes, opacity, or color values, if you see that they don’t represent bumps or indents in the way they should.
  3. Use Copy visible (Ctrl+Shift+C) in Gimp to copy the result to clipboard.
  4. Paste the image into nJob and use Heightmap to normalmap filter (or press 4 on the keyboard).
  5. Adjust the filter settings. I use Traditional mode most of the time. There is no numeric scale here, but I usually reset everything first, and then I click on the scale, so the slider moves by the same interval. Now adjust Scale and Blur radius to your liking. If you don’t know what to go for, just click the Scale slide once. Copy (Ctrl+C) the result, paste it back to Gimp, and export it as your normalmap.
  6. Launch TDM and run your test material map to see whether the result is correct. If not, switch to nJob, Undo (Ctr+Z) the filter operation, and repeat steps in point 5 until you get desired/correct result.

If you don’t know what to look for, search online for photo, or video reference of a surface you’re making. This will give you a sense of direction and you’ll eliminate guesswork. That said, don’t be afraid to experiment. Using some crazy values might lead you to interesting effects that you’ll be able to use later!

 

 

Notes:

 

Diffuse + normal vs. diffuse + normal + specular

 

If you only have diffuse and normalmap textures in your material, the result will be different when you add a specular map. Your normalmap will look stronger with specular, and your material will have more depth. In general, there’s no reason why you wouldn’t want to create a specular map: all real-world surfaces are shiny and reflective to some extent. There are materials in stock TDM that use only _d and _n textures, but the other way around will be more beneficial to your materials. Specular complements diffuse so closely, that it should be included every time, while normalmap doesn’t always look right. Sometimes the surface is very smooth, and details from the diffuse texture may look ugly or blocky when transferred to a normalmap. If that’s the case, it will be better to make a material without a normalmap, rather than without a specular.

 

As I mentioned earlier, it good to prototype 3 maps as fast as possible, and work on them simultaneously – they all influence each other. If you don’t know what to look for in a specular yet, and you want to prototype your normal first, you can use either _grey system texture in the specular slot.

 

obraz.png

Floor material with and without specular.

 

 

Normalizing normalmap images

 

One of most important steps in making normalmaps is normalizing your image. This is something similar to setting proper color range for your diffuse, so the game engine will interpret the image correctly. nJob does it pretty well automatically. If you use normalmap plugin for Gimp, you have to choose Conversion -> Normalize only, and the use 1 in Scale field (default). Unfortunately there is a slight difference in how both filters use normalization. This is related to how both filters treat flat normal color reference. While the logical value would be 127, 127, 255 (the range is 0-255, not 1-256), but idTech 4 and other game engines use 128, 128, 255. So does nJob and other normalmap applications. Normalmap plugin for Gimp uses 127, 127, 255 though. You may think that one pixel isn’t that big of a deal, but it actually offsets reflected light source quite a bit. This surface uses black diffuse texture, white specular, and a light placed right above it:

 

obraz.png

 

 

Even with converting a solid color to normalmap, Gimp normalmap plugin uses 127, 127, 255. If you plan to use it, you have to keep that in mind.

 

 

Stacking / mixing normalmap layers

 

Long ago, there was this popular method of “getting more details” out of heightmaps by duplicating base layer, setting mode to Overlay, using Gaussian blur, and then repeating this step several times. That method destroys and distorts information stored in the RGB channels, as Overlay mode introduces contrast from the overlaid image to the pixels below it. Try to stick to making the most of your normalmap out of your layers combined in a heightmap and converted to a normalmap first.

 

That said, idtech4 is pretty sensitive to normalmaps, especially when used with speculars. Sometimes a slight change in the opacity will make a difference in your material, while it will be almost invisible on the normalmap texture. Prototyping it the usual way is too time-consuming, and prone to guesswork.

 

In such cases, you can prepare your base normalmap, and then put another one on top, e.g. to have some surface details, like cracks or dents. To do this correctly, you have to preserve depth information in your base normalmap though. The most important thing here is the blue channel: it represents shading when you’re looking at the surface in a perpendicular line. In order to mitigate this, you can use second normalmap in Overlay layer mode, but you have to keep the blue channel of the normalmap underneath intact. Overlay mode takes bright and dark pixels of the current layer, and makes the layer underneath bright or dark. If you create a layer and fill it with solid grey color (RGB 128), and then set its mode to Overlay, you’ll notice that the color has no effect, it becomes invisible. You have to do the same with blue channel of your second normalmap.

 

You can do this in Channels tab in Gimp. Just deselect all the channels but blue, and use the Bucket Fill tool with RGB 128 color selected. Be sure to hold Shift to Fill the whole selection. You should see the normalmap changing color to grey, with green and magenta shapes. Now you can set the layer mode to Overlay and adjust the opacity to your needs.

 

obraz.png

Smooth or rough? The choice is yours, just be mindful of consequences.

 

 

Next part will cover specular maps, how they work in TDM, and how you can use them to achieve interesting effects.


Edited by Judith, 06 June 2018 - 07:11 AM.

  • Bikerdude, AluminumHaste, SiyahParsomen and 1 other like this

#4 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1266 posts

Posted 04 June 2018 - 05:47 AM

(Reserved for part 3 specular maps)


Edited by Judith, 04 June 2018 - 05:48 AM.


#5 Obsttorte

Obsttorte

    Scripting guru, Mapper

  • Active Developer
  • PipPipPipPipPip
  • 5565 posts

Posted 04 June 2018 - 01:55 PM


3. You dont want the light to decay into complete darkness, thats why you need an ambient_world light. Place another light in the same room, make the radius long enough so it encompasses the whole room. Make it an ambient light (properties -> Classname -> Lights -> atdm:ambient_world; light properties -> light texture -> ambientlightnfo). Set the color to something like RGB 8, 8, 8.

If you use this entity the setting are already set. You only need to set them if you create the light from scratch. The ambient_world light is identified by its unique name (not classname), and is important for missions as it is rendered differently. In an example setup as described here it is not necessary (although it doesn't hurt either). Neither the main ambient nor any other ambient light needs to be atdm:ambient_world.


FM's: Builder Roads, Old Habits, Old Habits Rebuild
WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.
Mapping and Scripting: Apples and Peaches
Sculptris Models and Tutorials: Obsttortes Models
My wiki articles: Obstipedia
Let's Map TDM YouTube playlist: ObstlerTube
Texture Blending in DR: DR ASE Blend Exporter

End of shameless self promotion.

#6 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1266 posts

Posted 04 June 2018 - 02:32 PM

Hmm, maybe I remembered it wrong, but if I just create a light and name it ambient_world, the map is dark. If I use both entity class and ambient_world name, it works as it should.

 

If I don't set the ambient_world name, I see a message in the console telling me that ambient_world hasn't been found, but there is a light with ambient_world entity class, so it will be used as one anyway.



#7 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1266 posts

Posted 05 June 2018 - 07:19 AM

Before I go further, a question about normals: what is proper flat normal color for idTech4? I can't find any info on that.

 

Edit: nvm, found it.


Edited by Judith, 05 June 2018 - 07:44 AM.


#8 Bikerdude

Bikerdude

    Mod hero

  • Member
  • PipPipPipPipPip
  • 19851 posts

Posted 05 June 2018 - 10:35 AM

Edit: nvm, found it.

Wonna post the link, so people that come here canl see what your refering too etc.


Edited by Bikerdude, 05 June 2018 - 12:23 PM.


#9 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1266 posts

Posted 05 June 2018 - 10:39 AM

https://www.iddevnet...m3/bumpmaps.php

 

I will refer to that later in the next part of the tutorial. I just found out that the old Gimp normalmap plugin wasn't usin this value, and there are certain consequences. In short, it's better to use nJob and the like.


Edited by Judith, 05 June 2018 - 10:43 AM.


#10 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1266 posts

Posted 06 June 2018 - 07:28 AM

The second part is up, I will need a few more days for the last part. Probably won't happen until next week.



#11 Obsttorte

Obsttorte

    Scripting guru, Mapper

  • Active Developer
  • PipPipPipPipPip
  • 5565 posts

Posted 07 June 2018 - 03:21 AM

Hmm, maybe I remembered it wrong, but if I just create a light and name it ambient_world, the map is dark. If I use both entity class and ambient_world name, it works as it should.

 

If I don't set the ambient_world name, I see a message in the console telling me that ambient_world hasn't been found, but there is a light with ambient_world entity class, so it will be used as one anyway.

Well, you have to set both shader and light color when creating a new light.

 

If you don't set the name to ambient_world, it will work as an ambient light, of course, if it is one. But it will not use the shader reserved for the main ambient light (and setting ambient rendering to simple will most probably cause your mission to turn pretty dark). As the code comment says that it attempts to use a different one, there is a little chance that it picks the one you want it to, but that's a bit random.

 

I am refering to what I remember and would have to take a look at the code, though to see how it works exactly.


FM's: Builder Roads, Old Habits, Old Habits Rebuild
WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.
Mapping and Scripting: Apples and Peaches
Sculptris Models and Tutorials: Obsttortes Models
My wiki articles: Obstipedia
Let's Map TDM YouTube playlist: ObstlerTube
Texture Blending in DR: DR ASE Blend Exporter

End of shameless self promotion.

#12 RPGista

RPGista

    Advanced Member

  • Member
  • PipPipPip
  • 1509 posts

Posted 07 June 2018 - 05:49 PM

Very good work and very informative. I quite like that the information is extensive but it is always centered around how it will look in game, and talks about ways of doing that systematically.

 

"There are materials in stock TDM that use only _d and _n textures, but the other way around will be more beneficial to your materials. Specular complements diffuse so closely, that it should be included every time, while normalmap doesn’t always look right. Sometimes the surface is very smooth, and details from the diffuse texture may look ugly or blocky when transferred to a normalmap. If that’s the case, it will be better to make a material without a normalmap, rather than without a specular."

 

I really subscribe to that.

 

Looking foward to the next section.


  • Judith likes this

#13 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 37106 posts

Posted 07 June 2018 - 06:44 PM

I really subscribe to that.

 

 

I'm curious what your reasoning is.  The prevailing opinion until now has been that specularmaps in idTech4 tend to make materials look like plastic.  It's why we stopped using them for non-shiny materials early on.



#14 RPGista

RPGista

    Advanced Member

  • Member
  • PipPipPip
  • 1509 posts

Posted 07 June 2018 - 11:26 PM

Oh, its just that Ive noticed that really fine surface details, specially on smaller texture sizes, usually look better with a good specular and a detailed diffuse map, rather than a normal bump, which (again, when the resolution is not that high) tends to make them look very rough, very coarse. IMO, a lot of situations where you need subtle details can be solved without a normal map.


  • Judith likes this

#15 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1266 posts

Posted 08 June 2018 - 01:43 AM

I quite like that the information is extensive but it is always centered around how it will look in game, and talks about ways of doing that systematically.

 

Thanks, that's exactly what I'm going for: trying to understand the main principle and get predictable results every time.

 

As for the speculars, I only checked several TDM materials, but all of them were using grayscale speculars. The thing is, idTech4 also supports RGB speculars, and you can use that to get interesting results. Also, it's hard to get a decent look using speculars and TDM's stock entity lights, as they are very bright and contrasty, often burning out highlights, even without postprocessing enabled. Having more toned down lights solves this problem, although it has some gameplay and design consequences. That's either thing for a separate article, or at least a longer footnote :)


Edited by Judith, 08 June 2018 - 02:53 AM.


#16 rich_is_bored

rich_is_bored

    Advanced Member

  • Member
  • PipPipPip
  • 872 posts

Posted 08 June 2018 - 07:54 PM

The specular maps worked alright in Doom 3 because the environment called for lots of shiny metallic surfaces. But in a more real world setting there are more dielectric surfaces than not. And since you can't adjust glossiness to tone down bright highlights you darken your specular to compensate and sacrifice color saturation.


  • RPGista likes this

#17 Obsttorte

Obsttorte

    Scripting guru, Mapper

  • Active Developer
  • PipPipPipPipPip
  • 5565 posts

Posted 09 June 2018 - 03:12 AM

Couldn't that be solved by altering the parts of the interaction shader that deals with the specular part?


FM's: Builder Roads, Old Habits, Old Habits Rebuild
WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.
Mapping and Scripting: Apples and Peaches
Sculptris Models and Tutorials: Obsttortes Models
My wiki articles: Obstipedia
Let's Map TDM YouTube playlist: ObstlerTube
Texture Blending in DR: DR ASE Blend Exporter

End of shameless self promotion.

#18 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1266 posts

Posted 09 June 2018 - 03:47 AM

You can use speculars based on inverted diffuse maps to simulate dielectric surfaces, the only problem is that you don't have a separate parameter to adjust specular power.





Reply to this topic



  



Also tagged with one or more of these keywords: tutorial, textures, materials

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users