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.

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

  • //todo

Normal/Height

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.