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 rises and black lowers, while grey is even. Bumpmaps can be combined with virtually any other shader, and some only work with bumpmaps.
    • Normal/Height/Displace: A normalmap is a red-green-pinkish purple colored image which is more accurate than a bumpmap. It does the same purpose, but on a more accurate and better scale. It's also harder to make.
    • 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.
    • 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.

Creating and Adding Shaders

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 SSBump

//to be done

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.
  • 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).

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

  • 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).

Using SSBump

//to be done

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

  • To make a pulse shader,

Scripting

  • There are many kinds of shaders out there. Lots of them combine individual shaders. A very good list of all texture shaders can be found on Quadropolis. NOTE: Quadropolis may not be appropriate for children.
  • A very basic example:

    setshader bumpparallaxworld //bump-map and normal-map
    texture 0 "textures/textureX.jpg" //diffuse, or color, texture
    texture z "textures/textureX_Bump.jpg" //bump map
    texture n "textures/textureX_Normal.jpg" //normal map

  • As you can see, setshader determines the type of shader used. This is in effect until the next setshader line. Each individual texture is called up by its respective command, based on the type of shader map it is.