XML technologies / SVG / Filters, transformations and gradients / Using and combining filters and lighting effectively / Lighting effects / Defining the light source’s color

(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)

You can also control the light source’s color. Simply add the style attribute inside the filter elements <feDiffuseLighting> or <feSpecularLighting>. Define the color there with the property lighting-color. The following example demonstrates this. It creates three filters: the first produces a yellow light source and the second a green one. The third combines both lighting effects.

<filter id="FLicht01">
  <feSpecularLighting in="SourceGraphic" specularConstant="1" surfaceScale="1" specularExponent="5" style="lighting-color:yellow">
    <feDistantLight azimuth="10" elevation="30" />
  </feSpecularLighting>
  <feComposite in2="SourceGraphic" operator="atop" />
</filter>
<filter id="FLicht02">
  <feDiffuseLighting in="SourceGraphic" diffuseConstant="1" surfaceScale="1" style="lighting-color:lime">
    <feDistantLight azimuth="10" elevation="30" />
  </feDiffuseLighting>
</filter>
<filter id="FLicht03">
  <feDiffuseLighting in="SourceGraphic" diffuseConstant="1" surfaceScale="1" style="lighting-color:lime" result="Diffuse"> 
    <feDistantLight azimuth="10" elevation="30"/>
  </feDiffuseLighting>
  <feSpecularLighting in="SourceGraphic" specularConstant="1" surfaceScale="1" specularExponent="5" style="lighting-color:yellow">
    <feDistantLight azimuth="10" elevation="30" />
  </feSpecularLighting>
  <feComposite in2="Diffuse" operator="atop" />
</filter>

The result looks as follows:

Filter results for the light source’s color

Figure: Filter results for the light source’s color.

   

 

 

 

back to top