Chiseled

The word svg cut into gold on a weathered metal plate, built from one chain of SVG filter primitives with a light you can move.

What you are seeing

Large lowercase gold letters spelling svg sit on a dark plate of rusted, pitted metal. A pool of white light falls from one corner and each letter casts a soft shadow away from it. Below, the letters W O W and an exclamation mark glow white. Four small switches at the top right choose the corner the light comes from.

How it works

The chiseled filter loads a texture with feImage, turns its brightness into a height map and lights it with a spotlight, which gives the plate its pitted relief.

The letters get their own bump map from a blurred copy of their alpha channel. A distant light and a gamma curve turn that into the rounded gold edge.

Screen and multiply blends combine the light with the texture, then a dilated, blurred and offset copy of the text adds the cast shadow. The switches only change light and shadow attributes, and the browser recalculates the filter.

History

Published on October 4, 2009.

Source

/filterEffects/chiseled.svg
<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================= -->
<!-- Vincent Hardy                                                           -->
<!-- License terms: see svg-wow.org                                         -->
<!-- CC0 http://creativecommons.org/publicdomain/zero/1.0/                   -->
<!-- Restoration: the rust photo is replaced by an original procedural       -->
<!-- texture, the layout scales to the viewport, keyboard controls added.    -->
<!-- ======================================================================= -->

<?xml-stylesheet type="text/css" href="../res/2.0/style/wowNeutral.css" ?>
<svg width="100%" height="100%" viewBox="0 -50 800 550"
     style="background:black"
     xmlns="http://www.w3.org/2000/svg"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xlink="http://www.w3.org/1999/xlink">
    <title>Chiseled</title>
    <desc>The word svg cut into gold, lit by a spotlight on a weathered metal plate, with the letters WOW! glowing white below. Four small switches at the top right move the light to a different corner.</desc>
    <style>
      g[role=button] { outline: none }
      g[role=button]:focus rect { stroke: white; stroke-width: 2 }
    </style>
    <rect x="-3000" y="-3000" width="6800" height="6800" fill="black" />

<svg width="800" height="550" viewBox="0 0 800 550"
     x="0" y="0"
     xmlns="http://www.w3.org/2000/svg"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:sw="http://www.svgopen.org/2004/svgWow"
     xmlns:xlink="http://www.w3.org/1999/xlink">

    <script><![CDATA[
function moveLight (x, y, pointsAtX, pointsAtY, azimuth, dx, dy) {
    var spotLight = document.getElementById("spotLight");
    var distantLight = document.getElementById("distantLight");
    var offset = document.getElementById("offset");

    spotLight.setAttribute("x", x);
    spotLight.setAttribute("y", y);
    spotLight.setAttribute("pointsAtX", pointsAtX);
    spotLight.setAttribute("pointsAtY", pointsAtY);
    distantLight.setAttribute("azimuth", azimuth);
    offset.setAttribute("dx", dx);
    offset.setAttribute("dy", dy);
}

document.addEventListener("keydown", function (evt) {
    var ids = { "1": "topLeft", "2": "topRight", "3": "bottomLeft", "4": "bottomRight" };
    var target = null;
    if (ids[evt.key]) {
        target = document.getElementById(ids[evt.key]);
    } else if ((evt.key === "Enter" || evt.key === " ") && evt.target.getAttribute && evt.target.getAttribute("role") === "button") {
        target = evt.target;
    }
    if (target) {
        evt.preventDefault();
        target.dispatchEvent(new MouseEvent("click", { bubbles: true }));
    }
});
    ]]></script>

    <defs>
        <filter id="glow" height="150%" y="-25%">
            <feFlood flood-color="white" />
            <feComposite in2="SourceAlpha" operator="in" />
            <feGaussianBlur stdDeviation="4" />
            <feComponentTransfer>
                <feFuncA type="linear" slope="3" intercept="0" />
            </feComponentTransfer>
            <feMerge>
                <feMergeNode />
                <feMergeNode in="SourceGraphic" />
            </feMerge>
        </filter>

        <filter id="chiseled" filterUnits="userSpaceOnUse" x="0" y="0" width="600" height="400">
            <!-- =========================================================== -->
            <!-- Background lighting                                         -->
            <!-- =========================================================== -->
            <!-- Base texture . Build a texture map from it -->
            <feImage xlink:href="chiseled-texture.jpg" preserveAspectRatio="none" result="texture"/>
            <feMerge result="textureAndGraphic">
                <feMergeNode />
                <feMergeNode in="SourceGraphic" />
            </feMerge>
            <feColorMatrix type="luminanceToAlpha" in="texture"
                                                           result="textureMap"/>

            <feGaussianBlur in="SourceAlpha" stdDeviation="6" result="blur"/>

            <feDiffuseLighting in="textureMap" surfaceScale="2" lighting-color="white"
                          diffuseConstant="1" result="backgroundDiff">
                <feSpotLight id="spotLight" x="50" y="50" z="150"
                             pointsAtX="150" pointsAtY="150" pointsAtZ="0"
                             specularExponent="8" />
            </feDiffuseLighting>

            <feDiffuseLighting in="blur" surfaceScale="6" lighting-color="white"
                          diffuseConstant="1.2" result="foregroundDiffAll">
                <feDistantLight id="distantLight" azimuth="-135" elevation="40" />
            </feDiffuseLighting>
            <feComponentTransfer>
                <feFuncR type="gamma" amplitude="1" exponent="3" offset="0"/>
                <feFuncG type="gamma" amplitude="1" exponent="3" offset="0"/>
                <feFuncB type="gamma" amplitude="1" exponent="3" offset="0"/>
            </feComponentTransfer>
            <feComposite operator="in" in2="SourceAlpha"/>
            <feConvolveMatrix order="3" kernelMatrix="0.0625 0.0625 0.0625
                                                     0.0625 0.5 0.0625
                                                     0.0625 0.0625 0.0625"
                                                       result="foregroundDiff"/>

            <feMerge result="diff">
                <feMergeNode in="backgroundDiff" />
                <feMergeNode in="foregroundDiff" />
            </feMerge>

            <feColorMatrix type="luminanceToAlpha" in="diff" result="screenMask"/>
            <feComponentTransfer result="multiplyMask">
                <feFuncA type="linear" slope="-1" intercept="1"/>
            </feComponentTransfer>

            <feBlend mode="screen" in2="textureAndGraphic" in="diff" result="screen"/>
            <feBlend mode="multiply" in2="textureAndGraphic" in="diff" result="multiply"/>

            <feComposite operator="in" in="screen" in2="screenMask" result="maskedScreen"/>
            <feComposite operator="in" in="multiply" in2="multiplyMask" result="maskedMultiply"/>

            <feComposite operator="arithmetic" in="maskedScreen" in2="maskedMultiply"
                        k1="0" k2="1" k3="1" k4="0" result="background" />


            <!-- =========================================================== -->
            <!-- Shadow                                                      -->
            <!-- =========================================================== -->
            <!-- Create a blur to build the shadow. -->
            <feMorphology operator="dilate" in="SourceAlpha" radius="4" />
            <feGaussianBlur stdDeviation="4" result="blur"/>
            <feOffset id="offset" dx="12" dy="12" result="offsetBlur"/>
            <feComposite in2="SourceAlpha" operator="out" result="shadow" />

            <feMerge>
                <feMergeNode in="background" />
                <feMergeNode in="shadow"/>
            </feMerge>
        </filter>

    </defs>

    <g transform="translate(100,50)">
       <g>
           <g font-weight="normal" text-anchor="middle" font-family="Garamond, 'Apple Garamond', Baskerville, 'Hoefler Text', 'Times New Roman', Times, serif">
               <!-- Inset clip hides the 1px lighting edge Chromium draws at the filter region border -->
               <clipPath id="plateClip"><rect x="1" y="1" width="598" height="398"/></clipPath>
               <g clip-path="url(#plateClip)">
               <text x="300" y="230" font-size="310"
                  fill="gold" filter="url(#chiseled)">svg</text>
               </g>
               <g transform="translate(35,295)"
                  font-weight="bold" font-size="30" filter="url(#glow)">
                    <text x="100">W</text>
                    <text x="168">O</text>
                    <text x="236">W</text>
                    <text x="304">!</text>
                </g>
           </g>
        </g>
    </g>


    <g id="topRight" transform="translate(570, 10)" cursor="pointer" tabindex="0" role="button" aria-label="Move the light to the top right" onclick="moveLight(550, 50, 400, 150, -45, -12, 12)">
        <title>Light from top right (key 2)</title>
        <rect width="20" height="10" fill="silver" stroke="gray" />
        <circle cx="17.5" cy="2.5" r="2" fill="crimson" />
    </g>

    <g id="bottomRight" transform="translate(545, 10)" cursor="pointer" tabindex="0" role="button" aria-label="Move the light to the bottom right" onclick="moveLight(550, 350, 400, 200, 45, -12, -12)">
        <title>Light from bottom right (key 4)</title>
        <rect width="20" height="10" fill="silver" stroke="gray" />
        <circle cx="17.5" cy="7.5" r="2" fill="crimson" />
    </g>

    <g id="topLeft" transform="translate(520, 10)" cursor="pointer" tabindex="0" role="button" aria-label="Move the light to the top left" onclick="moveLight(50, 50, 150, 150, -135, 12, 12)">
        <title>Light from top left (key 1)</title>
        <rect width="20" height="10" fill="silver" stroke="gray" />
        <circle cx="2.5" cy="2.5" r="2" fill="crimson" />
    </g>

    <g id="bottomLeft" transform="translate(495, 10)" cursor="pointer" tabindex="0" role="button" aria-label="Move the light to the bottom left" onclick="moveLight(50, 350, 150, 200, 135, 12, -12)">
        <title>Light from bottom left (key 3)</title>
        <rect width="20" height="10" fill="silver" stroke="gray" />
        <circle cx="2.5" cy="7.5" r="2" fill="crimson" />
    </g>

    <text font-size="15px" font-family="sans-serif" text-anchor="end" fill="silver" x="485" y="18">click on symbols to change light position:</text>
</svg>
</svg>
/filterEffects/chiseled.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Chiseled | SVG Wow!</title>
<meta name="description" content="Gold lettering cut into weathered metal, built from a single chain of SVG filter primitives with a movable light.">
<style>html,body{margin:0;height:100%;background:#111;color:#ddd;font:15px/1.45 system-ui,-apple-system,"Segoe UI",sans-serif}body{display:flex;flex-direction:column;min-height:100%}header{display:flex;flex-wrap:wrap;gap:4px 16px;align-items:baseline;padding:10px 16px}h1{font-size:18px;margin:0;color:#fff}p{margin:0;color:#aaa}a{color:#ffc14d}iframe{flex:1;width:100%;min-height:320px;border:0;background:#000;display:block}</style>
</head>
<body>
<header>
<h1>Chiseled</h1>
<p>Vincent Hardy, 2009. Use the four switches or keys 1 to 4 to move the light.</p>
<p><a href="/gallery/chiseled/">Gallery page</a> ยท <a href="chiseled.svg">Open the SVG</a></p>
</header>
<iframe src="chiseled.svg" title="Chiseled demo"></iframe>
</body>
</html>
/res/2.0/style/wowNeutral.css
/*
 * Template Style Configuration
 */

/**
 * =====================================================================
 * Basic rendering classes.
 * =====================================================================
 */

 svg {
     overflow: visible;
 }

.white { 
  fill: white;
  stroke: white;
  stop-color: white;
  flood-color: white;
}

.black { 
  fill: black;
  stroke: black;
  stop-color: black;
  color: black;
  flood-color: black;
}

.lightGray { 
  fill: rgb(191,191,191);
  stroke: rgb(191,191,191);
  stop-color: rgb(191,191,191);
  color: rgb(191,191,191);
  flood-color: rgb(191,191,191);
}

.midGray { 
  fill: rgb(128,128,128);
  stroke: rgb(128,128,128);
  stop-color: rgb(128,128,128);
  flood-color: rgb(128,128,128);
}

.darkGray {  
  fill: rgb(25,25,25);
  stroke: rgb(25,25,25);
  stop-color: rgb(25,25,25);
  color: rgb(25,25,25);
  flood-color: rgb(25,25,25);
}

.midHighlight { 
  fill: rgb(255,209,31);
  stroke: rgb(255,209,31);
  color: rgb(255,209,31);
  stop-color: rgb(255,209,31);
  flood-color: rgb(255,209,31);
}

.darkHighlight { 
  fill: rgb(145,0,0);
  stroke: rgb(145,0,0);
  color: rgb(145,0,0);
  stop-color: rgb(145,0,0);
  flood-color: rgb(145,0,0);
}

.fillWhite { 
  fill: white;
}

.fillBlack { 
  fill: rgb(9,60,91);
}

.fillLightGray {  
  fill: rgb(191,191,191);
}

.fillMidGray { 
  fill: rgb(128,128,128);
}

.fillDarkGray { 
  fill: rgb(25,25,25);
}

.fillBlack {  
  fill: black;
}

.fillMidHighlight { 
  fill: rgb(255,209,31);
}

.fillDarkHighlight { 
  fill: rgb(145,0,0);
}

.strokeWhite { 
  stroke: white;
}

.strokeBlack { 
  stroke: rgb(9,60,91);
}

.strokeLightGray { 
  stroke: rgb(191,191,191);
}

.strokeMidGray { 
  stroke: rgb(128,128,128);
}

.strokeDarkGray { 
  stroke: rgb(25,25,25);
}

.strokeBlack {  
  stroke: black;
}

.strokeMidHighlight { 
  stroke: rgb(255,209,31);
}

.strokeDarkHighlight {  
  stroke: rgb(145,0,0);
}

.fillNone { 
  fill: none;
}

.strokeNone {  
  stroke: none;
}

.noFill { 
  fill: none;
}

.crisp { 
  shape-rendering: crispEdges;
}

.hidden { 
  visibility: hidden;
}

/**
 * =====================================================================
 * Text rendering classes.
 * =====================================================================
 */

defaultFontFamily { 
  font-family: 'Myriad', "Gill Sans";
}

#demoTitle {  
  font-family: 'Myriad', 'Myriad Pro', "Gill Sans";
  font-weight: bold;
  font-size: 25px;
}

.titleText {
  font-family: 'Myriad', 'Myriad Pro', "Gill Sans";
  font-weight: bold;
  font-size: 25px;
}

.labelTitle {  
  font-family: 'Myriad', 'Myriad Pro', "Gill Sans";
  font-size: 16px;
  font-weight: bold;
}

.label { 
  font-family: 'Myriad', 'Myriad Pro', "Gill Sans";
  font-size: 16px;
}

.labelHot { 
  font-family: 'Myriad', 'Myriad Pro', "Gill Sans";
  font-size: 16px;
  font-weight: bold;
}

.code { 
  font-family: 'Courier New';
  font-weight: bold;
  font-size: 16px;
}

/**
 * =====================================================================
 * GUI rendering classes.
 * =====================================================================
 */

.buttonLabel { 
  font-family: Larabiefont;
  font-weight: bold;
  font-size: 16px;
  fill: #222;
}

.textFieldBackground { 
  fill: #eeeeee;
  stroke: black;
}

.hotTextFieldBackground { 
  fill: white;
  stroke: crimson;
  stroke-width: 2;
}

.thumbCold {
    fill: black;
    fill-opacity: 0.5;
    stroke: white;
    stroke-width: 1;
    shape-rendering: crispEdges;
}

.thumbHot {
    fill: none;
    fill-opacity: 1;
    stroke: white;
    stroke-width: 4;
}

.thumbHighlight {
    fill: black;
    fill-opacity: 0;
    stroke: white;
    stroke-width: 1;
}

#presentationNavigation {
    display: none;
}