Creating special shader maps for textures

From Platinum Arts Sandbox Free 3D Game Maker
Jump to: navigation, search

About Shaders

What is a Shader?

  • In the Cube 2 engine (and many other engines), shaders are used to change a texture without actually changing the texture itself. How? A shader will take a 2nd texture, based off of the original, and will apply a special effect based on what kind of shader you use and the texture provided for it. Keep in mind that some textures won't really need shaders, and that adding a shader could end up making the texture look bad.

What kind of shaders are there?

  • There are many different kinds of shaders, and you can combine some of them. Here's a basic list of common shaders:

Bump/Height

  • A bumpmap (which may go by other names) is a greyscale image which bumps parts of a texture up or down (raising or lowering parts), based on the color. In a bumpmap, white (rgb 255, 255, 255) rises and black (rgb 0, 0, 0) lowers, while grey (rgb 127, 127, 127) is even. Bumpmaps can be combined with virtually any other shader, and some only work with bumpmaps. Bumpmaps are designed for adding "scratches, dings and bumps" to models or textures.
  • Bumpmaps, as described at the BlenderWiki, store an intensity.

Normal/Height/Displace

  • A normalmap is a red-green-pinkish purple colored image which provides the illusion of depth by changing angles of light to create perspective. They are more realistic as they change with lighting direction.
  • Normalmaps, according to the BlenderWiki, store directions.

Decal

  • A decal is an image which is added to an image after something happens to that texture. In Cube 2: Sauerbraten, decals are used to add bullet holes to textures, while in Red Eclipse, decals are used to add burn and plasma marks.

Glow

  • A glowmap allows a texture to glow in the dark.

Pulse

  • Like a glowmap, but the glowing "pulses". It's like a light being turned on and off, back and forth.

Specular

  • A specular map, or specmap, controls the amount of light a texture, or an area of a texture, receives or reflects. Specular maps are lighter (closer to white) when they reflect more light, while they are usually darker (closer to black) when they receive light and don't reflect it. A specular map of rock, for example, would be relatively dark.

Creating Shaders

  • There are two parts to creating a shader and applying it to a texture: actually creating the shader map (based off of your diffuse, or color, map) and scripting it in (so the shader is applied to the texture within Sandbox).

Actually creating the texture

Bump/Height

  • Bumpmaps can be made in a variety of ways.

Using GIMP

  • Desaturate the texture
  • Change contrast/brightness as required
  • invert as necessary (remember - light areas raise, darks depress/lower and grey is neutral)
  • If preferred, copy the layer, use threshold, apply opacity/transparency as wanted, then merge layers
  • save as texture_bump.jpg

Using a 3D package

  • Create a high-poly model and then an unwrapped low-poly model (a plane, typically). From there, you may be able to bake a displacement texture from the high poly to the low-poly depending on your program.

Normal/Height

  • Normalmaps usually requires special tools such as the GIMP Normal-map Plugin, Smart Normal, SSBump Generator, or other bump-to-normal converters to work.
  • Before you make a normal map, make sure your bumpmap is seamless. Also make sure it has smoothed edges. A normal map detects corners well, but a vertical bump won't appear.
  • Load the bumpmap into whatever you're going to use, and then convert. See below for instructions on the given sources above.
  • Once you've made your Normal map, save it as texture_normal.jpg and test it in Sandbox (see below). If you see random straight lines in places, then use GIMP to make the texture seamless.
  • If you want, follow up by following this great tutorial on enhancing normalmaps.

Using a photo-editor plugin

  • To use a plugin for a photo editor (e.g. the GIMP, Paint.net, Photoshop), find and download the plugin, install it into the program that uses it, then find and execute it within the editor. A tutorial for paint.net can be found here: Making Seamless textures.

Using SmartNormal

  • First: What is SmartNormal?
    • SmartNormal is an online program which converts bumpmaps to normalmaps. While you can always use it online, you can also download and install SmartNormal. SmartNormal is incredibly useful in its speed and it also keeps your settings from your previous texture and applies it to your newly loaded texture.
  • Using SmartNormal is incredibly easy. Just visit the site, load your image, then move the bias (strength) and blur sliders as you like. When picking a filter, Sobel seems to be a lot stronger while Condensed is the exact same as the default (no-filter) look. I recommend you invert the source as well, as the normal map should look the opposite of what it does (so rocks jutting out would actually look like they're pointing in, and vice-versa).
  • I believe SmartNormal has a habit of messing with a texture's borders; with that in mind, open up your normalmap and make sure it's seamless.

Using SSBump

  • Begin by clicking on the "generate normal map" button in the menu of buttons. This brings up a new menu.
  • From there, hit the lower green plus button at the lower left. This is the "add layer" button which adds a layer to your normalmap. You start with no layers, so it's required you hit the button to begin.
    • A menu called "layer presets" will show up. If you want to experiment with settings, you should just select the default option. However, if you like to use presets, go ahead and pick one.
      • What I like to do is to have a fine detail layer and combine that with a medium or large detail layer. That provides a good balance of details and displacement.
  • Once you have a layer selected, browse for your bumpmap (or diffuse, though a bump is better) via the "image file" selection. The browse button is at the end of the text field.
  • From there, tweak the settings as you like and use the two eye buttons at the lower left corner to preview your image. Once you're done, hit the save button to save.

Using a 3D package

  • Create a high-poly model and then an unwrapped low-poly model (a plane, typically). Your high poly model should have beveled edges for the normal map to use (as a normal map doesn't detect vertical drops). From there, you can bake a normal map from the high poly to the low-poly.

Decal

  • A decal only needs to be a transparent .png. Alternatively, you could just use texture blending and painting, unless you want a specific shape.

Glow

  • We have a great glowmap tutorial made by Hirato here on the wiki @ Glowmaps.

Pulse

  • Pulse shaders can use just diffuse textures to start, and are made primarily by scripting. However, you can also throw in a glowmap texture and a specmap texture if you would like.

Specular

  • You can edit a bumpmap to create a specular map. As previously mentioned, lighter colors (yes, colors, you're not limited to greyscale, so experiment) tend to reflect more light while darker colors absorb light. You can change an image's brightness and contrast to get the result you want.