Mapdev:specular

From Spring
Jump to navigationJump to search

Specular

Gives you per-pixel control over the color and intensity of specular highlights anywhere on the map. You could eg. make all highlights red, or have them depend on the type of material that a pixel represents, or something more exotic. The alpha channel defines how "polished" the surface looks (glossiness), and the RGB color is the amount of light that gets reflected for each color channel.

Icon-caution.png Caution
requires clients to have GLSL-spec hardware
Mapdev-specular.jpg Mapdev-spec with.jpg
Example Specular Texture Ingame Result

Specification

mapinfo.lua

The relevant sections of the mapinfo.lua

  • If specularTex points to a file that does not exist, you will get full unmoderated specularity based on whatever your map's lighting settings are
local mapinfo = {
   resources = {
      ...
      specularTex = "",
      ...
   },
   ...
   lighting = {
      ...
      groundSpecularColor = {0.1, 0.1, 0.1},
      ...
   },
   ...
}

Image File

File Location ./maps/
File Format PNG, TGA
Colour Depth 8bpp
Channels RGBA
Resolution Any, recommended powers of two, will be stretched over the terrain.
  • The RGB channels will control the red, green, and blue contribution per highlight
  • The Alpha channel (multiplied by 16) becomes the specular exponent. Or on other words controls the sharpness of the specular highlights, the higher the value the sharper the highlights.
  • You have to set the RGB values to zero if you want no specular contribution
  • If you omit the alpha channel, or have a fully opaque image, the specular exponent is at its max and the results are a very sharp specular highlights.
Icon-caution.png Caution
If you set the alpha value of the specular texture to zero, or you will get the below result. Use almost zero instead.
Mapdev-spec alpha issue.jpg

Forum Discussion