XML technologies / SVG / Filters, transformations and gradients / Using and combining filters and lighting effectively / Lighting effects / Defining lighting effects
(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)
Light sources so far have been defined inside the filter element <feDiffuseLighting>, producing diffuse light. Another option is the element <feSpecularLighting>. Both are explained here.
The element <feDiffuseLighting> has, besides the universal attributes, these attributes:
surfaceScalesets the light source’s height and angle, thus the shadow strength. Positive and negative values are accepted; the default is 1.diffuseConstantsets brightness with positive values: higher means brighter, and 0 means no visible light.
Applied successively to the previous example’s circle, these filters produce:
Figure: Results of the feDiffuseLighting filters on the circle.
Note:
Inside the <feDiffuseLighting> element, only one light source is allowed. For several, define multiple lighting effects and combine their results with <feComposite>.
The second lighting option is the tag <feSpecularLighting>. Unlike <feDiffuseLighting>, it produces transparent rather than opaque lighting. Transparency depends on its attributes, listed below:
surfaceScalesets height and angle, thus shadow strength. Positive and negative numbers are allowed; the default is 1.specularConstantsets brightness with positive values: higher means brighter. At 0 no light is visible; the default is 1.specularExponentsets lighting transparency: higher means more transparent. Values range from 1 to 128, defaulting to 1.
Although documentation does not say the filter element <feComposite> is required, tests with Adobe SVG Viewer showed no visible effect unless the result was merged with the original through the <feComposite> instruction. Without it, correct display occurs only when applying <feSpecularLighting> to an external graphic included with the <image> tag in the SVG graphic.
Note:
In the filter element <feComposite>, the attribute in is optional. Omitting it automatically uses the preceding filter element’s result, also avoiding the need to specify its attribute result.
Figure: Results of the feSpecularLighting filters.
Copyright © verlag moderne industrie GmbH 2001
You may print the online version for your private use.
Otherwise, this chapter from “Das Einsteigerseminar SVG — Webgrafiken mit XML” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
verlag moderne industrie GmbH, Justus-von-Liebig-Straße 1, D-86899 Landsberg/Lech, fon ++49 (0) 81 91 / 125 – 0, leserservice(at)mi-verlag.de
back to top