LightsAndColor: Difference between revisions

From Arianne
Jump to navigation Jump to search
imported>Kiheru
Available blends: Started writing blend descriptions
imported>Kiheru
Available blends: Started writing blend descriptions
(No difference)

Revision as of 18:38, 29 April 2013

Stendhal provides two ways to modify the colors of the zone maps. One that affects the entire zone uniformly, including any entities there, and another for local effects. For both of them the coloring method is specified in the zone's xml.

As an example, int_semos_storage_-1 specifies the following for its coloring:

<source lang="xml">

 <attributes>
   <parameter name="color_method">multiply</parameter>
   <parameter name="color">#413263</parameter>
   <parameter name="blend_method">bleach</parameter>
 </attributes>

</source>

This specifies both the zone wide, and local coloring methods.

Zone coloring mode

The following line in the Semos storage zone's definition specifies the coloring mode for the entire zone, and all entities within: <source lang="xml">

 <parameter name="color_method">multiply</parameter>

</source> It tells the Stendhal client to use the multiply mode blending, see Blend modes for more information. For multiplication the color which everything is multiplied needs to be known too, and that is specified at the next line: <source lang="xml">

 <parameter name="color">#413263</parameter>

</source> The color definition is the same as in html, and many programs, the GIMP for example, can display colors in that form. In the case you need to do it by hand, the numbers after # are the red, green and blue components, two for each in that order. Each component is in hexadecimal and in range 00 to ff.

Blend layers

TODO

Blend modes

Coloring in Stendhal is based on blend modes. Some of the modes provided by the Stendhal client are similar to those in image manipulation programs, but some are specifically developed for the purposes of the game.

Currently the client provides the following modes:

Bleach

This Stendhal specific mode is used for lighting. The effect is cancelling the effect of multiply based on the lightness of the blending layer image. Also the restored light is tinted based on the color of blend layer image, so it is possible to have colored lights.

Bleach is named "bleach" in the xml, and is technically available only for zones where the general mode is multiply or time. However if the general mode is something else "bleach" will fall back to generic_light, so specifying bleach mode when you want to use the blend layers for lighting is safe.

Generic light

Also a mode that is used for lights. Unlike bleach, generic light can not create colored lights, but on the other hand it works on all zones regardless of the general lighting mode, including those that have no general mode specified at all.

Generic light is turned on with "generic_light", and it also serves as a fall back mode for bleach as noted above.

Multiply

Multiply is similar to a mode provided by many graphics programs. In Stendhal it is used to simulate colored lighting, that is, the normal colors on the maps correspond to white light, and multiply is used to cut out some of light, with the color components of the zone color corresponding to the amount of remaining light.

Multiply can be turned on with "multiply" in the xml. This is also the method used by the time pseudo mode.

The exact formulas for the blend modes used by Stendhal can be found in the source file src/games/stendhal/client/gui/j2d/Blend.java.